Frustum Class Reference

#include <frustum.h>

List of all members.

Public Types

typedef GLPlaned TPlane
enum  TPlaneID {
  PL_LEFT = 0, PL_RIGHT, PL_TOP, PL_BOTTOM,
  PL_NEAR, PL_FAR
}
enum  ClipState { OUTSIDE, INSIDE, INTERSECT }
enum  Halfspace { NEGATIVE = -1, POSITIVE = +1, ON_PLANE = 0 }

Public Member Functions

 Frustum ()
 Frustum (const Frustum &f)
 Frustum (const GLMatrix4d &m)
void set (const GLMatrix4d &m, bool normalize=true)
 Sets the frustrum clipping planes from matrix m.
void transform (const GLMatrix4d &m, bool normalize=true)
 Transforms frustum planes to test objects in object space.
const TPlanegetPlane (TPlaneID planeID)
 Gets one frustum plane.
void normalizePlane (TPlaneID planeID)
 Normalizes given plane.
void normalizeAllPlanes (void)
 Normalizes all frustum planes.
bool testPoint (const GLVector3d &p)
ClipState testSphere (const GLVector3d &center, const double r) const
ClipState testBox (const GLVector3d &center, const GLVector3d &extent) const

Static Public Member Functions

static Halfspace classifyPoint (const TPlane &plane, const GLVector3d &point, const double eps=0.0f)

Private Types

typedef std::vector< TPlaneTPlaneContainer

Private Member Functions

int mi (int row, int col)
 "matrix index" - helper method

Private Attributes

TPlaneContainer mPlanes
 six clipping planes of frustum


Detailed Description

Definition at line 11 of file frustum.h.


Member Typedef Documentation

typedef GLPlaned Frustum::TPlane
 

Definition at line 14 of file frustum.h.

typedef std::vector<TPlane> Frustum::TPlaneContainer [private]
 

Definition at line 109 of file frustum.h.


Member Enumeration Documentation

enum Frustum::ClipState
 

Enumerator:
OUTSIDE 
INSIDE 
INTERSECT 

Definition at line 25 of file frustum.h.

enum Frustum::Halfspace
 

Enumerator:
NEGATIVE 
POSITIVE 
ON_PLANE 

Definition at line 82 of file frustum.h.

enum Frustum::TPlaneID
 

Enumerator:
PL_LEFT 
PL_RIGHT 
PL_TOP 
PL_BOTTOM 
PL_NEAR 
PL_FAR 

Definition at line 16 of file frustum.h.


Constructor & Destructor Documentation

Frustum::Frustum  )  [inline]
 

Definition at line 31 of file frustum.h.

Frustum::Frustum const Frustum f  ) 
 

Definition at line 6 of file frustum.cpp.

References mPlanes.

Frustum::Frustum const GLMatrix4d &  m  )  [inline]
 

Definition at line 34 of file frustum.h.

References set().

Here is the call graph for this function:


Member Function Documentation

Frustum::Halfspace Frustum::classifyPoint const TPlane plane,
const GLVector3d &  point,
const double  eps = 0.0f
[static]
 

Definition at line 109 of file frustum.cpp.

References NEGATIVE, ON_PLANE, and POSITIVE.

Referenced by TerrainRoetger::build_quadtree(), testBox(), and testPoint().

const TPlane& Frustum::getPlane TPlaneID  planeID  )  [inline]
 

Gets one frustum plane.

Parameters:
planeID unique plane ID
Returns:
apropriate frustum plane

Definition at line 64 of file frustum.h.

References mPlanes.

Referenced by TerrainRoetger::build_quadtree(), and testPoint().

int Frustum::mi int  row,
int  col
[inline, private]
 

"matrix index" - helper method

computes index to GLMatrix4d from col, row coordinates

Parameters:
row which row (1..4)
col which column (1..4)
Returns:
resulting index (0 .. 16)

Definition at line 103 of file frustum.h.

References assertL.

Referenced by set().

void Frustum::normalizeAllPlanes void   ) 
 

Normalizes all frustum planes.

Definition at line 23 of file frustum.cpp.

References normalizePlane(), PL_BOTTOM, PL_FAR, PL_LEFT, PL_NEAR, PL_RIGHT, and PL_TOP.

Referenced by set().

Here is the call graph for this function:

void Frustum::normalizePlane TPlaneID  planeID  ) 
 

Normalizes given plane.

Divides the normal vector and D by normal vector length.

Parameters:
planeID which plane (0..6 or TPlaneID)

Definition at line 12 of file frustum.cpp.

References assertL, and mPlanes.

Referenced by normalizeAllPlanes().

void Frustum::set const GLMatrix4d &  m,
bool  normalize = true
 

Sets the frustrum clipping planes from matrix m.

Initializes 6 frustum clipping planes p[0] ... p[5]

Parameters:
m an OpenGL matrix the frustum extract from
normalize if set to true, planes will be normalized (this is necessary for further tests against those planes)
Note:
m should be "OpenGL_Projection_Matrix" * "OpenGL Model View Matrix"

Definition at line 33 of file frustum.cpp.

References mi(), mPlanes, normalizeAllPlanes(), PL_BOTTOM, PL_FAR, PL_LEFT, PL_NEAR, PL_RIGHT, and PL_TOP.

Referenced by Camera::computeFrustum(), and Frustum().

Here is the call graph for this function:

Frustum::ClipState Frustum::testBox const GLVector3d &  center,
const GLVector3d &  extent
const
 

Definition at line 157 of file frustum.cpp.

References classifyPoint(), mPlanes, NEGATIVE, and OUTSIDE.

Referenced by TerrainGeoMipMap::frustumCulling().

Here is the call graph for this function:

bool Frustum::testPoint const GLVector3d &  p  ) 
 

Definition at line 121 of file frustum.cpp.

References classifyPoint(), getPlane(), PL_BOTTOM, PL_FAR, PL_LEFT, PL_NEAR, PL_RIGHT, and PL_TOP.

Here is the call graph for this function:

Frustum::ClipState Frustum::testSphere const GLVector3d &  center,
const double  r
const
 

Definition at line 138 of file frustum.cpp.

References mPlanes, and OUTSIDE.

void Frustum::transform const GLMatrix4d &  m,
bool  normalize = true
 

Transforms frustum planes to test objects in object space.

In many cases, the frustum is defined by projection a transformation matrix of the camera. But there can be other transformations that transforms objects from object space to world space. If we would like to test those objects to frustum intersection, we should apply the OS->WS transformations to objects and test these transformed objects. Instead, for each object we transform the frustum with the same OS->WS matrix and test the object against the frustum in OS.

Definition at line 93 of file frustum.cpp.

References mPlanes.

Referenced by TerrainRoetger::update(), and TerrainGeoMipMap::update().


Member Data Documentation

TPlaneContainer Frustum::mPlanes [private]
 

six clipping planes of frustum

Definition at line 110 of file frustum.h.

Referenced by Frustum(), getPlane(), normalizePlane(), set(), testBox(), testSphere(), and transform().


The documentation for this class was generated from the following files:
Generated on Wed Apr 12 14:14:47 2006 for bjs by  doxygen 1.4.5