sinfiles.h (10164B)
1 /* 2 =========================================================================== 3 Copyright (C) 1999-2005 Id Software, Inc. 4 5 This file is part of Quake III Arena source code. 6 7 Quake III Arena source code is free software; you can redistribute it 8 and/or modify it under the terms of the GNU General Public License as 9 published by the Free Software Foundation; either version 2 of the License, 10 or (at your option) any later version. 11 12 Quake III Arena source code is distributed in the hope that it will be 13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with Foobar; if not, write to the Free Software 19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 =========================================================================== 21 */ 22 23 /* 24 ============================================================================== 25 26 .BSP file format 27 28 ============================================================================== 29 */ 30 31 #define SIN 32 33 #define SINBSPVERSION 41 34 35 // upper design bounds 36 // leaffaces, leafbrushes, planes, and verts are still bounded by 37 // 16 bit short limits 38 #define SIN_MAX_MAP_MODELS 1024 39 #define SIN_MAX_MAP_BRUSHES 8192 40 #define SIN_MAX_MAP_ENTITIES 2048 41 #define SIN_MAX_MAP_ENTSTRING 0x40000 42 #define SIN_MAX_MAP_TEXINFO 8192 43 44 #define SIN_MAX_MAP_AREAS 256 45 #define SIN_MAX_MAP_AREAPORTALS 1024 46 #define SIN_MAX_MAP_PLANES 65536 47 #define SIN_MAX_MAP_NODES 65536 48 #define SIN_MAX_MAP_BRUSHSIDES 65536 49 #define SIN_MAX_MAP_LEAFS 65536 50 #define SIN_MAX_MAP_VERTS 65536 51 #define SIN_MAX_MAP_FACES 65536 52 #define SIN_MAX_MAP_LEAFFACES 65536 53 #define SIN_MAX_MAP_LEAFBRUSHES 65536 54 #define SIN_MAX_MAP_PORTALS 65536 55 #define SIN_MAX_MAP_EDGES 128000 56 #define SIN_MAX_MAP_SURFEDGES 256000 57 #define SIN_MAX_MAP_LIGHTING 0x320000 58 #define SIN_MAX_MAP_VISIBILITY 0x280000 59 60 #ifdef SIN 61 #define SIN_MAX_MAP_LIGHTINFO 8192 62 #endif 63 64 #ifdef SIN 65 #undef SIN_MAX_MAP_LIGHTING //undef the Quake2 bsp version 66 #define SIN_MAX_MAP_LIGHTING 0x300000 67 #endif 68 69 #ifdef SIN 70 #undef SIN_MAX_MAP_VISIBILITY //undef the Quake2 bsp version 71 #define SIN_MAX_MAP_VISIBILITY 0x280000 72 #endif 73 74 //============================================================================= 75 76 typedef struct 77 { 78 int fileofs, filelen; 79 } sin_lump_t; 80 81 #define SIN_LUMP_ENTITIES 0 82 #define SIN_LUMP_PLANES 1 83 #define SIN_LUMP_VERTEXES 2 84 #define SIN_LUMP_VISIBILITY 3 85 #define SIN_LUMP_NODES 4 86 #define SIN_LUMP_TEXINFO 5 87 #define SIN_LUMP_FACES 6 88 #define SIN_LUMP_LIGHTING 7 89 #define SIN_LUMP_LEAFS 8 90 #define SIN_LUMP_LEAFFACES 9 91 #define SIN_LUMP_LEAFBRUSHES 10 92 #define SIN_LUMP_EDGES 11 93 #define SIN_LUMP_SURFEDGES 12 94 #define SIN_LUMP_MODELS 13 95 #define SIN_LUMP_BRUSHES 14 96 #define SIN_LUMP_BRUSHSIDES 15 97 #define SIN_LUMP_POP 16 98 #define SIN_LUMP_AREAS 17 99 #define SIN_LUMP_AREAPORTALS 18 100 101 #ifdef SIN 102 #define SIN_LUMP_LIGHTINFO 19 103 #define SINHEADER_LUMPS 20 104 #endif 105 106 typedef struct 107 { 108 int ident; 109 int version; 110 sin_lump_t lumps[SINHEADER_LUMPS]; 111 } sin_dheader_t; 112 113 typedef struct 114 { 115 float mins[3], maxs[3]; 116 float origin[3]; // for sounds or lights 117 int headnode; 118 int firstface, numfaces; // submodels just draw faces 119 // without walking the bsp tree 120 } sin_dmodel_t; 121 122 typedef struct 123 { 124 float point[3]; 125 } sin_dvertex_t; 126 127 128 // 0-2 are axial planes 129 #define PLANE_X 0 130 #define PLANE_Y 1 131 #define PLANE_Z 2 132 133 // 3-5 are non-axial planes snapped to the nearest 134 #define PLANE_ANYX 3 135 #define PLANE_ANYY 4 136 #define PLANE_ANYZ 5 137 138 // planes (x&~1) and (x&~1)+1 are allways opposites 139 140 typedef struct 141 { 142 float normal[3]; 143 float dist; 144 int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate 145 } sin_dplane_t; 146 147 148 // contents flags are seperate bits 149 // a given brush can contribute multiple content bits 150 // multiple brushes can be in a single leaf 151 152 // these definitions also need to be in q_shared.h! 153 154 // lower bits are stronger, and will eat weaker brushes completely 155 #ifdef SIN 156 #define CONTENTS_FENCE 4 157 #endif 158 // remaining contents are non-visible, and don't eat brushes 159 160 #ifdef SIN 161 #define CONTENTS_DUMMYFENCE 0x1000 162 #endif 163 164 #ifdef SIN 165 #define SURF_MASKED 0x2 // surface texture is masked 166 #endif 167 168 #define SURF_SKY 0x4 // don't draw, but add to skybox 169 #define SURF_WARP 0x8 // turbulent water warp 170 171 #ifdef SIN 172 #define SURF_NONLIT 0x10 // surface is not lit 173 #define SURF_NOFILTER 0x20 // surface is not bi-linear filtered 174 #endif 175 176 #define SURF_FLOWING 0x40 // scroll towards angle 177 #define SURF_NODRAW 0x80 // don't bother referencing the texture 178 179 #define SURF_HINT 0x100 // make a primary bsp splitter 180 #define SURF_SKIP 0x200 // completely ignore, allowing non-closed brushes 181 182 #ifdef SIN 183 #define SURF_CONVEYOR 0x40 // surface is not lit 184 #endif 185 186 #ifdef SIN 187 #define SURF_WAVY 0x400 // surface has waves 188 #define SURF_RICOCHET 0x800 // projectiles bounce literally bounce off this surface 189 #define SURF_PRELIT 0x1000 // surface has intensity information for pre-lighting 190 #define SURF_MIRROR 0x2000 // surface is a mirror 191 #define SURF_CONSOLE 0x4000 // surface is a console 192 #define SURF_USECOLOR 0x8000 // surface is lit with non-lit * color 193 #define SURF_HARDWAREONLY 0x10000 // surface has been damaged 194 #define SURF_DAMAGE 0x20000 // surface can be damaged 195 #define SURF_WEAK 0x40000 // surface has weak hit points 196 #define SURF_NORMAL 0x80000 // surface has normal hit points 197 #define SURF_ADD 0x100000 // surface will be additive 198 #define SURF_ENVMAPPED 0x200000 // surface is envmapped 199 #define SURF_RANDOMANIMATE 0x400000 // surface start animating on a random frame 200 #define SURF_ANIMATE 0x800000 // surface animates 201 #define SURF_RNDTIME 0x1000000 // time between animations is random 202 #define SURF_TRANSLATE 0x2000000 // surface translates 203 #define SURF_NOMERGE 0x4000000 // surface is not merged in csg phase 204 #define SURF_TYPE_BIT0 0x8000000 // 0 bit of surface type 205 #define SURF_TYPE_BIT1 0x10000000 // 1 bit of surface type 206 #define SURF_TYPE_BIT2 0x20000000 // 2 bit of surface type 207 #define SURF_TYPE_BIT3 0x40000000 // 3 bit of surface type 208 209 #define SURF_START_BIT 27 210 #define SURFACETYPE_FROM_FLAGS( x ) ( ( x >> (SURF_START_BIT) ) & 0xf ) 211 212 213 #define SURF_TYPE_SHIFT(x) ( (x) << (SURF_START_BIT) ) // macro for getting proper bit mask 214 215 #define SURF_TYPE_NONE SURF_TYPE_SHIFT(0) 216 #define SURF_TYPE_WOOD SURF_TYPE_SHIFT(1) 217 #define SURF_TYPE_METAL SURF_TYPE_SHIFT(2) 218 #define SURF_TYPE_STONE SURF_TYPE_SHIFT(3) 219 #define SURF_TYPE_CONCRETE SURF_TYPE_SHIFT(4) 220 #define SURF_TYPE_DIRT SURF_TYPE_SHIFT(5) 221 #define SURF_TYPE_FLESH SURF_TYPE_SHIFT(6) 222 #define SURF_TYPE_GRILL SURF_TYPE_SHIFT(7) 223 #define SURF_TYPE_GLASS SURF_TYPE_SHIFT(8) 224 #define SURF_TYPE_FABRIC SURF_TYPE_SHIFT(9) 225 #define SURF_TYPE_MONITOR SURF_TYPE_SHIFT(10) 226 #define SURF_TYPE_GRAVEL SURF_TYPE_SHIFT(11) 227 #define SURF_TYPE_VEGETATION SURF_TYPE_SHIFT(12) 228 #define SURF_TYPE_PAPER SURF_TYPE_SHIFT(13) 229 #define SURF_TYPE_DUCT SURF_TYPE_SHIFT(14) 230 #define SURF_TYPE_WATER SURF_TYPE_SHIFT(15) 231 #endif 232 233 234 typedef struct 235 { 236 int planenum; 237 int children[2]; // negative numbers are -(leafs+1), not nodes 238 short mins[3]; // for frustom culling 239 short maxs[3]; 240 unsigned short firstface; 241 unsigned short numfaces; // counting both sides 242 } sin_dnode_t; 243 244 #ifdef SIN 245 246 typedef struct sin_lightvalue_s 247 { 248 int value; // light emission, etc 249 vec3_t color; 250 float direct; 251 float directangle; 252 float directstyle; 253 char directstylename[32]; 254 } sin_lightvalue_t; 255 256 typedef struct sin_texinfo_s 257 { 258 float vecs[2][4]; // [s/t][xyz offset] 259 int flags; // miptex flags + overrides 260 char texture[64]; // texture name (textures/*.wal) 261 int nexttexinfo; // for animations, -1 = end of chain 262 float trans_mag; 263 int trans_angle; 264 int base_angle; 265 float animtime; 266 float nonlit; 267 float translucence; 268 float friction; 269 float restitution; 270 vec3_t color; 271 char groupname[32]; 272 } sin_texinfo_t; 273 274 #endif //SIN 275 276 // note that edge 0 is never used, because negative edge nums are used for 277 // counterclockwise use of the edge in a face 278 typedef struct 279 { 280 unsigned short v[2]; // vertex numbers 281 } sin_dedge_t; 282 283 #ifdef MAXLIGHTMAPS 284 #undef MAXLIGHTMAPS 285 #endif 286 #define MAXLIGHTMAPS 16 287 typedef struct 288 { 289 unsigned short planenum; 290 short side; 291 292 int firstedge; // we must support > 64k edges 293 short numedges; 294 short texinfo; 295 296 // lighting info 297 byte styles[MAXLIGHTMAPS]; 298 int lightofs; // start of [numstyles*surfsize] samples 299 #ifdef SIN 300 int lightinfo; 301 #endif 302 } sin_dface_t; 303 304 typedef struct 305 { 306 int contents; // OR of all brushes (not needed?) 307 308 short cluster; 309 short area; 310 311 short mins[3]; // for frustum culling 312 short maxs[3]; 313 314 unsigned short firstleafface; 315 unsigned short numleaffaces; 316 317 unsigned short firstleafbrush; 318 unsigned short numleafbrushes; 319 } sin_dleaf_t; 320 321 typedef struct 322 { 323 unsigned short planenum; // facing out of the leaf 324 short texinfo; 325 #ifdef SIN 326 int lightinfo; 327 #endif 328 } sin_dbrushside_t; 329 330 typedef struct 331 { 332 int firstside; 333 int numsides; 334 int contents; 335 } sin_dbrush_t; 336 337 #define ANGLE_UP -1 338 #define ANGLE_DOWN -2 339 340 341 // the visibility lump consists of a header with a count, then 342 // byte offsets for the PVS and PHS of each cluster, then the raw 343 // compressed bit vectors 344 #define DVIS_PVS 0 345 #define DVIS_PHS 1 346 typedef struct 347 { 348 int numclusters; 349 int bitofs[8][2]; // bitofs[numclusters][2] 350 } sin_dvis_t; 351 352 // each area has a list of portals that lead into other areas 353 // when portals are closed, other areas may not be visible or 354 // hearable even if the vis info says that it should be 355 typedef struct 356 { 357 int portalnum; 358 int otherarea; 359 } sin_dareaportal_t; 360 361 typedef struct 362 { 363 int numareaportals; 364 int firstareaportal; 365 } sin_darea_t;