Public Types | Public Member Functions | Public Attributes

gmtl::Frustum< DATA_TYPE > Class Template Reference
[Abstract Data Types: Matrix, Vec, Quat, Coord, Sphere, Plane]

This class defines a View Frustum Volume as a set of 6 planes. More...

#include <Frustum.h>

List of all members.

Public Types

enum  PlaneNames {
  PLANE_LEFT = 0, PLANE_RIGHT = 1, PLANE_BOTTOM = 2, PLANE_TOP = 3,
  PLANE_NEAR = 4, PLANE_FAR = 5
}
 

An enum to name the plane indicies.

More...
typedef DATA_TYPE DataType
typedef Frustum< DATA_TYPE > FrustumType

Public Member Functions

 Frustum ()
 Constructs a new frustum with all planes in default state.
 Frustum (const gmtl::Matrix< DATA_TYPE, 4, 4 > &projMatrix)
 Constructs a new frustum with the given projection matrix.
 Frustum (const gmtl::Matrix< DATA_TYPE, 4, 4 > &modelviewMatrix, const gmtl::Matrix< DATA_TYPE, 4, 4 > &projMatrix)
 Constructs a new frustum with given projection and modelview matricies.
void extractPlanes (const gmtl::Matrix< DATA_TYPE, 4, 4 > &modelviewMatrix, const gmtl::Matrix< DATA_TYPE, 4, 4 > &projMatrix)
 Extracts the planes from the given projection matrix.
void extractPlanes (const gmtl::Matrix< DATA_TYPE, 4, 4 > &projMatrix)
 Extracts the planes from the given projection and modelview matricies.

Public Attributes

gmtl::Plane< DATA_TYPE > mPlanes [6]

Detailed Description

template<typename DATA_TYPE>
class gmtl::Frustum< DATA_TYPE >

This class defines a View Frustum Volume as a set of 6 planes.

Definition at line 23 of file Frustum.h.


Member Typedef Documentation

template<typename DATA_TYPE>
typedef DATA_TYPE gmtl::Frustum< DATA_TYPE >::DataType

Definition at line 26 of file Frustum.h.

template<typename DATA_TYPE>
typedef Frustum<DATA_TYPE> gmtl::Frustum< DATA_TYPE >::FrustumType

Definition at line 27 of file Frustum.h.


Member Enumeration Documentation

template<typename DATA_TYPE>
enum gmtl::Frustum::PlaneNames

An enum to name the plane indicies.

To have you not must remember those numbers.

Enumerator:
PLANE_LEFT 

left clipping plane equals 0

PLANE_RIGHT 

right clipping plane equals 1

PLANE_BOTTOM 

bottom clipping plane equals 2

PLANE_TOP 

top clipping plane equals 3

PLANE_NEAR 

near clipping plane equals 4

PLANE_FAR 

far clipping plane equals 5

Definition at line 33 of file Frustum.h.

   {
      PLANE_LEFT = 0,      
      PLANE_RIGHT = 1,   
      PLANE_BOTTOM = 2,   
      PLANE_TOP = 3,      
      PLANE_NEAR = 4,      
      PLANE_FAR = 5      
   };


Constructor & Destructor Documentation

template<typename DATA_TYPE>
gmtl::Frustum< DATA_TYPE >::Frustum (  )  [inline]

Constructs a new frustum with all planes in default state.

Definition at line 46 of file Frustum.h.

   {
   
   }

template<typename DATA_TYPE>
gmtl::Frustum< DATA_TYPE >::Frustum ( const gmtl::Matrix< DATA_TYPE, 4, 4 > &  projMatrix  )  [inline]

Constructs a new frustum with the given projection matrix.

Parameters:
projMatrix The projection matrix of your camera or light etc. to construct the planes from.

Definition at line 57 of file Frustum.h.

   {
      extractPlanes(projMatrix);
   }

template<typename DATA_TYPE>
gmtl::Frustum< DATA_TYPE >::Frustum ( const gmtl::Matrix< DATA_TYPE, 4, 4 > &  modelviewMatrix,
const gmtl::Matrix< DATA_TYPE, 4, 4 > &  projMatrix 
) [inline]

Constructs a new frustum with given projection and modelview matricies.

the matricies are multiplied in this order:

 M = projMatrix * modelviewMatrix

The planes are then extracted from M.

Parameters:
modelviewMatrix The modelview matrix of you camera or light etc. to construct the planes from.
projMatrix The projection matrix of your camera or light or whatever.

Definition at line 77 of file Frustum.h.

   {
      extractPlanes(modelviewMatrix, projMatrix);
   }


Member Function Documentation

template<typename DATA_TYPE>
void gmtl::Frustum< DATA_TYPE >::extractPlanes ( const gmtl::Matrix< DATA_TYPE, 4, 4 > &  modelviewMatrix,
const gmtl::Matrix< DATA_TYPE, 4, 4 > &  projMatrix 
) [inline]

Extracts the planes from the given projection matrix.

Parameters:
projMatrix The projection matrix of you camera or light or what ever.

Definition at line 89 of file Frustum.h.

   {
      extractPlanes(projMatrix * modelviewMatrix);
   }

template<typename DATA_TYPE>
void gmtl::Frustum< DATA_TYPE >::extractPlanes ( const gmtl::Matrix< DATA_TYPE, 4, 4 > &  projMatrix  )  [inline]

Extracts the planes from the given projection and modelview matricies.

The matricies are multiplied in this order:

 M = projMatrix * modelviewMatrix

The planes are then extracted from M.

Parameters:
modelviewMatrix The modelview matrix of you camera or light etc. to construct the planes from.
projMatrix The projection matrix of you camera or light etc. to construct the planes from.

Definition at line 110 of file Frustum.h.

   {
      const gmtl::Matrix<DATA_TYPE, 4, 4>& m = projMatrix;

      //left
      mPlanes[PLANE_LEFT].setNormal(gmtl::Vec<DATA_TYPE, 3>(m[3][0] + m[0][0],
                                                            m[3][1] + m[0][1],
                                                            m[3][2] + m[0][2]));
      mPlanes[PLANE_LEFT].setOffset(m[3][3] + m[0][3]);
      //right
      mPlanes[PLANE_RIGHT].setNormal(gmtl::Vec<DATA_TYPE, 3>(m[3][0] - m[0][0],
                                                             m[3][1] - m[0][1],
                                                             m[3][2] - m[0][2]));
      mPlanes[PLANE_RIGHT].setOffset(m[3][3] - m[0][3]);
      //bottom
      mPlanes[PLANE_BOTTOM].setNormal(gmtl::Vec<DATA_TYPE, 3>(m[3][0] + m[1][0],
                                                              m[3][1] + m[1][1],
                                                              m[3][2] + m[1][2]));
      mPlanes[PLANE_BOTTOM].setOffset(m[3][3] + m[1][3]);
      //top
      mPlanes[PLANE_TOP].setNormal(gmtl::Vec<DATA_TYPE, 3>(m[3][0] - m[1][0],
                                                           m[3][1] - m[1][1],
                                                           m[3][2] - m[1][2]));
      mPlanes[PLANE_TOP].setOffset(m[3][3] - m[1][3]);
      //near
      mPlanes[PLANE_NEAR].setNormal(gmtl::Vec<DATA_TYPE, 3>(m[3][0] + m[2][0],
                                                            m[3][1] + m[2][1],
                                                            m[3][2] + m[2][2]));
      mPlanes[PLANE_NEAR].setOffset(m[2][3] + m[3][3]);
      //far
      mPlanes[PLANE_FAR].setNormal(gmtl::Vec<DATA_TYPE, 3>(m[3][0] - m[2][0],
                                                           m[3][1] - m[2][1],
                                                           m[3][2] - m[2][2]));
      mPlanes[PLANE_FAR].setOffset(m[3][3] - m[2][3]);
   }


Member Data Documentation

template<typename DATA_TYPE>
gmtl::Plane<DATA_TYPE> gmtl::Frustum< DATA_TYPE >::mPlanes[6]

Definition at line 146 of file Frustum.h.


The documentation for this class was generated from the following file: