Class GorgonBoundingFrustum
Defines a frustum which can be used in frustum culling, zoom to Extents (zoom to fit) operations, (matrix, frustum, camera) interchange, and many kind of intersection testing.
Inherited Members
Namespace: Gorgon.Renderers.Data
Assembly: Gorgon.Core.dll
Syntax
public class GorgonBoundingFrustum
Properties
| Edit this page View SourceCorners
Property to return the corner list for this frustum.
Declaration
public GorgonBoundingFrustum.CornerList Corners { get; }
Property Value
Type | Description |
---|---|
GorgonBoundingFrustum.CornerList |
IsOrthographic
Indicate whether the current BoundingFrustrum is Orthographic.
Declaration
public bool IsOrthographic { get; }
Property Value
Type | Description |
---|---|
bool |
Planes
Property to return the plane list for this frustum.
Declaration
public GorgonBoundingFrustum.PlaneList Planes { get; }
Property Value
Type | Description |
---|---|
GorgonBoundingFrustum.PlaneList |
Methods
| Edit this page View SourceCreate(in Matrix4x4)
Function to create a new bounding frustum by building the planes based on the view and projection matrix.
Declaration
public static GorgonBoundingFrustum Create(in Matrix4x4 viewProjMatrix)
Parameters
Type | Name | Description |
---|---|---|
Matrix4x4 | viewProjMatrix | The combined view and projection matrix. |
Returns
Type | Description |
---|---|
GorgonBoundingFrustum | The new bounding frustum. |
Create(in Matrix4x4, in Matrix4x4)
Function to create a new bounding frustum by building the planes based on the view and projection matrix.
Declaration
public static GorgonBoundingFrustum Create(in Matrix4x4 viewMatrix, in Matrix4x4 projectionMatrix)
Parameters
Type | Name | Description |
---|---|---|
Matrix4x4 | viewMatrix | The view matrix. |
Matrix4x4 | projectionMatrix | The projection matrix. |
Returns
Type | Description |
---|---|
GorgonBoundingFrustum | The new bounding frustum. |
CreateInverted(GorgonBoundingFrustum)
Function to create an inverted (inside out) frustum.
Declaration
public static GorgonBoundingFrustum CreateInverted(GorgonBoundingFrustum frustum)
Parameters
Type | Name | Description |
---|---|---|
GorgonBoundingFrustum | frustum | The frustum to invert. |
Returns
Type | Description |
---|---|
GorgonBoundingFrustum | The inverted frustum. |
FromCamera(Vector3, Vector3, Vector3, float, float, float, float)
Creates a new frustum relaying on perspective camera parameters
Declaration
public static GorgonBoundingFrustum FromCamera(Vector3 cameraPos, Vector3 lookDir, Vector3 upDir, float fov, float znear, float zfar, float aspect)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | cameraPos | The camera pos. |
Vector3 | lookDir | The look dir. |
Vector3 | upDir | Up dir. |
float | fov | The fov. |
float | znear | The znear. |
float | zfar | The zfar. |
float | aspect | The aspect. |
Returns
Type | Description |
---|---|
GorgonBoundingFrustum | The bounding frustum calculated from perspective camera |
GetHeightAtDepth(float)
Get the height of the frustum at specified depth.
Declaration
public float GetHeightAtDepth(float depth)
Parameters
Type | Name | Description |
---|---|---|
float | depth | the depth at which to calculate frustum height. |
Returns
Type | Description |
---|---|
float | Height of the frustum at the specified depth |
GetWidthAtDepth(float)
Get the width of the frustum at specified depth.
Declaration
public float GetWidthAtDepth(float depth)
Parameters
Type | Name | Description |
---|---|---|
float | depth | the depth at which to calculate frustum width. |
Returns
Type | Description |
---|---|
float | With of the frustum at the specified depth |
GetZoomToExtentsShiftDistance(in GorgonBoundingBox)
Get the distance which when added to camera position along the lookat direction will do the effect of zoom to extents (zoom to fit) operation, so all the passed points will fit in the current view. if the returned value is positive, the camera will move toward the lookat direction (ZoomIn). if the returned value is negative, the camera will move in the reverse direction of the lookat direction (ZoomOut).
Declaration
public float GetZoomToExtentsShiftDistance(in GorgonBoundingBox boundingBox)
Parameters
Type | Name | Description |
---|---|---|
GorgonBoundingBox | boundingBox | The bounding box. |
Returns
Type | Description |
---|---|
float | The zoom to fit distance |
GetZoomToExtentsShiftDistance(ReadOnlySpan<Vector3>)
Get the distance which when added to camera position along the lookat direction will do the effect of zoom to extents (zoom to fit) operation, so all the passed points will fit in the current view. if the returned value is positive, the camera will move toward the lookat direction (ZoomIn). if the returned value is negative, the camera will move in the reverse direction of the lookat direction (ZoomOut).
Declaration
public float GetZoomToExtentsShiftDistance(ReadOnlySpan<Vector3> points)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<Vector3> | points | The points. |
Returns
Type | Description |
---|---|
float | The zoom to fit distance |
GetZoomToExtentsShiftVector(in GorgonBoundingBox)
Get the vector shift which when added to camera position will do the effect of zoom to extents (zoom to fit) operation, so all the passed points will fit in the current view.
Declaration
public Vector3 GetZoomToExtentsShiftVector(in GorgonBoundingBox boundingBox)
Parameters
Type | Name | Description |
---|---|---|
GorgonBoundingBox | boundingBox | The bounding box. |
Returns
Type | Description |
---|---|
Vector3 | The zoom to fit vector |
GetZoomToExtentsShiftVector(ReadOnlySpan<Vector3>)
Get the vector shift which when added to camera position will do the effect of zoom to extents (zoom to fit) operation, so all the passed points will fit in the current view.
Declaration
public Vector3 GetZoomToExtentsShiftVector(ReadOnlySpan<Vector3> points)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<Vector3> | points | The points. |
Returns
Type | Description |
---|---|
Vector3 | The zoom to fit vector |
Update(in Matrix4x4)
Function to update the frustum with a new view/projection matrix.
Declaration
public void Update(in Matrix4x4 viewProjection)
Parameters
Type | Name | Description |
---|---|---|
Matrix4x4 | viewProjection | The view and projection matrix used to calculate the planes and corners for the frustum. |
Update(in Matrix4x4, in Matrix4x4)
Function to update the frustum with a new view/projection matrix.
Declaration
public void Update(in Matrix4x4 view, in Matrix4x4 projection)
Parameters
Type | Name | Description |
---|---|---|
Matrix4x4 | view | The view matrix used to calculate the planes and corners for the frustum. |
Matrix4x4 | projection | The projection matrix used to calculate the planes and corners for the frustum. |