"L. Spiro Engine"

F:/My Projects/LSEngine/Modules/LSMathLib/Src/Frustum/LSMFrustum.h

00001 
00019 #ifndef __LSM_FRUSTUM_H__
00020 #define __LSM_FRUSTUM_H__
00021 
00022 #include "../LSMMathLib.h"
00023 #include "../Matrix/LSMMatrix4x4.h"
00024 #include "../Plane/LSMPlane3.h"
00025 
00026 namespace lsm {
00027 
00028         // == Enumerations.
00032         enum LSM_FRUSTUM_PLANES {
00033                 LSM_FP_LEFT,
00034                 LSM_FP_RIGHT,
00035                 LSM_FP_TOP,
00036                 LSM_FP_BOTTOM,
00037                 LSM_FP_NEAR,
00038                 LSM_FP_FAR,
00039                 LSM_FP_TOTAL
00040         };
00041 
00045         enum LSM_FRUSTUM_POINTS {
00046                 LSM_FP_FAR_BOTTOM_LEFT,
00047                 LSM_FP_FAR_TOP_LEFT,
00048                 LSM_FP_FAR_TOP_RIGHT,
00049                 LSM_FP_FAR_BOTTOM_RIGHT,
00050                 LSM_FP_NEAR_BOTTOM_LEFT,
00051                 LSM_FP_NEAR_TOP_LEFT,
00052                 LSM_FP_NEAR_TOP_RIGHT,
00053                 LSM_FP_NEAR_BOTTOM_RIGHT,
00054         };
00055 
00056 
00066         class CFrustum {
00067                 // All is public.  This class has no secrets.
00068         public :
00069                 // == Operators.
00077                 const CPlane3 & LSE_FCALL       operator [] ( LSUINT32 _ui32Index ) const;
00078 
00079 
00080                 // == Functions.
00089                 LSVOID LSE_FCALL                        ExtractFromMatrix(
00090                         const CMatrix4x4 &_mMatrix,
00091                         LSBOOL _bNormalizePlanes = false );
00092 
00100                 LSE_INLINE LSBOOL LSE_FCALL     TestPoint( const CVector3 &_vPoint ) const;
00101 
00112                 static LSVOID LSE_CALL          GetCornersOfPlanes( LSM_FRUSTUM_PLANES _fpPlane0, LSM_FRUSTUM_PLANES _fpPlane1,
00113                         LSM_FRUSTUM_POINTS _fpRet[2] );
00114 
00121                 static LSVOID LSE_CALL          GetNeighbors( LSM_FRUSTUM_PLANES _fpPlane, LSM_FRUSTUM_PLANES _fpRet[4] );
00122 
00123 
00124                 // == Members.
00125 #pragma pack( push, 1 )
00126 
00129                 CPlane3                                         m_pLeftPlane;
00130 
00134                 CPlane3                                         m_pRightPlane;
00135 
00139                 CPlane3                                         m_pTopPlane;
00140 
00144                 CPlane3                                         m_pBottomPlane;
00145 
00149                 CPlane3                                         m_pNearPlane;
00150 
00154                 CPlane3                                         m_pFarPlane;
00155 #pragma pack( pop )
00156 
00157 
00158         protected :
00159                 // == Operators.
00167                 CPlane3 & LSE_FCALL                     operator [] ( LSUINT32 _ui32Index );
00168         };
00169 
00170 
00171         // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00172         // DEFINITIONS
00173         // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00174         // == Operators.
00182         LSE_INLINE const CPlane3 & LSE_FCALL CFrustum::operator [] ( LSUINT32 _ui32Index ) const {
00183                 return reinterpret_cast<const CPlane3 *>(this)[_ui32Index];
00184         }
00185 
00186         // == Functions.
00194         LSE_INLINE LSBOOL LSE_FCALL CFrustum::TestPoint( const CVector3 &_vPoint ) const {
00195                 if ( (m_pLeftPlane.SignedDistance( _vPoint ) < LSM_ZERO)
00196                         || (m_pRightPlane.SignedDistance( _vPoint ) < LSM_ZERO)
00197                         || (m_pTopPlane.SignedDistance( _vPoint ) < LSM_ZERO)
00198                         || (m_pBottomPlane.SignedDistance( _vPoint ) < LSM_ZERO)
00199                         || (m_pNearPlane.SignedDistance( _vPoint ) < LSM_ZERO)
00200                         || (m_pFarPlane.SignedDistance( _vPoint ) < LSM_ZERO) ) {
00201                         return false;
00202                 }
00203                 return true;
00204         }
00205 
00206         // == Operators.
00214         LSE_INLINE CPlane3 & LSE_FCALL CFrustum::operator [] ( LSUINT32 _ui32Index ) {
00215                 return reinterpret_cast<CPlane3 *>(this)[_ui32Index];
00216         }
00217 
00218 }       // namespace lsm
00219 
00220 #endif  // __LSM_FRUSTUM_H__
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator