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