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

BSPFILE.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 // upper design bounds
00025 // leaffaces, leafbrushes, planes, and verts are still bounded by
00026 // 16 bit short limits
00027 #define MAX_MAP_MODELS      1024
00028 #define MAX_MAP_BRUSHES     8192
00029 #define MAX_MAP_ENTITIES    2048
00030 #define MAX_MAP_PATHS       2048
00031 #define MAX_MAP_ENTSTRING   0x20000
00032 #define MAX_MAP_TEXTURES    1024
00033 #define MAX_MAP_TEXINFO     8192
00034 
00035 #define MAX_MAP_PLANES      65536
00036 #define MAX_MAP_NODES       65536
00037 #define MAX_MAP_BRUSHSIDES  65536
00038 #define MAX_MAP_LEAFS       65536
00039 #define MAX_MAP_VERTS       65536
00040 #define MAX_MAP_FACES       65536
00041 #define MAX_MAP_LEAFFACES   65536
00042 #define MAX_MAP_LEAFBRUSHES 65536
00043 #define MAX_MAP_PORTALS     65536
00044 #define MAX_MAP_EDGES       128000
00045 #define MAX_MAP_SURFEDGES   256000
00046 #define MAX_MAP_MIPTEX      0x200000
00047 #define MAX_MAP_LIGHTING    0x200000
00048 #define MAX_MAP_VISIBILITY  0x100000
00049 
00050 // key / value pair sizes
00051 
00052 #define MAX_KEY     32
00053 #define MAX_VALUE   1024
00054 
00055 //=============================================================================
00056 
00057 #define BSPVERSION  34
00058 
00059 typedef struct
00060 {
00061     int     fileofs, filelen;
00062 } lump_t;
00063 
00064 #define LUMP_ENTITIES       0
00065 #define LUMP_PLANES         1
00066 #define LUMP_TEXTURES       2
00067 #define LUMP_VERTEXES       3
00068 #define LUMP_VISIBILITY     4
00069 #define LUMP_NODES          5
00070 #define LUMP_TEXINFO        6
00071 #define LUMP_FACES          7
00072 #define LUMP_LIGHTING       8
00073 #define LUMP_LEAFS          9
00074 #define LUMP_LEAFFACES      10
00075 #define LUMP_LEAFBRUSHES    11
00076 #define LUMP_EDGES          12
00077 #define LUMP_SURFEDGES      13
00078 #define LUMP_MODELS         14
00079 #define LUMP_PATHS          15
00080 #define LUMP_BRUSHES        16
00081 #define LUMP_BRUSHSIDES     17
00082 #define LUMP_POP            18
00083 
00084 #define HEADER_LUMPS    18
00085 
00086 typedef struct
00087 {
00088     int         version;    
00089     lump_t      lumps[HEADER_LUMPS];
00090 } dheader_t;
00091 
00092 typedef struct
00093 {
00094     float       mins[3], maxs[3];
00095     float       origin[3];      // for sounds or lights
00096     int         headnode;
00097     int         visleafs;       // not including the solid leaf 0
00098     int         firstface, numfaces;
00099 } dmodel_t;
00100 
00101 typedef struct
00102 {
00103     int         nummiptex;
00104     int         dataofs[4];     // [nummiptex]
00105 } dmiptexlump_t;
00106 
00107 #define MIPLEVELS   4
00108 typedef struct miptex_s
00109 {
00110     char        name[16];
00111     unsigned    width, height;
00112     unsigned    offsets[MIPLEVELS];     // four mip maps stored
00113     int         flags;
00114     int         value;
00115 } miptex_t;
00116 
00117 
00118 typedef struct
00119 {
00120     float   point[3];
00121 } dvertex_t;
00122 
00123 
00124 // 0-2 are axial planes
00125 #define PLANE_X         0
00126 #define PLANE_Y         1
00127 #define PLANE_Z         2
00128 
00129 // 3-5 are non-axial planes snapped to the nearest
00130 #define PLANE_ANYX      3
00131 #define PLANE_ANYY      4
00132 #define PLANE_ANYZ      5
00133 
00134 // planes (x&~1) and (x&~1)+1 are allways opposites
00135 
00136 typedef struct
00137 {
00138     float   normal[3];
00139     float   dist;
00140     int     type;       // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
00141 } dplane_t;
00142 
00143 
00144 // contents flags are seperate bits
00145 // a given brush can contribute multiple content bits
00146 // multiple brushes can be in a single leaf
00147 
00148 // lower bits are stronger, and will eat weaker brushes completely
00149 #define CONTENTS_SOLID          1       // an eye is never valid in a solid
00150 #define CONTENTS_WINDOW         2       // translucent, but not watery
00151 #define CONTENTS_LAVA           8
00152 #define CONTENTS_SLIME          16
00153 #define CONTENTS_WATER          32
00154 #define CONTENTS_THINWATER      64      // translucent faces
00155 
00156 #define LAST_VISIBLE_CONTENTS   64
00157 
00158 // remaining contents are non-visible, and don't eat brushes
00159 #define CONTENTS_MONSTER        128
00160 #define CONTENTS_PLAYERCLIP     256
00161 #define CONTENTS_MONSTERCLIP    512
00162 
00163 
00164 // currents can be added to any other contents, and may be mixed
00165 #define CONTENTS_CURRENT_0      1024
00166 #define CONTENTS_CURRENT_90     2048
00167 #define CONTENTS_CURRENT_180    4096
00168 #define CONTENTS_CURRENT_270    8192
00169 #define CONTENTS_CURRENT_UP     16384
00170 #define CONTENTS_CURRENT_DOWN   32768
00171 
00172 #define CONTENTS_ORIGIN         65536       // removed before processing
00173 
00174 
00175 
00176 // !!! if this is changed, it must be changed in asm_i386.h too !!!
00177 typedef struct
00178 {
00179     int         planenum;
00180     int         children[2];    // negative numbers are -(leafs+1), not nodes
00181     short       mins[3];        // for frustom culling
00182     short       maxs[3];
00183     unsigned short  firstface;
00184     unsigned short  numfaces;   // counting both sides
00185 } dnode_t;
00186 
00187 typedef struct texinfo_s
00188 {
00189     float       vecs[2][4];     // [s/t][xyz offset]
00190     int         miptex;
00191     int         flags;          // miptex flags + overrides
00192     int         value;          // light emition, etc
00193 } texinfo_t;
00194 
00195 #define TEX_SPECIAL     1       // sky or slime, no lightmap or 256 subdivision
00196 #define SURF_LIGHT      2
00197 
00198 #define SURF_WATER      4
00199 #define SURF_SLIME      8
00200 #define SURF_LAVA       16
00201 #define SURF_WINDOW     32
00202 
00203 #define SURF_SKY        64
00204 #define SURF_MIRROR     128
00205 
00206 #define SURF_SLIPPERY   256
00207 
00208 // note that edge 0 is never used, because negative edge nums are used for
00209 // counterclockwise use of the edge in a face
00210 typedef struct
00211 {
00212     unsigned short  v[2];       // vertex numbers
00213 } dedge_t;
00214 
00215 #define MAXLIGHTMAPS    4
00216 typedef struct
00217 {
00218     unsigned short  planenum;
00219     short       side;
00220 
00221     int         firstedge;      // we must support > 64k edges
00222     short       numedges;   
00223     short       texinfo;
00224 
00225 // lighting info
00226     byte        styles[MAXLIGHTMAPS];
00227     int         lightofs;       // start of [numstyles*surfsize] samples
00228 } dface_t;
00229 
00230 typedef struct
00231 {
00232     int         contents;           // OR of all brushes
00233     int         visofs;             // -1 = no visibility info
00234 
00235     short       mins[3];            // for frustum culling
00236     short       maxs[3];
00237 
00238     unsigned short      firstleafface;
00239     unsigned short      numleaffaces;
00240 
00241     unsigned short      firstleafbrush;
00242     unsigned short      numleafbrushes;
00243 } dleaf_t;
00244 
00245 
00246 typedef struct
00247 {
00248     unsigned short  planenum;       // facing out of the leaf
00249     short   texinfo;
00250 } dbrushside_t;
00251 
00252 typedef struct
00253 {
00254     int         firstside;
00255     int         numsides;
00256     int         contents;
00257 } dbrush_t;
00258 
00259 typedef struct
00260 {
00261     float       origin[3];
00262     float       angles[3];
00263     int         next, prev;
00264     int         flags;
00265     float       speed;
00266 } dpath_t;
00267 
00268 //============================================================================
00269 
00270 #ifndef QUAKE_GAME
00271 
00272 #define ANGLE_UP    -1
00273 #define ANGLE_DOWN  -2
00274 
00275 
00276 // the utilities get to be lazy and just use large static arrays
00277 
00278 extern  int         nummodels;
00279 extern  dmodel_t    dmodels[MAX_MAP_MODELS];
00280 
00281 extern  int         visdatasize;
00282 extern  byte        dvisdata[MAX_MAP_VISIBILITY];
00283 
00284 extern  int         lightdatasize;
00285 extern  byte        dlightdata[MAX_MAP_LIGHTING];
00286 
00287 extern  int         texdatasize;
00288 extern  byte        dtexdata[MAX_MAP_MIPTEX]; // (dmiptexlump_t)
00289 
00290 extern  int         entdatasize;
00291 extern  char        dentdata[MAX_MAP_ENTSTRING];
00292 
00293 extern  int         numleafs;
00294 extern  dleaf_t     dleafs[MAX_MAP_LEAFS];
00295 
00296 extern  int         numplanes;
00297 extern  dplane_t    dplanes[MAX_MAP_PLANES];
00298 
00299 extern  int         numvertexes;
00300 extern  dvertex_t   dvertexes[MAX_MAP_VERTS];
00301 
00302 extern  int         numnodes;
00303 extern  dnode_t     dnodes[MAX_MAP_NODES];
00304 
00305 extern  int         numtexinfo;
00306 extern  texinfo_t   texinfo[MAX_MAP_TEXINFO];
00307 
00308 extern  int         numfaces;
00309 extern  dface_t     dfaces[MAX_MAP_FACES];
00310 
00311 extern  int         numedges;
00312 extern  dedge_t     dedges[MAX_MAP_EDGES];
00313 
00314 extern  int         numleaffaces;
00315 extern  unsigned short  dleaffaces[MAX_MAP_LEAFFACES];
00316 
00317 extern  int         numleafbrushes;
00318 extern  unsigned short  dleafbrushes[MAX_MAP_LEAFBRUSHES];
00319 
00320 extern  int         numsurfedges;
00321 extern  int         dsurfedges[MAX_MAP_SURFEDGES];
00322 
00323 extern  int         numpaths;
00324 extern  dpath_t     dpaths[MAX_MAP_PATHS];
00325 
00326 extern  int         numbrushes;
00327 extern  dbrush_t    dbrushes[MAX_MAP_BRUSHES];
00328 
00329 extern  int         numbrushsides;
00330 extern  dbrushside_t    dbrushsides[MAX_MAP_BRUSHSIDES];
00331 
00332 
00333 void DecompressVis (byte *in, byte *decompressed);
00334 int CompressVis (byte *vis, byte *dest);
00335 
00336 void    LoadBSPFile (char *filename);
00337 void    WriteBSPFile (char *filename);
00338 void    PrintBSPFileSizes (void);
00339 
00340 //===============
00341 
00342 
00343 typedef struct epair_s
00344 {
00345     struct epair_s  *next;
00346     char    *key;
00347     char    *value;
00348 } epair_t;
00349 
00350 typedef struct
00351 {
00352     vec3_t      origin;
00353     int         firstbrush;
00354     int         numbrushes;
00355     epair_t     *epairs;
00356 } entity_t;
00357 
00358 extern  int         num_entities;
00359 extern  entity_t    entities[MAX_MAP_ENTITIES];
00360 
00361 void    ParseEntities (void);
00362 void    UnparseEntities (void);
00363 
00364 void    SetKeyValue (entity_t *ent, char *key, char *value);
00365 char    *ValueForKey (entity_t *ent, char *key);
00366 // will return "" if not present
00367 
00368 vec_t   FloatForKey (entity_t *ent, char *key);
00369 void    GetVectorForKey (entity_t *ent, char *key, vec3_t vec);
00370 
00371 epair_t *ParseEpair (void);
00372 
00373 void PrintEntity (entity_t *ent);
00374 
00375 extern  int     r_leaftovis[MAX_MAP_LEAFS];
00376 extern  int     r_vistoleaf[MAX_MAP_LEAFS];
00377 extern  int     r_numvisleafs;
00378 
00379 #endif

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