l_bsp_hl.h (7949B)
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 // upper design bounds 23 24 #define HL_MAX_MAP_HULLS 4 25 26 #define HL_MAX_MAP_MODELS 400 27 #define HL_MAX_MAP_BRUSHES 4096 28 #define HL_MAX_MAP_ENTITIES 1024 29 #define HL_MAX_MAP_ENTSTRING (128*1024) 30 31 #define HL_MAX_MAP_PLANES 32767 32 #define HL_MAX_MAP_NODES 32767 // because negative shorts are contents 33 #define HL_MAX_MAP_CLIPNODES 32767 // 34 #define HL_MAX_MAP_LEAFS 8192 35 #define HL_MAX_MAP_VERTS 65535 36 #define HL_MAX_MAP_FACES 65535 37 #define HL_MAX_MAP_MARKSURFACES 65535 38 #define HL_MAX_MAP_TEXINFO 8192 39 #define HL_MAX_MAP_EDGES 256000 40 #define HL_MAX_MAP_SURFEDGES 512000 41 #define HL_MAX_MAP_TEXTURES 512 42 #define HL_MAX_MAP_MIPTEX 0x200000 43 #define HL_MAX_MAP_LIGHTING 0x200000 44 #define HL_MAX_MAP_VISIBILITY 0x200000 45 46 #define HL_MAX_MAP_PORTALS 65536 47 48 // key / value pair sizes 49 50 #define MAX_KEY 32 51 #define MAX_VALUE 1024 52 53 //============================================================================= 54 55 56 #define HL_BSPVERSION 30 57 #define HL_TOOLVERSION 2 58 59 60 typedef struct 61 { 62 int fileofs, filelen; 63 } hl_lump_t; 64 65 #define HL_LUMP_ENTITIES 0 66 #define HL_LUMP_PLANES 1 67 #define HL_LUMP_TEXTURES 2 68 #define HL_LUMP_VERTEXES 3 69 #define HL_LUMP_VISIBILITY 4 70 #define HL_LUMP_NODES 5 71 #define HL_LUMP_TEXINFO 6 72 #define HL_LUMP_FACES 7 73 #define HL_LUMP_LIGHTING 8 74 #define HL_LUMP_CLIPNODES 9 75 #define HL_LUMP_LEAFS 10 76 #define HL_LUMP_MARKSURFACES 11 77 #define HL_LUMP_EDGES 12 78 #define HL_LUMP_SURFEDGES 13 79 #define HL_LUMP_MODELS 14 80 81 #define HL_HEADER_LUMPS 15 82 83 typedef struct 84 { 85 float mins[3], maxs[3]; 86 float origin[3]; 87 int headnode[HL_MAX_MAP_HULLS]; 88 int visleafs; // not including the solid leaf 0 89 int firstface, numfaces; 90 } hl_dmodel_t; 91 92 typedef struct 93 { 94 int version; 95 hl_lump_t lumps[HL_HEADER_LUMPS]; 96 } hl_dheader_t; 97 98 typedef struct 99 { 100 int nummiptex; 101 int dataofs[4]; // [nummiptex] 102 } hl_dmiptexlump_t; 103 104 #define MIPLEVELS 4 105 typedef struct hl_miptex_s 106 { 107 char name[16]; 108 unsigned width, height; 109 unsigned offsets[MIPLEVELS]; // four mip maps stored 110 } hl_miptex_t; 111 112 113 typedef struct 114 { 115 float point[3]; 116 } hl_dvertex_t; 117 118 119 // 0-2 are axial planes 120 #define PLANE_X 0 121 #define PLANE_Y 1 122 #define PLANE_Z 2 123 124 // 3-5 are non-axial planes snapped to the nearest 125 #define PLANE_ANYX 3 126 #define PLANE_ANYY 4 127 #define PLANE_ANYZ 5 128 129 typedef struct 130 { 131 float normal[3]; 132 float dist; 133 int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate 134 } hl_dplane_t; 135 136 137 138 #define HL_CONTENTS_EMPTY -1 139 #define HL_CONTENTS_SOLID -2 140 #define HL_CONTENTS_WATER -3 141 #define HL_CONTENTS_SLIME -4 142 #define HL_CONTENTS_LAVA -5 143 #define HL_CONTENTS_SKY -6 144 #define HL_CONTENTS_ORIGIN -7 // removed at csg time 145 #define HL_CONTENTS_CLIP -8 // changed to contents_solid 146 147 #define HL_CONTENTS_CURRENT_0 -9 148 #define HL_CONTENTS_CURRENT_90 -10 149 #define HL_CONTENTS_CURRENT_180 -11 150 #define HL_CONTENTS_CURRENT_270 -12 151 #define HL_CONTENTS_CURRENT_UP -13 152 #define HL_CONTENTS_CURRENT_DOWN -14 153 154 #define HL_CONTENTS_TRANSLUCENT -15 155 156 // !!! if this is changed, it must be changed in asm_i386.h too !!! 157 typedef struct 158 { 159 int planenum; 160 short children[2]; // negative numbers are -(leafs+1), not nodes 161 short mins[3]; // for sphere culling 162 short maxs[3]; 163 unsigned short firstface; 164 unsigned short numfaces; // counting both sides 165 } hl_dnode_t; 166 167 typedef struct 168 { 169 int planenum; 170 short children[2]; // negative numbers are contents 171 } hl_dclipnode_t; 172 173 174 typedef struct hl_texinfo_s 175 { 176 float vecs[2][4]; // [s/t][xyz offset] 177 int miptex; 178 int flags; 179 } hl_texinfo_t; 180 #define TEX_SPECIAL 1 // sky or slime, no lightmap or 256 subdivision 181 182 // note that edge 0 is never used, because negative edge nums are used for 183 // counterclockwise use of the edge in a face 184 typedef struct 185 { 186 unsigned short v[2]; // vertex numbers 187 } hl_dedge_t; 188 189 #define MAXLIGHTMAPS 4 190 typedef struct 191 { 192 short planenum; 193 short side; 194 195 int firstedge; // we must support > 64k edges 196 short numedges; 197 short texinfo; 198 199 // lighting info 200 byte styles[MAXLIGHTMAPS]; 201 int lightofs; // start of [numstyles*surfsize] samples 202 } hl_dface_t; 203 204 205 #define AMBIENT_WATER 0 206 #define AMBIENT_SKY 1 207 #define AMBIENT_SLIME 2 208 #define AMBIENT_LAVA 3 209 210 #define NUM_AMBIENTS 4 // automatic ambient sounds 211 212 // leaf 0 is the generic HL_CONTENTS_SOLID leaf, used for all solid areas 213 // all other leafs need visibility info 214 typedef struct 215 { 216 int contents; 217 int visofs; // -1 = no visibility info 218 219 short mins[3]; // for frustum culling 220 short maxs[3]; 221 222 unsigned short firstmarksurface; 223 unsigned short nummarksurfaces; 224 225 byte ambient_level[NUM_AMBIENTS]; 226 } hl_dleaf_t; 227 228 229 //============================================================================ 230 231 #ifndef QUAKE_GAME 232 233 #define ANGLE_UP -1 234 #define ANGLE_DOWN -2 235 236 237 // the utilities get to be lazy and just use large static arrays 238 239 extern int hl_nummodels; 240 extern hl_dmodel_t *hl_dmodels;//[MAX_MAP_MODELS]; 241 extern int hl_dmodels_checksum; 242 243 extern int hl_visdatasize; 244 extern byte *hl_dvisdata;//[MAX_MAP_VISIBILITY]; 245 extern int hl_dvisdata_checksum; 246 247 extern int hl_lightdatasize; 248 extern byte *hl_dlightdata;//[MAX_MAP_LIGHTING]; 249 extern int hl_dlightdata_checksum; 250 251 extern int hl_texdatasize; 252 extern byte *hl_dtexdata;//[MAX_MAP_MIPTEX]; // (dmiptexlump_t) 253 extern int hl_dtexdata_checksum; 254 255 extern int hl_entdatasize; 256 extern char *hl_dentdata;//[MAX_MAP_ENTSTRING]; 257 extern int hl_dentdata_checksum; 258 259 extern int hl_numleafs; 260 extern hl_dleaf_t *hl_dleafs;//[MAX_MAP_LEAFS]; 261 extern int hl_dleafs_checksum; 262 263 extern int hl_numplanes; 264 extern hl_dplane_t *hl_dplanes;//[MAX_MAP_PLANES]; 265 extern int hl_dplanes_checksum; 266 267 extern int hl_numvertexes; 268 extern hl_dvertex_t *hl_dvertexes;//[MAX_MAP_VERTS]; 269 extern int hl_dvertexes_checksum; 270 271 extern int hl_numnodes; 272 extern hl_dnode_t *hl_dnodes;//[MAX_MAP_NODES]; 273 extern int hl_dnodes_checksum; 274 275 extern int hl_numtexinfo; 276 extern hl_texinfo_t *hl_texinfo;//[MAX_MAP_TEXINFO]; 277 extern int hl_texinfo_checksum; 278 279 extern int hl_numfaces; 280 extern hl_dface_t *hl_dfaces;//[MAX_MAP_FACES]; 281 extern int hl_dfaces_checksum; 282 283 extern int hl_numclipnodes; 284 extern hl_dclipnode_t *hl_dclipnodes;//[MAX_MAP_CLIPNODES]; 285 extern int hl_dclipnodes_checksum; 286 287 extern int hl_numedges; 288 extern hl_dedge_t *hl_dedges;//[MAX_MAP_EDGES]; 289 extern int hl_dedges_checksum; 290 291 extern int hl_nummarksurfaces; 292 extern unsigned short *hl_dmarksurfaces;//[MAX_MAP_MARKSURFACES]; 293 extern int hl_dmarksurfaces_checksum; 294 295 extern int hl_numsurfedges; 296 extern int *hl_dsurfedges;//[MAX_MAP_SURFEDGES]; 297 extern int hl_dsurfedges_checksum; 298 299 int FastChecksum(void *buffer, int bytes); 300 301 void HL_AllocMaxBSP(void); 302 void HL_FreeMaxBSP(void); 303 304 void HL_DecompressVis(byte *in, byte *decompressed); 305 int HL_CompressVis(byte *vis, byte *dest); 306 307 void HL_LoadBSPFile(char *filename, int offset, int length); 308 void HL_WriteBSPFile(char *filename); 309 void HL_PrintBSPFileSizes(void); 310 void HL_PrintBSPFileSizes(void); 311 void HL_ParseEntities(void); 312 void HL_UnparseEntities(void); 313 314 #endif