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 reletive pathnames
00036 #define MAX_QPATH       64
00037 
00038 
00039 /*
00040 ========================================================================
00041 
00042 QVM files
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;          // ( dataLength - litLength ) should be byteswapped on load
00059     int     bssLength;          // zero filled memory appended to datalength
00060 } vmHeader_t;
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        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 // 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 
00215 MD4 file format
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;      // these are indexes into the boneReferences,
00226     float       boneWeight;     // not the global per-frame bone list
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];     // variable sized
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];    // polyset name
00245     char        shader[MAX_QPATH];
00246     int         shaderIndex;        // for in-game use
00247 
00248     int         ofsHeader;          // this will be a negative number
00249 
00250     int         numVerts;
00251     int         ofsVerts;
00252 
00253     int         numTriangles;
00254     int         ofsTriangles;
00255 
00256     // Bone references are a set of ints representing all the bones
00257     // present in any vertex weights for this surface.  This is
00258     // needed because a model may have surfaces that need to be
00259     // drawn at different sort times, and we don't want to have
00260     // to re-interpolate all the bones for each surface.
00261     int         numBoneReferences;
00262     int         ofsBoneReferences;
00263 
00264     int         ofsEnd;             // next surface follows
00265 } md4Surface_t;
00266 
00267 typedef struct {
00268     float       matrix[3][4];
00269 } md4Bone_t;
00270 
00271 typedef struct {
00272     vec3_t      bounds[2];          // bounds of all surfaces of all LOD's for this frame
00273     vec3_t      localOrigin;        // midpoint of bounds, used for sphere cull
00274     float       radius;             // dist from localOrigin to corner
00275     char        name[16];
00276     md4Bone_t   bones[1];           // [numBones]
00277 } md4Frame_t;
00278 
00279 typedef struct {
00280     int         numSurfaces;
00281     int         ofsSurfaces;        // first surface, others follow
00282     int         ofsEnd;             // next lod follows
00283 } md4LOD_t;
00284 
00285 typedef struct {
00286     int         ident;
00287     int         version;
00288 
00289     char        name[MAX_QPATH];    // model name
00290 
00291     // frames and bones are shared by all levels of detail
00292     int         numFrames;
00293     int         numBones;
00294     int         ofsFrames;          // md4Frame_t[numFrames]
00295 
00296     // each level of detail has completely separate sets of surfaces
00297     int         numLODs;
00298     int         ofsLODs;
00299 
00300     int         ofsEnd;             // end of file
00301 } md4Header_t;
00302 
00303 
00304 /*
00305 ==============================================================================
00306 
00307   .BSP file format
00308 
00309 ==============================================================================
00310 */
00311 
00312 
00313 #define BSP_IDENT   (('P'<<24)+('S'<<16)+('B'<<8)+'I')
00314         // little-endian "IBSP"
00315 
00316 #define BSP_VERSION         46
00317 
00318 
00319 // there shouldn't be any problem with increasing these values at the
00320 // expense of more memory allocation in the utilities
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 // key / value pair sizes in the entities lump
00346 #define MAX_KEY             32
00347 #define MAX_VALUE           1024
00348 
00349 // the editor uses these predefined yaw angles to orient entities up or down
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 // planes x^1 is allways the opposite of plane x
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];    // negative numbers are -(leafs+1), not nodes
00415     int         mins[3];        // for frustom culling
00416     int         maxs[3];
00417 } dnode_t;
00418 
00419 typedef struct {
00420     int         cluster;            // -1 = opaque cluster (do I still store these?)
00421     int         area;
00422 
00423     int         mins[3];            // for frustum culling
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;           // positive plane side faces out of the leaf
00435     int         shaderNum;
00436 } dbrushside_t;
00437 
00438 typedef struct {
00439     int         firstSide;
00440     int         numSides;
00441     int         shaderNum;      // the shader that determines the contents flags
00442 } dbrush_t;
00443 
00444 typedef struct {
00445     char        shader[MAX_QPATH];
00446     int         brushNum;
00447     int         visibleSide;    // the brush side that ray tests need to clip against (-1 == none)
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];    // for patches, [0] and [1] are lodbounds
00483 
00484     int         patchWidth;
00485     int         patchHeight;
00486 } dsurface_t;
00487 
00488 
00489 #endif

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