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