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