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