C# Class Axiom.Core.Frustum

A frustum represents a pyramid, capped at the near and far end which is used to represent either a visible area or a projection area. Can be used for a number of applications.
Inheritance: Axiom.Core.MovableObject, IRenderable
Datei anzeigen Open project: WolfgangSt/axiom Class Usage Examples

Protected Properties

Property Type Description
_boundingBox Axiom.Math.AxisAlignedBox
_coeffB float[]
_coeffL float[]
_coeffR float[]
_coeffT float[]
_farDistance float
_focalLength float
_frustumExtentsManuallySet bool
_frustumOffset Vector2
_lastParentOrientation Axiom.Math.Quaternion
_lastParentPosition Vector3
_left float
_material Axiom.Graphics.Material
_orthoHeight float
_planes Axiom.Math.Plane[]
_projectionMatrix Axiom.Math.Matrix4
_projectionMatrixRS Axiom.Math.Matrix4
_projectionMatrixRSDepth Axiom.Math.Matrix4
_recalculateFrustum bool
_recalculateFrustumPlanes bool
_recalculateVertexData bool
_recalculateView bool
_recalculateWorldSpaceCorners bool
_vertexData Axiom.Graphics.VertexData
_viewMatrix Axiom.Math.Matrix4
_worldSpaceCorners Vector3[]
customParams List
dummyLightList LightList
isReflected bool
lastLinkedObliqueProjPlane Axiom.Math.Plane
lastLinkedReflectionPlane Axiom.Math.Plane
linkedObliqueProjPlane IDerivedPlaneProvider
linkedReflectionPlane IDerivedPlaneProvider
obliqueProjPlane Axiom.Math.Plane
renderOperation Axiom.Graphics.RenderOperation
useObliqueDepthProjection bool

Private Properties

Property Type Description
Initialize void

Public Methods

Method Description
CalcViewMatrixRelative ( Vector3 texProjRelativeOrigin, Matrix4 &tmp ) : void
DisableCustomNearClipPlane ( ) : void

Disables any custom near clip plane.

DisableReflection ( ) : void

Disables reflection modification previously turned on with EnableReflection(Plane).

EnableCustomNearClipPlane ( IDerivedPlaneProvider plane ) : void

Links the frustum to a custom near clip plane, which can be used to clip geometry in a custom manner without using user clip planes.

There are several applications for clipping a scene arbitrarily by a single plane; the most common is when rendering a reflection to a texture, and you only want to render geometry that is above the water plane (to do otherwise results in artefacts). Whilst it is possible to use user clip planes, they are not supported on all cards, and sometimes are not hardware accelerated when they are available. Instead, where a single clip plane is involved, this technique uses a 'fudging' of the near clip plane, which is available and fast on all hardware, to perform as the arbitrary clip plane. This does change the shape of the frustum, leading to some depth buffer loss of precision, but for many of the uses of this technique that is not an issue.

This version of the method links to a plane, rather than requiring a by-value plane definition, and therefore you can make changes to the plane (e.g. by moving / rotating the node it is attached to) and they will automatically affect this object.

This technique only works for perspective projection.

EnableCustomNearClipPlane ( Plane plane ) : void

Links the frustum to a custom near clip plane, which can be used to clip geometry in a custom manner without using user clip planes.

There are several applications for clipping a scene arbitrarily by a single plane; the most common is when rendering a reflection to a texture, and you only want to render geometry that is above the water plane (to do otherwise results in artefacts). Whilst it is possible to use user clip planes, they are not supported on all cards, and sometimes are not hardware accelerated when they are available. Instead, where a single clip plane is involved, this technique uses a 'fudging' of the near clip plane, which is available and fast on all hardware, to perform as the arbitrary clip plane. This does change the shape of the frustum, leading to some depth buffer loss of precision, but for many of the uses of this technique that is not an issue.

This version of the method links to a plane, rather than requiring a by-value plane definition, and therefore you can make changes to the plane (e.g. by moving / rotating the node it is attached to) and they will automatically affect this object.

This technique only works for perspective projection.

EnableReflection ( IDerivedPlaneProvider plane ) : void

Modifies this frustum so it always renders from the reflection of itself through the plane specified. Note that this version of the method links to a plane so that changes to it are picked up automatically.

This is obviously useful for performing planar reflections.

EnableReflection ( Plane plane ) : void

Modifies this camera so it always renders from the reflection of itself through the plane specified.

This is obviously useful for rendering planar reflections.

Frustum ( ) : System

Default constructor.

Frustum ( string name ) : System
GetCustomParameter ( int index ) : Vector4
GetFrustumExtents ( float &left, float &right, float &top, float &bottom ) : void
GetSquaredViewDepth ( Camera camera ) : float
GetWorldTransforms ( Matrix4 matrices ) : void
IsObjectVisible ( AxisAlignedBox box ) : bool

Overloaded method.

IsObjectVisible ( AxisAlignedBox box, FrustumPlane &culledBy ) : bool

Tests whether the given box is visible in the Frustum.

IsObjectVisible ( Sphere sphere ) : bool

Overloaded method.

IsObjectVisible ( Sphere sphere, FrustumPlane &culledBy ) : bool

Tests whether the given sphere is in the viewing frustum.

IsObjectVisible ( Vector3 vertex ) : bool

Overloaded method.

IsObjectVisible ( Vector3 vertex, FrustumPlane &culledBy ) : bool

Tests whether the given 3D point is in the viewing frustum.

NotifyCurrentCamera ( Camera camera ) : void

ProjectSphere ( Sphere sphere, float &left, float &top, float &right, float &bottom ) : bool
ResetFrustumExtents ( ) : void
SetCustomParameter ( int index, Vector4 val ) : void
SetCustomProjectionMatrix ( bool enable ) : void
SetCustomProjectionMatrix ( bool enable, Matrix4 projMatrix ) : void
SetCustomViewMatrix ( bool enable ) : void
SetCustomViewMatrix ( bool enable, Matrix4 viewMatrix ) : void
SetFrustumExtents ( float left, float right, float top, float bottom ) : void
SetOrthoWindow ( float w, float h ) : void

Set view area size for orthographic mode.

Note that this method adjusts the frustum's aspect ratio.

UpdateCustomGpuParameter ( GpuProgramParameters entry, GpuProgramParameters gpuParams ) : void
UpdateRenderQueue ( RenderQueue queue ) : void

Implemented to add outself to the rendering queue.

this ( FrustumPlane plane ) : Plane

An indexer that accepts a FrustumPlane enum value and return the appropriate plane side of the Frustum.

Protected Methods

Method Description
CalculateProjectionParameters ( Real &vpLeft, Real &vpRight, Real &vpBottom, Real &vpTop ) : void
GetOrientationForViewUpdate ( ) : Quaternion

Get the derived orientation of this frustum.

GetPositionForViewUpdate ( ) : Vector3

Get the derived position of this frustum.

InvalidateFrustum ( ) : void

Signal to update frustum information.

InvalidateView ( ) : void

Signal to update view information.

UpdateFrustum ( ) : void

Updates the frustum data.

UpdateFrustumPlanes ( ) : void
UpdateVertexData ( ) : void
UpdateView ( ) : void

Updates the view matrix.

UpdateWorldSpaceCorners ( ) : void
_updateFrustum ( ) : void
_updateFrustumPlanes ( ) : void
_updateView ( ) : void
_updateWorldSpaceCorners ( ) : void
dispose ( bool disposeManagedResources ) : void

Class level dispose method

When implementing this method in an inherited class the following template should be used; protected override void dispose( bool disposeManagedResources ) { if ( !isDisposed ) { if ( disposeManagedResources ) { // Dispose managed resources. } // There are no unmanaged resources to release, but // if we add them, they need to be released here. } // If it is available, make the call to the // base class's Dispose(Boolean) method base.dispose( disposeManagedResources ); }

Private Methods

Method Description
Initialize ( ) : void

Method Details

CalcViewMatrixRelative() public method

public CalcViewMatrixRelative ( Vector3 texProjRelativeOrigin, Matrix4 &tmp ) : void
texProjRelativeOrigin Vector3
tmp Axiom.Math.Matrix4
return void

CalculateProjectionParameters() protected method

protected CalculateProjectionParameters ( Real &vpLeft, Real &vpRight, Real &vpBottom, Real &vpTop ) : void
vpLeft Real
vpRight Real
vpBottom Real
vpTop Real
return void

DisableCustomNearClipPlane() public method

Disables any custom near clip plane.
public DisableCustomNearClipPlane ( ) : void
return void

DisableReflection() public method

Disables reflection modification previously turned on with EnableReflection(Plane).
public DisableReflection ( ) : void
return void

EnableCustomNearClipPlane() public method

Links the frustum to a custom near clip plane, which can be used to clip geometry in a custom manner without using user clip planes.

There are several applications for clipping a scene arbitrarily by a single plane; the most common is when rendering a reflection to a texture, and you only want to render geometry that is above the water plane (to do otherwise results in artefacts). Whilst it is possible to use user clip planes, they are not supported on all cards, and sometimes are not hardware accelerated when they are available. Instead, where a single clip plane is involved, this technique uses a 'fudging' of the near clip plane, which is available and fast on all hardware, to perform as the arbitrary clip plane. This does change the shape of the frustum, leading to some depth buffer loss of precision, but for many of the uses of this technique that is not an issue.

This version of the method links to a plane, rather than requiring a by-value plane definition, and therefore you can make changes to the plane (e.g. by moving / rotating the node it is attached to) and they will automatically affect this object.

This technique only works for perspective projection.

public EnableCustomNearClipPlane ( IDerivedPlaneProvider plane ) : void
plane IDerivedPlaneProvider The plane to link to to perform the clipping.
return void

EnableCustomNearClipPlane() public method

Links the frustum to a custom near clip plane, which can be used to clip geometry in a custom manner without using user clip planes.

There are several applications for clipping a scene arbitrarily by a single plane; the most common is when rendering a reflection to a texture, and you only want to render geometry that is above the water plane (to do otherwise results in artefacts). Whilst it is possible to use user clip planes, they are not supported on all cards, and sometimes are not hardware accelerated when they are available. Instead, where a single clip plane is involved, this technique uses a 'fudging' of the near clip plane, which is available and fast on all hardware, to perform as the arbitrary clip plane. This does change the shape of the frustum, leading to some depth buffer loss of precision, but for many of the uses of this technique that is not an issue.

This version of the method links to a plane, rather than requiring a by-value plane definition, and therefore you can make changes to the plane (e.g. by moving / rotating the node it is attached to) and they will automatically affect this object.

This technique only works for perspective projection.

public EnableCustomNearClipPlane ( Plane plane ) : void
plane Axiom.Math.Plane The plane to link to to perform the clipping.
return void

EnableReflection() public method

Modifies this frustum so it always renders from the reflection of itself through the plane specified. Note that this version of the method links to a plane so that changes to it are picked up automatically.
This is obviously useful for performing planar reflections.
public EnableReflection ( IDerivedPlaneProvider plane ) : void
plane IDerivedPlaneProvider
return void

EnableReflection() public method

Modifies this camera so it always renders from the reflection of itself through the plane specified.
This is obviously useful for rendering planar reflections.
public EnableReflection ( Plane plane ) : void
plane Axiom.Math.Plane
return void

Frustum() public method

Default constructor.
public Frustum ( ) : System
return System

Frustum() public method

public Frustum ( string name ) : System
name string
return System

GetCustomParameter() public method

public GetCustomParameter ( int index ) : Vector4
index int
return Vector4

GetFrustumExtents() public method

public GetFrustumExtents ( float &left, float &right, float &top, float &bottom ) : void
left float
right float
top float
bottom float
return void

GetOrientationForViewUpdate() protected method

Get the derived orientation of this frustum.
protected GetOrientationForViewUpdate ( ) : Quaternion
return Axiom.Math.Quaternion

GetPositionForViewUpdate() protected method

Get the derived position of this frustum.
protected GetPositionForViewUpdate ( ) : Vector3
return Vector3

GetSquaredViewDepth() public method

public GetSquaredViewDepth ( Camera camera ) : float
camera Camera
return float

GetWorldTransforms() public method

public GetWorldTransforms ( Matrix4 matrices ) : void
matrices Axiom.Math.Matrix4
return void

InvalidateFrustum() protected method

Signal to update frustum information.
protected InvalidateFrustum ( ) : void
return void

InvalidateView() protected method

Signal to update view information.
protected InvalidateView ( ) : void
return void

IsObjectVisible() public method

Overloaded method.
public IsObjectVisible ( AxisAlignedBox box ) : bool
box Axiom.Math.AxisAlignedBox
return bool

IsObjectVisible() public method

Tests whether the given box is visible in the Frustum.
public IsObjectVisible ( AxisAlignedBox box, FrustumPlane &culledBy ) : bool
box Axiom.Math.AxisAlignedBox Bounding box to be checked.
culledBy FrustumPlane /// Optional FrustrumPlane params which will be filled by the plane which culled /// the box if the result was false. ///
return bool

IsObjectVisible() public method

Overloaded method.
public IsObjectVisible ( Sphere sphere ) : bool
sphere Axiom.Math.Sphere
return bool

IsObjectVisible() public method

Tests whether the given sphere is in the viewing frustum.
public IsObjectVisible ( Sphere sphere, FrustumPlane &culledBy ) : bool
sphere Axiom.Math.Sphere Bounding sphere to be checked.
culledBy FrustumPlane /// Optional FrustrumPlane params which will be filled by the plane which culled /// the box if the result was false. ///
return bool

IsObjectVisible() public method

Overloaded method.
public IsObjectVisible ( Vector3 vertex ) : bool
vertex Vector3
return bool

IsObjectVisible() public method

Tests whether the given 3D point is in the viewing frustum.
public IsObjectVisible ( Vector3 vertex, FrustumPlane &culledBy ) : bool
vertex Vector3 3D point to check for frustum visibility.
culledBy FrustumPlane /// Optional FrustrumPlane params which will be filled by the plane which culled /// the box if the result was false. ///
return bool

NotifyCurrentCamera() public method

public NotifyCurrentCamera ( Camera camera ) : void
camera Camera
return void

ProjectSphere() public method

public ProjectSphere ( Sphere sphere, float &left, float &top, float &right, float &bottom ) : bool
sphere Axiom.Math.Sphere
left float
top float
right float
bottom float
return bool

ResetFrustumExtents() public method

public ResetFrustumExtents ( ) : void
return void

SetCustomParameter() public method

public SetCustomParameter ( int index, Vector4 val ) : void
index int
val Vector4
return void

SetCustomProjectionMatrix() public method

public SetCustomProjectionMatrix ( bool enable ) : void
enable bool
return void

SetCustomProjectionMatrix() public method

public SetCustomProjectionMatrix ( bool enable, Matrix4 projMatrix ) : void
enable bool
projMatrix Axiom.Math.Matrix4
return void

SetCustomViewMatrix() public method

public SetCustomViewMatrix ( bool enable ) : void
enable bool
return void

SetCustomViewMatrix() public method

public SetCustomViewMatrix ( bool enable, Matrix4 viewMatrix ) : void
enable bool
viewMatrix Axiom.Math.Matrix4
return void

SetFrustumExtents() public method

public SetFrustumExtents ( float left, float right, float top, float bottom ) : void
left float
right float
top float
bottom float
return void

SetOrthoWindow() public method

Set view area size for orthographic mode.
Note that this method adjusts the frustum's aspect ratio.
public SetOrthoWindow ( float w, float h ) : void
w float Width of the area to be visible
h float Height of the area to be visible
return void

UpdateCustomGpuParameter() public method

public UpdateCustomGpuParameter ( GpuProgramParameters entry, GpuProgramParameters gpuParams ) : void
entry Axiom.Graphics.GpuProgramParameters
gpuParams Axiom.Graphics.GpuProgramParameters
return void

UpdateFrustum() protected method

Updates the frustum data.
protected UpdateFrustum ( ) : void
return void

UpdateFrustumPlanes() protected method

protected UpdateFrustumPlanes ( ) : void
return void

UpdateRenderQueue() public method

Implemented to add outself to the rendering queue.
public UpdateRenderQueue ( RenderQueue queue ) : void
queue Axiom.Graphics.RenderQueue
return void

UpdateVertexData() protected method

protected UpdateVertexData ( ) : void
return void

UpdateView() protected method

Updates the view matrix.
protected UpdateView ( ) : void
return void

UpdateWorldSpaceCorners() protected method

protected UpdateWorldSpaceCorners ( ) : void
return void

_updateFrustum() protected method

protected _updateFrustum ( ) : void
return void

_updateFrustumPlanes() protected method

protected _updateFrustumPlanes ( ) : void
return void

_updateView() protected method

protected _updateView ( ) : void
return void

_updateWorldSpaceCorners() protected method

protected _updateWorldSpaceCorners ( ) : void
return void

dispose() protected method

Class level dispose method
When implementing this method in an inherited class the following template should be used; protected override void dispose( bool disposeManagedResources ) { if ( !isDisposed ) { if ( disposeManagedResources ) { // Dispose managed resources. } // There are no unmanaged resources to release, but // if we add them, they need to be released here. } // If it is available, make the call to the // base class's Dispose(Boolean) method base.dispose( disposeManagedResources ); }
protected dispose ( bool disposeManagedResources ) : void
disposeManagedResources bool True if Unmanaged resources should be released.
return void

this() public method

An indexer that accepts a FrustumPlane enum value and return the appropriate plane side of the Frustum.
public this ( FrustumPlane plane ) : Plane
plane FrustumPlane
return Axiom.Math.Plane

Property Details

_boundingBox protected_oe property

Bounding box of this frustum.
protected AxisAlignedBox,Axiom.Math _boundingBox
return Axiom.Math.AxisAlignedBox

_coeffB protected_oe property

protected float[] _coeffB
return float[]

_coeffL protected_oe property

protected float[] _coeffL
return float[]

_coeffR protected_oe property

protected float[] _coeffR
return float[]

_coeffT protected_oe property

protected float[] _coeffT
return float[]

_farDistance protected_oe property

Far clip distance - default 10000.
protected float _farDistance
return float

_focalLength protected_oe property

Focal length of frustum (for stereo rendering, defaults to 1.0)
protected float _focalLength
return float

_frustumExtentsManuallySet protected_oe property

protected bool _frustumExtentsManuallySet
return bool

_frustumOffset protected_oe property

Off-axis frustum center offset - default (0.0, 0.0)
protected Vector2 _frustumOffset
return Vector2

_lastParentOrientation protected_oe property

Stored versions of parent orientation.
protected Quaternion,Axiom.Math _lastParentOrientation
return Axiom.Math.Quaternion

_lastParentPosition protected_oe property

Stored versions of parent position.
protected Vector3 _lastParentPosition
return Vector3

_left protected_oe property

protected float _left
return float

_material protected_oe property

Material to use when rendering this frustum.
protected Material,Axiom.Graphics _material
return Axiom.Graphics.Material

_orthoHeight protected_oe property

protected float _orthoHeight
return float

_planes protected_oe property

The 6 main clipping planes.
protected Plane[],Axiom.Math _planes
return Axiom.Math.Plane[]

_projectionMatrix protected_oe property

The normal projection matrix for this frustum, ie the projection matrix which conforms to standard right-handed rules and uses depth range [-1,+1].
This differs from the rendering-API dependent getProjectionMatrixRS in that it always returns a right-handed projection matrix with depth range [-1,+1], result no matter what rendering API is being used - this is required for some uniform algebra for example.
protected Matrix4,Axiom.Math _projectionMatrix
return Axiom.Math.Matrix4

_projectionMatrixRS protected_oe property

Gets the projection matrix for this frustum adjusted for the current rendersystem specifics (may be right or left-handed, depth range may vary).
This method retrieves the rendering-API dependent version of the projection matrix. If you want a 'typical' projection matrix then use _projectionMatrix.
protected Matrix4,Axiom.Math _projectionMatrixRS
return Axiom.Math.Matrix4

_projectionMatrixRSDepth protected_oe property

The depth-adjusted projection matrix for the current rendersystem, but one which still conforms to right-hand rules.
This differs from the rendering-API dependent getProjectionMatrix in that it always returns a right-handed projection matrix result no matter what rendering API is being used - this is required for vertex and fragment programs for example. However, the resulting depth range may still vary between render systems since D3D uses [0,1] and GL uses [-1,1], and the range must be kept the same between programmable and fixed-function pipelines.
protected Matrix4,Axiom.Math _projectionMatrixRSDepth
return Axiom.Math.Matrix4

_recalculateFrustum protected_oe property

Something's changed in the frustum shape?
protected bool _recalculateFrustum
return bool

_recalculateFrustumPlanes protected_oe property

protected bool _recalculateFrustumPlanes
return bool

_recalculateVertexData protected_oe property

protected bool _recalculateVertexData
return bool

_recalculateView protected_oe property

Something in the view pos has changed?
protected bool _recalculateView
return bool

_recalculateWorldSpaceCorners protected_oe property

Signal to recalculate World Space Corners
protected bool _recalculateWorldSpaceCorners
return bool

_vertexData protected_oe property

Vertex info for rendering this frustum.
protected VertexData,Axiom.Graphics _vertexData
return Axiom.Graphics.VertexData

_viewMatrix protected_oe property

Pre-calced view matrix.
protected Matrix4,Axiom.Math _viewMatrix
return Axiom.Math.Matrix4

_worldSpaceCorners protected_oe property

Frustum corners in world space.
protected Vector3[] _worldSpaceCorners
return Vector3[]

customParams protected_oe property

protected List customParams
return List

dummyLightList protected_oe property

Dummy list for IRenderable.Lights since we wont be lit.
protected LightList dummyLightList
return LightList

isReflected protected_oe property

Is this frustum to act as a reflection of itself?
protected bool isReflected
return bool

lastLinkedObliqueProjPlane protected_oe property

Record of the last world-space oblique depth projection plane info used.
protected Plane,Axiom.Math lastLinkedObliqueProjPlane
return Axiom.Math.Plane

lastLinkedReflectionPlane protected_oe property

Record of the last world-space reflection plane info used.
protected Plane,Axiom.Math lastLinkedReflectionPlane
return Axiom.Math.Plane

linkedObliqueProjPlane protected_oe property

Reference to oblique projection plane (automatically updated).
protected IDerivedPlaneProvider linkedObliqueProjPlane
return IDerivedPlaneProvider

linkedReflectionPlane protected_oe property

Reference of a reflection plane (automatically updated).
protected IDerivedPlaneProvider linkedReflectionPlane
return IDerivedPlaneProvider

obliqueProjPlane protected_oe property

Fixed oblique projection plane.
protected Plane,Axiom.Math obliqueProjPlane
return Axiom.Math.Plane

renderOperation protected_oe property

protected RenderOperation,Axiom.Graphics renderOperation
return Axiom.Graphics.RenderOperation

useObliqueDepthProjection protected_oe property

Is this frustum using an oblique depth projection?
protected bool useObliqueDepthProjection
return bool