Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

qfiles.h

Go to the documentation of this file.
00001 /*
00002 ===========================================================================
00003 Copyright (C) 1999-2005 Id Software, Inc.
00004 
00005 This file is part of Quake III Arena source code.
00006 
00007 Quake III Arena source code is free software; you can redistribute it
00008 and/or modify it under the terms of the GNU General Public License as
00009 published by the Free Software Foundation; either version 2 of the License,
00010 or (at your option) any later version.
00011 
00012 Quake III Arena source code is distributed in the hope that it will be
00013 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Foobar; if not, write to the Free Software
00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020 ===========================================================================
00021 */
00022 #ifndef __QFILES_H__
00023 #define __QFILES_H__
00024 
00025 //
00026 // qfiles.h: quake file formats
00027 // This file must be identical in the quake and utils directories
00028 //
00029 
00030 // surface geometry should not exceed these limits
00031 #define SHADER_MAX_VERTEXES 1000
00032 #define SHADER_MAX_INDEXES  (6*SHADER_MAX_VERTEXES)
00033 
00034 
00035 // the maximum size of game relative pathnames
00036 #define MAX_QPATH       64
00037 
00038 /*
00039 ========================================================================
00040 
00041 QVM files
00042 
00043 ========================================================================
00044 */
00045 
00046 #define VM_MAGIC    0x12721444
00047 typedef struct {
00048     int     vmMagic;
00049 
00050     int     instructionCount;
00051 
00052     int     codeOffset;
00053     int     codeLength;
00054 
00055     int     dataOffset;
00056     int     dataLength;
00057     int     litLength;          // ( dataLength - litLength ) should be byteswapped on load
00058     int     bssLength;          // zero filled memory appended to datalength
00059 } vmHeader_t;
00060 
00061 
00062 /*
00063 ========================================================================
00064 
00065 PCX files are used for 8 bit images
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;           // unbounded
00084 } pcx_t;
00085 
00086 
00087 /*
00088 ========================================================================
00089 
00090 TGA files are used for 24/32 bit images
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 .MD3 triangle model file format
00109 
00110 ========================================================================
00111 */
00112 
00113 #define MD3_IDENT           (('3'<<24)+('P'<<16)+('D'<<8)+'I')
00114 #define MD3_VERSION         15
00115 
00116 // limits
00117 #define MD3_MAX_LODS        3
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 // vertex scales
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];    // tag name
00137     vec3_t      origin;
00138     vec3_t      axis[3];
00139 } md3Tag_t;
00140 
00141 /*
00142 ** md3Surface_t
00143 **
00144 ** CHUNK            SIZE
00145 ** header           sizeof( md3Surface_t )
00146 ** shaders          sizeof( md3Shader_t ) * numShaders
00147 ** triangles[0]     sizeof( md3Triangle_t ) * numTriangles
00148 ** st               sizeof( md3St_t ) * numVerts
00149 ** XyzNormals       sizeof( md3XyzNormal_t ) * numVerts * numFrames
00150 */
00151 typedef struct {
00152     int     ident;              // 
00153 
00154     char    name[MAX_QPATH];    // polyset name
00155 
00156     int     flags;
00157     int     numFrames;          // all surfaces in a model should have the same
00158 
00159     int     numShaders;         // all surfaces in a model should have the same
00160     int     numVerts;
00161 
00162     int     numTriangles;
00163     int     ofsTriangles;
00164 
00165     int     ofsShaders;         // offset from start of md3Surface_t
00166     int     ofsSt;              // texture coords are common for all frames
00167     int     ofsXyzNormals;      // numVerts * numFrames
00168 
00169     int     ofsEnd;             // next surface follows
00170 } md3Surface_t;
00171 
00172 typedef struct {
00173     char            name[MAX_QPATH];
00174     int             shaderIndex;    // for in-game use
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];    // model name
00195 
00196     int         flags;
00197 
00198     int         numFrames;
00199     int         numTags;            
00200     int         numSurfaces;
00201 
00202     int         numSkins;
00203 
00204     int         ofsFrames;          // offset for first frame
00205     int         ofsTags;            // numFrames * numTags
00206     int         ofsSurfaces;        // first surface, others follow
00207 
00208     int         ofsEnd;             // end of file
00209 } md3Header_t;
00210 
00211 /*
00212 ==============================================================================
00213 
00214 MD4 file format
00215 
00216 ==============================================================================
00217 */
00218 
00219 #define MD4_IDENT           (('4'<<24)+('P'<<16)+('D'<<8)+'I')
00220 #define MD4_VERSION         1
00221 #define MD4_MAX_BONES       128
00222 
00223 typedef struct {
00224     int         boneIndex;      // these are indexes into the boneReferences,
00225     float          boneWeight;      // not the global per-frame bone list
00226     vec3_t      offset;
00227 } md4Weight_t;
00228 
00229 typedef struct {
00230     vec3_t      normal;
00231     vec2_t      texCoords;
00232     int         numWeights;
00233     md4Weight_t weights[1];     // variable sized
00234 } md4Vertex_t;
00235 
00236 typedef struct {
00237     int         indexes[3];
00238 } md4Triangle_t;
00239 
00240 typedef struct {
00241     int         ident;
00242 
00243     char        name[MAX_QPATH];    // polyset name
00244     char        shader[MAX_QPATH];
00245     int         shaderIndex;        // for in-game use
00246 
00247     int         ofsHeader;          // this will be a negative number
00248 
00249     int         numVerts;
00250     int         ofsVerts;
00251 
00252     int         numTriangles;
00253     int         ofsTriangles;
00254 
00255     // Bone references are a set of ints representing all the bones
00256     // present in any vertex weights for this surface.  This is
00257     // needed because a model may have surfaces that need to be
00258     // drawn at different sort times, and we don't want to have
00259     // to re-interpolate all the bones for each surface.
00260     int         numBoneReferences;
00261     int         ofsBoneReferences;
00262 
00263     int         ofsEnd;             // next surface follows
00264 } md4Surface_t;
00265 
00266 typedef struct {
00267     float       matrix[3][4];
00268 } md4Bone_t;
00269 
00270 typedef struct {
00271     vec3_t      bounds[2];          // bounds of all surfaces of all LOD's for this frame
00272     vec3_t      localOrigin;        // midpoint of bounds, used for sphere cull
00273     float       radius;             // dist from localOrigin to corner
00274     md4Bone_t   bones[1];           // [numBones]
00275 } md4Frame_t;
00276 
00277 typedef struct {
00278     int         numSurfaces;
00279     int         ofsSurfaces;        // first surface, others follow
00280     int         ofsEnd;             // next lod follows
00281 } md4LOD_t;
00282 
00283 typedef struct {
00284     int         ident;
00285     int         version;
00286 
00287     char        name[MAX_QPATH];    // model name
00288 
00289     // frames and bones are shared by all levels of detail
00290     int         numFrames;
00291     int         numBones;
00292     int         ofsBoneNames;       // char name[ MAX_QPATH ]
00293     int         ofsFrames;          // md4Frame_t[numFrames]
00294 
00295     // each level of detail has completely separate sets of surfaces
00296     int         numLODs;
00297     int         ofsLODs;
00298 
00299     int         ofsEnd;             // end of file
00300 } md4Header_t;
00301 
00302 
00303 /*
00304 ==============================================================================
00305 
00306   .BSP file format
00307 
00308 ==============================================================================
00309 */
00310 
00311 
00312 #define BSP_IDENT   (('P'<<24)+('S'<<16)+('B'<<8)+'I')
00313         // little-endian "IBSP"
00314 
00315 #define BSP_VERSION         46
00316 
00317 
00318 // there shouldn't be any problem with increasing these values at the
00319 // expense of more memory allocation in the utilities
00320 #define MAX_MAP_MODELS      0x400
00321 #define MAX_MAP_BRUSHES     0x8000
00322 #define MAX_MAP_ENTITIES    0x800
00323 #define MAX_MAP_ENTSTRING   0x40000
00324 #define MAX_MAP_SHADERS     0x400
00325 
00326 #define MAX_MAP_AREAS       0x100   // MAX_MAP_AREA_BYTES in q_shared must match!
00327 #define MAX_MAP_FOGS        0x100
00328 #define MAX_MAP_PLANES      0x20000
00329 #define MAX_MAP_NODES       0x20000
00330 #define MAX_MAP_BRUSHSIDES  0x20000
00331 #define MAX_MAP_LEAFS       0x20000
00332 #define MAX_MAP_LEAFFACES   0x20000
00333 #define MAX_MAP_LEAFBRUSHES 0x40000
00334 #define MAX_MAP_PORTALS     0x20000
00335 #define MAX_MAP_LIGHTING    0x800000
00336 #define MAX_MAP_LIGHTGRID   0x800000
00337 #define MAX_MAP_VISIBILITY  0x200000
00338 
00339 #define MAX_MAP_DRAW_SURFS  0x20000
00340 #define MAX_MAP_DRAW_VERTS  0x80000
00341 #define MAX_MAP_DRAW_INDEXES    0x80000
00342 
00343 
00344 // key / value pair sizes in the entities lump
00345 #define MAX_KEY             32
00346 #define MAX_VALUE           1024
00347 
00348 // the editor uses these predefined yaw angles to orient entities up or down
00349 #define ANGLE_UP            -1
00350 #define ANGLE_DOWN          -2
00351 
00352 #define LIGHTMAP_WIDTH      128
00353 #define LIGHTMAP_HEIGHT     128
00354 
00355 #define MAX_WORLD_COORD     ( 128*1024 )
00356 #define MIN_WORLD_COORD     ( -128*1024 )
00357 #define WORLD_SIZE          ( MAX_WORLD_COORD - MIN_WORLD_COORD )
00358 
00359 //=============================================================================
00360 
00361 
00362 typedef struct {
00363     int     fileofs, filelen;
00364 } lump_t;
00365 
00366 #define LUMP_ENTITIES       0
00367 #define LUMP_SHADERS        1
00368 #define LUMP_PLANES         2
00369 #define LUMP_NODES          3
00370 #define LUMP_LEAFS          4
00371 #define LUMP_LEAFSURFACES   5
00372 #define LUMP_LEAFBRUSHES    6
00373 #define LUMP_MODELS         7
00374 #define LUMP_BRUSHES        8
00375 #define LUMP_BRUSHSIDES     9
00376 #define LUMP_DRAWVERTS      10
00377 #define LUMP_DRAWINDEXES    11
00378 #define LUMP_FOGS           12
00379 #define LUMP_SURFACES       13
00380 #define LUMP_LIGHTMAPS      14
00381 #define LUMP_LIGHTGRID      15
00382 #define LUMP_VISIBILITY     16
00383 #define HEADER_LUMPS        17
00384 
00385 typedef struct {
00386     int         ident;
00387     int         version;
00388 
00389     lump_t      lumps[HEADER_LUMPS];
00390 } dheader_t;
00391 
00392 typedef struct {
00393     float       mins[3], maxs[3];
00394     int         firstSurface, numSurfaces;
00395     int         firstBrush, numBrushes;
00396 } dmodel_t;
00397 
00398 typedef struct {
00399     char        shader[MAX_QPATH];
00400     int         surfaceFlags;
00401     int         contentFlags;
00402 } dshader_t;
00403 
00404 // planes x^1 is allways the opposite of plane x
00405 
00406 typedef struct {
00407     float       normal[3];
00408     float       dist;
00409 } dplane_t;
00410 
00411 typedef struct {
00412     int         planeNum;
00413     int         children[2];    // negative numbers are -(leafs+1), not nodes
00414     int         mins[3];        // for frustom culling
00415     int         maxs[3];
00416 } dnode_t;
00417 
00418 typedef struct {
00419     int         cluster;            // -1 = opaque cluster (do I still store these?)
00420     int         area;
00421 
00422     int         mins[3];            // for frustum culling
00423     int         maxs[3];
00424 
00425     int         firstLeafSurface;
00426     int         numLeafSurfaces;
00427 
00428     int         firstLeafBrush;
00429     int         numLeafBrushes;
00430 } dleaf_t;
00431 
00432 typedef struct {
00433     int         planeNum;           // positive plane side faces out of the leaf
00434     int         shaderNum;
00435 } dbrushside_t;
00436 
00437 typedef struct {
00438     int         firstSide;
00439     int         numSides;
00440     int         shaderNum;      // the shader that determines the contents flags
00441 } dbrush_t;
00442 
00443 typedef struct {
00444     char        shader[MAX_QPATH];
00445     int         brushNum;
00446     int         visibleSide;    // the brush side that ray tests need to clip against (-1 == none)
00447 } dfog_t;
00448 
00449 typedef struct {
00450     vec3_t      xyz;
00451     float       st[2];
00452     float       lightmap[2];
00453     vec3_t      normal;
00454     byte        color[4];
00455 } drawVert_t;
00456 
00457 typedef enum {
00458     MST_BAD,
00459     MST_PLANAR,
00460     MST_PATCH,
00461     MST_TRIANGLE_SOUP,
00462     MST_FLARE
00463 } mapSurfaceType_t;
00464 
00465 typedef struct {
00466     int         shaderNum;
00467     int         fogNum;
00468     int         surfaceType;
00469 
00470     int         firstVert;
00471     int         numVerts;
00472 
00473     int         firstIndex;
00474     int         numIndexes;
00475 
00476     int         lightmapNum;
00477     int         lightmapX, lightmapY;
00478     int         lightmapWidth, lightmapHeight;
00479 
00480     vec3_t      lightmapOrigin;
00481     vec3_t      lightmapVecs[3];    // for patches, [0] and [1] are lodbounds
00482 
00483     int         patchWidth;
00484     int         patchHeight;
00485 } dsurface_t;
00486 
00487 
00488 #endif

Generated on Thu Aug 25 12:37:19 2005 for Quake III Arena by  doxygen 1.3.9.1