Initial revision
[0ad:0ad.git] / terrain / Frustum.h
1 //***********************************************************
2 //
3 // Name:                Frustum.H
4 // Last Update: 24/2/02
5 // Author:              Poya Manouchehri
6 //
7 // Description: CFrustum is a collection of planes which define
8 //                              a viewing space. Usually associated with the
9 //                              camera, there are 6 planes which define the
10 //                              view pyramid. But we allow more planes per
11 //                              frustum which maybe used for portal rendering,
12 //                              where a portal may have 3 or more edges.
13 //
14 //***********************************************************
15
16 #ifndef FRUSTUM_H
17 #define FRUSTUM_H
18
19 #include "Plane.H"
20
21 //10 planes should be enough
22 #define MAX_NUM_FRUSTUM_PLANES          (10)
23
24
25 struct SBoundingBox
26 {
27         CVector3D m_BoxMin;
28         CVector3D m_BoxMax;
29 };
30
31 class CFrustum
32 {
33         public:
34                 CFrustum ();
35                 ~CFrustum ();
36
37                 //Set the number of planes to use for
38                 //calculations. This is clipped to 
39                 //[0,MAX_NUM_FRUSTUM_PLANES]
40                 void SetNumPlanes (int num);
41
42                 //The following methods return true if the shape is
43                 //partially or completely in front of the frustum planes
44                 bool IsPointVisible (CVector3D &point);
45                 bool IsSphereVisible (CVector3D &center, float radius);
46                 bool IsBoxVisible (CVector3D &position, SBoundingBox &bounds);
47
48         public:
49                 //make the planes public for ease of use
50                 CPlane m_aPlanes[MAX_NUM_FRUSTUM_PLANES];
51
52         private:
53                 int m_NumPlanes;
54 };
55                 
56 #endif