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

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