Debian Codegraph @

tools/quake2/extra/qe4/qfiles.h

raw symbols SCIP
1 /*
2 ===========================================================================
3 Copyright (C) 1997-2006 Id Software, Inc.
4
5 This file is part of Quake 2 Tools source code.
6
7 Quake 2 Tools source code is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the License,
10 or (at your option) any later version.
11
12 Quake 2 Tools source code is distributed in the hope that it will be
13 useful, 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 Quake 2 Tools source code; 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 /*
107 ========================================================================
108
109 .SP2 sprite file format
110
111 ========================================================================
112 */
113
114 #define IDSPRITEHEADER (('2'<<24)+('S'<<16)+('D'<<8)+'I')
115 // little-endian "IDS2"
116 #define SPRITE_VERSION 2
117
118 typedef struct
119 {
120 int width, height;
121 int origin_x, origin_y; // raster coordinates inside pic
122 char name[MAX_SKINNAME]; // name of pcx file
123 } dsprframe_t;
124
125 typedef struct {
126 int ident;
127 int version;
128 int numframes;
129 dsprframe_t frames[1]; // variable sized
130 } dsprite_t;
131
132 /*
133 ==============================================================================
134
135 .WAL texture file format
136
137 ==============================================================================
138 */
139
140
141 #define MIPLEVELS 4
142 typedef struct miptex_s
143 {
144 char name[32];
145 unsigned width, height;
146 unsigned offsets[MIPLEVELS]; // four mip maps stored
147 char animname[32]; // next frame in animation chain
148 int flags;
149 int contents;
150 int value;
151 } miptex_t;
152
153
154
155 /*
156 ==============================================================================
157
158 .BSP file format
159
160 ==============================================================================
161 */
162
163 #define IDBSPHEADER (('P'<<24)+('S'<<16)+('B'<<8)+'I')
164 // little-endian "IBSP"
165
166 #define BSPVERSION 36
167
168
169 // upper design bounds
170 // leaffaces, leafbrushes, planes, and verts are still bounded by
171 // 16 bit short limits
172 #define MAX_MAP_MODELS 1024
173 #define MAX_MAP_BRUSHES 8192
174 #define MAX_MAP_ENTITIES 2048
175 #define MAX_MAP_ENTSTRING 0x20000
176 #define MAX_MAP_TEXINFO 8192
177
178 #define MAX_MAP_PLANES 65536
179 #define MAX_MAP_NODES 65536
180 #define MAX_MAP_BRUSHSIDES 65536
181 #define MAX_MAP_LEAFS 65536
182 #define MAX_MAP_VERTS 65536
183 #define MAX_MAP_FACES 65536
184 #define MAX_MAP_LEAFFACES 65536
185 #define MAX_MAP_LEAFBRUSHES 65536
186 #define MAX_MAP_PORTALS 65536
187 #define MAX_MAP_EDGES 128000
188 #define MAX_MAP_SURFEDGES 256000
189 #define MAX_MAP_LIGHTING 0x200000
190 #define MAX_MAP_VISIBILITY 0x100000
191
192 // key / value pair sizes
193
194 #define MAX_KEY 32
195 #define MAX_VALUE 1024
196
197 //=============================================================================
198
199 typedef struct
200 {
201 int fileofs, filelen;
202 } lump_t;
203
204 #define LUMP_ENTITIES 0
205 #define LUMP_PLANES 1
206 #define LUMP_VERTEXES 2
207 #define LUMP_VISIBILITY 3
208 #define LUMP_NODES 4
209 #define LUMP_TEXINFO 5
210 #define LUMP_FACES 6
211 #define LUMP_LIGHTING 7
212 #define LUMP_LEAFS 8
213 #define LUMP_LEAFFACES 9
214 #define LUMP_LEAFBRUSHES 10
215 #define LUMP_EDGES 11
216 #define LUMP_SURFEDGES 12
217 #define LUMP_MODELS 13
218 #define LUMP_BRUSHES 14
219 #define LUMP_BRUSHSIDES 15
220 #define LUMP_POP 16
221
222 #define HEADER_LUMPS 17
223
224 typedef struct
225 {
226 int ident;
227 int version;
228 lump_t lumps[HEADER_LUMPS];
229 } dheader_t;
230
231 typedef struct
232 {
233 float mins[3], maxs[3];
234 float origin[3]; // for sounds or lights
235 int headnode;
236 int firstface, numfaces; // submodels just draw faces
237 // without walking the bsp tree
238 } dmodel_t;
239
240
241 typedef struct
242 {
243 float point[3];
244 } dvertex_t;
245
246
247 // 0-2 are axial planes
248 #define PLANE_X 0
249 #define PLANE_Y 1
250 #define PLANE_Z 2
251
252 // 3-5 are non-axial planes snapped to the nearest
253 #define PLANE_ANYX 3
254 #define PLANE_ANYY 4
255 #define PLANE_ANYZ 5
256
257 // planes (x&~1) and (x&~1)+1 are allways opposites
258
259 typedef struct
260 {
261 float normal[3];
262 float dist;
263 int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
264 } dplane_t;
265
266
267 // contents flags are seperate bits
268 // a given brush can contribute multiple content bits
269 // multiple brushes can be in a single leaf
270
271 // lower bits are stronger, and will eat weaker brushes completely
272 #define CONTENTS_SOLID 1 // an eye is never valid in a solid
273 #define CONTENTS_WINDOW 2 // translucent, but not watery
274 #define CONTENTS_AUX 4
275 #define CONTENTS_LAVA 8
276 #define CONTENTS_SLIME 16
277 #define CONTENTS_WATER 32
278 #define CONTENTS_MIST 64
279 #define LAST_VISIBLE_CONTENTS 64
280
281 // remaining contents are non-visible, and don't eat brushes
282 #define CONTENTS_PLAYERCLIP 0x10000
283 #define CONTENTS_MONSTERCLIP 0x20000
284
285 // currents can be added to any other contents, and may be mixed
286 #define CONTENTS_CURRENT_0 0x40000
287 #define CONTENTS_CURRENT_90 0x80000
288 #define CONTENTS_CURRENT_180 0x100000
289 #define CONTENTS_CURRENT_270 0x200000
290 #define CONTENTS_CURRENT_UP 0x400000
291 #define CONTENTS_CURRENT_DOWN 0x800000
292
293 #define CONTENTS_ORIGIN 0x1000000 // removed before bsping an entity
294
295 #define CONTENTS_MONSTER 0x2000000 // should never be on a brush, only in game
296 #define CONTENTS_DEADMONSTER 0x4000000
297 #define CONTENTS_DETAIL 0x8000000 // brushes to be added after vis leafs
298 #define CONTENTS_TRANSLUCENT 0x10000000 // auto set if any surface has trans
299
300
301
302 typedef struct
303 {
304 int planenum;
305 int children[2]; // negative numbers are -(leafs+1), not nodes
306 short mins[3]; // for frustom culling
307 short maxs[3];
308 unsigned short firstface;
309 unsigned short numfaces; // counting both sides
310 } dnode_t;
311
312
313 typedef struct texinfo_s
314 {
315 float vecs[2][4]; // [s/t][xyz offset]
316 int flags; // miptex flags + overrides
317 int value; // light emission, etc
318 char texture[32]; // texture name (textures/*.wal)
319 int nexttexinfo; // for animations, -1 = end of chain
320 } texinfo_t;
321
322
323 #define SURF_LIGHT 0x1 // value will hold the light strength
324
325 #define SURF_SLICK 0x2 // effects game physics
326
327 #define SURF_SKY 0x4 // don't draw, but add to skybox
328 #define SURF_WARP 0x8 // turbulent water warp
329 #define SURF_TRANS33 0x10
330 #define SURF_TRANS66 0x20
331 #define SURF_FLOWING 0x40 // scroll towards angle
332 #define SURF_NODRAW 0x80 // don't bother referencing the texture
333
334
335 // note that edge 0 is never used, because negative edge nums are used for
336 // counterclockwise use of the edge in a face
337 typedef struct
338 {
339 unsigned short v[2]; // vertex numbers
340 } dedge_t;
341
342 #define MAXLIGHTMAPS 4
343 typedef struct
344 {
345 unsigned short planenum;
346 short side;
347
348 int firstedge; // we must support > 64k edges
349 short numedges;
350 short texinfo;
351
352 // lighting info
353 byte styles[MAXLIGHTMAPS];
354 int lightofs; // start of [numstyles*surfsize] samples
355 } dface_t;
356
357 typedef struct
358 {
359 int contents; // OR of all brushes (not needed?)
360
361 int pvsofs; // -1 = no info
362 int phsofs; // -1 = no info
363
364 short mins[3]; // for frustum culling
365 short maxs[3];
366
367 unsigned short firstleafface;
368 unsigned short numleaffaces;
369
370 unsigned short firstleafbrush;
371 unsigned short numleafbrushes;
372 } dleaf_t;
373
374 typedef struct
375 {
376 unsigned short planenum; // facing out of the leaf
377 short texinfo;
378 } dbrushside_t;
379
380 typedef struct
381 {
382 int firstside;
383 int numsides;
384 int contents;
385 } dbrush_t;
386
387 #define ANGLE_UP -1
388 #define ANGLE_DOWN -2
389