overview wiki api reference download
 All Classes Functions Variables Typedefs Enumerations Enumerator
Public Member Functions
gameplay::Frustum Class Reference

#include <Frustum.h>

List of all members.

Public Member Functions

 Frustum ()
 Frustum (const Matrix &matrix)
 Frustum (const Frustum &frustum)
 ~Frustum ()
const PlanegetNear () const
const PlanegetFar () const
const PlanegetLeft () const
const PlanegetRight () const
const PlanegetBottom () const
const PlanegetTop () const
void getMatrix (Matrix *dst) const
void getCorners (Vector3 *corners) const
void getNearCorners (Vector3 *corners) const
void getFarCorners (Vector3 *corners) const
bool intersects (const Vector3 &point) const
bool intersects (float x, float y, float z) const
bool intersects (const BoundingSphere &sphere) const
bool intersects (const BoundingBox &box) const
float intersects (const Plane &plane) const
float intersects (const Ray &ray) const
void set (const Frustum &frustum)
void set (const Matrix &matrix)

Detailed Description

Defines a 3-dimensional frustum.

A frustum in computer graphics is generally a volume of 3D space, defined as the part of a rectangular pyramid that lies between two planes perpendicular to its center line. A frustum is often used to represent what a "camera" sees in your 3D space.

The Frustum class allows you to define a bounding frustum using a combined matrix that is generally the product of a view matrix and a projection matrix.

You can query a Frustum object for any one of its bounding planes, for its corners, and for whether it intersects with a given object. Since objects that don't intersect with your view frustum generally don't need to be rendered, culling them quickly can save you a lot of rendering time.


Constructor & Destructor Documentation

Constructs the default frustum (corresponds to the identity matrix).

gameplay::Frustum::Frustum ( const Matrix matrix)

Constructs a new frustum from the specified view projection matrix.

Parameters:
matrixThe view projection matrix to create this frustum from.
gameplay::Frustum::Frustum ( const Frustum frustum)

Constructs a new frustum from the given frustum.

Parameters:
frustumThe frustum to create this frustum from.

Destructor.


Member Function Documentation

Gets the bottom plane of the frustum.

Returns:
bottom The bottom plane.
void gameplay::Frustum::getCorners ( Vector3 corners) const

Gets the corners of the frustum in the specified array.

The corners are stored in the following order: (N-near, F-far, L-left, R-right, B-bottom, T-top) LTN, LBN, RBN, RTN, RTF, RBF, LBF, LTF.

Parameters:
cornersThe array (of at least size 8) to store the corners in.
const Plane& gameplay::Frustum::getFar ( ) const

Gets the far plane of the frustum.

Returns:
far The far plane.
void gameplay::Frustum::getFarCorners ( Vector3 corners) const

Gets the corners of the frustum's far plane in the specified array.

The corners are stored in the following order: right-top, right-bottom, left-bottom, left-top.

Parameters:
cornersThe array (of at least size 4) to store the corners in.

Gets the left plane of the frustum.

Returns:
left The left plane.
void gameplay::Frustum::getMatrix ( Matrix dst) const

Gets the projection matrix corresponding to the frustum in the specified matrix.

Parameters:
dstThe projection matrix to copy into.

Gets the near plane of the frustum.

Returns:
near The near plane.
void gameplay::Frustum::getNearCorners ( Vector3 corners) const

Gets the corners of the frustum's near plane in the specified array.

The corners are stored in the following order: left-top, left-bottom, right-bottom, right-top.

Parameters:
cornersThe array (of at least size 4) to store the corners in.

Gets the right plane of the frustum.

Returns:
right The right plane.
const Plane& gameplay::Frustum::getTop ( ) const

Gets the top plane of the frustum.

Returns:
top The top plane.
bool gameplay::Frustum::intersects ( const Vector3 point) const

Tests whether this frustum intersects the specified point.

Parameters:
pointThe point to test intersection with.
Returns:
true if the specified point intersects this frustum; false otherwise.
bool gameplay::Frustum::intersects ( float  x,
float  y,
float  z 
) const

Tests whether this frustum intersects the specified point.

Parameters:
xThe x coordinate.
yThe y coordinate.
zThe z coordinate.
Returns:
true if the specified point intersects this frustum; false otherwise.
bool gameplay::Frustum::intersects ( const BoundingSphere sphere) const

Tests whether this frustum intersects the specified bounding sphere.

Parameters:
sphereThe bounding sphere to test intersection with.
Returns:
true if the specified bounding sphere intersects this frustum; false otherwise.
bool gameplay::Frustum::intersects ( const BoundingBox box) const

Tests whether this frustum intersects the specified bounding box.

Parameters:
boxThe bounding box to test intersection with.
Returns:
true if the specified bounding box intersects this frustum; false otherwise.
float gameplay::Frustum::intersects ( const Plane plane) const

Tests whether this frustum intersects the specified plane.

Parameters:
planeThe plane to test intersection with.
Returns:
Plane::INTERSECTS_BACK if the specified bounding object is in the negative half-space of this plane, Plane::INTERSECTS_FRONT if it is in the positive half-space of this plane, and Plane::INTERSECTS_INTERSECTING if it intersects this plane.
float gameplay::Frustum::intersects ( const Ray ray) const

Tests whether this frustum intersects the specified ray.

Parameters:
rayThe ray to test intersection with.
Returns:
Plane::INTERSECTS_BACK if the specified ray is in the negative half-space of this plane, Plane::INTERSECTS_FRONT if it is in the positive half-space of this plane, and Plane::INTERSECTS_INTERSECTING if it intersects this plane.
void gameplay::Frustum::set ( const Frustum frustum)

Sets this frustum to the specified frustum.

Parameters:
frustumThe frustum to set to.
void gameplay::Frustum::set ( const Matrix matrix)

Sets the frustum to the frustum corresponding to the specified view projection matrix.

Parameters:
matrixThe view projection matrix.
 All Classes Functions Variables Typedefs Enumerations Enumerator