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

l_bsp_q1.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 
00026 #define Q1_MAX_MAP_HULLS        4
00027 
00028 #define Q1_MAX_MAP_MODELS       256
00029 #define Q1_MAX_MAP_BRUSHES      4096
00030 #define Q1_MAX_MAP_ENTITIES 1024
00031 #define Q1_MAX_MAP_ENTSTRING    65536
00032 
00033 #define Q1_MAX_MAP_PLANES       8192
00034 #define Q1_MAX_MAP_NODES        32767       // because negative shorts are contents
00035 #define Q1_MAX_MAP_CLIPNODES    32767       //
00036 #define Q1_MAX_MAP_LEAFS        32767       // 
00037 #define Q1_MAX_MAP_VERTS        65535
00038 #define Q1_MAX_MAP_FACES        65535
00039 #define Q1_MAX_MAP_MARKSURFACES 65535
00040 #define Q1_MAX_MAP_TEXINFO      4096
00041 #define Q1_MAX_MAP_EDGES        256000
00042 #define Q1_MAX_MAP_SURFEDGES    512000
00043 #define Q1_MAX_MAP_MIPTEX       0x200000
00044 #define Q1_MAX_MAP_LIGHTING 0x100000
00045 #define Q1_MAX_MAP_VISIBILITY   0x100000
00046 
00047 // key / value pair sizes
00048 
00049 #define MAX_KEY     32
00050 #define MAX_VALUE   1024
00051 
00052 //=============================================================================
00053 
00054 
00055 #define Q1_BSPVERSION   29
00056 
00057 typedef struct
00058 {
00059     int fileofs, filelen;
00060 } q1_lump_t;
00061 
00062 #define Q1_LUMP_ENTITIES    0
00063 #define Q1_LUMP_PLANES      1
00064 #define Q1_LUMP_TEXTURES    2
00065 #define Q1_LUMP_VERTEXES    3
00066 #define Q1_LUMP_VISIBILITY  4
00067 #define Q1_LUMP_NODES       5
00068 #define Q1_LUMP_TEXINFO 6
00069 #define Q1_LUMP_FACES       7
00070 #define Q1_LUMP_LIGHTING    8
00071 #define Q1_LUMP_CLIPNODES   9
00072 #define Q1_LUMP_LEAFS       10
00073 #define Q1_LUMP_MARKSURFACES 11
00074 #define Q1_LUMP_EDGES       12
00075 #define Q1_LUMP_SURFEDGES   13
00076 #define Q1_LUMP_MODELS      14
00077 
00078 #define Q1_HEADER_LUMPS 15
00079 
00080 typedef struct
00081 {
00082     float       mins[3], maxs[3];
00083     float       origin[3];
00084     int     headnode[Q1_MAX_MAP_HULLS];
00085     int     visleafs;       // not including the solid leaf 0
00086     int     firstface, numfaces;
00087 } q1_dmodel_t;
00088 
00089 typedef struct
00090 {
00091     int         version;    
00092     q1_lump_t   lumps[Q1_HEADER_LUMPS];
00093 } q1_dheader_t;
00094 
00095 typedef struct
00096 {
00097     int     nummiptex;
00098     int     dataofs[4];     // [nummiptex]
00099 } q1_dmiptexlump_t;
00100 
00101 #define MIPLEVELS   4
00102 typedef struct q1_miptex_s
00103 {
00104     char        name[16];
00105     unsigned    width, height;
00106     unsigned    offsets[MIPLEVELS];     // four mip maps stored
00107 } q1_miptex_t;
00108 
00109 
00110 typedef struct
00111 {
00112     float   point[3];
00113 } q1_dvertex_t;
00114 
00115 
00116 // 0-2 are axial planes
00117 #define PLANE_X         0
00118 #define PLANE_Y         1
00119 #define PLANE_Z         2
00120 
00121 // 3-5 are non-axial planes snapped to the nearest
00122 #define PLANE_ANYX      3
00123 #define PLANE_ANYY      4
00124 #define PLANE_ANYZ      5
00125 
00126 typedef struct
00127 {
00128     float   normal[3];
00129     float   dist;
00130     int     type;       // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
00131 } q1_dplane_t;
00132 
00133 
00134 
00135 #define Q1_CONTENTS_EMPTY       -1
00136 #define Q1_CONTENTS_SOLID       -2
00137 #define Q1_CONTENTS_WATER       -3
00138 #define Q1_CONTENTS_SLIME       -4
00139 #define Q1_CONTENTS_LAVA        -5
00140 #define Q1_CONTENTS_SKY     -6
00141 
00142 // !!! if this is changed, it must be changed in asm_i386.h too !!!
00143 typedef struct
00144 {
00145     int     planenum;
00146     short       children[2];    // negative numbers are -(leafs+1), not nodes
00147     short       mins[3];        // for sphere culling
00148     short       maxs[3];
00149     unsigned short  firstface;
00150     unsigned short  numfaces;   // counting both sides
00151 } q1_dnode_t;
00152 
00153 typedef struct
00154 {
00155     int     planenum;
00156     short       children[2];    // negative numbers are contents
00157 } q1_dclipnode_t;
00158 
00159 
00160 typedef struct q1_texinfo_s
00161 {
00162     float       vecs[2][4];     // [s/t][xyz offset]
00163     int     miptex;
00164     int     flags;
00165 } q1_texinfo_t;
00166 #define TEX_SPECIAL     1       // sky or slime, no lightmap or 256 subdivision
00167 
00168 // note that edge 0 is never used, because negative edge nums are used for
00169 // counterclockwise use of the edge in a face
00170 typedef struct
00171 {
00172     unsigned short  v[2];       // vertex numbers
00173 } q1_dedge_t;
00174 
00175 #define MAXLIGHTMAPS    4
00176 typedef struct
00177 {
00178     short       planenum;
00179     short       side;
00180 
00181     int     firstedge;      // we must support > 64k edges
00182     short       numedges;   
00183     short       texinfo;
00184 
00185 // lighting info
00186     byte        styles[MAXLIGHTMAPS];
00187     int     lightofs;       // start of [numstyles*surfsize] samples
00188 } q1_dface_t;
00189 
00190 
00191 
00192 #define AMBIENT_WATER   0
00193 #define AMBIENT_SKY     1
00194 #define AMBIENT_SLIME   2
00195 #define AMBIENT_LAVA    3
00196 
00197 #define NUM_AMBIENTS            4       // automatic ambient sounds
00198 
00199 // leaf 0 is the generic Q1_CONTENTS_SOLID leaf, used for all solid areas
00200 // all other leafs need visibility info
00201 typedef struct
00202 {
00203     int             contents;
00204     int             visofs;             // -1 = no visibility info
00205 
00206     short               mins[3];            // for frustum culling
00207     short               maxs[3];
00208 
00209     unsigned short  firstmarksurface;
00210     unsigned short  nummarksurfaces;
00211 
00212     byte        ambient_level[NUM_AMBIENTS];
00213 } q1_dleaf_t;
00214 
00215 //============================================================================
00216 
00217 #ifndef QUAKE_GAME
00218 
00219 // the utilities get to be lazy and just use large static arrays
00220 
00221 extern  int             q1_nummodels;
00222 extern  q1_dmodel_t     *q1_dmodels;//[MAX_MAP_MODELS];
00223 
00224 extern  int             q1_visdatasize;
00225 extern  byte                *q1_dvisdata;//[MAX_MAP_VISIBILITY];
00226 
00227 extern  int             q1_lightdatasize;
00228 extern  byte                *q1_dlightdata;//[MAX_MAP_LIGHTING];
00229 
00230 extern  int             q1_texdatasize;
00231 extern  byte                *q1_dtexdata;//[MAX_MAP_MIPTEX]; // (dmiptexlump_t)
00232 
00233 extern  int             q1_entdatasize;
00234 extern  char                *q1_dentdata;//[MAX_MAP_ENTSTRING];
00235 
00236 extern  int             q1_numleafs;
00237 extern  q1_dleaf_t      *q1_dleafs;//[MAX_MAP_LEAFS];
00238 
00239 extern  int             q1_numplanes;
00240 extern  q1_dplane_t     *q1_dplanes;//[MAX_MAP_PLANES];
00241 
00242 extern  int             q1_numvertexes;
00243 extern  q1_dvertex_t    *q1_dvertexes;//[MAX_MAP_VERTS];
00244 
00245 extern  int             q1_numnodes;
00246 extern  q1_dnode_t      *q1_dnodes;//[MAX_MAP_NODES];
00247 
00248 extern  int             q1_numtexinfo;
00249 extern  q1_texinfo_t    *q1_texinfo;//[MAX_MAP_TEXINFO];
00250 
00251 extern  int             q1_numfaces;
00252 extern  q1_dface_t      *q1_dfaces;//[MAX_MAP_FACES];
00253 
00254 extern  int             q1_numclipnodes;
00255 extern  q1_dclipnode_t  *q1_dclipnodes;//[MAX_MAP_CLIPNODES];
00256 
00257 extern  int             q1_numedges;
00258 extern  q1_dedge_t      *q1_dedges;//[MAX_MAP_EDGES];
00259 
00260 extern  int             q1_nummarksurfaces;
00261 extern  unsigned short  *q1_dmarksurfaces;//[MAX_MAP_MARKSURFACES];
00262 
00263 extern  int             q1_numsurfedges;
00264 extern  int             *q1_dsurfedges;//[MAX_MAP_SURFEDGES];
00265 
00266 
00267 void Q1_AllocMaxBSP(void);
00268 void Q1_FreeMaxBSP(void);
00269 void Q1_LoadBSPFile(char *filename, int offset, int length);
00270 void Q1_WriteBSPFile(char *filename);
00271 void Q1_PrintBSPFileSizes(void);
00272 void Q1_ParseEntities(void);
00273 void Q1_UnparseEntities(void);
00274 
00275 #endif

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