00001 /****************************************************************************************/ 00002 /* GBSPFile.h */ 00003 /* */ 00004 /* Author: John Pollard */ 00005 /* Description: BSP loader */ 00006 /* */ 00007 /* The contents of this file are subject to the Genesis3D Public License */ 00008 /* Version 1.01 (the "License"); you may not use this file except in */ 00009 /* compliance with the License. You may obtain a copy of the License at */ 00010 /* http://www.genesis3d.com */ 00011 /* */ 00012 /* Software distributed under the License is distributed on an "AS IS" */ 00013 /* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See */ 00014 /* the License for the specific language governing rights and limitations */ 00015 /* under the License. */ 00016 /* */ 00017 /* The Original Code is Genesis3D, released March 25, 1999. */ 00018 /* Genesis3D Version 1.1 released November 15, 1999 */ 00019 /* Copyright (C) 1999 WildTangent, Inc. All Rights Reserved */ 00020 /* */ 00021 /****************************************************************************************/ 00022 #ifndef GE_GBSPFILE_H 00023 #define GE_GBSPFILE_H 00024 00025 #include <Stdio.h> 00026 00027 #include "BaseType.h" 00028 #include "Vec3d.h" 00029 #include <windows.h> 00030 #include "DCommon.h" 00031 #include "VFile.h" 00032 #include "Motion.h" 00033 00034 #ifdef __cplusplus 00035 extern "C" { 00036 #endif 00037 00038 #define GBSP_VERSION 15 00039 00040 #define GBSP_CHUNK_HEADER 0 00041 00042 #define GBSP_CHUNK_MODELS 1 00043 #define GBSP_CHUNK_NODES 2 00044 #define GBSP_CHUNK_BNODES 3 00045 #define GBSP_CHUNK_LEAFS 4 00046 #define GBSP_CHUNK_CLUSTERS 5 00047 #define GBSP_CHUNK_AREAS 6 00048 #define GBSP_CHUNK_AREA_PORTALS 7 00049 #define GBSP_CHUNK_LEAF_SIDES 8 00050 #define GBSP_CHUNK_PORTALS 9 00051 #define GBSP_CHUNK_PLANES 10 00052 #define GBSP_CHUNK_FACES 11 00053 #define GBSP_CHUNK_LEAF_FACES 12 00054 #define GBSP_CHUNK_VERT_INDEX 13 00055 #define GBSP_CHUNK_VERTS 14 00056 #define GBSP_CHUNK_RGB_VERTS 15 00057 #define GBSP_CHUNK_ENTDATA 16 00058 00059 #define GBSP_CHUNK_TEXINFO 17 00060 #define GBSP_CHUNK_TEXTURES 18 00061 #define GBSP_CHUNK_TEXDATA 19 00062 00063 #define GBSP_CHUNK_LIGHTDATA 20 00064 #define GBSP_CHUNK_VISDATA 21 00065 #define GBSP_CHUNK_SKYDATA 22 00066 #define GBSP_CHUNK_PALETTES 23 00067 #define GBSP_CHUNK_MOTIONS 24 00068 00069 #define GBSP_CHUNK_END 0xffff 00070 00071 #ifndef GE_CONTENTS_TYPES 00072 #define GE_CONTENTS_TYPES 00073 00074 //*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= 00075 // IF THESE FLAGS CHANGE, THEY MUST CHANGE IN GBSPFILE.H in Genesis AND GBSPLIB, and Genesis.H!!!!! 00076 //*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= 00077 #define GE_CONTENTS_SOLID (1<<0) // Solid (Visible) 00078 #define GE_CONTENTS_WINDOW (1<<1) // Window (Visible) 00079 #define GE_CONTENTS_EMPTY (1<<2) // Empty but Visible (water, lava, etc...) 00080 00081 #define GE_CONTENTS_TRANSLUCENT (1<<3) // Vis will see through it 00082 #define GE_CONTENTS_WAVY (1<<4) // Wavy (Visible) 00083 #define GE_CONTENTS_DETAIL (1<<5) // Won't be included in vis oclusion 00084 00085 #define GE_CONTENTS_CLIP (1<<6) // Structural but not visible 00086 #define GE_CONTENTS_HINT (1<<7) // Primary splitter (Non-Visible) 00087 #define GE_CONTENTS_AREA (1<<8) // Area seperator leaf (Non-Visible) 00088 00089 #define GE_CONTENTS_FLOCKING (1<<9) 00090 #define GE_CONTENTS_SHEET (1<<10) 00091 #define GE_RESERVED3 (1<<11) 00092 #define GE_RESERVED4 (1<<12) 00093 #define GE_RESERVED5 (1<<13) 00094 #define GE_RESERVED6 (1<<14) 00095 #define GE_RESERVED7 (1<<15) 00096 00097 // 16-31 reserved for user contents 00098 #define GE_CONTENTS_USER1 (1<<16) 00099 #define GE_CONTENTS_USER2 (1<<17) 00100 #define GE_CONTENTS_USER3 (1<<18) 00101 #define GE_CONTENTS_USER4 (1<<19) 00102 #define GE_CONTENTS_USER5 (1<<20) 00103 #define GE_CONTENTS_USER6 (1<<21) 00104 #define GE_CONTENTS_USER7 (1<<22) 00105 #define GE_CONTENTS_USER8 (1<<23) 00106 #define GE_CONTENTS_USER9 (1<<24) 00107 #define GE_CONTENTS_USER10 (1<<25) 00108 #define GE_CONTENTS_USER11 (1<<26) 00109 #define GE_CONTENTS_USER12 (1<<27) 00110 #define GE_CONTENTS_USER13 (1<<28) 00111 #define GE_CONTENTS_USER14 (1<<29) 00112 #define GE_CONTENTS_USER15 (1<<30) 00113 #define GE_CONTENTS_USER16 (1<<31) 00114 // 16-31 reserved for user contents 00115 00116 00117 // These contents are all solid types 00118 #define GE_CONTENTS_SOLID_CLIP (GE_CONTENTS_SOLID | GE_CONTENTS_WINDOW | GE_CONTENTS_CLIP) 00119 #define GE_CONTENTS_CANNOT_OCCUPY GE_CONTENTS_SOLID_CLIP 00120 00121 // These contents are all visible types 00122 #define GE_VISIBLE_CONTENTS ( GE_CONTENTS_SOLID | \ 00123 GE_CONTENTS_EMPTY | \ 00124 GE_CONTENTS_WINDOW | \ 00125 GE_CONTENTS_WAVY) 00126 00127 #endif 00128 00129 #define BSP_CONTENTS_SOLID -1 00130 #define BSP_CONTENTS_EMPTY -2 00131 00132 #define PLANE_X 0 00133 #define PLANE_Y 1 00134 #define PLANE_Z 2 00135 #define PLANE_ANYX 3 00136 #define PLANE_ANYY 4 00137 #define PLANE_ANYZ 5 00138 #define PLANE_ANY 6 00139 00140 typedef struct 00141 { 00142 int32 Type; // Type of chunk 00143 int32 Size; // Size of each element 00144 int32 Elements; // Number of elements 00145 } GBSP_Chunk; 00146 00147 typedef struct 00148 { 00149 int32 Type; 00150 int32 Size; 00151 int32 Elements; 00152 void *Data; 00153 } GBSP_ChunkData; 00154 00155 typedef struct 00156 { 00157 char TAG[5]; // 'G','B','S','P','0' 00158 int32 Version; 00159 SYSTEMTIME BSPTime; 00160 } GBSP_Header; 00161 00162 typedef struct 00163 { 00164 geVec3d Axis; // Axis of rotation 00165 geFloat Dpm; // Degres per minute 00166 int32 Textures[6]; // Texture indexes for all six sides... 00167 geFloat DrawScale; 00168 } GFX_SkyData; 00169 00170 typedef struct 00171 { 00172 geVec3d Normal; 00173 geFloat Dist; 00174 int32 Type; // Defined in MathLib.h (PLANE_X, PLANE_Y, etc...) 00175 } GFX_Plane; 00176 00177 typedef struct 00178 { 00179 int32 Children[2]; // Children, indexed into GFXNodes, < 0 = Leaf 00180 int32 NumFaces; // Num faces 00181 int32 FirstFace; // First face 00182 int32 PlaneNum; // 00183 geVec3d Mins; // For BBox frustum culling 00184 geVec3d Maxs; 00185 } GFX_Node; 00186 00187 typedef struct 00188 { 00189 int32 Children[2]; // Children, indexed into GFXBNodes, < 0 = Contents 00190 int32 PlaneNum; // 00191 //int32 PlaneSide; 00192 } GFX_BNode; 00193 00194 typedef struct 00195 { 00196 int32 ModelNum; 00197 int32 Area; 00198 } GFX_AreaPortal; 00199 00200 typedef struct 00201 { 00202 int32 NumAreaPortals; 00203 int32 FirstAreaPortal; 00204 } GFX_Area; 00205 00206 typedef struct 00207 { 00208 int32 Contents; // Contents of leaf 00209 geVec3d Mins; // For BBox vis testing 00210 geVec3d Maxs; 00211 int32 FirstFace; // First face in GFXLeafFaces 00212 int32 NumFaces; 00213 int32 FirstPortal; // Number of portals 00214 int32 NumPortals; // First portal 00215 00216 int32 Cluster; // Cluster area for this leaf 00217 int32 Area; // -1 = Area, 0 = Solid > 0 = Area number 00218 00219 int32 FirstSide; // Beveled sides for BBox collisions 00220 int32 NumSides; 00221 } GFX_Leaf; 00222 00223 typedef struct 00224 { 00225 int32 VisOfs; 00226 } GFX_Cluster; 00227 00228 typedef struct 00229 { 00230 int32 PlaneNum; 00231 int32 PlaneSide; 00232 } GFX_LeafSide; 00233 00234 typedef struct 00235 { 00236 int32 FirstVert; // First vertex indexed in GFXVertices 00237 int32 NumVerts; // Number of vertices in face 00238 int32 PlaneNum; // PlaneNum 00239 int32 PlaneSide; // 0 = Same direction of plane normal 00240 int32 TexInfo; 00241 int32 LightOfs; // Offset info GFXLightData, -1 = No light 00242 int32 LWidth; // Lightmap width 00243 int32 LHeight; // Lightmap height 00244 uint8 LTypes[4]; 00245 } GFX_Face; 00246 00247 typedef struct 00248 { 00249 int32 RootNode[2]; // Top level Node in GFXNodes/GFXBNodes 00250 geVec3d Mins; 00251 geVec3d Maxs; 00252 geVec3d Origin; 00253 int32 FirstFace; // First face in GFXFaces 00254 int32 NumFaces; // Number of faces 00255 int32 FirstLeaf; // First leaf in GFXLeafs; 00256 int32 NumLeafs; // Number of leafs (including solid leafs) 00257 int32 FirstCluster; // First leaf cluster ijn GFXCLusters 00258 int32 NumClusters; // Number of clusters in this model 00259 int32 Areas[2]; 00260 geMotion * Motion; 00261 } GFX_Model; 00262 00263 typedef struct 00264 { 00265 char Name[32]; 00266 uint32 Flags; 00267 int32 Width; 00268 int32 Height; 00269 int32 Offset; 00270 int32 PaletteIndex; 00271 } GFX_Texture; 00272 00273 typedef struct 00274 { 00275 geVec3d Vecs[2]; 00276 geFloat Shift[2]; 00277 geFloat DrawScale[2]; 00278 int32 Flags; 00279 geFloat FaceLight; // Used in radiosity satge only (remove?) 00280 geFloat ReflectiveScale; 00281 geFloat Alpha; 00282 geFloat MipMapBias; 00283 int32 Texture; 00284 } GFX_TexInfo; 00285 00286 typedef struct 00287 { 00288 geVec3d Origin; // Center of portal 00289 int32 LeafTo; // Leaf looking into 00290 } GFX_Portal; 00291 00292 typedef struct 00293 { 00294 GBSP_Header GBSPHeader; // Header 00295 GFX_SkyData GFXSkyData; // Sky data 00296 GFX_Model *GFXModels; // Model data 00297 GFX_Node *GFXNodes; // Nodes 00298 GFX_BNode *GFXBNodes; // Bevel Clip Nodes 00299 GFX_Leaf *GFXLeafs; // Leafs 00300 GFX_Cluster *GFXClusters; 00301 GFX_Area *GFXAreas; 00302 GFX_AreaPortal *GFXAreaPortals; 00303 GFX_Plane *GFXPlanes; // Planes 00304 GFX_Face *GFXFaces; // Faces 00305 int32 *GFXLeafFaces; 00306 GFX_LeafSide *GFXLeafSides; 00307 geVec3d *GFXVerts; // Verts 00308 int32 *GFXVertIndexList; // Index list 00309 geVec3d *GFXRGBVerts; // RGBVerts 00310 00311 uint8 *GFXEntData; 00312 GFX_Texture *GFXTextures; // Textures 00313 GFX_TexInfo *GFXTexInfo; // TexInfo 00314 uint8 *GFXTexData; // TexData 00315 DRV_Palette *GFXPalettes; // Texture palettes 00316 00317 uint8 *GFXLightData; // Lightmap data 00318 uint8 *GFXVisData; // Vis data 00319 GFX_Portal *GFXPortals; // Portal data 00320 00321 int32 NumGFXModels; 00322 int32 NumGFXNodes; 00323 int32 NumGFXBNodes; 00324 int32 NumGFXLeafs; 00325 int32 NumGFXClusters; 00326 int32 NumGFXAreas; 00327 int32 NumGFXAreaPortals; 00328 int32 NumGFXPlanes; 00329 int32 NumGFXFaces; 00330 int32 NumGFXLeafFaces; 00331 int32 NumGFXLeafSides; 00332 int32 NumGFXVerts; 00333 int32 NumGFXVertIndexList; 00334 int32 NumGFXRGBVerts; 00335 00336 int32 NumGFXEntData; 00337 int32 NumGFXTextures; 00338 int32 NumGFXTexInfo; 00339 int32 NumGFXTexData; 00340 int32 NumGFXPalettes; 00341 00342 int32 NumGFXLightData; 00343 int32 NumGFXVisData; 00344 int32 NumGFXPortals; 00345 00346 } GBSP_BSPData; 00347 00348 geBoolean GBSP_LoadGBSPFile(geVFile *File, GBSP_BSPData *BSP); 00349 geBoolean GBSP_FreeGBSPFile(GBSP_BSPData *BSP); 00350 00351 #ifdef __cplusplus 00352 } 00353 #endif 00354 00355 #endif
1.3.2