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 
00023 //
00024 // qfiles.h: quake file formats
00025 // This file must be identical in the quake and utils directories
00026 //
00027 
00028 /*
00029 ========================================================================
00030 
00031 .MD2 triangle model file format
00032 
00033 ========================================================================
00034 */
00035 
00036 #define IDALIASHEADER       (('2'<<24)+('P'<<16)+('D'<<8)+'I')
00037 #define ALIAS_VERSION   8
00038 
00039 #define MAX_TRIANGLES   4096
00040 #define MAX_VERTS       2048
00041 #define MAX_FRAMES      512
00042 #define MAX_MD2SKINS    32
00043 #define MAX_SKINNAME    64
00044 
00045 typedef struct
00046 {
00047     short   s;
00048     short   t;
00049 } dstvert_t;
00050 
00051 typedef struct 
00052 {
00053     short   index_xyz[3];
00054     short   index_st[3];
00055 } dtriangle_t;
00056 
00057 typedef struct
00058 {
00059     byte    v[3];           // scaled byte to fit in frame mins/maxs
00060     byte    lightnormalindex;
00061 } dtrivertx_t;
00062 
00063 typedef struct
00064 {
00065     float       scale[3];   // multiply byte verts by this
00066     float       translate[3];   // then add this
00067     char        name[16];   // frame name from grabbing
00068     dtrivertx_t verts[1];   // variable sized
00069 } daliasframe_t;
00070 
00071 
00072 // the glcmd format:
00073 // a positive integer starts a tristrip command, followed by that many
00074 // vertex structures.
00075 // a negative integer starts a trifan command, followed by -x vertexes
00076 // a zero indicates the end of the command list.
00077 // a vertex consists of a floating point s, a floating point t,
00078 // and an integer vertex index.
00079 
00080 
00081 typedef struct
00082 {
00083     int         ident;
00084     int         version;
00085 
00086     int         skinwidth;
00087     int         skinheight;
00088     int         framesize;      // byte size of each frame
00089 
00090     int         num_skins;
00091     int         num_xyz;
00092     int         num_st;         // greater than num_xyz for seams
00093     int         num_tris;
00094     int         num_glcmds;     // dwords in strip/fan command list
00095     int         num_frames;
00096 
00097     int         ofs_skins;      // each skin is a MAX_SKINNAME string
00098     int         ofs_st;         // byte offset from start for stverts
00099     int         ofs_tris;       // offset for dtriangles
00100     int         ofs_frames;     // offset for first frame
00101     int         ofs_glcmds; 
00102     int         ofs_end;        // end of file
00103 
00104 } dmdl_t;
00105 
00106 #define MD3_IDENT           (('3'<<24)+('P'<<16)+('D'<<8)+'I')
00107 #define MAX_QPATH           64      // max length of a quake game pathname
00108 #define MD3_XYZ_SCALE       (1.0/64)
00109 
00110 typedef struct {
00111     int         ident;
00112     int         version;
00113 
00114     char        name[MAX_QPATH];    // model name
00115 
00116     int         flags;
00117 
00118     int         numFrames;
00119     int         numTags;            
00120     int         numSurfaces;
00121 
00122     int         numSkins;
00123 
00124     int         ofsFrames;          // offset for first frame
00125     int         ofsTags;            // numFrames * numTags
00126     int         ofsSurfaces;        // first surface, others follow
00127 
00128     int         ofsEnd;             // end of file
00129 } md3Header_t;
00130 
00131 typedef struct {
00132     int     ident;              // 
00133 
00134     char    name[MAX_QPATH];    // polyset name
00135 
00136     int     flags;
00137     int     numFrames;          // all surfaces in a model should have the same
00138 
00139     int     numShaders;         // all surfaces in a model should have the same
00140     int     numVerts;
00141 
00142     int     numTriangles;
00143     int     ofsTriangles;
00144 
00145     int     ofsShaders;         // offset from start of md3Surface_t
00146     int     ofsSt;              // texture coords are common for all frames
00147     int     ofsXyzNormals;      // numVerts * numFrames
00148 
00149     int     ofsEnd;             // next surface follows
00150 
00151 } md3Surface_t;
00152 
00153 typedef struct {
00154     char            name[MAX_QPATH];
00155     int             shaderIndex;    // for in-game use
00156 } md3Shader_t;
00157 
00158 typedef struct {
00159     int         indexes[3];
00160 } md3Triangle_t;
00161 
00162 typedef struct {
00163     float       st[2];
00164 } md3St_t;
00165 
00166 typedef struct {
00167     short       xyz[3];
00168     short       normal;
00169 } md3XyzNormal_t;
00170 
00171 
00172 typedef struct
00173 {
00174   float st[2];
00175   int   nVertIndex;
00176 } glst_t;
00177 
00178 typedef struct
00179 {
00180   int     nCount;
00181   int     ObjectIndex;
00182   glst_t  GlSt;
00183 } gl_t;
00184 
00185 /*
00186 ========================================================================
00187 
00188 .SP2 sprite file format
00189 
00190 ========================================================================
00191 */
00192 
00193 #define IDSPRITEHEADER  (('2'<<24)+('S'<<16)+('D'<<8)+'I')
00194         // little-endian "IDS2"
00195 #define SPRITE_VERSION  2
00196 
00197 typedef struct
00198 {
00199     int     width, height;
00200     int     origin_x, origin_y;     // raster coordinates inside pic
00201     char    name[MAX_SKINNAME];     // name of pcx file
00202 } dsprframe_t;
00203 
00204 typedef struct {
00205     int         ident;
00206     int         version;
00207     int         numframes;
00208     dsprframe_t frames[1];          // variable sized
00209 } dsprite_t;
00210 
00211 /*
00212 ==============================================================================
00213 
00214   .WAL texture file format
00215 
00216 ==============================================================================
00217 */
00218 
00219 
00220 #define MIPLEVELS   4
00221 typedef struct miptex_s
00222 {
00223     char        name[32];
00224     unsigned    width, height;
00225     unsigned    offsets[MIPLEVELS];     // four mip maps stored
00226     char        animname[32];           // next frame in animation chain
00227     int         flags;
00228     int         contents;
00229     int         value;
00230 } miptex_t;
00231 
00232 
00233 
00234 /*
00235 ==============================================================================
00236 
00237   .BSP file format
00238 
00239 ==============================================================================
00240 */
00241 
00242 #define IDBSPHEADER (('P'<<24)+('S'<<16)+('B'<<8)+'I')
00243         // little-endian "IBSP"
00244 
00245 #define BSPVERSION  36
00246 
00247 
00248 // upper design bounds
00249 // leaffaces, leafbrushes, planes, and verts are still bounded by
00250 // 16 bit short limits
00251 #define MAX_MAP_MODELS      1024
00252 #define MAX_MAP_BRUSHES     8192
00253 #define MAX_MAP_ENTITIES    2048
00254 #define MAX_MAP_ENTSTRING   0x20000
00255 #define MAX_MAP_TEXINFO     8192
00256 
00257 #define MAX_MAP_PLANES      65536
00258 #define MAX_MAP_NODES       65536
00259 #define MAX_MAP_BRUSHSIDES  65536
00260 #define MAX_MAP_LEAFS       65536
00261 #define MAX_MAP_VERTS       65536
00262 #define MAX_MAP_FACES       65536
00263 #define MAX_MAP_LEAFFACES   65536
00264 #define MAX_MAP_LEAFBRUSHES 65536
00265 #define MAX_MAP_PORTALS     65536
00266 #define MAX_MAP_EDGES       128000
00267 #define MAX_MAP_SURFEDGES   256000
00268 #define MAX_MAP_LIGHTING    0x200000
00269 #define MAX_MAP_VISIBILITY  0x100000
00270 
00271 #define MAX_WORLD_COORD     ( 128*1024 )
00272 #define MIN_WORLD_COORD     ( -128*1024 )
00273 #define WORLD_SIZE          ( MAX_WORLD_COORD - MIN_WORLD_COORD )
00274 
00275 #define MAX_BRUSH_SIZE      ( WORLD_SIZE )
00276 
00277 // key / value pair sizes
00278 
00279 #define MAX_KEY     32
00280 #define MAX_VALUE   1024
00281 
00282 //=============================================================================
00283 
00284 typedef struct
00285 {
00286     int     fileofs, filelen;
00287 } lump_t;
00288 
00289 #define LUMP_ENTITIES       0
00290 #define LUMP_PLANES         1
00291 #define LUMP_VERTEXES       2
00292 #define LUMP_VISIBILITY     3
00293 #define LUMP_NODES          4
00294 #define LUMP_TEXINFO        5
00295 #define LUMP_FACES          6
00296 #define LUMP_LIGHTING       7
00297 #define LUMP_LEAFS          8
00298 #define LUMP_LEAFFACES      9
00299 #define LUMP_LEAFBRUSHES    10
00300 #define LUMP_EDGES          11
00301 #define LUMP_SURFEDGES      12
00302 #define LUMP_MODELS         13
00303 #define LUMP_BRUSHES        14
00304 #define LUMP_BRUSHSIDES     15
00305 #define LUMP_POP            16
00306 
00307 #define HEADER_LUMPS        17
00308 
00309 typedef struct
00310 {
00311     int         ident;
00312     int         version;    
00313     lump_t      lumps[HEADER_LUMPS];
00314 } dheader_t;
00315 
00316 typedef struct
00317 {
00318     float       mins[3], maxs[3];
00319     float       origin[3];      // for sounds or lights
00320     int         headnode;
00321     int         firstface, numfaces;    // submodels just draw faces
00322                                         // without walking the bsp tree
00323 } dmodel_t;
00324 
00325 
00326 typedef struct
00327 {
00328     float   point[3];
00329 } dvertex_t;
00330 
00331 
00332 // 0-2 are axial planes
00333 #define PLANE_X         0
00334 #define PLANE_Y         1
00335 #define PLANE_Z         2
00336 
00337 // 3-5 are non-axial planes snapped to the nearest
00338 #define PLANE_ANYX      3
00339 #define PLANE_ANYY      4
00340 #define PLANE_ANYZ      5
00341 
00342 // planes (x&~1) and (x&~1)+1 are allways opposites
00343 
00344 typedef struct
00345 {
00346     float   normal[3];
00347     float   dist;
00348     int     type;       // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
00349 } dplane_t;
00350 
00351 
00352 // contents flags are seperate bits
00353 // a given brush can contribute multiple content bits
00354 // multiple brushes can be in a single leaf
00355 
00356 // lower bits are stronger, and will eat weaker brushes completely
00357 #define CONTENTS_SOLID          1       // an eye is never valid in a solid
00358 #define CONTENTS_WINDOW         2       // translucent, but not watery
00359 #define CONTENTS_AUX            4
00360 #define CONTENTS_LAVA           8
00361 #define CONTENTS_SLIME          16
00362 #define CONTENTS_WATER          32
00363 #define CONTENTS_MIST           64
00364 #define LAST_VISIBLE_CONTENTS   64
00365 
00366 // remaining contents are non-visible, and don't eat brushes
00367 #define CONTENTS_PLAYERCLIP     0x10000
00368 #define CONTENTS_MONSTERCLIP    0x20000
00369 
00370 // currents can be added to any other contents, and may be mixed
00371 #define CONTENTS_CURRENT_0      0x40000
00372 #define CONTENTS_CURRENT_90     0x80000
00373 #define CONTENTS_CURRENT_180    0x100000
00374 #define CONTENTS_CURRENT_270    0x200000
00375 #define CONTENTS_CURRENT_UP     0x400000
00376 #define CONTENTS_CURRENT_DOWN   0x800000
00377 
00378 #define CONTENTS_ORIGIN             0x1000000     // removed before bsping an entity
00379 
00380 #define CONTENTS_MONSTER            0x2000000     // should never be on a brush, only in game
00381 #define CONTENTS_DEADMONSTER      0x4000000   // corpse
00382 #define CONTENTS_DETAIL             0x8000000     // brushes to be added after vis leafs
00383 #define CONTENTS_TRANSLUCENT      0x10000000    // auto set if any surface has trans
00384 #define CONTENTS_LADDER         0x20000000  // ladder
00385 #define CONTENTS_NEGATIVE_CURVE 0x40000000  // reverse inside / outside
00386 
00387 #define CONTENTS_KEEP   (CONTENTS_DETAIL | CONTENTS_NEGATIVE_CURVE)
00388 
00389 
00390 typedef struct
00391 {
00392     int         planenum;
00393     int         children[2];    // negative numbers are -(leafs+1), not nodes
00394     short       mins[3];        // for frustom culling
00395     short       maxs[3];
00396     unsigned short  firstface;
00397     unsigned short  numfaces;   // counting both sides
00398 } dnode_t;
00399 
00400 
00401 typedef struct texinfo_s
00402 {
00403     float       vecs[2][4];     // [s/t][xyz offset]
00404     int         flags;          // miptex flags + overrides
00405     int         value;          // light emission, etc
00406     char        texture[32];    // texture name (textures/*.wal)
00407     int         nexttexinfo;    // for animations, -1 = end of chain
00408 } texinfo_t;
00409 
00410 
00411 #define SURF_LIGHT      0x1     // value will hold the light strength
00412 
00413 #define SURF_SLICK      0x2     // effects game physics
00414 
00415 #define SURF_SKY        0x4     // don't draw, but add to skybox
00416 #define SURF_WARP       0x8     // turbulent water warp
00417 #define SURF_TRANS33    0x10
00418 #define SURF_TRANS66    0x20
00419 #define SURF_FLOWING    0x40    // scroll towards angle
00420 #define SURF_NODRAW     0x80    // don't bother referencing the texture
00421 
00422 #define SURF_PATCH        0x20000000
00423 #define SURF_CURVE_FAKE     0x40000000
00424 #define SURF_CURVE          0x80000000
00425 #define SURF_KEEP       (SURF_CURVE | SURF_CURVE_FAKE | SURF_PATCH)
00426 
00427 // note that edge 0 is never used, because negative edge nums are used for
00428 // counterclockwise use of the edge in a face
00429 typedef struct
00430 {
00431     unsigned short  v[2];       // vertex numbers
00432 } dedge_t;
00433 
00434 #define MAXLIGHTMAPS    4
00435 typedef struct
00436 {
00437     unsigned short  planenum;
00438     short       side;
00439 
00440     int         firstedge;      // we must support > 64k edges
00441     short       numedges;   
00442     short       texinfo;
00443 
00444 // lighting info
00445     byte        styles[MAXLIGHTMAPS];
00446     int         lightofs;       // start of [numstyles*surfsize] samples
00447 } dface_t;
00448 
00449 typedef struct
00450 {
00451     int         contents;           // OR of all brushes (not needed?)
00452 
00453     int         pvsofs;             // -1 = no info
00454     int         phsofs;             // -1 = no info
00455 
00456     short       mins[3];            // for frustum culling
00457     short       maxs[3];
00458 
00459     unsigned short      firstleafface;
00460     unsigned short      numleaffaces;
00461 
00462     unsigned short      firstleafbrush;
00463     unsigned short      numleafbrushes;
00464 } dleaf_t;
00465 
00466 typedef struct
00467 {
00468     unsigned short  planenum;       // facing out of the leaf
00469     short   texinfo;
00470 } dbrushside_t;
00471 
00472 typedef struct
00473 {
00474     int         firstside;
00475     int         numsides;
00476     int         contents;
00477 } dbrush_t;
00478 
00479 #define ANGLE_UP    -1
00480 #define ANGLE_DOWN  -2
00481 

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