AaronCameron.net
No ads. No Profit. No Master, But Truth.
Not a Member? - Login or Create an Account
Tuesday the 22nd of May 2012 @ 02:17am
Front Page Journal Projects Your Profile About
[]

LibN2L-4 Library Code Reference

Classes
Compounds
Files
Members
Method Index
Full Reference

cRFrustum.h

Go to the documentation of this file.
00001 /************************************************************************
00002 Nova-2 Library (libN2L, or simply n2l) Game development C++ Library
00003 Copyright (C) 2002  Aaron Cameron
00004 
00005 This library is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU Lesser General Public
00007 License as published by the Free Software Foundation; either
00008 version 2.1 of the License, or (at your option) any later version.
00009 
00010 This library is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 Lesser General Public License for more details.
00014 
00015 You should have received a copy of the GNU Lesser General Public
00016 License along with this library; if not, write to the Free Software
00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00018 
00019 A copy of the GNU Lesser General Public License has been provided with
00020 this library in the file 'COPYING'.
00021 
00022 Contact information for the author of this library has been provided
00023 with this library in the file 'AUTHOR'.
00024 ************************************************************************/
00025 
00026 #ifndef _n2l4_cRFrustum_h
00027 #define _n2l4_cRFrustum_h
00028 
00029 #include "n2l/n2l.h"
00030 #include "n2l/geometry.h"
00031 
00032 
00033 namespace n2l
00034 {
00035     class cRFrustum
00036     {
00037     public:
00038         typedef enum {
00039             ClipPlane_Right,
00040             ClipPlane_Left,
00041             ClipPlane_Bottom,
00042             ClipPlane_Top,
00043             ClipPlane_Far,
00044             ClipPlane_Near,
00045 
00046             ClipPlane_NumClipPlanes
00047         } tClipPlane;
00048 
00049         typedef enum {
00050             ClipPlaneMask_Right =   0x01,
00051             ClipPlaneMask_Left =    0x02,
00052             ClipPlaneMask_Bottom =  0x04,
00053             ClipPlaneMask_Top =     0x10,
00054             ClipPlaneMask_Far =     0x20,
00055             ClipPlaneMask_Near =    0x40
00056         } tClipPlaneMask;
00057 
00058         cRFrustum();
00059 
00060         cRFrustum( const tMatrix44f &iProjectionMatrix,
00061             const tMatrix44f &iModelViewMatrix );
00062 
00063         cRFrustum( const cRFrustum &iFrustum );
00064 
00065         ~cRFrustum();
00066 
00067         void set( const tMatrix44f &iProjectionMatrix,
00068             const tMatrix44f &iModelViewMatrix );
00069 
00070         cRFrustum &operator =( const cRFrustum &iFrustum );
00071 
00072         const tBool testSphere( const tVector3f &iCenter, 
00073             const tFloat &iRadius ) const;
00074 
00075         const tBool testAABox( const tVector3f &iCenter, 
00076             const tVector3f &iDimensions ) const;
00077 
00078         const tBool testPoint( const tVector3f &iPoint ) const;
00079 
00080         const tBool testQuad(
00081             const tVector3f &i0, const tVector3f &i1, 
00082             const tVector3f &i2, const tVector3f &i3 ) const;
00083 
00084         // Masked variations of above tests.  Planes in the
00085         // mask will not be tested, and will be assumed passed.
00086         const tBool testSphere( const tVector3f &iCenter, 
00087             const tFloat &iRadius, const tUint &iMask ) const;
00088 
00089 
00095         void halfNearFarVectorBase( tVector3f &oBottomLeftPos,
00096             tVector3f &oRightEdge, tVector3f &oUpEdge ) const;
00097 
00098         inline const tPlane3f &plane( const tClipPlane iPlane ) const { 
00099             assert( iPlane>=0 && iPlane<ClipPlane_NumClipPlanes );
00100             return mPlane[iPlane];
00101         }
00102 
00107         void projectPoint( tVector3f &oPos,
00108             const tVector3f &iPos ) const;
00109     
00110     private:
00111         tMatrix44f mProj, mModel;
00112 
00113         tPlane3f mPlane[ClipPlane_NumClipPlanes];
00114         
00115     };
00116 
00117 }
00118 
00119 #endif
©2012 Aaron Cameron