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