1 /* 2 Copyright (C) 1999-2006 Id Software, Inc. and contributors. 3 For a list of contributors, see the accompanying CONTRIBUTORS file. 4 5 This file is part of GtkRadiant. 6 7 GtkRadiant is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation; either version 2 of the License, or 10 (at your option) any later version. 11 12 GtkRadiant is distributed in the hope that it will be useful, 13 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 GtkRadiant; if not, write to the Free Software 19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 */ 21 22 // 23 // qfiles.h: quake file formats 24 // This file must be identical in the quake and utils directories 25 // 26 27 /* 28 ======================================================================== 29 30 The .pak files are just a linear collapse of a directory tree 31 32 ======================================================================== 33 */ 34 35 #ifdef WIN32 36 #ifdef NDEBUG // Don't show in a Release build 37 #pragma warning(disable : 4305) // truncate from double to float 38 #pragma warning(disable : 4244) // conversion from double to float 39 #pragma warning(disable : 4018) // signed/unsigned mismatch 40 #endif 41 #endif 42 43 #define IDPAKHEADER ( ( 'K' << 24 ) + ( 'C' << 16 ) + ( 'A' << 8 ) + 'P' ) 44 45 typedef struct 46 { 47 char name[56]; 48 int filepos, filelen; 49 } dpackfile_t; 50 51 typedef struct 52 { 53 int ident; // == IDPAKHEADER 54 int dirofs; 55 int dirlen; 56 } dpackheader_t; 57 58 #define MAX_FILES_IN_PACK 4096 59 60 61 /* 62 ======================================================================== 63 64 PCX files are used for as many images as possible 65 66 ======================================================================== 67 */ 68 69 typedef struct 70 { 71 char manufacturer; 72 char version; 73 char encoding; 74 char bits_per_pixel; 75 unsigned short xmin,ymin,xmax,ymax; 76 unsigned short hres,vres; 77 unsigned char palette[48]; 78 char reserved; 79 char color_planes; 80 unsigned short bytes_per_line; 81 unsigned short palette_type; 82 char filler[58]; 83 unsigned char data; // unbounded 84 } pcx_t; 85 86 87 /* 88 ======================================================================== 89 90 .MD2 triangle model file format 91 92 ======================================================================== 93 */ 94 95 #define IDALIASHEADER ( ( '2' << 24 ) + ( 'P' << 16 ) + ( 'D' << 8 ) + 'I' ) 96 #define ALIAS_VERSION 8 97 98 #define MAX_TRIANGLES 4096 99 #define MAX_VERTS 2048 100 #define MAX_FRAMES 512 101 #define MAX_MD2SKINS 32 102 #define MAX_SKINNAME 64 103 104 typedef struct 105 { 106 short s; 107 short t; 108 } dstvert_t; 109 110 typedef struct 111 { 112 short index_xyz[3]; 113 short index_st[3]; 114 } dtriangle_t; 115 116 typedef struct 117 { 118 byte v[3]; // scaled byte to fit in frame mins/maxs 119 byte lightnormalindex; 120 } dtrivertx_t; 121 122 #define DTRIVERTX_V0 0 123 #define DTRIVERTX_V1 1 124 #define DTRIVERTX_V2 2 125 #define DTRIVERTX_LNI 3 126 #define DTRIVERTX_SIZE 4 127 128 typedef struct 129 { 130 float scale[3]; // multiply byte verts by this 131 float translate[3]; // then add this 132 char name[16]; // frame name from grabbing 133 dtrivertx_t verts[1]; // variable sized 134 } daliasframe_t; 135 136 137 // the glcmd format: 138 // a positive integer starts a tristrip command, followed by that many 139 // vertex structures. 140 // a negative integer starts a trifan command, followed by -x vertexes 141 // a zero indicates the end of the command list. 142 // a vertex consists of a floating point s, a floating point t, 143 // and an integer vertex index. 144 145 146 typedef struct 147 { 148 int ident; 149 int version; 150 151 int skinwidth; 152 int skinheight; 153 int framesize; // byte size of each frame 154 155 int num_skins; 156 int num_xyz; 157 int num_st; // greater than num_xyz for seams 158 int num_tris; 159 int num_glcmds; // dwords in strip/fan command list 160 int num_frames; 161 162 int ofs_skins; // each skin is a MAX_SKINNAME string 163 int ofs_st; // byte offset from start for stverts 164 int ofs_tris; // offset for dtriangles 165 int ofs_frames; // offset for first frame 166 int ofs_glcmds; 167 int ofs_end; // end of file 168 169 } dmdl_t; 170 171 /* 172 ======================================================================== 173 174 .SP2 sprite file format 175 176 ======================================================================== 177 */ 178 179 #define IDSPRITEHEADER ( ( '2' << 24 ) + ( 'S' << 16 ) + ( 'D' << 8 ) + 'I' ) 180 // little-endian "IDS2" 181 #define SPRITE_VERSION 2 182 183 typedef struct 184 { 185 int width, height; 186 int origin_x, origin_y; // raster coordinates inside pic 187 char name[MAX_SKINNAME]; // name of pcx file 188 } dsprframe_t; 189 190 typedef struct { 191 int ident; 192 int version; 193 int numframes; 194 dsprframe_t frames[1]; // variable sized 195 } dsprite_t; 196 197 /* 198 ============================================================================== 199 200 .WAL texture file format 201 202 ============================================================================== 203 */ 204 205 206 #define MIPLEVELS 4 207 typedef struct miptex_s 208 { 209 char name[32]; 210 unsigned width, height; 211 unsigned offsets[MIPLEVELS]; // four mip maps stored 212 char animname[32]; // next frame in animation chain 213 int flags; 214 int contents; 215 int value; 216 } miptex_t; 217 218 /* 219 ============================================================================== 220 221 - .WAL texture file format 222 + .M8 texture file format 223 224 ============================================================================== 225 */ 226 227 typedef struct palette_s 228 { 229 union 230 { 231 struct 232 { 233 byte r,g,b; 234 }; 235 }; 236 } palette_t; 237 238 #define MIP_VERSION 2 239 #define PAL_SIZE 256 240 #define H2_MIPLEVELS 16 241 242 typedef struct miptex_m8_s 243 { 244 int version; 245 char name[32]; 246 unsigned width[H2_MIPLEVELS], height[H2_MIPLEVELS]; 247 unsigned offsets[H2_MIPLEVELS]; // four mip maps stored 248 char animname[32]; // next frame in animation chain 249 palette_t palette[PAL_SIZE]; 250 int flags; 251 int contents; 252 int value; 253 } miptex_m8_t; 254 255 256 #define MIP32_VERSION 4 257 258 #define MIP32_NOMIP_FLAG2 0x00000001 259 #define MIP32_DETAILER_FLAG2 0x00000002 260 261 typedef struct miptex_m32_s 262 { 263 int version; 264 char name[128]; 265 char altname[128]; // texture substitution 266 char animname[128]; // next frame in animation chain 267 char damagename[128]; // image that should be shown when damaged 268 unsigned width[H2_MIPLEVELS], height[H2_MIPLEVELS]; 269 unsigned offsets[H2_MIPLEVELS]; 270 int flags; 271 int contents; 272 int value; 273 float scale_x, scale_y; 274 int mip_scale; 275 276 // detail texturing info 277 char dt_name[128]; // detailed texture name 278 float dt_scale_x, dt_scale_y; 279 float dt_u, dt_v; 280 float dt_alpha; 281 int dt_src_blend_mode, dt_dst_blend_mode; 282 283 int flags2; 284 int unused[19]; // future expansion to maintain compatibility with h2 285 } miptex_m32_t; 286 287 288 289 290 /* 291 ============================================================================== 292 293 .BSP file format 294 295 ============================================================================== 296 */ 297 298 #define IDBSPHEADER ( ( 'P' << 24 ) + ( 'S' << 16 ) + ( 'B' << 8 ) + 'I' ) 299 // little-endian "IBSP" 300 301 #define BSPVERSION 38 302 303 304 // upper design bounds 305 // leaffaces, leafbrushes, planes, and verts are still bounded by 306 // 16 bit short limits 307 #define MAX_MAP_MODELS 1024 308 #define MAX_MAP_BRUSHES 8192 309 #define MAX_MAP_ENTITIES 2048 310 #define MAX_MAP_ENTSTRING 0x40000 311 #define MAX_MAP_TEXINFO 8192 312 313 #define MAX_MAP_AREAS 256 314 #define MAX_MAP_AREAPORTALS 1024 315 #define MAX_MAP_PLANES 65536 316 #define MAX_MAP_NODES 65536 317 #define MAX_MAP_BRUSHSIDES 65536 318 #define MAX_MAP_LEAFS 65536 319 #define MAX_MAP_VERTS 65536 320 #define MAX_MAP_FACES 65536 321 #define MAX_MAP_LEAFFACES 65536 322 #define MAX_MAP_LEAFBRUSHES 65536 323 #define MAX_MAP_PORTALS 65536 324 #define MAX_MAP_EDGES 128000 325 #define MAX_MAP_SURFEDGES 256000 326 #define MAX_MAP_LIGHTING 0x200000 327 #define MAX_MAP_VISIBILITY 0x100000 328 329 // key / value pair sizes 330 331 #define MAX_KEY 32 332 #define MAX_VALUE 1024 333 334 //============================================================================= 335 336 typedef struct 337 { 338 int fileofs, filelen; 339 } lump_t; 340 341 #define LUMP_ENTITIES 0 342 #define LUMP_PLANES 1 343 #define LUMP_VERTEXES 2 344 #define LUMP_VISIBILITY 3 345 #define LUMP_NODES 4 346 #define LUMP_TEXINFO 5 347 #define LUMP_FACES 6 348 #define LUMP_LIGHTING 7 349 #define LUMP_LEAFS 8 350 #define LUMP_LEAFFACES 9 351 #define LUMP_LEAFBRUSHES 10 352 #define LUMP_EDGES 11 353 #define LUMP_SURFEDGES 12 354 #define LUMP_MODELS 13 355 #define LUMP_BRUSHES 14 356 #define LUMP_BRUSHSIDES 15 357 #define LUMP_POP 16 358 #define LUMP_AREAS 17 359 #define LUMP_AREAPORTALS 18 360 #define HEADER_LUMPS 19 361 362 typedef struct 363 { 364 int ident; 365 int version; 366 lump_t lumps[HEADER_LUMPS]; 367 } dheader_t; 368 369 typedef struct 370 { 371 float mins[3], maxs[3]; 372 float origin[3]; // for sounds or lights 373 int headnode; 374 int firstface, numfaces; // submodels just draw faces 375 // without walking the bsp tree 376 } dmodel_t; 377 378 379 typedef struct 380 { 381 float point[3]; 382 } dvertex_t; 383 384 385 // 0-2 are axial planes 386 #define PLANE_X 0 387 #define PLANE_Y 1 388 #define PLANE_Z 2 389 390 // 3-5 are non-axial planes snapped to the nearest 391 #define PLANE_ANYX 3 392 #define PLANE_ANYY 4 393 #define PLANE_ANYZ 5 394 395 // planes (x&~1) and (x&~1)+1 are allways opposites 396 397 typedef struct 398 { 399 float normal[3]; 400 float dist; 401 int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate 402 } dplane_t; 403 404 405 // contents flags are seperate bits 406 // a given brush can contribute multiple content bits 407 // multiple brushes can be in a single leaf 408 409 // these definitions also need to be in q_shared.h! 410 411 // lower bits are stronger, and will eat weaker brushes completely 412 #define CONTENTS_SOLID 1 // an eye is never valid in a solid 413 #define CONTENTS_WINDOW 2 // translucent, but not watery 414 #define CONTENTS_AUX 4 415 #define CONTENTS_LAVA 8 416 #define CONTENTS_SLIME 16 417 #define CONTENTS_WATER 32 418 #define CONTENTS_MIST 64 419 #define LAST_VISIBLE_CONTENTS 64 420 421 // remaining contents are non-visible, and don't eat brushes 422 423 #define CONTENTS_AREAPORTAL 0x8000 424 425 #define CONTENTS_PLAYERCLIP 0x10000 426 #define CONTENTS_MONSTERCLIP 0x20000 427 428 // currents can be added to any other contents, and may be mixed 429 #define CONTENTS_CURRENT_0 0x40000 430 #define CONTENTS_CURRENT_90 0x80000 431 #define CONTENTS_CURRENT_180 0x100000 432 #define CONTENTS_CURRENT_270 0x200000 433 #define CONTENTS_CURRENT_UP 0x400000 434 #define CONTENTS_CURRENT_DOWN 0x800000 435 436 #define CONTENTS_ORIGIN 0x1000000 // removed before bsping an entity 437 438 #define CONTENTS_MONSTER 0x2000000 // should never be on a brush, only in game 439 #define CONTENTS_DEADMONSTER 0x4000000 440 #define CONTENTS_DETAIL 0x8000000 // brushes to be added after vis leafs 441 #define CONTENTS_TRANSLUCENT 0x10000000 // auto set if any surface has trans 442 #define CONTENTS_LADDER 0x20000000 443 444 445 446 #define SURF_LIGHT 0x1 // value will hold the light strength 447 448 #define SURF_SLICK 0x2 // effects game physics 449 450 #define SURF_SKY 0x4 // don't draw, but add to skybox 451 #define SURF_WARP 0x8 // turbulent water warp 452 #define SURF_TRANS33 0x10 453 #define SURF_TRANS66 0x20 454 #define SURF_FLOWING 0x40 // scroll towards angle 455 #define SURF_NODRAW 0x80 // don't bother referencing the texture 456 457 #define SURF_HINT 0x100 // make a primary bsp splitter 458 #define SURF_SKIP 0x200 // completely ignore, allowing non-closed brushes 459 460 461 462 typedef struct 463 { 464 int planenum; 465 int children[2]; // negative numbers are -(leafs+1), not nodes 466 short mins[3]; // for frustom culling 467 short maxs[3]; 468 unsigned short firstface; 469 unsigned short numfaces; // counting both sides 470 } dnode_t; 471 472 473 typedef struct texinfo_s 474 { 475 float vecs[2][4]; // [s/t][xyz offset] 476 int flags; // miptex flags + overrides 477 int value; // light emission, etc 478 char texture[32]; // texture name (textures/*.wal) 479 int nexttexinfo; // for animations, -1 = end of chain 480 } texinfo_t; 481 482 483 // note that edge 0 is never used, because negative edge nums are used for 484 // counterclockwise use of the edge in a face 485 typedef struct 486 { 487 unsigned short v[2]; // vertex numbers 488 } dedge_t; 489 490 #define MAXLIGHTMAPS 4 491 typedef struct 492 { 493 unsigned short planenum; 494 short side; 495 496 int firstedge; // we must support > 64k edges 497 short numedges; 498 short texinfo; 499 500 // lighting info 501 byte styles[MAXLIGHTMAPS]; 502 int lightofs; // start of [numstyles*surfsize] samples 503 } dface_t; 504 505 typedef struct 506 { 507 int contents; // OR of all brushes (not needed?) 508 509 short cluster; 510 short area; 511 512 short mins[3]; // for frustum culling 513 short maxs[3]; 514 515 unsigned short firstleafface; 516 unsigned short numleaffaces; 517 518 unsigned short firstleafbrush; 519 unsigned short numleafbrushes; 520 } dleaf_t; 521 522 typedef struct 523 { 524 unsigned short planenum; // facing out of the leaf 525 short texinfo; 526 } dbrushside_t; 527 528 typedef struct 529 { 530 int firstside; 531 int numsides; 532 int contents; 533 } dbrush_t; 534 535 #define ANGLE_UP -1 536 #define ANGLE_DOWN -2 537 538 539 // the visibility lump consists of a header with a count, then 540 // byte offsets for the PVS and PHS of each cluster, then the raw 541 // compressed bit vectors 542 #define DVIS_PVS 0 543 #define DVIS_PHS 1 544 typedef struct 545 { 546 int numclusters; 547 int bitofs[8][2]; // bitofs[numclusters][2] 548 } dvis_t; 549 550 // each area has a list of portals that lead into other areas 551 // when portals are closed, other areas may not be visible or 552 // hearable even if the vis info says that it should be 553 typedef struct 554 { 555 int portalnum; 556 int otherarea; 557 } dareaportal_t; 558 559 typedef struct 560 { 561 int numareaportals; 562 int firstareaportal; 563 } darea_t; 564