OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
qfiles.h
1/*
2===========================================================================
3Copyright (C) 1999-2005 Id Software, Inc.
4
5This file is part of Quake III Arena source code.
6
7Quake III Arena source code is free software; you can redistribute it
8and/or modify it under the terms of the GNU General Public License as
9published by the Free Software Foundation; either version 2 of the License,
10or (at your option) any later version.
11
12Quake III Arena source code is distributed in the hope that it will be
13useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with Quake III Arena source code; if not, write to the Free Software
19Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20===========================================================================
21*/
22#ifndef __QFILES_H__
23#define __QFILES_H__
24
25#include "q_shared.h"
26
27//
28// qfiles.h: quake file formats
29// This file must be identical in the quake and utils directories
30//
31
32//Ignore __attribute__ on non-gcc platforms
33#ifndef __GNUC__
34#ifndef __attribute__
35#define __attribute__(x)
36#endif
37#endif
38
39// surface geometry should not exceed these limits
40#define SHADER_MAX_VERTEXES 2048 // 1000 su44: I've increased it a bit...
41#define SHADER_MAX_INDEXES (6*SHADER_MAX_VERTEXES)
42#define SHADER_MAX_TRIANGLES (2*SHADER_MAX_VERTEXES)
43
44// the maximum size of game relative pathnames
45#define MAX_QPATH 256
46
47/*
48========================================================================
49
50QVM files
51
52========================================================================
53*/
54
55#define VM_MAGIC 0x12721444
56#define VM_MAGIC_VER2 0x12721445
57typedef struct {
58 int vmMagic;
59
60 int instructionCount;
61
62 int codeOffset;
63 int codeLength;
64
65 int dataOffset;
66 int dataLength;
67 int litLength; // ( dataLength - litLength ) should be byteswapped on load
68 int bssLength; // zero filled memory appended to datalength
69
71 int jtrgLength; // number of jump table targets
73
74
75/*
76========================================================================
77
78PCX files are used for 8 bit images
79
80========================================================================
81*/
82
83typedef struct {
84 char manufacturer;
85 char version;
86 char encoding;
87 char bits_per_pixel;
88 unsigned short xmin,ymin,xmax,ymax;
89 unsigned short hres,vres;
90 unsigned char palette[48];
91 char reserved;
92 char color_planes;
93 unsigned short bytes_per_line;
94 unsigned short palette_type;
95 char filler[58];
96 unsigned char data[1]; // unbounded
97} pcx_t;
98
99
100/*
101========================================================================
102
103TGA files are used for 24/32 bit images
104
105========================================================================
106*/
107
108typedef struct _TargaHeader {
109 unsigned char id_length, colormap_type, image_type;
110 unsigned short colormap_index, colormap_length;
111 unsigned char colormap_size;
112 unsigned short x_origin, y_origin, width, height;
113 unsigned char pixel_size, attributes;
114} TargaHeader;
115
116/*
117========================================================================
118
119FTX files are pre mipmapped files for OpenMOHAA
120
121========================================================================
122*/
123#define FENCEMASK_VERSION 2
124#define FTX_EXTENSION ".ftx"
125
126typedef struct ftx_s {
127 int width;
128 int height;
129 int has_alpha;
130 // data follows
131} ftx_t;
132
133/*
134========================================================================
135
136.MD3 triangle model file format
137
138========================================================================
139*/
140
141#define MD3_IDENT (('3'<<24)+('P'<<16)+('D'<<8)+'I')
142#define MD3_VERSION 15
143
144// limits
145#define MD3_MAX_LODS 3
146#define MD3_MAX_TRIANGLES 8192 // per surface
147#define MD3_MAX_VERTS 4096 // per surface
148#define MD3_MAX_SHADERS 256 // per surface
149#define MD3_MAX_FRAMES 1024 // per model
150#define MD3_MAX_SURFACES 32 // per model
151#define MD3_MAX_TAGS 16 // per frame
152
153// vertex scales
154#define MD3_XYZ_SCALE (1.0/64)
155
156typedef struct md3Frame_s {
157 vec3_t bounds[2];
158 vec3_t localOrigin;
159 float radius;
160 char name[16];
161} md3Frame_t;
162
163typedef struct md3Tag_s {
164 char name[MAX_QPATH]; // tag name
165 vec3_t origin;
166 vec3_t axis[3];
167} md3Tag_t;
168
169/*
170** md3Surface_t
171**
172** CHUNK SIZE
173** header sizeof( md3Surface_t )
174** shaders sizeof( md3Shader_t ) * numShaders
175** triangles[0] sizeof( md3Triangle_t ) * numTriangles
176** st sizeof( md3St_t ) * numVerts
177** XyzNormals sizeof( md3XyzNormal_t ) * numVerts * numFrames
178*/
179typedef struct {
180 int ident; //
181
182 char name[MAX_QPATH]; // polyset name
183
184 int flags;
185 int numFrames; // all surfaces in a model should have the same
186
187 int numShaders; // all surfaces in a model should have the same
188 int numVerts;
189
190 int numTriangles;
191 int ofsTriangles;
192
193 int ofsShaders; // offset from start of md3Surface_t
194 int ofsSt; // texture coords are common for all frames
195 int ofsXyzNormals; // numVerts * numFrames
196
197 int ofsEnd; // next surface follows
199
200typedef struct {
201 char name[MAX_QPATH];
202 int shaderIndex; // for in-game use
204
205typedef struct {
206 int indexes[3];
208
209typedef struct {
210 float st[2];
211} md3St_t;
212
213typedef struct {
214 short xyz[3];
215 short normal;
217
218typedef struct {
219 int ident;
220 int version;
221
222 char name[MAX_QPATH]; // model name
223
224 int flags;
225
226 int numFrames;
227 int numTags;
228 int numSurfaces;
229
230 int numSkins;
231
232 int ofsFrames; // offset for first frame
233 int ofsTags; // numFrames * numTags
234 int ofsSurfaces; // first surface, others follow
235
236 int ofsEnd; // end of file
238
239/*
240 * Here are the definitions for Ravensoft's model format of md4. Raven stores their
241 * playermodels in .mdr files, in some games, which are pretty much like the md4
242 * format implemented by ID soft. It seems like ID's original md4 stuff is not used at all.
243 * MDR is being used in EliteForce, JediKnight2 and Soldiers of Fortune2 (I think).
244 * So this comes in handy for anyone who wants to make it possible to load player
245 * models from these games.
246 * This format has bone tags, which is similar to the thing you have in md3 I suppose.
247 * Raven has released their version of md3view under GPL enabling me to add support
248 * to this codebase. Thanks to Steven Howes aka Skinner for helping with example
249 * source code.
250 *
251 * - Thilo Schulz (arny@ats.s.bawue.de)
252 */
253
254#define MDR_IDENT (('5'<<24)+('M'<<16)+('D'<<8)+'R')
255#define MDR_VERSION 2
256#define MDR_MAX_BONES 128
257
258typedef struct {
259 int boneIndex; // these are indexes into the boneReferences,
260 float boneWeight; // not the global per-frame bone list
261 vec3_t offset;
263
264typedef struct {
265 vec3_t normal;
266 vec2_t texCoords;
267 int numWeights;
268 mdrWeight_t weights[1]; // variable sized
270
271typedef struct {
272 int indexes[3];
274
275typedef struct {
276 int ident;
277
278 char name[MAX_QPATH]; // polyset name
279 char shader[MAX_QPATH];
280 int shaderIndex; // for in-game use
281
282 int ofsHeader; // this will be a negative number
283
284 int numVerts;
285 int ofsVerts;
286
287 int numTriangles;
288 int ofsTriangles;
289
290 // Bone references are a set of ints representing all the bones
291 // present in any vertex weights for this surface. This is
292 // needed because a model may have surfaces that need to be
293 // drawn at different sort times, and we don't want to have
294 // to re-interpolate all the bones for each surface.
295 int numBoneReferences;
296 int ofsBoneReferences;
297
298 int ofsEnd; // next surface follows
300
301typedef struct {
302 float matrix[3][4];
303} mdrBone_t;
304
305typedef struct {
306 vec3_t bounds[2]; // bounds of all surfaces of all LOD's for this frame
307 vec3_t localOrigin; // midpoint of bounds, used for sphere cull
308 float radius; // dist from localOrigin to corner
309 char name[16];
310 mdrBone_t bones[1]; // [numBones]
311} mdrFrame_t;
312
313typedef struct {
314 unsigned char Comp[24]; // MC_COMP_BYTES is in MatComp.h, but don't want to couple
316
317typedef struct {
318 vec3_t bounds[2]; // bounds of all surfaces of all LOD's for this frame
319 vec3_t localOrigin; // midpoint of bounds, used for sphere cull
320 float radius; // dist from localOrigin to corner
321 mdrCompBone_t bones[1]; // [numBones]
323
324typedef struct {
325 int numSurfaces;
326 int ofsSurfaces; // first surface, others follow
327 int ofsEnd; // next lod follows
328} mdrLOD_t;
329
330typedef struct {
331 int boneIndex;
332 char name[32];
333} mdrTag_t;
334
335typedef struct {
336 int ident;
337 int version;
338
339 char name[MAX_QPATH]; // model name
340
341 // frames and bones are shared by all levels of detail
342 int numFrames;
343 int numBones;
344 int ofsFrames; // mdrFrame_t[numFrames]
345
346 // each level of detail has completely separate sets of surfaces
347 int numLODs;
348 int ofsLODs;
349
350 int numTags;
351 int ofsTags;
352
353 int ofsEnd; // end of file
355
356/*
357==============================================================================
358
359 .BSP file format
360
361==============================================================================
362*/
363
364
365#define BSP_IDENT (('5'<<24)+('1'<<16)+('0'<<8)+'2')
366 // little-endian "2015"
367
368#define BSP_BETA_VERSION 17 // Beta Allied Assault
369#define BSP_MIN_VERSION 17 // Beta Allied Assault
370#define BSP_VERSION 19 // Allied Assault
371#define BSP_MAX_VERSION 21 // Breakthrough
372
373
374// there shouldn't be any problem with increasing these values at the
375// expense of more memory allocation in the utilities
376#define MAX_MAP_MODELS 0x400
377#define MAX_MAP_BRUSHES 0x8000
378#define MAX_MAP_ENTITIES 0x2000 // 0x800 // su44: increased for t2l1.map
379#define MAX_MAP_ENTSTRING 0x100000 //0x40000 // su44: increased for t2l1.map
380#define MAX_MAP_SHADERS 0x400
381
382#define MAX_MAP_AREAS 0x100 // MAX_MAP_AREA_BYTES in q_shared must match!
383#define MAX_MAP_FOGS 0x100
384#define MAX_MAP_PLANES 0x20000
385#define MAX_MAP_NODES 0x20000
386#define MAX_MAP_BRUSHSIDES 0x20000
387#define MAX_MAP_LEAFS 0x20000
388#define MAX_MAP_LEAFFACES 0x20000
389#define MAX_MAP_LEAFBRUSHES 0x40000
390#define MAX_MAP_PORTALS 0x20000
391#define MAX_MAP_LIGHTING 0x800000
392#define MAX_MAP_LIGHTGRID 0x800000
393#define MAX_MAP_VISIBILITY 0x200000
394
395#define MAX_MAP_DRAW_SURFS 0x20000
396#define MAX_MAP_DRAW_VERTS 0x80000
397#define MAX_MAP_DRAW_INDEXES 0x80000
398#define MAX_MAP_SPHERE_L_SIZE 1532
399
400
401#define MIN_MAP_SUBDIVISIONS 16
402
403
404// key / value pair sizes in the entities lump
405#define MAX_KEY 32
406#define MAX_VALUE 1024
407
408// the editor uses these predefined yaw angles to orient entities up or down
409#define ANGLE_UP -1
410#define ANGLE_DOWN -2
411
412#define LIGHTMAP_WIDTH 128
413#define LIGHTMAP_HEIGHT 128
414#define LIGHTMAP_SIZE 128 // IneQuation: moved it here, MUST MATCH THE FORMER TWO
415
416#define MAX_WORLD_COORD ( 128*128 )
417#define MIN_WORLD_COORD ( -128*128 )
418#define WORLD_SIZE ( MAX_WORLD_COORD - MIN_WORLD_COORD )
419
420//=============================================================================
421
422typedef struct fcm_s {
423 int iWidth;
424 int iHeight;
425} fcm_t;
426
427#define MAX_TERRAIN_VARNODES 63
428#define TERPATCH_FLIP 0x40
429#define TERPATCH_NEIGHBOR 0x80
430
431typedef struct varnode_s {
432 unsigned short flags;
433} varnode_t;
434
435typedef struct cTerraPatch_s {
436 byte flags;
437 byte lmapScale;
438 byte s;
439 byte t;
440
441 vec2_t texCoord[ 2 ][ 2 ];
442
443 signed char x;
444 signed char y;
445
446 short iBaseHeight;
447 unsigned short iShader;
448 unsigned short iLightMap;
449
450 short iNorth;
451 short iEast;
452 short iSouth;
453 short iWest;
454
455 varnode_t varTree[2][MAX_TERRAIN_VARNODES];
456
457 unsigned char heightmap[ 9 * 9 ];
458} cTerraPatch_t;
459
460typedef struct cStaticModel_s {
461 char model[128];
462 vec3_t origin;
463 vec3_t angles;
464 float scale;
465 int firstVertexData;
466 int numVertexData;
467} cStaticModel_t;
468
469typedef struct {
470 void *buffer;
471 int length;
472} gamelump_t;
473
474typedef struct {
475 int fileofs, filelen;
476} lump_t;
477
478
479#define LUMP_FOGS 0
480#define LUMP_LIGHTGRID 0
481// new lump defines. lump numbers are different in mohaa
482#define LUMP_SHADERS 0
483#define LUMP_PLANES 1
484#define LUMP_LIGHTMAPS 2
485#define LUMP_SURFACES 3
486#define LUMP_DRAWVERTS 4
487#define LUMP_DRAWINDEXES 5
488#define LUMP_LEAFBRUSHES 6
489#define LUMP_LEAFSURFACES 7
490#define LUMP_LEAFS 8
491#define LUMP_NODES 9
492#define LUMP_SIDEEQUATIONS 10
493#define LUMP_BRUSHSIDES 11
494#define LUMP_BRUSHES 12
495/*
496#define LUMP_FOGS 13
497LUMP_FOGS was removed in BSP version 19, since moh version 1.10
498*/
499#define LUMP_MODELS 13
500#define LUMP_ENTITIES 14
501#define LUMP_VISIBILITY 15
502#define LUMP_LIGHTGRIDPALETTE 16
503#define LUMP_LIGHTGRIDOFFSETS 17
504#define LUMP_LIGHTGRIDDATA 18
505#define LUMP_SPHERELIGHTS 19
506#define LUMP_SPHERELIGHTVIS 20
507#define LUMP_LIGHTDEFS 21
508#define LUMP_TERRAIN 22
509#define LUMP_TERRAININDEXES 23
510#define LUMP_STATICMODELDATA 24
511#define LUMP_STATICMODELDEF 25
512#define LUMP_STATICMODELINDEXES 26
513#define LUMP_DUMMY10 27
514
515#define HEADER_LUMPS 28
516
517typedef struct {
518 int ident;
519 int version;
520 int checksum;
521
522 lump_t lumps[ HEADER_LUMPS ];
523} dheader_t;
524
525static lump_t *Q_GetLumpByVersion(dheader_t *header, int lump)
526{
527 if (header->version <= 18) {
528 if (lump > LUMP_BRUSHES) {
529 return &header->lumps[lump + 1];
530 }
531 return &header->lumps[lump];
532 }
533
534 return &header->lumps[lump];
535}
536
537typedef struct {
538 float mins[3], maxs[3];
539 int firstSurface, numSurfaces;
540 int firstBrush, numBrushes;
541} dmodel_t;
542
543typedef struct {
544 char shader[ 64 ];
545 int surfaceFlags;
546 int contentFlags;
547 int subdivisions;
548 char fenceMaskImage[ 64 ];
549} dshader_t;
550
551typedef struct baseshader_s {
552 char shader[ 64 ];
553 int surfaceFlags;
554 int contentFlags;
555} baseshader_t;
556
557// planes x^1 is allways the opposite of plane x
558
559typedef struct {
560 float normal[3];
561 float dist;
562} dplane_t;
563
564typedef struct {
565 int planeNum;
566 int children[2]; // negative numbers are -(leafs+1), not nodes
567 int mins[3]; // for frustom culling
568 int maxs[3];
569} dnode_t;
570
571typedef struct {
572 int cluster; // -1 = opaque cluster (do I still store these?)
573 int area;
574
575 int mins[3]; // for frustum culling
576 int maxs[3];
577
578 int firstLeafSurface;
579 int numLeafSurfaces;
580
581 int firstLeafBrush;
582 int numLeafBrushes;
583
584 //added for mohaa
585 int firstTerraPatch;
586 int numTerraPatches;
587 int firstStaticModel;
588 int numStaticModels;
589} dleaf_t;
590
591// old leaf version
592typedef struct {
593 int cluster;
594 int area;
595
596 int mins[ 3 ];
597 int maxs[ 3 ];
598
599 int firstLeafSurface;
600 int numLeafSurfaces;
601
602 int firstLeafBrush;
603 int numLeafBrushes;
604
605 int firstTerraPatch;
606 int numTerraPatches;
608
609// su44: It seems that sideEquations
610// are somehow related to fencemasks...
611// MoHAA loads them only in CM (CM_LoadMap).
612typedef struct {
613 float fSeq[ 4 ];
614 float fTeq[ 4 ];
616
617typedef struct {
618 int planeNum; // positive plane side faces out of the leaf
619 int shaderNum;
620
621 //added for mohaa
622 int equationNum; // su44: that's a dsideEquation_t index
624
625typedef struct {
626 int firstSide;
627 int numSides;
628 int shaderNum; // the shader that determines the contents flags
629} dbrush_t;
630
631typedef struct {
632 char shader[MAX_QPATH];
633 int brushNum;
634 int visibleSide; // the brush side that ray tests need to clip against (-1 == none)
635} dfog_t;
636
637typedef struct {
638 vec3_t xyz;
639 float st[2];
640 float lightmap[2];
641 vec3_t normal;
642 byte color[4];
643} drawVert_t;
644
645typedef struct {
646 vec3_t xyz;
647 float st[ 2 ];
648 int collapseMap;
649 float lodExtra; // depending on the vertexNumber, will be 0 - minLOD, 1 - lodScale or 2 - lodBias
650 vec3_t normal;
651 byte color[ 4 ];
653
654#define drawVert_t_cleared(x) drawVert_t (x) = {{0, 0, 0}, {0, 0}, {0, 0}, {0, 0, 0}, {0, 0, 0, 0}}
655
656typedef enum {
657 MST_BAD,
658 MST_PLANAR,
659 MST_PATCH,
660 MST_TRIANGLE_SOUP,
661 MST_FLARE,
662 MST_TERRAIN
663} mapSurfaceType_t;
664
665typedef struct {
666 int shaderNum;
667 int fogNum;
668 int surfaceType;
669
670 int firstVert;
671 int numVerts;
672
673 int firstIndex;
674 int numIndexes;
675
676 int lightmapNum;
677 int lightmapX, lightmapY;
678 int lightmapWidth, lightmapHeight;
679
680 vec3_t lightmapOrigin;
681 vec3_t lightmapVecs[ 3 ]; // for patches, [0] and [1] are lodbounds
682
683 int patchWidth;
684 int patchHeight;
685
686 //added for mohaa
687 float subdivisions;
688} dsurface_t;
689
690// IneQuation was here
691typedef struct dterPatch_s {
692 byte flags;
693 byte scale;
694 byte lmCoords[2];
695 float texCoords[8];
696 char x;
697 char y;
698 short baseZ;
699 unsigned short shader;
700 short lightmap;
701 short dummy[4];
702 short vertFlags[2][63];
703 byte heightmap[9][9];
704} dterPatch_t;
705
706// su44 was here
707typedef struct dstaticModel_s {
708 char model[128];
709 vec3_t origin;
710 vec3_t angles;
711 float scale;
712 int firstVertexData;
713 short numVertexData;
714} dstaticModel_t;
715
716typedef struct {
717 float origin[3];
718 float color[3];
719 float intensity;
720 int leaf;
721 qboolean needs_trace;
722 qboolean spot_light;
723 float spot_dir[3];
724 float spot_radiusbydistance;
725} dspherel_t;
726
727typedef struct {
728 float origin[3];
729 float axis[3];
730 int bounds[3];
732
733typedef struct {
734 int lightIntensity;
735 int lightAngle;
736 int lightmapResolution;
737 qboolean twoSided;
738 qboolean lightLinear;
739 vec3_t lightColor;
740 float lightFalloff;
741 float backsplashFraction;
742 float backsplashDistance;
743 float lightSubdivide;
744 qboolean autosprite;
746
747typedef struct {
748 vec3_t origin;
749 vec3_t color;
750 float intensity;
751 int leaf;
752 qboolean needs_trace;
753 qboolean spot_light;
754 vec3_t spot_dir;
755 float spot_radiusbydistance;
757
758#endif
Definition qfiles.h:108
Definition qfiles.h:551
Definition qfiles.h:460
Definition qfiles.h:435
Definition qfiles.h:625
Definition qfiles.h:617
Definition qfiles.h:631
Definition qfiles.h:517
Definition qfiles.h:592
Definition qfiles.h:571
Definition qfiles.h:727
Definition qfiles.h:733
Definition qfiles.h:537
Definition qfiles.h:564
Definition qfiles.h:559
Definition qfiles.h:645
Definition qfiles.h:637
Definition qfiles.h:543
Definition qfiles.h:612
Definition qfiles.h:716
Definition qfiles.h:707
Definition qfiles.h:665
Definition qfiles.h:691
Definition qfiles.h:422
Definition qfiles.h:126
Definition qfiles.h:469
Definition qfiles.h:474
Definition qfiles.h:747
Definition qfiles.h:156
Definition qfiles.h:218
Definition qfiles.h:200
Definition qfiles.h:209
Definition qfiles.h:179
Definition qfiles.h:163
Definition qfiles.h:205
Definition qfiles.h:213
Definition qfiles.h:301
Definition qfiles.h:313
Definition qfiles.h:317
Definition qfiles.h:305
Definition qfiles.h:335
Definition qfiles.h:324
Definition qfiles.h:275
Definition qfiles.h:330
Definition qfiles.h:271
Definition qfiles.h:264
Definition qfiles.h:258
Definition qfiles.h:83
Definition qfiles.h:431
Definition qfiles.h:57
int jtrgLength
!! below here is VM_MAGIC_VER2 !!!
Definition qfiles.h:71