Gorgon
Show / Hide Table of Contents

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.

Inheritance
object
GorgonBoundingFrustum
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: Gorgon.Renderers.Data
Assembly: Gorgon.Core.dll
Syntax
public class GorgonBoundingFrustum

Properties

| Edit this page View Source

Corners

Property to return the corner list for this frustum.

Declaration
public GorgonBoundingFrustum.CornerList Corners { get; }
Property Value
Type Description
GorgonBoundingFrustum.CornerList
| Edit this page View Source

IsOrthographic

Indicate whether the current BoundingFrustrum is Orthographic.

Declaration
public bool IsOrthographic { get; }
Property Value
Type Description
bool
| Edit this page View Source

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 Source

Create(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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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

| Edit this page View Source

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

| Edit this page View Source

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

| Edit this page View Source

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

| Edit this page View Source

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

| Edit this page View Source

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

| Edit this page View Source

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

| Edit this page View Source

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.

| Edit this page View Source

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.

Extension Methods

GorgonDebugExtensions.ValidateObject<T>(T, string)
GorgonNullExtensions.AsNullable<T>(object)
GorgonNullExtensions.IfNull<T>(object, T)
GorgonNullExtensions.IsNull(object)
  • Edit this page
  • View Source
In this article
Back to top Copyright 2023 - Licensed under the MIT license by Michael Winsor (Tape_Worm).
Send comments on this topic to the author