5c156291824761693f07c8b7e9137031da5b9b15
[genesis3d.git] / G3D / World / FRUSTUM.H
1 /****************************************************************************************/\r
2 /*  Frustum.h                                                                           */\r
3 /*                                                                                      */\r
4 /*  Author: John Pollard                                                                */\r
5 /*  Description: Frustum creation/clipping                                              */\r
6 /*                                                                                      */\r
7 /*  The contents of this file are subject to the Genesis3D Public License               */\r
8 /*  Version 1.01 (the "License"); you may not use this file except in                   */\r
9 /*  compliance with the License. You may obtain a copy of the License at                */\r
10 /*  http://www.genesis3d.com                                                            */\r
11 /*                                                                                      */\r
12 /*  Software distributed under the License is distributed on an "AS IS"                 */\r
13 /*  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See                */\r
14 /*  the License for the specific language governing rights and limitations              */\r
15 /*  under the License.                                                                  */\r
16 /*                                                                                      */\r
17 /*  The Original Code is Genesis3D, released March 25, 1999.                            */\r
18 /*  Genesis3D Version 1.1 released November 15, 1999                                 */\r
19 /*  Copyright (C) 1999 WildTangent, Inc. All Rights Reserved           */\r
20 /*                                                                                      */\r
21 /****************************************************************************************/\r
22 #ifndef GE_FRUSTUM_H\r
23 #define GE_FRUSTUM_H\r
24 \r
25 #include <Assert.h>\r
26 //#include <Windows.h>\r
27 \r
28 #include "BaseType.h"\r
29 #include "GBSPFile.h"\r
30 #include "Vec3d.h"\r
31 #include "Camera.h"\r
32 #include "XForm3d.h"\r
33 #include "Surface.h"\r
34 \r
35 #ifdef __cplusplus\r
36 extern "C" {\r
37 #endif\r
38 \r
39 #define MAX_FCP                                         32                      // Max ClipPlanes for frustum...\r
40 \r
41 #define CLIP_PLANE_EPSILON  0.001f\r
42 \r
43 //================================================================================\r
44 //      Structure defines\r
45 //================================================================================\r
46 typedef struct Frustum_Info\r
47 {\r
48         int32                   NumPlanes;                                      // Number of frustum planes to clip against\r
49         GFX_Plane               Planes[MAX_FCP];                        // Planes to clip against\r
50                                         \r
51         // Quick LUTS For BBox testing against frustum\r
52         int32                   FrustumBBoxIndexes[MAX_FCP*6];\r
53         int32                   *pFrustumBBoxIndexes[MAX_FCP];\r
54 } Frustum_Info;\r
55 \r
56 //================================================================================\r
57 //      Function ProtoTypes\r
58 //================================================================================\r
59 void Frustum_SetFromCamera(Frustum_Info *Info, geCamera *Camera);\r
60 geBoolean Frustum_SetFromPoly(Frustum_Info *Info, geVec3d *Verts, int32 NumVerts, geBoolean Flip);\r
61 void Frustum_RotateToWorldSpace(Frustum_Info *In, geCamera *Camera, Frustum_Info *Out);\r
62 void Frustum_TransformToWorldSpace(const Frustum_Info *In, const geCamera *Camera, Frustum_Info *Out);\r
63 \r
64 geBoolean gePlane_ClipVertsFannedUVRGB( const geVec3d *In, const Surf_TexVert *TIn, int32 NumIn, \r
65                                                                                 const GFX_Plane *Plane, \r
66                                                                                 geVec3d *Out, Surf_TexVert *TOut, int32 *NumOut);\r
67 \r
68 geBoolean Frustum_ClipToPlane(          GFX_Plane *pPlane, \r
69                                                                         geVec3d *pIn, geVec3d *pOut,\r
70                                                                         int32 NumVerts, int32 *OutVerts);\r
71 geBoolean Frustum_ClipToPlaneUV(        GFX_Plane *pPlane, \r
72                                                                         geVec3d *pIn, geVec3d *pOut,\r
73                                                                         Surf_TexVert *pTIn, Surf_TexVert *pTOut,\r
74                                                                         int32 NumVerts, int32 *OutVerts);\r
75 \r
76 geBoolean Frustum_ClipToPlaneUVRGB(GFX_Plane *pPlane, \r
77                                                                         geVec3d *pIn, geVec3d *pOut,\r
78                                                                         Surf_TexVert *pTIn, Surf_TexVert *pTOut,\r
79                                                                         int32 NumVerts, int32 *OutVerts);\r
80 \r
81 geBoolean Frustum_ClipToPlaneUVRGBA(GFX_Plane *pPlane, \r
82                                                                         geVec3d *pIn, geVec3d *pOut,\r
83                                                                         Surf_TexVert *pTIn, Surf_TexVert *pTOut,\r
84                                                                         int32 NumVerts, int32 *OutVerts);\r
85 \r
86 geBoolean Frustum_ClipToPlaneRGB(       GFX_Plane *pPlane, \r
87                                                                         geVec3d *pIn, geVec3d *pOut,\r
88                                                                         Surf_TexVert *pTIn, Surf_TexVert *pTOut,\r
89                                                                         int32 NumVerts, int32 *OutVerts);\r
90 \r
91 geBoolean Frustum_ClipToPlaneL(         GFX_Plane *pPlane, \r
92                                                                         GE_LVertex *pIn, GE_LVertex *pOut,\r
93                                                                         int32 NumVerts, int32 *OutVerts);       // CB added\r
94 \r
95 void Frustum_Project(geVec3d *pIn, Surf_TexVert *pTIn, DRV_TLVertex *pOut, int32 NumVerts, const geCamera *Camera);\r
96 void Frustum_ProjectRGB(geVec3d *pIn, Surf_TexVert *pTIn, DRV_TLVertex *pOut, int32 NumVerts, const geCamera *Camera);\r
97 void Frustum_ProjectRGBA(geVec3d *pIn, Surf_TexVert *pTIn, DRV_TLVertex *pOut, int32 NumVerts, const geCamera *Camera);\r
98 void Frustum_ProjectRGBNoClamp(geVec3d *pIn, Surf_TexVert *pTIn, DRV_TLVertex *pOut, int32 NumVerts, const geCamera *Camera);\r
99 \r
100 geBoolean Frustum_PointsInFrustum(const geVec3d *Pin, const GFX_Plane *Plane, int32 NumVerts, int32 *c);\r
101 \r
102 geBoolean Frustum_PointInFrustum(const Frustum_Info *Fi, const geVec3d *Point, geFloat Radius);\r
103 \r
104 geBoolean Frustum_ClipAllPlanesL(const Frustum_Info * Fi,uint32 ClipFlags,GE_LVertex *Verts, int32 *pNumVerts);\r
105 \r
106 \r
107 #ifdef __cplusplus\r
108 }\r
109 #endif\r
110 \r
111 #endif\r