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