1/* 2Copyright (C) 1996-1997 Id Software, Inc. 3 4This program is free software; you can redistribute it and/or 5modify it under the terms of the GNU General Public License 6as published by the Free Software Foundation; either version 2 7of the License, or (at your option) any later version. 8 9This program is distributed in the hope that it will be useful, 10but WITHOUT ANY WARRANTY; without even the implied warranty of 11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 13See the GNU General Public License for more details. 14 15You should have received a copy of the GNU General Public License 16along with this program; if not, write to the Free Software 17Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 19*/ 20 21 22// upper design bounds 23 24#define MAX_MAP_HULLS 4 25 26#define MAX_MAP_MODELS 256 27#define MAX_MAP_BRUSHES 4096 28#define MAX_MAP_ENTITIES 1024 29#define MAX_MAP_ENTSTRING 65536 30 31#define MAX_MAP_PLANES 8192 32#define MAX_MAP_NODES 32767 // because negative shorts are contents 33#define MAX_MAP_CLIPNODES 32767 // 34#define MAX_MAP_LEAFS 32767 // 35#define MAX_MAP_VERTS 65535 36#define MAX_MAP_FACES 65535 37#define MAX_MAP_MARKSURFACES 65535 38#define MAX_MAP_TEXINFO 4096 39#define MAX_MAP_EDGES 256000 40#define MAX_MAP_SURFEDGES 512000 41#define MAX_MAP_MIPTEX 0x200000 42#define MAX_MAP_LIGHTING 0x100000 43#define MAX_MAP_VISIBILITY 0x100000 44 45// key / value pair sizes 46 47#define MAX_KEY 32 48#define MAX_VALUE 1024 49 50 51//============================================================================= 52 53 54#define BSPVERSION 29 55 56typedef struct 57{ 58 int fileofs, filelen; 59} lump_t; 60 61#define LUMP_ENTITIES 0 62#define LUMP_PLANES 1 63#define LUMP_TEXTURES 2 64#define LUMP_VERTEXES 3 65#define LUMP_VISIBILITY 4 66#define LUMP_NODES 5 67#define LUMP_TEXINFO 6 68#define LUMP_FACES 7 69#define LUMP_LIGHTING 8 70#define LUMP_CLIPNODES 9 71#define LUMP_LEAFS 10 72#define LUMP_MARKSURFACES 11 73#define LUMP_EDGES 12 74#define LUMP_SURFEDGES 13 75#define LUMP_MODELS 14 76 77#define HEADER_LUMPS 15 78 79typedef struct 80{ 81 float mins[3], maxs[3]; 82 float origin[3]; 83 int headnode[MAX_MAP_HULLS]; 84 int visleafs; // not including the solid leaf 0 85 int firstface, numfaces; 86} dmodel_t; 87 88typedef struct 89{ 90 int version; 91 lump_t lumps[HEADER_LUMPS]; 92} dheader_t; 93 94typedef struct 95{ 96 int nummiptex; 97 int dataofs[4]; // [nummiptex] 98} dmiptexlump_t; 99 100#define MIPLEVELS 4 101typedef struct miptex_s 102{ 103 char name[16]; 104 unsigned width, height; 105 unsigned offsets[MIPLEVELS]; // four mip maps stored 106} miptex_t; 107 108 109typedef struct 110{ 111 float point[3]; 112} dvertex_t; 113 114 115// 0-2 are axial planes 116#define PLANE_X 0 117#define PLANE_Y 1 118#define PLANE_Z 2 119 120// 3-5 are non-axial planes snapped to the nearest 121#define PLANE_ANYX 3 122#define PLANE_ANYY 4 123#define PLANE_ANYZ 5 124 125typedef struct 126{ 127 float normal[3]; 128 float dist; 129 int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate 130} dplane_t; 131 132 133 134#define CONTENTS_EMPTY -1 135#define CONTENTS_SOLID -2 136#define CONTENTS_WATER -3 137#define CONTENTS_SLIME -4 138#define CONTENTS_LAVA -5 139#define CONTENTS_SKY -6 140 141// !!! if this is changed, it must be changed in asm_i386.h too !!! 142typedef struct 143{ 144 int planenum; 145 short children[2]; // negative numbers are -(leafs+1), not nodes 146 short mins[3]; // for sphere culling 147 short maxs[3]; 148 unsigned short firstface; 149 unsigned short numfaces; // counting both sides 150} dnode_t; 151 152typedef struct 153{ 154 int planenum; 155 short children[2]; // negative numbers are contents 156} dclipnode_t; 157 158 159typedef struct texinfo_s 160{ 161 float vecs[2][4]; // [s/t][xyz offset] 162 int miptex; 163 int flags; 164} texinfo_t; 165#define TEX_SPECIAL 1 // sky or slime, no lightmap or 256 subdivision 166 167// note that edge 0 is never used, because negative edge nums are used for 168// counterclockwise use of the edge in a face 169typedef struct 170{ 171 unsigned short v[2]; // vertex numbers 172} dedge_t; 173 174#define MAXLIGHTMAPS 4 175typedef struct 176{ 177 short planenum; 178 short side; 179 180 int firstedge; // we must support > 64k edges 181 short numedges; 182 short texinfo; 183 184// lighting info 185 byte styles[MAXLIGHTMAPS]; 186 int lightofs; // start of [numstyles*surfsize] samples 187} dface_t; 188 189 190 191#define AMBIENT_WATER 0 192#define AMBIENT_SKY 1 193#define AMBIENT_SLIME 2 194#define AMBIENT_LAVA 3 195 196#define NUM_AMBIENTS 4 // automatic ambient sounds 197 198// leaf 0 is the generic CONTENTS_SOLID leaf, used for all solid areas 199// all other leafs need visibility info 200typedef struct 201{ 202 int contents; 203 int visofs; // -1 = no visibility info 204 205 short mins[3]; // for frustum culling 206 short maxs[3]; 207 208 unsigned short firstmarksurface; 209 unsigned short nummarksurfaces; 210 211 byte ambient_level[NUM_AMBIENTS]; 212} dleaf_t; 213 214//============================================================================ 215 216#ifndef QUAKE_GAME 217 218// the utilities get to be lazy and just use large static arrays 219 220extern int nummodels; 221extern dmodel_t dmodels[MAX_MAP_MODELS]; 222 223extern int visdatasize; 224extern byte dvisdata[MAX_MAP_VISIBILITY]; 225 226extern int lightdatasize; 227extern byte dlightdata[MAX_MAP_LIGHTING]; 228 229extern int texdatasize; 230extern byte dtexdata[MAX_MAP_MIPTEX]; // (dmiptexlump_t) 231 232extern int entdatasize; 233extern char dentdata[MAX_MAP_ENTSTRING]; 234 235extern int numleafs; 236extern dleaf_t dleafs[MAX_MAP_LEAFS]; 237 238extern int numplanes; 239extern dplane_t dplanes[MAX_MAP_PLANES]; 240 241extern int numvertexes; 242extern dvertex_t dvertexes[MAX_MAP_VERTS]; 243 244extern int numnodes; 245extern dnode_t dnodes[MAX_MAP_NODES]; 246 247extern int numtexinfo; 248extern texinfo_t texinfo[MAX_MAP_TEXINFO]; 249 250extern int numfaces; 251extern dface_t dfaces[MAX_MAP_FACES]; 252 253extern int numclipnodes; 254extern dclipnode_t dclipnodes[MAX_MAP_CLIPNODES]; 255 256extern int numedges; 257extern dedge_t dedges[MAX_MAP_EDGES]; 258 259extern int nummarksurfaces; 260extern unsigned short dmarksurfaces[MAX_MAP_MARKSURFACES]; 261 262extern int numsurfedges; 263extern int dsurfedges[MAX_MAP_SURFEDGES]; 264 265 266 267void LoadBSPFile (char *filename); 268void WriteBSPFile (char *filename); 269void PrintBSPFileSizes (void); 270 271#endif 272