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

q3files.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 PCX files are used for 8 bit images
00043 
00044 ========================================================================
00045 * 
00046 
00047 typedef struct {
00048     char    manufacturer;
00049     char    version;
00050     char    encoding;
00051     char    bits_per_pixel;
00052     unsigned short  xmin,ymin,xmax,ymax;
00053     unsigned short  hres,vres;
00054     unsigned char   palette[48];
00055     char    reserved;
00056     char    color_planes;
00057     unsigned short  bytes_per_line;
00058     unsigned short  palette_type;
00059     char    filler[58];
00060     unsigned char   data;           // unbounded
00061 } pcx_t;
00062 
00063 
00064 /*
00065 ========================================================================
00066 
00067 TGA files are used for 24/32 bit images
00068 
00069 ========================================================================
00070 * 
00071 
00072 typedef struct _TargaHeader {
00073     unsigned char   id_length, colormap_type, image_type;
00074     unsigned short  colormap_index, colormap_length;
00075     unsigned char   colormap_size;
00076     unsigned short  x_origin, y_origin, width, height;
00077     unsigned char   pixel_size, attributes;
00078 } TargaHeader;
00079 
00080 
00081 */
00082 
00083 /*
00084 ========================================================================
00085 
00086 .MD3 triangle model file format
00087 
00088 ========================================================================
00089 */
00090 
00091 #define MD3_IDENT           (('3'<<24)+('P'<<16)+('D'<<8)+'I')
00092 #define MD3_VERSION         15
00093 
00094 // limits
00095 #define MD3_MAX_LODS        4
00096 #define MD3_MAX_TRIANGLES   8192    // per surface
00097 #define MD3_MAX_VERTS       4096    // per surface
00098 #define MD3_MAX_SHADERS     256     // per surface
00099 #define MD3_MAX_FRAMES      1024    // per model
00100 #define MD3_MAX_SURFACES    32      // per model
00101 #define MD3_MAX_TAGS        16      // per frame
00102 
00103 // vertex scales
00104 #define MD3_XYZ_SCALE       (1.0/64)
00105 
00106 typedef struct md3Frame_s {
00107     vec3_t      bounds[2];
00108     vec3_t      localOrigin;
00109     float       radius;
00110     char        name[16];
00111 } md3Frame_t;
00112 
00113 typedef struct md3Tag_s {
00114     char        name[MAX_QPATH];    // tag name
00115     vec3_t      origin;
00116     vec3_t      axis[3];
00117 } md3Tag_t;
00118 
00119 /*
00120 ** md3Surface_t
00121 **
00122 ** CHUNK            SIZE
00123 ** header           sizeof( md3Surface_t )
00124 ** shaders          sizeof( md3Shader_t ) * numShaders
00125 ** triangles[0]     sizeof( md3Triangle_t ) * numTriangles
00126 ** st               sizeof( md3St_t ) * numVerts
00127 ** XyzNormals       sizeof( md3XyzNormal_t ) * numVerts * numFrames
00128 */
00129 
00130 typedef struct {
00131     int     ident;              // 
00132 
00133     char    name[MAX_QPATH];    // polyset name
00134 
00135     int     flags;
00136     int     numFrames;          // all surfaces in a model should have the same
00137 
00138     int     numShaders;         // all surfaces in a model should have the same
00139     int     numVerts;
00140 
00141     int     numTriangles;
00142     int     ofsTriangles;
00143 
00144     int     ofsShaders;         // offset from start of md3Surface_t
00145     int     ofsSt;              // texture coords are common for all frames
00146     int     ofsXyzNormals;      // numVerts * numFrames
00147 
00148     int     ofsEnd;             // next surface follows
00149 } md3Surface_t;
00150 
00151 typedef struct {
00152     char            name[MAX_QPATH];
00153     int             shaderIndex;    // for in-game use
00154 } md3Shader_t;
00155 
00156 typedef struct {
00157     int         indexes[3];
00158 } md3Triangle_t;
00159 
00160 typedef struct {
00161     float       st[2];
00162 } md3St_t;
00163 
00164 typedef struct {
00165     short       xyz[3];
00166     short       normal;
00167 } md3XyzNormal_t;
00168 
00169 typedef struct {
00170     int         ident;
00171     int         version;
00172 
00173     char        name[MAX_QPATH];    // model name
00174 
00175     int         flags;
00176 
00177     int         numFrames;
00178     int         numTags;            
00179     int         numSurfaces;
00180 
00181     int         numSkins;
00182 
00183     int         ofsFrames;          // offset for first frame
00184     int         ofsTags;            // numFrames * numTags
00185     int         ofsSurfaces;        // first surface, others follow
00186 
00187     int         ofsEnd;             // end of file
00188 } md3Header_t;
00189 
00190 
00191 
00192 /*
00193 ==============================================================================
00194 
00195   .BSP file format
00196 
00197 ==============================================================================
00198 */
00199 
00200 
00201 #define Q3_BSP_IDENT    (('P'<<24)+('S'<<16)+('B'<<8)+'I')
00202         // little-endian "IBSP"
00203 
00204 #define Q3_BSP_VERSION          46
00205 
00206 
00207 // there shouldn't be any problem with increasing these values at the
00208 // expense of more memory allocation in the utilities
00209 #define Q3_MAX_MAP_MODELS       0x400
00210 #define Q3_MAX_MAP_BRUSHES      0x8000
00211 #define Q3_MAX_MAP_ENTITIES 0x800
00212 #define Q3_MAX_MAP_ENTSTRING    0x10000
00213 #define Q3_MAX_MAP_SHADERS      0x400
00214 
00215 #define Q3_MAX_MAP_AREAS        0x100   // MAX_MAP_AREA_BYTES in q_shared must match!
00216 #define Q3_MAX_MAP_FOGS     0x100
00217 #define Q3_MAX_MAP_PLANES       0x10000
00218 #define Q3_MAX_MAP_NODES        0x10000
00219 #define Q3_MAX_MAP_BRUSHSIDES   0x10000
00220 #define Q3_MAX_MAP_LEAFS        0x10000
00221 #define Q3_MAX_MAP_LEAFFACES    0x10000
00222 #define Q3_MAX_MAP_LEAFBRUSHES  0x10000
00223 #define Q3_MAX_MAP_PORTALS      0x10000
00224 #define Q3_MAX_MAP_LIGHTING 0x400000
00225 #define Q3_MAX_MAP_LIGHTGRID    0x400000
00226 #define Q3_MAX_MAP_VISIBILITY   0x200000
00227 
00228 #define Q3_MAX_MAP_DRAW_SURFS   0x20000
00229 #define Q3_MAX_MAP_DRAW_VERTS   0x80000
00230 #define Q3_MAX_MAP_DRAW_INDEXES 0x80000
00231 
00232 
00233 // key / value pair sizes in the entities lump
00234 #define Q3_MAX_KEY              32
00235 #define Q3_MAX_VALUE            1024
00236 
00237 // the editor uses these predefined yaw angles to orient entities up or down
00238 #define ANGLE_UP            -1
00239 #define ANGLE_DOWN          -2
00240 
00241 #define LIGHTMAP_WIDTH      128
00242 #define LIGHTMAP_HEIGHT     128
00243 
00244 
00245 //=============================================================================
00246 
00247 
00248 typedef struct {
00249     int     fileofs, filelen;
00250 } q3_lump_t;
00251 
00252 #define Q3_LUMP_ENTITIES        0
00253 #define Q3_LUMP_SHADERS     1
00254 #define Q3_LUMP_PLANES          2
00255 #define Q3_LUMP_NODES           3
00256 #define Q3_LUMP_LEAFS           4
00257 #define Q3_LUMP_LEAFSURFACES    5
00258 #define Q3_LUMP_LEAFBRUSHES 6
00259 #define Q3_LUMP_MODELS          7
00260 #define Q3_LUMP_BRUSHES     8
00261 #define Q3_LUMP_BRUSHSIDES      9
00262 #define Q3_LUMP_DRAWVERTS       10
00263 #define Q3_LUMP_DRAWINDEXES 11
00264 #define Q3_LUMP_FOGS            12
00265 #define Q3_LUMP_SURFACES        13
00266 #define Q3_LUMP_LIGHTMAPS       14
00267 #define Q3_LUMP_LIGHTGRID       15
00268 #define Q3_LUMP_VISIBILITY      16
00269 #define Q3_HEADER_LUMPS     17
00270 
00271 typedef struct {
00272     int         ident;
00273     int         version;
00274 
00275     q3_lump_t       lumps[Q3_HEADER_LUMPS];
00276 } q3_dheader_t;
00277 
00278 typedef struct {
00279     float       mins[3], maxs[3];
00280     int         firstSurface, numSurfaces;
00281     int         firstBrush, numBrushes;
00282 } q3_dmodel_t;
00283 
00284 typedef struct {
00285     char        shader[MAX_QPATH];
00286     int         surfaceFlags;
00287     int         contentFlags;
00288 } q3_dshader_t;
00289 
00290 // planes (x&~1) and (x&~1)+1 are allways opposites
00291 
00292 typedef struct {
00293     float       normal[3];
00294     float       dist;
00295 } q3_dplane_t;
00296 
00297 typedef struct {
00298     int         planeNum;
00299     int         children[2];    // negative numbers are -(leafs+1), not nodes
00300     int         mins[3];        // for frustom culling
00301     int         maxs[3];
00302 } q3_dnode_t;
00303 
00304 typedef struct {
00305     int         cluster;            // -1 = opaque cluster (do I still store these?)
00306     int         area;
00307 
00308     int         mins[3];            // for frustum culling
00309     int         maxs[3];
00310 
00311     int         firstLeafSurface;
00312     int         numLeafSurfaces;
00313 
00314     int         firstLeafBrush;
00315     int         numLeafBrushes;
00316 } q3_dleaf_t;
00317 
00318 typedef struct {
00319     int         planeNum;           // positive plane side faces out of the leaf
00320     int         shaderNum;
00321 } q3_dbrushside_t;
00322 
00323 typedef struct {
00324     int         firstSide;
00325     int         numSides;
00326     int         shaderNum;      // the shader that determines the contents flags
00327 } q3_dbrush_t;
00328 
00329 typedef struct {
00330     char        shader[MAX_QPATH];
00331     int         brushNum;
00332     int         visibleSide;    // the brush side that ray tests need to clip against (-1 == none)
00333 } q3_dfog_t;
00334 
00335 typedef struct {
00336     vec3_t      xyz;
00337     float       st[2];
00338     float       lightmap[2];
00339     vec3_t      normal;
00340     byte        color[4];
00341 } q3_drawVert_t;
00342 
00343 typedef enum {
00344     MST_BAD,
00345     MST_PLANAR,
00346     MST_PATCH,
00347     MST_TRIANGLE_SOUP,
00348     MST_FLARE
00349 } q3_mapSurfaceType_t;
00350 
00351 typedef struct {
00352     int         shaderNum;
00353     int         fogNum;
00354     int         surfaceType;
00355 
00356     int         firstVert;
00357     int         numVerts;
00358 
00359     int         firstIndex;
00360     int         numIndexes;
00361 
00362     int         lightmapNum;
00363     int         lightmapX, lightmapY;
00364     int         lightmapWidth, lightmapHeight;
00365 
00366     vec3_t      lightmapOrigin;
00367     vec3_t      lightmapVecs[3];    // for patches, [0] and [1] are lodbounds
00368 
00369     int         patchWidth;
00370     int         patchHeight;
00371 } q3_dsurface_t;
00372 
00373 
00374 #endif

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