Page principale | Hiérarchie des classes | Liste alphabétique | Liste des classes | Liste des fichiers | Membres de classe

C:/Projects/ngn/include/frustum.h

00001 /***************************************************************************
00002  *            frustum.h
00003  *
00004  *  Tue Jan  6 06:48:42 2004
00005  *  Copyright  2004  thierry schartz
00006  *  Email thierry.schartz@bluebottle.com
00007  ****************************************************************************/
00008 /*
00009  *  This program is free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  This program is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU Library General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU General Public License
00020  *  along with this program; if not, write to the Free Software
00021  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00022  */
00023  /*     This code was taken and adapted from http://www.GameTutorials.com. Thanks to them !!!
00024                 DigiBen@GameTutorials.com
00025                 http://www.GameTutorials.com
00026  */
00027  #ifndef _FRUSTUM_H
00028  #define _FRUSTUM_H
00029  
00030 #ifdef WIN32
00031 #include <windows.h>
00032 #endif
00033 
00034  
00035 #include "vector3d.h"
00036 #include "box.h"
00037 #include "light.h"
00038 
00039 #define COMPLETE_OUT 0
00040 #define INTERSECT    1
00041 #define COMPLETE_IN  2
00042 
00043 
00044 namespace ngn {
00045         namespace core {
00046 
00047 
00048                         enum eFrustumSide
00049                         {
00050                                 RIGHT   = 0,       
00051                                 LEFT    = 1,       
00052                                 BOTTOM  = 2,      
00053                                 TOP     = 3,       
00054                                 BACK    = 4,     
00055                                 FRONT   = 5      
00056                         }; 
00057 
00058                         enum ePlane
00059                         {
00060                                 // Ax + By + Cz + D
00061                                 A=1,
00062                                 B=2,
00063                                 C=3,
00064                                 D=4
00065                         };
00066  
00067 
00068                         class Frustum
00069                          {
00070                                 public:
00071                                         Frustum();
00072                                         Frustum( const Frustum& other );
00073                                         virtual ~Frustum();
00074                                         void calculateFrustum();
00075                                         bool pointInFrustum( Vector3df p ) const;
00076                                         bool sphereInFrustum( Vector3df center, float radius )const;
00077                                         bool cubeInFrustum( Vector3df center, float halfsize )const;
00078                                         int boxInFrustum( float x, float y, float z, float x2, float y2, float z2 )const;
00079                                         int boxInFrustum( Vector3df min, Vector3df max )const;
00080                                         int boxInFrustum( Box& box ) const; 
00081                                         bool lightInFrustum( Light& light ) const;
00082 
00083                                 private:
00084                                         void normalizePlane( float frustum[6][4], int side );
00085 
00086                                         float m_frustum[6][4];  // the frustum
00087                         };
00088 
00089 
00090 
00091 
00092                  }//core
00093 }//ngn
00094 #endif /* _FRUSTUM_H */

Généré le Fri Nov 19 14:20:29 2004 pour NGN par  doxygen 1.3.9.1