Struct BoundingFrustum
- Namespace
- HelixToolkit.Maths
- Assembly
- HelixToolkit.Maths.dll
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.
public struct BoundingFrustum : IEquatable<BoundingFrustum>
- Implements
- Inherited Members
- Extension Methods
Constructors
BoundingFrustum(Matrix4x4)
Creates a new instance of BoundingFrustum.
public BoundingFrustum(Matrix4x4 matrix)
Parameters
matrixMatrix4x4Combined matrix that usually takes view × projection matrix.
Properties
Bottom
Gets the bottom plane of the BoundingFrustum.
public readonly Plane Bottom { get; }
Property Value
Far
Gets the far plane of the BoundingFrustum.
public readonly Plane Far { get; }
Property Value
IsOrthographic
Indicate whether the current BoundingFrustrum is Orthographic.
public readonly bool IsOrthographic { get; }
Property Value
- bool
trueif the current BoundingFrustrum is Orthographic; otherwise,false.
Left
Gets the left plane of the BoundingFrustum.
public readonly Plane Left { get; }
Property Value
Matrix
Gets or sets the Matrix that describes this bounding frustum.
public Matrix4x4 Matrix { readonly get; set; }
Property Value
Near
Gets the near plane of the BoundingFrustum.
public readonly Plane Near { get; }
Property Value
Right
Gets the right plane of the BoundingFrustum.
public readonly Plane Right { get; }
Property Value
Top
Gets the top plane of the BoundingFrustum.
public readonly Plane Top { get; }
Property Value
Methods
Contains(BoundingBox)
Determines the intersection relationship between the frustum and a bounding box.
public readonly ContainmentType Contains(BoundingBox box)
Parameters
boxBoundingBoxThe box.
Returns
- ContainmentType
Type of the containment
Contains(ref BoundingBox)
Determines the intersection relationship between the frustum and a bounding box.
public readonly ContainmentType Contains(ref BoundingBox box)
Parameters
boxBoundingBoxThe box.
Returns
- ContainmentType
Type of the containment
Contains(ref BoundingBox, out ContainmentType)
Determines the intersection relationship between the frustum and a bounding box.
public readonly void Contains(ref BoundingBox box, out ContainmentType result)
Parameters
boxBoundingBoxThe box.
resultContainmentTypeType of the containment.
Contains(BoundingSphere)
Determines the intersection relationship between the frustum and a bounding sphere.
public readonly ContainmentType Contains(BoundingSphere sphere)
Parameters
sphereBoundingSphereThe sphere.
Returns
- ContainmentType
Type of the containment
Contains(ref BoundingSphere)
Determines the intersection relationship between the frustum and a bounding sphere.
public readonly ContainmentType Contains(ref BoundingSphere sphere)
Parameters
sphereBoundingSphereThe sphere.
Returns
- ContainmentType
Type of the containment
Contains(ref BoundingSphere, out ContainmentType)
Determines the intersection relationship between the frustum and a bounding sphere.
public readonly void Contains(ref BoundingSphere sphere, out ContainmentType result)
Parameters
sphereBoundingSphereThe sphere.
resultContainmentTypeType of the containment.
Contains(Vector3)
Checks whether a point lay inside, intersects or lay outside the frustum.
public readonly ContainmentType Contains(Vector3 point)
Parameters
pointVector3The point.
Returns
- ContainmentType
Type of the containment
Contains(ref Vector3)
Checks whether a point lay inside, intersects or lay outside the frustum.
public readonly ContainmentType Contains(ref Vector3 point)
Parameters
pointVector3The point.
Returns
- ContainmentType
Type of the containment
Equals(BoundingFrustum)
Determines whether the specified BoundingFrustum is equal to this instance.
public readonly bool Equals(BoundingFrustum other)
Parameters
otherBoundingFrustumThe BoundingFrustum to compare with this instance.
Returns
- bool
trueif the specified BoundingFrustum is equal to this instance; otherwise,false.
Equals(ref BoundingFrustum)
Determines whether the specified BoundingFrustum is equal to this instance.
public readonly bool Equals(ref BoundingFrustum other)
Parameters
otherBoundingFrustumThe BoundingFrustum to compare with this instance.
Returns
- bool
trueif the specified BoundingFrustum 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
Returns
FromCamera(FrustumCameraParams)
Creates a new frustum relaying on perspective camera parameters
public static BoundingFrustum FromCamera(FrustumCameraParams cameraParams)
Parameters
cameraParamsFrustumCameraParamsThe camera params.
Returns
- BoundingFrustum
The bounding frustum from camera params
FromCamera(Vector3, Vector3, Vector3, float, float, float, float)
Creates a new frustum relaying on perspective camera parameters
public static BoundingFrustum FromCamera(Vector3 cameraPos, Vector3 lookDir, Vector3 upDir, float fov, float znear, float zfar, float aspect)
Parameters
cameraPosVector3The camera pos.
lookDirVector3The look dir.
upDirVector3Up dir.
fovfloatThe fov.
znearfloatThe znear.
zfarfloatThe zfar.
aspectfloatThe aspect.
Returns
- BoundingFrustum
The bounding frustum calculated from perspective camera
GetCameraParams()
Extracts perspective camera parameters from the frustum, doesn't work with orthographic frustums.
public FrustumCameraParams GetCameraParams()
Returns
- FrustumCameraParams
Perspective camera parameters from the frustum
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)
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)
public void GetCorners(Vector3[] corners)
Parameters
cornersVector3[]
GetHashCode()
Returns the hash code for this instance.
public override readonly int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
GetHeightAtDepth(float)
Get the height of the frustum at specified depth.
public readonly float GetHeightAtDepth(float depth)
Parameters
depthfloatthe depth at which to calculate frustum height.
Returns
- float
Height of the frustum at the specified depth
GetPlane(int)
Returns one of the 6 planes related to this frustum.
public readonly Plane GetPlane(int index)
Parameters
indexintPlane index where 0 fro Left, 1 for Right, 2 for Top, 3 for Bottom, 4 for Near, 5 for Far
Returns
GetWidthAtDepth(float)
Get the width of the frustum at specified depth.
public readonly float GetWidthAtDepth(float depth)
Parameters
depthfloatthe depth at which to calculate frustum width.
Returns
- float
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).
public readonly float GetZoomToExtentsShiftDistance(ref BoundingBox boundingBox)
Parameters
boundingBoxBoundingBoxThe bounding box.
Returns
- float
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).
public readonly float GetZoomToExtentsShiftDistance(Vector3[] points)
Parameters
pointsVector3[]The points.
Returns
- float
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.
public readonly Vector3 GetZoomToExtentsShiftVector(ref BoundingBox boundingBox)
Parameters
boundingBoxBoundingBoxThe 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.
public readonly Vector3 GetZoomToExtentsShiftVector(Vector3[] points)
Parameters
pointsVector3[]The points.
Returns
- Vector3
The zoom to fit vector
Intersects(ref BoundingBox)
Checks whether the current BoundingFrustum intersects a BoundingBox.
public readonly bool Intersects(ref BoundingBox box)
Parameters
boxBoundingBoxThe box.
Returns
- bool
trueif the current BoundingFrustum intersects a BoundingSphere.
Intersects(ref BoundingBox, out bool)
Checks whether the current BoundingFrustum intersects a BoundingBox.
public readonly void Intersects(ref BoundingBox box, out bool result)
Parameters
boxBoundingBoxThe box.
resultbooltrueif the current BoundingFrustum intersects a BoundingSphere.
Intersects(ref BoundingSphere)
Checks whether the current BoundingFrustum intersects a BoundingSphere.
public readonly bool Intersects(ref BoundingSphere sphere)
Parameters
sphereBoundingSphereThe sphere.
Returns
- bool
Type of the containment
Intersects(ref BoundingSphere, out bool)
Checks whether the current BoundingFrustum intersects a BoundingSphere.
public readonly void Intersects(ref BoundingSphere sphere, out bool result)
Parameters
sphereBoundingSphereThe sphere.
resultboolSet to
trueif the current BoundingFrustum intersects a BoundingSphere.
Intersects(ref Ray)
Checks whether the current BoundingFrustum intersects the specified Ray.
public readonly bool Intersects(ref Ray ray)
Parameters
rayRayThe ray.
Returns
- bool
trueif the current BoundingFrustum intersects the specified Ray.
Intersects(ref Ray, out float?, out float?)
Checks whether the current BoundingFrustum intersects the specified Ray.
public readonly bool Intersects(ref Ray ray, out float? inDistance, out float? outDistance)
Parameters
rayRayThe Ray to check for intersection with.
inDistancefloat?The distance at which the ray enters the frustum if there is an intersection and the ray starts outside the frustum.
outDistancefloat?The distance at which the ray exits the frustum if there is an intersection.
Returns
- bool
trueif the current BoundingFrustum intersects the specified Ray.
Intersects(ref Plane)
Checks whether the current BoundingFrustum intersects the specified Plane.
public PlaneIntersectionType Intersects(ref Plane plane)
Parameters
planePlaneThe plane.
Returns
- PlaneIntersectionType
Plane intersection type.
Intersects(ref Plane, out PlaneIntersectionType)
Checks whether the current BoundingFrustum intersects the specified Plane.
public void Intersects(ref Plane plane, out PlaneIntersectionType result)
Parameters
planePlaneThe plane.
resultPlaneIntersectionTypePlane intersection type.
Operators
operator ==(BoundingFrustum, BoundingFrustum)
Implements the operator ==.
public static bool operator ==(BoundingFrustum left, BoundingFrustum right)
Parameters
leftBoundingFrustumThe left.
rightBoundingFrustumThe right.
Returns
- bool
The result of the operator.
operator !=(BoundingFrustum, BoundingFrustum)
Implements the operator !=.
public static bool operator !=(BoundingFrustum left, BoundingFrustum right)
Parameters
leftBoundingFrustumThe left.
rightBoundingFrustumThe right.
Returns
- bool
The result of the operator.