2 ===========================================================================
3 Copyright (C) 1997-2006 Id Software, Inc.
5 This file is part of Quake 2 Tools source code.
7 Quake 2 Tools source code is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the License,
10 or (at your option) any later version.
12 Quake 2 Tools source code is distributed in the hope that it will be
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Quake 2 Tools source code; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 ===========================================================================
23 // upper design bounds
24 // leaffaces, leafbrushes, planes, and verts are still bounded by
25 // 16 bit short limits
26 #define MAX_MAP_MODELS 1024
27 #define MAX_MAP_BRUSHES 8192
28 #define MAX_MAP_ENTITIES 2048
29 #define MAX_MAP_PATHS 2048
30 #define MAX_MAP_ENTSTRING 0x20000
31 #define MAX_MAP_TEXTURES 1024
32 #define MAX_MAP_TEXINFO 8192
34 #define MAX_MAP_PLANES 65536
35 #define MAX_MAP_NODES 65536
36 #define MAX_MAP_BRUSHSIDES 65536
37 #define MAX_MAP_LEAFS 65536
38 #define MAX_MAP_VERTS 65536
39 #define MAX_MAP_FACES 65536
40 #define MAX_MAP_LEAFFACES 65536
41 #define MAX_MAP_LEAFBRUSHES 65536
42 #define MAX_MAP_PORTALS 65536
43 #define MAX_MAP_EDGES 128000
44 #define MAX_MAP_SURFEDGES 256000
45 #define MAX_MAP_MIPTEX 0x200000
46 #define MAX_MAP_LIGHTING 0x200000
47 #define MAX_MAP_VISIBILITY 0x100000
49 // key / value pair sizes
52 #define MAX_VALUE 1024
54 //=============================================================================
63 #define LUMP_ENTITIES 0
65 #define LUMP_TEXTURES 2
66 #define LUMP_VERTEXES 3
67 #define LUMP_VISIBILITY 4
69 #define LUMP_TEXINFO 6
71 #define LUMP_LIGHTING 8
73 #define LUMP_LEAFFACES 10
74 #define LUMP_LEAFBRUSHES 11
76 #define LUMP_SURFEDGES 13
77 #define LUMP_MODELS 14
79 #define LUMP_BRUSHES 16
80 #define LUMP_BRUSHSIDES 17
83 #define HEADER_LUMPS 18
88 lump_t lumps[HEADER_LUMPS];
93 float mins[3], maxs[3];
94 float origin[3]; // for sounds or lights
96 int visleafs; // not including the solid leaf 0
97 int firstface, numfaces;
103 int dataofs[4]; // [nummiptex]
107 typedef struct miptex_s
110 unsigned width, height;
111 unsigned offsets[MIPLEVELS]; // four mip maps stored
123 // 0-2 are axial planes
128 // 3-5 are non-axial planes snapped to the nearest
133 // planes (x&~1) and (x&~1)+1 are allways opposites
139 int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
143 // contents flags are seperate bits
144 // a given brush can contribute multiple content bits
145 // multiple brushes can be in a single leaf
147 // lower bits are stronger, and will eat weaker brushes completely
148 #define CONTENTS_SOLID 1 // an eye is never valid in a solid
149 #define CONTENTS_WINDOW 2 // translucent, but not watery
150 #define CONTENTS_LAVA 8
151 #define CONTENTS_SLIME 16
152 #define CONTENTS_WATER 32
153 #define CONTENTS_THINWATER 64 // translucent faces
155 #define LAST_VISIBLE_CONTENTS 64
157 // remaining contents are non-visible, and don't eat brushes
158 #define CONTENTS_MONSTER 128
159 #define CONTENTS_PLAYERCLIP 256
160 #define CONTENTS_MONSTERCLIP 512
163 // currents can be added to any other contents, and may be mixed
164 #define CONTENTS_CURRENT_0 1024
165 #define CONTENTS_CURRENT_90 2048
166 #define CONTENTS_CURRENT_180 4096
167 #define CONTENTS_CURRENT_270 8192
168 #define CONTENTS_CURRENT_UP 16384
169 #define CONTENTS_CURRENT_DOWN 32768
171 #define CONTENTS_ORIGIN 65536 // removed before processing
175 // !!! if this is changed, it must be changed in asm_i386.h too !!!
179 int children[2]; // negative numbers are -(leafs+1), not nodes
180 short mins[3]; // for frustom culling
182 unsigned short firstface;
183 unsigned short numfaces; // counting both sides
186 typedef struct texinfo_s
188 float vecs[2][4]; // [s/t][xyz offset]
190 int flags; // miptex flags + overrides
191 int value; // light emition, etc
194 #define TEX_SPECIAL 1 // sky or slime, no lightmap or 256 subdivision
200 #define SURF_WINDOW 32
203 #define SURF_MIRROR 128
205 #define SURF_SLIPPERY 256
207 // note that edge 0 is never used, because negative edge nums are used for
208 // counterclockwise use of the edge in a face
211 unsigned short v[2]; // vertex numbers
214 #define MAXLIGHTMAPS 4
217 unsigned short planenum;
220 int firstedge; // we must support > 64k edges
225 byte styles[MAXLIGHTMAPS];
226 int lightofs; // start of [numstyles*surfsize] samples
231 int contents; // OR of all brushes
232 int visofs; // -1 = no visibility info
234 short mins[3]; // for frustum culling
237 unsigned short firstleafface;
238 unsigned short numleaffaces;
240 unsigned short firstleafbrush;
241 unsigned short numleafbrushes;
247 unsigned short planenum; // facing out of the leaf
267 //============================================================================
272 #define ANGLE_DOWN -2
275 // the utilities get to be lazy and just use large static arrays
277 extern int nummodels;
278 extern dmodel_t dmodels[MAX_MAP_MODELS];
280 extern int visdatasize;
281 extern byte dvisdata[MAX_MAP_VISIBILITY];
283 extern int lightdatasize;
284 extern byte dlightdata[MAX_MAP_LIGHTING];
286 extern int texdatasize;
287 extern byte dtexdata[MAX_MAP_MIPTEX]; // (dmiptexlump_t)
289 extern int entdatasize;
290 extern char dentdata[MAX_MAP_ENTSTRING];
293 extern dleaf_t dleafs[MAX_MAP_LEAFS];
295 extern int numplanes;
296 extern dplane_t dplanes[MAX_MAP_PLANES];
298 extern int numvertexes;
299 extern dvertex_t dvertexes[MAX_MAP_VERTS];
302 extern dnode_t dnodes[MAX_MAP_NODES];
304 extern int numtexinfo;
305 extern texinfo_t texinfo[MAX_MAP_TEXINFO];
308 extern dface_t dfaces[MAX_MAP_FACES];
311 extern dedge_t dedges[MAX_MAP_EDGES];
313 extern int numleaffaces;
314 extern unsigned short dleaffaces[MAX_MAP_LEAFFACES];
316 extern int numleafbrushes;
317 extern unsigned short dleafbrushes[MAX_MAP_LEAFBRUSHES];
319 extern int numsurfedges;
320 extern int dsurfedges[MAX_MAP_SURFEDGES];
323 extern dpath_t dpaths[MAX_MAP_PATHS];
325 extern int numbrushes;
326 extern dbrush_t dbrushes[MAX_MAP_BRUSHES];
328 extern int numbrushsides;
329 extern dbrushside_t dbrushsides[MAX_MAP_BRUSHSIDES];
332 void DecompressVis (byte *in, byte *decompressed);
333 int CompressVis (byte *vis, byte *dest);
335 void LoadBSPFile (char *filename);
336 void WriteBSPFile (char *filename);
337 void PrintBSPFileSizes (void);
342 typedef struct epair_s
344 struct epair_s *next;
357 extern int num_entities;
358 extern entity_t entities[MAX_MAP_ENTITIES];
360 void ParseEntities (void);
361 void UnparseEntities (void);
363 void SetKeyValue (entity_t *ent, char *key, char *value);
364 char *ValueForKey (entity_t *ent, char *key);
365 // will return "" if not present
367 vec_t FloatForKey (entity_t *ent, char *key);
368 void GetVectorForKey (entity_t *ent, char *key, vec3_t vec);
370 epair_t *ParseEpair (void);
372 void PrintEntity (entity_t *ent);
374 extern int r_leaftovis[MAX_MAP_LEAFS];
375 extern int r_vistoleaf[MAX_MAP_LEAFS];
376 extern int r_numvisleafs;