00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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
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];
00087 };
00088
00089
00090
00091
00092 }
00093 }
00094 #endif