1 //----------------------------------------------------------------------------- 2 // Frustum 3 //----------------------------------------------------------------------------- 4 5 #ifndef __FRUSTUM_H__ 6 #define __FRUSTUM_H__ 7 8 #include "types.h" 9 10 #define DEBUG_FRUSTUM 0 11 12 // BoxInFrustum will return one of this defines according to the position of the box in the frustum 13 #define COMPLETE_OUT 0 14 #define INTERSECT 1 15 #define COMPLETE_IN 2 16 17 // This will allow us to create an object to keep track of our frustum 18 class Frustum 19 { 20 public: 21 // Call this every time the camera moves to update the frustum 22 void CalculateFrustum(); 23 24 // This takes a 3D point and returns TRUE if it's inside of the frustum 25 bool PointInFrustum(float x, float y, float z); 26 27 // This takes a 3D point and a radius and returns TRUE if the sphere is inside of the frustum 28 bool SphereInFrustum(float x, float y, float z, float radius); 29 30 // This takes the center and half the length of the cube. 31 bool CubeInFrustum(float x, float y, float z, float size); 32 33 int BoxInFrustum(bboxf_t box); 34 int BoxInFrustum(bbox_t box); 35 36 private: 37 // This holds the A B C and D values for each side of our frustum. 38 float m_Frustum[6][4]; 39 40 float proj[16]; // This will hold our projection matrix 41 float modl[16]; // This will hold our modelview matrix 42 float clip[16]; // This will hold the clipping planes 43 }; 44 45 #endif /* __FRUSTUM_H__ */ 46