Debian Codegraph @

code/qcommon/qfiles.h

raw symbols ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 /*
2 ===========================================================================
3 Copyright (C) 1999-2005 Id Software, Inc.
4
5 This file is part of Quake III Arena source code.
6
7 Quake III Arena 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 III Arena 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 III Arena 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 #ifndef __QFILES_H__
23 #define __QFILES_H__
24
25 //
26 // qfiles.h: quake file formats
27 // This file must be identical in the quake and utils directories
28 //
29
30 // surface geometry should not exceed these limits
31 #define SHADER_MAX_VERTEXES 1000
32 #define SHADER_MAX_INDEXES (6*SHADER_MAX_VERTEXES)
33
34
35 // the maximum size of game relative pathnames
36 #define MAX_QPATH 64
37
38 /*
39 ========================================================================
40
41 QVM files
42
43 ========================================================================
44 */
45
46 #define VM_MAGIC 0x12721444
47 #define VM_MAGIC_VER2 0x12721445
48 typedef struct {
49 int vmMagic;
50
51 int instructionCount;
52
53 int codeOffset;
54 int codeLength;
55
56 int dataOffset;
57 int dataLength;
58 int litLength; // ( dataLength - litLength ) should be byteswapped on load
59 int bssLength; // zero filled memory appended to datalength
60
61 //!!! below here is VM_MAGIC_VER2 !!!
62 int jtrgLength; // number of jump table targets
63 } vmHeader_t;
64
65 /*
66 ========================================================================
67
68 .MD3 triangle model file format
69
70 ========================================================================
71 */
72
73 #define MD3_IDENT (('3'<<24)+('P'<<16)+('D'<<8)+'I')
74 #define MD3_VERSION 15
75
76 // limits
77 #define MD3_MAX_LODS 3
78 #define MD3_MAX_TRIANGLES 8192 // per surface
79 #define MD3_MAX_VERTS 4096 // per surface
80 #define MD3_MAX_SHADERS 256 // per surface
81 #define MD3_MAX_FRAMES 1024 // per model
82 #define MD3_MAX_SURFACES 32 // per model
83 #define MD3_MAX_TAGS 16 // per frame
84
85 // vertex scales
86 #define MD3_XYZ_SCALE (1.0/64)
87
88 typedef struct md3Frame_s {
89 vec3_t bounds[2];
90 vec3_t localOrigin;
91 float radius;
92 char name[16];
93 } md3Frame_t;
94
95 typedef struct md3Tag_s {
96 char name[MAX_QPATH]; // tag name
97 vec3_t origin;
98 vec3_t axis[3];
99 } md3Tag_t;
100
101 /*
102 ** md3Surface_t
103 **
104 ** CHUNK SIZE
105 ** header sizeof( md3Surface_t )
106 ** shaders sizeof( md3Shader_t ) * numShaders
107 ** triangles[0] sizeof( md3Triangle_t ) * numTriangles
108 ** st sizeof( md3St_t ) * numVerts
109 ** XyzNormals sizeof( md3XyzNormal_t ) * numVerts * numFrames
110 */
111 typedef struct {
112 int ident; //
113
114 char name[MAX_QPATH]; // polyset name
115
116 int flags;
117 int numFrames; // all surfaces in a model should have the same
118
119 int numShaders; // all surfaces in a model should have the same
120 int numVerts;
121
122 int numTriangles;
123 int ofsTriangles;
124
125 int ofsShaders; // offset from start of md3Surface_t
126 int ofsSt; // texture coords are common for all frames
127 int ofsXyzNormals; // numVerts * numFrames
128
129 int ofsEnd; // next surface follows
130 } md3Surface_t;
131
132 typedef struct {
133 char name[MAX_QPATH];
134 int shaderIndex; // for in-game use
135 } md3Shader_t;
136
137 typedef struct {
138 int indexes[3];
139 } md3Triangle_t;
140
141 typedef struct {
142 float st[2];
143 } md3St_t;
144
145 typedef struct {
146 short xyz[3];
147 short normal;
148 } md3XyzNormal_t;
149
150 typedef struct {
151 int ident;
152 int version;
153
154 char name[MAX_QPATH]; // model name
155
156 int flags;
157
158 int numFrames;
159 int numTags;
160 int numSurfaces;
161
162 int numSkins;
163
164 int ofsFrames; // offset for first frame
165 int ofsTags; // numFrames * numTags
166 int ofsSurfaces; // first surface, others follow
167
168 int ofsEnd; // end of file
169 } md3Header_t;
170
171 /*
172 ==============================================================================
173
174 MDR file format
175
176 ==============================================================================
177 */
178
179 /*
180 * Here are the definitions for Ravensoft's model format of md4. Raven stores their
181 * playermodels in .mdr files, in some games, which are pretty much like the md4
182 * format implemented by ID soft. It seems like ID's original md4 stuff is not used at all.
183 * MDR is being used in EliteForce, JediKnight2 and Soldiers of Fortune2 (I think).
184 * So this comes in handy for anyone who wants to make it possible to load player
185 * models from these games.
186 * This format has bone tags, which is similar to the thing you have in md3 I suppose.
187 * Raven has released their version of md3view under GPL enabling me to add support
188 * to this codebase. Thanks to Steven Howes aka Skinner for helping with example
189 * source code.
190 *
191 * - Thilo Schulz ([email protected])
192 */
193
194 #define MDR_IDENT (('5'<<24)+('M'<<16)+('D'<<8)+'R')
195 #define MDR_VERSION 2
196 #define MDR_MAX_BONES 128
197
198 typedef struct {
199 int boneIndex; // these are indexes into the boneReferences,
200 float boneWeight; // not the global per-frame bone list
201 vec3_t offset;
202 } mdrWeight_t;
203
204 typedef struct {
205 vec3_t normal;
206 vec2_t texCoords;
207 int numWeights;
208 mdrWeight_t weights[1]; // variable sized
209 } mdrVertex_t;
210
211 typedef struct {
212 int indexes[3];
213 } mdrTriangle_t;
214
215 typedef struct {
216 int ident;
217
218 char name[MAX_QPATH]; // polyset name
219 char shader[MAX_QPATH];
220 int shaderIndex; // for in-game use
221
222 int ofsHeader; // this will be a negative number
223
224 int numVerts;
225 int ofsVerts;
226
227 int numTriangles;
228 int ofsTriangles;
229
230 // Bone references are a set of ints representing all the bones
231 // present in any vertex weights for this surface. This is
232 // needed because a model may have surfaces that need to be
233 // drawn at different sort times, and we don't want to have
234 // to re-interpolate all the bones for each surface.
235 int numBoneReferences;
236 int ofsBoneReferences;
237
238 int ofsEnd; // next surface follows
239 } mdrSurface_t;
240
241 typedef struct {
242 float matrix[3][4];
243 } mdrBone_t;
244
245 typedef struct {
246 vec3_t bounds[2]; // bounds of all surfaces of all LOD's for this frame
247 vec3_t localOrigin; // midpoint of bounds, used for sphere cull
248 float radius; // dist from localOrigin to corner
249 char name[16];
250 mdrBone_t bones[1]; // [numBones]
251 } mdrFrame_t;
252
253 typedef struct {
254 unsigned char Comp[24]; // MC_COMP_BYTES is in MatComp.h, but don't want to couple
255 } mdrCompBone_t;
256
257 typedef struct {
258 vec3_t bounds[2]; // bounds of all surfaces of all LOD's for this frame
259 vec3_t localOrigin; // midpoint of bounds, used for sphere cull
260 float radius; // dist from localOrigin to corner
261 mdrCompBone_t bones[1]; // [numBones]
262 } mdrCompFrame_t;
263
264 typedef struct {
265 int numSurfaces;
266 int ofsSurfaces; // first surface, others follow
267 int ofsEnd; // next lod follows
268 } mdrLOD_t;
269
270 typedef struct {
271 int boneIndex;
272 char name[32];
273 } mdrTag_t;
274
275 typedef struct {
276 int ident;
277 int version;
278
279 char name[MAX_QPATH]; // model name
280
281 // frames and bones are shared by all levels of detail
282 int numFrames;
283 int numBones;
284 int ofsFrames; // mdrFrame_t[numFrames]
285
286 // each level of detail has completely separate sets of surfaces
287 int numLODs;
288 int ofsLODs;
289
290 int numTags;
291 int ofsTags;
292
293 int ofsEnd; // end of file
294 } mdrHeader_t;
295
296
297 /*
298 ==============================================================================
299
300 .BSP file format
301
302 ==============================================================================
303 */
304
305
306 #define BSP_IDENT (('P'<<24)+('S'<<16)+('B'<<8)+'I')
307 // little-endian "IBSP"
308
309 #define BSP_VERSION 46
310
311
312 // there shouldn't be any problem with increasing these values at the
313 // expense of more memory allocation in the utilities
314 #define MAX_MAP_MODELS 0x400
315 #define MAX_MAP_BRUSHES 0x8000
316 #define MAX_MAP_ENTITIES 0x800
317 #define MAX_MAP_ENTSTRING 0x40000
318 #define MAX_MAP_SHADERS 0x400
319
320 #define MAX_MAP_AREAS 0x100 // MAX_MAP_AREA_BYTES in q_shared must match!
321 #define MAX_MAP_FOGS 0x100
322 #define MAX_MAP_PLANES 0x20000
323 #define MAX_MAP_NODES 0x20000
324 #define MAX_MAP_BRUSHSIDES 0x20000
325 #define MAX_MAP_LEAFS 0x20000
326 #define MAX_MAP_LEAFFACES 0x20000
327 #define MAX_MAP_LEAFBRUSHES 0x40000
328 #define MAX_MAP_PORTALS 0x20000
329 #define MAX_MAP_LIGHTING 0x800000
330 #define MAX_MAP_LIGHTGRID 0x800000
331 #define MAX_MAP_VISIBILITY 0x200000
332
333 #define MAX_MAP_DRAW_SURFS 0x20000
334 #define MAX_MAP_DRAW_VERTS 0x80000
335 #define MAX_MAP_DRAW_INDEXES 0x80000
336
337
338 // key / value pair sizes in the entities lump
339 #define MAX_KEY 32
340 #define MAX_VALUE 1024
341
342 // the editor uses these predefined yaw angles to orient entities up or down
343 #define ANGLE_UP -1
344 #define ANGLE_DOWN -2
345
346 #define LIGHTMAP_WIDTH 128
347 #define LIGHTMAP_HEIGHT 128
348
349 #define MAX_WORLD_COORD ( 128*1024 )
350 #define MIN_WORLD_COORD ( -128*1024 )
351 #define WORLD_SIZE ( MAX_WORLD_COORD - MIN_WORLD_COORD )
352
353 //=============================================================================
354
355
356 typedef struct {
357 int fileofs, filelen;
358 } lump_t;
359
360 #define LUMP_ENTITIES 0
361 #define LUMP_SHADERS 1
362 #define LUMP_PLANES 2
363 #define LUMP_NODES 3
364 #define LUMP_LEAFS 4
365 #define LUMP_LEAFSURFACES 5
366 #define LUMP_LEAFBRUSHES 6
367 #define LUMP_MODELS 7
368 #define LUMP_BRUSHES 8
369 #define LUMP_BRUSHSIDES 9
370 #define LUMP_DRAWVERTS 10
371 #define LUMP_DRAWINDEXES 11
372 #define LUMP_FOGS 12
373 #define LUMP_SURFACES 13
374 #define LUMP_LIGHTMAPS 14
375 #define LUMP_LIGHTGRID 15
376 #define LUMP_VISIBILITY 16
377 #define HEADER_LUMPS 17
378
379 typedef struct {
380 int ident;
381 int version;
382
383 lump_t lumps[HEADER_LUMPS];
384 } dheader_t;
385
386 typedef struct {
387 float mins[3], maxs[3];
388 int firstSurface, numSurfaces;
389 int firstBrush, numBrushes;
390 } dmodel_t;
391
392 typedef struct {
393 char shader[MAX_QPATH];
394 int surfaceFlags;
395 int contentFlags;
396 } dshader_t;
397
398 // planes x^1 is allways the opposite of plane x
399
400 typedef struct {
401 float normal[3];
402 float dist;
403 } dplane_t;
404
405 typedef struct {
406 int planeNum;
407 int children[2]; // negative numbers are -(leafs+1), not nodes
408 int mins[3]; // for frustom culling
409 int maxs[3];
410 } dnode_t;
411
412 typedef struct {
413 int cluster; // -1 = opaque cluster (do I still store these?)
414 int area;
415
416 int mins[3]; // for frustum culling
417 int maxs[3];
418
419 int firstLeafSurface;
420 int numLeafSurfaces;
421
422 int firstLeafBrush;
423 int numLeafBrushes;
424 } dleaf_t;
425
426 typedef struct {
427 int planeNum; // positive plane side faces out of the leaf
428 int shaderNum;
429 } dbrushside_t;
430
431 typedef struct {
432 int firstSide;
433 int numSides;
434 int shaderNum; // the shader that determines the contents flags
435 } dbrush_t;
436
437 typedef struct {
438 char shader[MAX_QPATH];
439 int brushNum;
440 int visibleSide; // the brush side that ray tests need to clip against (-1 == none)
441 } dfog_t;
442
443 typedef struct {
444 vec3_t xyz;
445 float st[2];
446 float lightmap[2];
447 vec3_t normal;
448 byte color[4];
449 } drawVert_t;
450
451 #define drawVert_t_cleared(x) drawVert_t (x) = {{0, 0, 0}, {0, 0}, {0, 0}, {0, 0, 0}, {0, 0, 0, 0}}
452
453 typedef enum {
454 MST_BAD,
455 MST_PLANAR,
456 MST_PATCH,
457 MST_TRIANGLE_SOUP,
458 MST_FLARE
459 } mapSurfaceType_t;
460
461 typedef struct {
462 int shaderNum;
463 int fogNum;
464 int surfaceType;
465
466 int firstVert;
467 int numVerts;
468
469 int firstIndex;
470 int numIndexes;
471
472 int lightmapNum;
473 int lightmapX, lightmapY;
474 int lightmapWidth, lightmapHeight;
475
476 vec3_t lightmapOrigin;
477 vec3_t lightmapVecs[3]; // for patches, [0] and [1] are lodbounds
478
479 int patchWidth;
480 int patchHeight;
481 } dsurface_t;
482
483
484 #endif