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