Class BoundingFrustum
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.
Inheritance
Implements
Namespace: FlaxEngine
Assembly: FlaxEngine.CSharp.dll
Syntax
public sealed class BoundingFrustum : ValueType, IEquatable<BoundingFrustum>
Constructors
BoundingFrustum(Matrix)
Creates a new instance of BoundingFrustum.
Declaration
public BoundingFrustum(Matrix matrix)
Parameters
Matrix
matrix
Combined matrix that usually takes view × projection matrix. |
BoundingFrustum(ref Matrix)
Creates a new instance of BoundingFrustum.
Declaration
public BoundingFrustum(ref Matrix matrix)
Parameters
Matrix
matrix
Combined matrix that usually takes view × projection matrix. |
Properties
Bottom
Gets the bottom plane of the BoundingFrustum.
Declaration
public Plane Bottom { get; }
Property Value
Plane
|
Far
Gets the far plane of the BoundingFrustum.
Declaration
public Plane Far { get; }
Property Value
Plane
|
IsOrthographic
Indicate whether the current BoundingFrustum is Orthographic.
Declaration
public bool IsOrthographic { get; }
Property Value
System.Boolean
|
Left
Gets the left plane of the BoundingFrustum.
Declaration
public Plane Left { get; }
Property Value
Plane
|
Matrix
Gets or sets the Matrix that describes this bounding frustum.
Declaration
public Matrix Matrix { get; set; }
Property Value
Matrix
|
Near
Gets the near plane of the BoundingFrustum.
Declaration
public Plane Near { get; }
Property Value
Plane
|
Right
Gets the right plane of the BoundingFrustum.
Declaration
public Plane Right { get; }
Property Value
Plane
|
Top
Gets the top plane of the BoundingFrustum.
Declaration
public Plane Top { get; }
Property Value
Plane
|
Methods
Contains(BoundingBox)
Determines the intersection relationship between the frustum and a bounding box.
Declaration
public ContainmentType Contains(BoundingBox box)
Parameters
BoundingBox
box
The box. |
Returns
ContainmentType
Type of the containment |
Contains(ref BoundingBox)
Determines the intersection relationship between the frustum and a bounding box.
Declaration
public ContainmentType Contains(ref BoundingBox box)
Parameters
BoundingBox
box
The box. |
Returns
ContainmentType
Type of the containment |
Contains(ref BoundingBox, out ContainmentType)
Determines the intersection relationship between the frustum and a bounding box.
Declaration
public void Contains(ref BoundingBox box, out ContainmentType result)
Parameters
BoundingBox
box
The box. |
ContainmentType
result
Type of the containment. |
Contains(BoundingSphere)
Determines the intersection relationship between the frustum and a bounding sphere.
Declaration
public ContainmentType Contains(BoundingSphere sphere)
Parameters
BoundingSphere
sphere
The sphere. |
Returns
ContainmentType
Type of the containment |
Contains(ref BoundingSphere)
Determines the intersection relationship between the frustum and a bounding sphere.
Declaration
public ContainmentType Contains(ref BoundingSphere sphere)
Parameters
BoundingSphere
sphere
The sphere. |
Returns
ContainmentType
Type of the containment |
Contains(ref BoundingSphere, out ContainmentType)
Determines the intersection relationship between the frustum and a bounding sphere.
Declaration
public void Contains(ref BoundingSphere sphere, out ContainmentType result)
Parameters
BoundingSphere
sphere
The sphere. |
ContainmentType
result
Type of the containment. |
Contains(Vector3)
Checks whether a point lay inside, intersects or lay outside the frustum.
Declaration
public ContainmentType Contains(Vector3 point)
Parameters
Vector3
point
The point. |
Returns
ContainmentType
Type of the containment |
Contains(ref Vector3)
Checks whether a point lay inside, intersects or lay outside the frustum.
Declaration
public ContainmentType Contains(ref Vector3 point)
Parameters
Vector3
point
The point. |
Returns
ContainmentType
Type of the containment |
Equals(BoundingFrustum)
Determines whether the specified BoundingFrustum is equal to this instance.
Declaration
public bool Equals(BoundingFrustum other)
Parameters
BoundingFrustum
other
The BoundingFrustum to compare with this instance. |
Returns
System.Boolean
|
Equals(ref BoundingFrustum)
Determines whether the specified BoundingFrustum is equal to this instance.
Declaration
public bool Equals(ref BoundingFrustum other)
Parameters
BoundingFrustum
other
The BoundingFrustum to compare with this instance. |
Returns
System.Boolean
|
Equals(Object)
Determines whether the specified System.Object is equal to this instance.
Declaration
public override bool Equals(object obj)
Parameters
System.Object
obj
The System.Object to compare with this instance. |
Returns
System.Boolean
|
FromCamera(Vector3, Vector3, Vector3, Single, Single, Single, Single)
Creates a new frustum relaying on perspective camera parameters
Declaration
public static BoundingFrustum FromCamera(Vector3 cameraPos, Vector3 lookDir, Vector3 upDir, float fov, float znear, float zfar, float aspect)
Parameters
Vector3
cameraPos
The camera pos. |
Vector3
lookDir
The look dir. |
Vector3
upDir
Up dir. |
System.Single
fov
The fov. |
System.Single
znear
The Z near. |
System.Single
zfar
The Z far. |
System.Single
aspect
The aspect. |
Returns
BoundingFrustum
The bounding frustum calculated from perspective camera |
GetCorners()
Returns the 8 corners of the frustum, element0 is Near1 (near right down corner) , element1 is Near2 (near right top corner) , element2 is Near3 (near Left top corner) , element3 is Near4 (near Left down corner) , element4 is Far1 (far right down corner) , element5 is Far2 (far right top corner) , element6 is Far3 (far left top corner) , element7 is Far4 (far left down corner)
Declaration
public Vector3[] GetCorners()
Returns
Vector3[]
The 8 corners of the frustum |
GetCorners(Vector3[])
Returns the 8 corners of the frustum, element0 is Near1 (near right down corner) , element1 is Near2 (near right top corner) , element2 is Near3 (near Left top corner) , element3 is Near4 (near Left down corner) , element4 is Far1 (far right down corner) , element5 is Far2 (far right top corner) , element6 is Far3 (far left top corner) , element7 is Far4 (far left down corner)
Declaration
public void GetCorners(Vector3[] corners)
Parameters
Vector3[]
corners
|
GetHashCode()
Returns a hash code for this instance.
Declaration
public override int GetHashCode()
Returns
System.Int32
A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. |
GetHeightAtDepth(Single)
Get the height of the frustum at specified depth.
Declaration
public float GetHeightAtDepth(float depth)
Parameters
System.Single
depth
the depth at which to calculate frustum height. |
Returns
System.Single
Height of the frustum at the specified depth |
GetPlane(Int32)
Returns one of the 6 planes related to this frustum.
Declaration
public Plane GetPlane(int index)
Parameters
System.Int32
index
Plane index where 0 fro Left, 1 for Right, 2 for Top, 3 for Bottom, 4 for Near, 5 for Far |
Returns
Plane
The frustum plane. |
GetWidthAtDepth(Single)
Get the width of the frustum at specified depth.
Declaration
public float GetWidthAtDepth(float depth)
Parameters
System.Single
depth
the depth at which to calculate frustum width. |
Returns
System.Single
With of the frustum at the specified depth |
GetZoomToExtentsShiftDistance(ref BoundingBox)
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(ref BoundingBox boundingBox)
Parameters
BoundingBox
boundingBox
The bounding box. |
Returns
System.Single
The zoom to fit distance |
GetZoomToExtentsShiftDistance(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(Vector3[] points)
Parameters
Vector3[]
points
The points. |
Returns
System.Single
The zoom to fit distance |
GetZoomToExtentsShiftVector(ref BoundingBox)
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(ref BoundingBox boundingBox)
Parameters
BoundingBox
boundingBox
The bounding box. |
Returns
Vector3
The zoom to fit vector |
GetZoomToExtentsShiftVector(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(Vector3[] points)
Parameters
Vector3[]
points
The points. |
Returns
Vector3
The zoom to fit vector |
Intersects(ref BoundingBox)
Checks whether the current BoundingFrustum intersects a BoundingBox.
Declaration
public bool Intersects(ref BoundingBox box)
Parameters
BoundingBox
box
The box. |
Returns
System.Boolean
|
Intersects(ref BoundingBox, out Boolean)
Checks whether the current BoundingFrustum intersects a BoundingBox.
Declaration
public void Intersects(ref BoundingBox box, out bool result)
Parameters
BoundingBox
box
The box. |
System.Boolean
result
|
Intersects(ref BoundingSphere)
Checks whether the current BoundingFrustum intersects a BoundingSphere.
Declaration
public bool Intersects(ref BoundingSphere sphere)
Parameters
BoundingSphere
sphere
The sphere. |
Returns
System.Boolean
Type of the containment |
Intersects(ref BoundingSphere, out Boolean)
Checks whether the current BoundingFrustum intersects a BoundingSphere.
Declaration
public void Intersects(ref BoundingSphere sphere, out bool result)
Parameters
BoundingSphere
sphere
The sphere. |
System.Boolean
result
Set to |
Intersects(ref Plane)
Checks whether the current BoundingFrustum intersects the specified Plane.
Declaration
public PlaneIntersectionType Intersects(ref Plane plane)
Parameters
Plane
plane
The plane. |
Returns
PlaneIntersectionType
Plane intersection type. |
Intersects(ref Plane, out PlaneIntersectionType)
Checks whether the current BoundingFrustum intersects the specified Plane.
Declaration
public void Intersects(ref Plane plane, out PlaneIntersectionType result)
Parameters
Plane
plane
The plane. |
PlaneIntersectionType
result
Plane intersection type. |
Intersects(ref Ray)
Checks whether the current BoundingFrustum intersects the specified Ray.
Declaration
public bool Intersects(ref Ray ray)
Parameters
Ray
ray
The ray. |
Returns
System.Boolean
|
Intersects(ref Ray, out Nullable<Single>, out Nullable<Single>)
Checks whether the current BoundingFrustum intersects the specified Ray.
Declaration
public bool Intersects(ref Ray ray, out Nullable<float> inDistance, out Nullable<float> outDistance)
Parameters
Ray
ray
The Ray to check for intersection with. |
System.Nullable<System.Single>
inDistance
The distance at which the ray enters the frustum if there is an intersection and the ray starts outside the frustum. |
System.Nullable<System.Single>
outDistance
The distance at which the ray exits the frustum if there is an intersection. |
Returns
System.Boolean
|
Operators
Equality(BoundingFrustum, BoundingFrustum)
Implements the operator ==.
Declaration
public static bool operator ==(BoundingFrustum left, BoundingFrustum right)
Parameters
BoundingFrustum
left
The left. |
BoundingFrustum
right
The right. |
Returns
System.Boolean
The result of the operator. |
Inequality(BoundingFrustum, BoundingFrustum)
Implements the operator !=.
Declaration
public static bool operator !=(BoundingFrustum left, BoundingFrustum right)
Parameters
BoundingFrustum
left
The left. |
BoundingFrustum
right
The right. |
Returns
System.Boolean
The result of the operator. |