00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __QFILES_H__
00023 #define __QFILES_H__
00024
00025
00026
00027
00028
00029
00030
00031 #define SHADER_MAX_VERTEXES 1000
00032 #define SHADER_MAX_INDEXES (6*SHADER_MAX_VERTEXES)
00033
00034
00035
00036 #define MAX_QPATH 64
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #define VM_MAGIC 0x12721444
00048 typedef struct {
00049 int vmMagic;
00050
00051 int instructionCount;
00052
00053 int codeOffset;
00054 int codeLength;
00055
00056 int dataOffset;
00057 int dataLength;
00058 int litLength;
00059 int bssLength;
00060 } vmHeader_t;
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070 typedef struct {
00071 char manufacturer;
00072 char version;
00073 char encoding;
00074 char bits_per_pixel;
00075 unsigned short xmin,ymin,xmax,ymax;
00076 unsigned short hres,vres;
00077 unsigned char palette[48];
00078 char reserved;
00079 char color_planes;
00080 unsigned short bytes_per_line;
00081 unsigned short palette_type;
00082 char filler[58];
00083 unsigned char data;
00084 } pcx_t;
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095 typedef struct _TargaHeader {
00096 unsigned char id_length, colormap_type, image_type;
00097 unsigned short colormap_index, colormap_length;
00098 unsigned char colormap_size;
00099 unsigned short x_origin, y_origin, width, height;
00100 unsigned char pixel_size, attributes;
00101 } TargaHeader;
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113 #define MD3_IDENT (('3'<<24)+('P'<<16)+('D'<<8)+'I')
00114 #define MD3_VERSION 15
00115
00116
00117 #define MD3_MAX_LODS 4
00118 #define MD3_MAX_TRIANGLES 8192 // per surface
00119 #define MD3_MAX_VERTS 4096 // per surface
00120 #define MD3_MAX_SHADERS 256 // per surface
00121 #define MD3_MAX_FRAMES 1024 // per model
00122 #define MD3_MAX_SURFACES 32 // per model
00123 #define MD3_MAX_TAGS 16 // per frame
00124
00125
00126 #define MD3_XYZ_SCALE (1.0/64)
00127
00128 typedef struct md3Frame_s {
00129 vec3_t bounds[2];
00130 vec3_t localOrigin;
00131 float radius;
00132 char name[16];
00133 } md3Frame_t;
00134
00135 typedef struct md3Tag_s {
00136 char name[MAX_QPATH];
00137 vec3_t origin;
00138 vec3_t axis[3];
00139 } md3Tag_t;
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151 typedef struct {
00152 int ident;
00153
00154 char name[MAX_QPATH];
00155
00156 int flags;
00157 int numFrames;
00158
00159 int numShaders;
00160 int numVerts;
00161
00162 int numTriangles;
00163 int ofsTriangles;
00164
00165 int ofsShaders;
00166 int ofsSt;
00167 int ofsXyzNormals;
00168
00169 int ofsEnd;
00170 } md3Surface_t;
00171
00172 typedef struct {
00173 char name[MAX_QPATH];
00174 int shaderIndex;
00175 } md3Shader_t;
00176
00177 typedef struct {
00178 int indexes[3];
00179 } md3Triangle_t;
00180
00181 typedef struct {
00182 float st[2];
00183 } md3St_t;
00184
00185 typedef struct {
00186 short xyz[3];
00187 short normal;
00188 } md3XyzNormal_t;
00189
00190 typedef struct {
00191 int ident;
00192 int version;
00193
00194 char name[MAX_QPATH];
00195
00196 int flags;
00197
00198 int numFrames;
00199 int numTags;
00200 int numSurfaces;
00201
00202 int numSkins;
00203
00204 int ofsFrames;
00205 int ofsTags;
00206 int ofsSurfaces;
00207
00208 int ofsEnd;
00209 } md3Header_t;
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220 #define MD4_IDENT (('4'<<24)+('P'<<16)+('D'<<8)+'I')
00221 #define MD4_VERSION 1
00222 #define MD4_MAX_BONES 128
00223
00224 typedef struct {
00225 int boneIndex;
00226 float boneWeight;
00227 } md4Weight_t;
00228
00229 typedef struct {
00230 vec3_t vertex;
00231 vec3_t normal;
00232 float texCoords[2];
00233 int numWeights;
00234 md4Weight_t weights[1];
00235 } md4Vertex_t;
00236
00237 typedef struct {
00238 int indexes[3];
00239 } md4Triangle_t;
00240
00241 typedef struct {
00242 int ident;
00243
00244 char name[MAX_QPATH];
00245 char shader[MAX_QPATH];
00246 int shaderIndex;
00247
00248 int ofsHeader;
00249
00250 int numVerts;
00251 int ofsVerts;
00252
00253 int numTriangles;
00254 int ofsTriangles;
00255
00256
00257
00258
00259
00260
00261 int numBoneReferences;
00262 int ofsBoneReferences;
00263
00264 int ofsEnd;
00265 } md4Surface_t;
00266
00267 typedef struct {
00268 float matrix[3][4];
00269 } md4Bone_t;
00270
00271 typedef struct {
00272 vec3_t bounds[2];
00273 vec3_t localOrigin;
00274 float radius;
00275 char name[16];
00276 md4Bone_t bones[1];
00277 } md4Frame_t;
00278
00279 typedef struct {
00280 int numSurfaces;
00281 int ofsSurfaces;
00282 int ofsEnd;
00283 } md4LOD_t;
00284
00285 typedef struct {
00286 int ident;
00287 int version;
00288
00289 char name[MAX_QPATH];
00290
00291
00292 int numFrames;
00293 int numBones;
00294 int ofsFrames;
00295
00296
00297 int numLODs;
00298 int ofsLODs;
00299
00300 int ofsEnd;
00301 } md4Header_t;
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313 #define BSP_IDENT (('P'<<24)+('S'<<16)+('B'<<8)+'I')
00314
00315
00316 #define BSP_VERSION 46
00317
00318
00319
00320
00321 #define MAX_MAP_MODELS 0x400
00322 #define MAX_MAP_BRUSHES 0x8000
00323 #define MAX_MAP_ENTITIES 0x800
00324 #define MAX_MAP_ENTSTRING 0x40000
00325 #define MAX_MAP_SHADERS 0x400
00326
00327 #define MAX_MAP_AREAS 0x100 // MAX_MAP_AREA_BYTES in q_shared must match!
00328 #define MAX_MAP_FOGS 0x100
00329 #define MAX_MAP_PLANES 0x20000
00330 #define MAX_MAP_NODES 0x20000
00331 #define MAX_MAP_BRUSHSIDES 0x20000
00332 #define MAX_MAP_LEAFS 0x20000
00333 #define MAX_MAP_LEAFFACES 0x20000
00334 #define MAX_MAP_LEAFBRUSHES 0x40000
00335 #define MAX_MAP_PORTALS 0x20000
00336 #define MAX_MAP_LIGHTING 0x800000
00337 #define MAX_MAP_LIGHTGRID 0x800000
00338 #define MAX_MAP_VISIBILITY 0x200000
00339
00340 #define MAX_MAP_DRAW_SURFS 0x20000
00341 #define MAX_MAP_DRAW_VERTS 0x80000
00342 #define MAX_MAP_DRAW_INDEXES 0x80000
00343
00344
00345
00346 #define MAX_KEY 32
00347 #define MAX_VALUE 1024
00348
00349
00350 #define ANGLE_UP -1
00351 #define ANGLE_DOWN -2
00352
00353 #define LIGHTMAP_WIDTH 128
00354 #define LIGHTMAP_HEIGHT 128
00355
00356 #define MAX_WORLD_COORD ( 128*1024 )
00357 #define MIN_WORLD_COORD ( -128*1024 )
00358 #define WORLD_SIZE ( MAX_WORLD_COORD - MIN_WORLD_COORD )
00359
00360
00361
00362
00363 typedef struct {
00364 int fileofs, filelen;
00365 } lump_t;
00366
00367 #define LUMP_ENTITIES 0
00368 #define LUMP_SHADERS 1
00369 #define LUMP_PLANES 2
00370 #define LUMP_NODES 3
00371 #define LUMP_LEAFS 4
00372 #define LUMP_LEAFSURFACES 5
00373 #define LUMP_LEAFBRUSHES 6
00374 #define LUMP_MODELS 7
00375 #define LUMP_BRUSHES 8
00376 #define LUMP_BRUSHSIDES 9
00377 #define LUMP_DRAWVERTS 10
00378 #define LUMP_DRAWINDEXES 11
00379 #define LUMP_FOGS 12
00380 #define LUMP_SURFACES 13
00381 #define LUMP_LIGHTMAPS 14
00382 #define LUMP_LIGHTGRID 15
00383 #define LUMP_VISIBILITY 16
00384 #define HEADER_LUMPS 17
00385
00386 typedef struct {
00387 int ident;
00388 int version;
00389
00390 lump_t lumps[HEADER_LUMPS];
00391 } dheader_t;
00392
00393 typedef struct {
00394 float mins[3], maxs[3];
00395 int firstSurface, numSurfaces;
00396 int firstBrush, numBrushes;
00397 } dmodel_t;
00398
00399 typedef struct {
00400 char shader[MAX_QPATH];
00401 int surfaceFlags;
00402 int contentFlags;
00403 } dshader_t;
00404
00405
00406
00407 typedef struct {
00408 float normal[3];
00409 float dist;
00410 } dplane_t;
00411
00412 typedef struct {
00413 int planeNum;
00414 int children[2];
00415 int mins[3];
00416 int maxs[3];
00417 } dnode_t;
00418
00419 typedef struct {
00420 int cluster;
00421 int area;
00422
00423 int mins[3];
00424 int maxs[3];
00425
00426 int firstLeafSurface;
00427 int numLeafSurfaces;
00428
00429 int firstLeafBrush;
00430 int numLeafBrushes;
00431 } dleaf_t;
00432
00433 typedef struct {
00434 int planeNum;
00435 int shaderNum;
00436 } dbrushside_t;
00437
00438 typedef struct {
00439 int firstSide;
00440 int numSides;
00441 int shaderNum;
00442 } dbrush_t;
00443
00444 typedef struct {
00445 char shader[MAX_QPATH];
00446 int brushNum;
00447 int visibleSide;
00448 } dfog_t;
00449
00450 typedef struct {
00451 vec3_t xyz;
00452 float st[2];
00453 float lightmap[2];
00454 vec3_t normal;
00455 byte color[4];
00456 } drawVert_t;
00457
00458 typedef enum {
00459 MST_BAD,
00460 MST_PLANAR,
00461 MST_PATCH,
00462 MST_TRIANGLE_SOUP,
00463 MST_FLARE
00464 } mapSurfaceType_t;
00465
00466 typedef struct {
00467 int shaderNum;
00468 int fogNum;
00469 int surfaceType;
00470
00471 int firstVert;
00472 int numVerts;
00473
00474 int firstIndex;
00475 int numIndexes;
00476
00477 int lightmapNum;
00478 int lightmapX, lightmapY;
00479 int lightmapWidth, lightmapHeight;
00480
00481 vec3_t lightmapOrigin;
00482 vec3_t lightmapVecs[3];
00483
00484 int patchWidth;
00485 int patchHeight;
00486 } dsurface_t;
00487
00488
00489 #endif