Table of Contents

Struct Viewport

Namespace
HelixToolkit.Maths
Assembly
HelixToolkit.Maths.dll

Defines the viewport dimensions.

public struct Viewport : IEquatable<Viewport>
Implements
Inherited Members
Extension Methods

Constructors

Viewport(Rectangle)

Initializes a new instance of the Viewport struct.

public Viewport(Rectangle bounds)

Parameters

bounds Rectangle

A bounding box that defines the location and size of the viewport in a render target.

Viewport(int, int, int, int)

Initializes a new instance of the Viewport struct.

public Viewport(int x, int y, int width, int height)

Parameters

x int

The x coordinate of the upper-left corner of the viewport in pixels.

y int

The y coordinate of the upper-left corner of the viewport in pixels.

width int

The width of the viewport in pixels.

height int

The height of the viewport in pixels.

Viewport(int, int, int, int, float, float)

Initializes a new instance of the Viewport struct.

public Viewport(int x, int y, int width, int height, float minDepth, float maxDepth)

Parameters

x int

The x coordinate of the upper-left corner of the viewport in pixels.

y int

The y coordinate of the upper-left corner of the viewport in pixels.

width int

The width of the viewport in pixels.

height int

The height of the viewport in pixels.

minDepth float

The minimum depth of the clip volume.

maxDepth float

The maximum depth of the clip volume.

Viewport(uint, uint, uint, uint)

Initializes a new instance of the Viewport struct.

public Viewport(uint x, uint y, uint width, uint height)

Parameters

x uint
y uint
width uint
height uint

Viewport(uint, uint, uint, uint, float, float)

Initializes a new instance of the Viewport struct.

public Viewport(uint x, uint y, uint width, uint height, float minDepth, float maxDepth)

Parameters

x uint
y uint
width uint
height uint
minDepth float
maxDepth float

Fields

Height

Height dimension of the viewport.

public int Height

Field Value

int

MaxDepth

Gets or sets the maximum depth of the clip volume.

public float MaxDepth

Field Value

float

MinDepth

Gets or sets the minimum depth of the clip volume.

public float MinDepth

Field Value

float

Width

Width dimension of the viewport.

public int Width

Field Value

int

X

Position of the pixel coordinate of the upper-left corner of the viewport.

public int X

Field Value

int

Y

Position of the pixel coordinate of the upper-left corner of the viewport.

public int Y

Field Value

int

Properties

AspectRatio

Gets the aspect ratio used by the viewport.

public readonly float AspectRatio { get; }

Property Value

float

The aspect ratio.

Bounds

Gets the size of this resource.

public Rectangle Bounds { readonly get; set; }

Property Value

Rectangle

The bounds.

Methods

Equals(Viewport)

Determines whether the specified Viewport is equal to this instance.

public readonly bool Equals(Viewport other)

Parameters

other Viewport

The Viewport to compare with this instance.

Returns

bool

true if the specified Viewport is equal to this instance; otherwise, false.

Equals(ref Viewport)

Determines whether the specified Viewport is equal to this instance.

public readonly bool Equals(ref Viewport other)

Parameters

other Viewport

The Viewport to compare with this instance.

Returns

bool

true if the specified Viewport is equal to this instance; otherwise, false.

Equals(object?)

Determines whether the specified object is equal to this instance.

public override readonly bool Equals(object? obj)

Parameters

obj object

The object to compare with this instance.

Returns

bool

true if the specified object is equal to this instance; otherwise, false.

GetHashCode()

Returns a hash code for this instance.

public override readonly int GetHashCode()

Returns

int

A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.

Project(Vector3, Matrix4x4, Matrix4x4, Matrix4x4)

Projects a 3D vector from object space into screen space.

public readonly Vector3 Project(Vector3 source, Matrix4x4 projection, Matrix4x4 view, Matrix4x4 world)

Parameters

source Vector3

The vector to project.

projection Matrix4x4

The projection matrix.

view Matrix4x4

The view matrix.

world Matrix4x4

The world matrix.

Returns

Vector3

The projected vector.

Project(ref Vector3, ref Matrix4x4, out Vector3)

Projects a 3D vector from object space into screen space.

public readonly void Project(ref Vector3 source, ref Matrix4x4 matrix, out Vector3 vector)

Parameters

source Vector3

The vector to project.

matrix Matrix4x4

A combined WorldViewProjection matrix.

vector Vector3

The projected vector.

ToString()

Retrieves a string representation of this object.

public override readonly string ToString()

Returns

string

A string that represents this instance.

ToViewportF()

public readonly ViewportF ToViewportF()

Returns

ViewportF

Unproject(Vector3, Matrix4x4, Matrix4x4, Matrix4x4)

Converts a screen space point into a corresponding point in world space.

public readonly Vector3 Unproject(Vector3 source, Matrix4x4 projection, Matrix4x4 view, Matrix4x4 world)

Parameters

source Vector3

The vector to project.

projection Matrix4x4

The projection matrix.

view Matrix4x4

The view matrix.

world Matrix4x4

The world matrix.

Returns

Vector3

The unprojected Vector.

Unproject(ref Vector3, ref Matrix4x4, out Vector3)

Converts a screen space point into a corresponding point in world space.

public readonly void Unproject(ref Vector3 source, ref Matrix4x4 matrix, out Vector3 vector)

Parameters

source Vector3

The vector to project.

matrix Matrix4x4

An inverted combined WorldViewProjection matrix.

vector Vector3

The unprojected vector.

Operators

operator ==(Viewport, Viewport)

Implements the operator ==.

public static bool operator ==(Viewport left, Viewport right)

Parameters

left Viewport

The left.

right Viewport

The right.

Returns

bool

The result of the operator.

operator !=(Viewport, Viewport)

Implements the operator !=.

public static bool operator !=(Viewport left, Viewport right)

Parameters

left Viewport

The left.

right Viewport

The right.

Returns

bool

The result of the operator.