]> icculus.org git repositories - divverent/darkplaces.git/blob - bspfile.h
Made gecko bindings a bit more chatty in developer mode.
[divverent/darkplaces.git] / bspfile.h
1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19 */
20
21
22 #define MAX_MAP_HULLS           16              // was 4
23 #define MAX_MAP_LEAFS           65536   // was 8192
24
25 // key / value pair sizes
26
27 #define MAX_KEY         32
28 #define MAX_VALUE       1024
29
30 //=============================================================================
31
32
33 #define BSPVERSION      29
34 #define MCBSPVERSION 2
35
36 typedef struct lump_s
37 {
38         int             fileofs, filelen;
39 } lump_t;
40
41 #define LUMP_ENTITIES   0
42 #define LUMP_PLANES             1
43 #define LUMP_TEXTURES   2
44 #define LUMP_VERTEXES   3
45 #define LUMP_VISIBILITY 4
46 #define LUMP_NODES              5
47 #define LUMP_TEXINFO    6
48 #define LUMP_FACES              7
49 #define LUMP_LIGHTING   8
50 #define LUMP_CLIPNODES  9
51 #define LUMP_LEAFS              10
52 #define LUMP_MARKSURFACES 11
53 #define LUMP_EDGES              12
54 #define LUMP_SURFEDGES  13
55 #define LUMP_MODELS             14
56 #define HEADER_LUMPS    15
57
58 typedef struct hullinfo_s
59 {
60         int                     numhulls;
61         int                     filehulls;
62         float           hullsizes[MAX_MAP_HULLS][2][3];
63 } hullinfo_t;
64
65 // WARNING: this struct does NOT match q1bsp's disk format because MAX_MAP_HULLS has been changed by Sajt's MCBSP code, this struct is only being used in memory as a result
66 typedef struct dmodel_s
67 {
68         float           mins[3], maxs[3];
69         float           origin[3];
70         int                     headnode[MAX_MAP_HULLS];
71         int                     visleafs;               // not including the solid leaf 0
72         int                     firstface, numfaces;
73 } dmodel_t;
74
75 typedef struct dheader_s
76 {
77         int                     version;
78         lump_t          lumps[HEADER_LUMPS];
79 } dheader_t;
80
81 typedef struct dmiptexlump_s
82 {
83         int                     nummiptex;
84         int                     dataofs[4];             // [nummiptex]
85 } dmiptexlump_t;
86
87 #define MIPLEVELS       4
88 typedef struct miptex_s
89 {
90         char            name[16];
91         unsigned        width, height;
92         unsigned        offsets[MIPLEVELS];             // four mip maps stored
93 } miptex_t;
94
95
96 typedef struct dvertex_s
97 {
98         float   point[3];
99 } dvertex_t;
100
101
102 // 0-2 are axial planes
103 #define PLANE_X                 0
104 #define PLANE_Y                 1
105 #define PLANE_Z                 2
106
107 // 3-5 are non-axial planes snapped to the nearest
108 #define PLANE_ANYX              3
109 #define PLANE_ANYY              4
110 #define PLANE_ANYZ              5
111
112 typedef struct dplane_s
113 {
114         float   normal[3];
115         float   dist;
116         int             type;           // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
117 } dplane_t;
118
119
120 // contents values in Q1 maps
121 #define CONTENTS_EMPTY                  -1
122 #define CONTENTS_SOLID                  -2
123 #define CONTENTS_WATER                  -3
124 #define CONTENTS_SLIME                  -4
125 #define CONTENTS_LAVA                           -5
126 #define CONTENTS_SKY                            -6
127 // these were #ifdef QUAKE2 in the quake source
128 #define CONTENTS_ORIGIN                 -7 // removed at csg time
129 #define CONTENTS_CLIP                           -8 // changed to contents_solid
130 #define CONTENTS_CURRENT_0              -9
131 #define CONTENTS_CURRENT_90             -10
132 #define CONTENTS_CURRENT_180            -11
133 #define CONTENTS_CURRENT_270            -12
134 #define CONTENTS_CURRENT_UP             -13
135 #define CONTENTS_CURRENT_DOWN           -14
136
137 //contents flags in Q2 maps
138 #define CONTENTSQ2_SOLID                        0x00000001 // an eye is never valid in a solid
139 #define CONTENTSQ2_WINDOW                       0x00000002 // translucent, but not watery
140 #define CONTENTSQ2_AUX                          0x00000004
141 #define CONTENTSQ2_LAVA                         0x00000008
142 #define CONTENTSQ2_SLIME                        0x00000010
143 #define CONTENTSQ2_WATER                        0x00000020
144 #define CONTENTSQ2_MIST                         0x00000040
145 #define CONTENTSQ2_AREAPORTAL           0x00008000
146 #define CONTENTSQ2_PLAYERCLIP           0x00010000
147 #define CONTENTSQ2_MONSTERCLIP          0x00020000
148 #define CONTENTSQ2_CURRENT_0            0x00040000
149 #define CONTENTSQ2_CURRENT_90           0x00080000
150 #define CONTENTSQ2_CURRENT_180          0x00100000
151 #define CONTENTSQ2_CURRENT_270          0x00200000
152 #define CONTENTSQ2_CURRENT_UP           0x00400000
153 #define CONTENTSQ2_CURRENT_DOWN         0x00800000
154 #define CONTENTSQ2_ORIGIN                       0x01000000 // removed before bsping an entity
155 #define CONTENTSQ2_MONSTER                      0x02000000 // should never be on a brush, only in game
156 #define CONTENTSQ2_DEADMONSTER          0x04000000
157 #define CONTENTSQ2_DETAIL                       0x08000000 // brushes to be added after vis leafs
158 #define CONTENTSQ2_TRANSLUCENT          0x10000000 // auto set if any surface has trans
159 #define CONTENTSQ2_LADDER                       0x20000000
160
161 //contents flags in Q3 maps
162 #define CONTENTSQ3_SOLID                        0x00000001 // solid (opaque and transparent)
163 #define CONTENTSQ3_LAVA                         0x00000008 // lava
164 #define CONTENTSQ3_SLIME                        0x00000010 // slime
165 #define CONTENTSQ3_WATER                        0x00000020 // water
166 #define CONTENTSQ3_FOG                          0x00000040 // unused?
167 #define CONTENTSQ3_AREAPORTAL           0x00008000 // areaportal (separates areas)
168 #define CONTENTSQ3_PLAYERCLIP           0x00010000 // block players
169 #define CONTENTSQ3_MONSTERCLIP          0x00020000 // block monsters
170 #define CONTENTSQ3_TELEPORTER           0x00040000 // hint for Q3's bots
171 #define CONTENTSQ3_JUMPPAD                      0x00080000 // hint for Q3's bots
172 #define CONTENTSQ3_CLUSTERPORTAL        0x00100000 // hint for Q3's bots
173 #define CONTENTSQ3_DONOTENTER           0x00200000 // hint for Q3's bots
174 #define CONTENTSQ3_ORIGIN                       0x01000000 // used by origin brushes to indicate origin of bmodel (removed by map compiler)
175 #define CONTENTSQ3_BODY                         0x02000000 // used by bbox entities (should never be on a brush)
176 #define CONTENTSQ3_CORPSE                       0x04000000 // used by dead bodies (SOLID_CORPSE in darkplaces)
177 #define CONTENTSQ3_DETAIL                       0x08000000 // brushes that do not split the bsp tree (decorations)
178 #define CONTENTSQ3_STRUCTURAL           0x10000000 // brushes that split the bsp tree
179 #define CONTENTSQ3_TRANSLUCENT          0x20000000 // leaves surfaces that are inside for rendering
180 #define CONTENTSQ3_TRIGGER                      0x40000000 // used by trigger entities
181 #define CONTENTSQ3_NODROP                       0x80000000 // remove items that fall into this brush
182
183 #define SUPERCONTENTS_SOLID                     0x00000001
184 #define SUPERCONTENTS_WATER                     0x00000002
185 #define SUPERCONTENTS_SLIME                     0x00000004
186 #define SUPERCONTENTS_LAVA                      0x00000008
187 #define SUPERCONTENTS_SKY                       0x00000010
188 #define SUPERCONTENTS_BODY                      0x00000020
189 #define SUPERCONTENTS_CORPSE            0x00000040
190 #define SUPERCONTENTS_NODROP            0x00000080
191 #define SUPERCONTENTS_PLAYERCLIP        0x00000100
192 #define SUPERCONTENTS_MONSTERCLIP       0x00000200
193 #define SUPERCONTENTS_DONOTENTER        0x00000400
194 #define SUPERCONTENTS_LIQUIDSMASK       (SUPERCONTENTS_LAVA | SUPERCONTENTS_SLIME | SUPERCONTENTS_WATER)
195
196 /*
197 #define SUPERCONTENTS_DEADMONSTER       0x00000000
198 #define SUPERCONTENTS_CURRENT_0         0x00000000
199 #define SUPERCONTENTS_CURRENT_90        0x00000000
200 #define SUPERCONTENTS_CURRENT_180       0x00000000
201 #define SUPERCONTENTS_CURRENT_270       0x00000000
202 #define SUPERCONTENTS_CURRENT_DOWN      0x00000000
203 #define SUPERCONTENTS_CURRENT_UP        0x00000000
204 #define SUPERCONTENTS_AREAPORTAL        0x00000000
205 #define SUPERCONTENTS_AUX                       0x00000000
206 #define SUPERCONTENTS_CLUSTERPORTAL     0x00000000
207 #define SUPERCONTENTS_DETAIL            0x00000000
208 #define SUPERCONTENTS_STRUCTURAL        0x00000000
209 #define SUPERCONTENTS_DONOTENTER        0x00000000
210 #define SUPERCONTENTS_JUMPPAD           0x00000000
211 #define SUPERCONTENTS_LADDER            0x00000000
212 #define SUPERCONTENTS_MONSTER           0x00000000
213 #define SUPERCONTENTS_MONSTERCLIP       0x00000000
214 #define SUPERCONTENTS_PLAYERCLIP        0x00000000
215 #define SUPERCONTENTS_TELEPORTER        0x00000000
216 #define SUPERCONTENTS_TRANSLUCENT       0x00000000
217 #define SUPERCONTENTS_TRIGGER           0x00000000
218 #define SUPERCONTENTS_WINDOW            0x00000000
219 */
220
221
222 typedef struct dnode_s
223 {
224         int                     planenum;
225         short           children[2];    // negative numbers are -(leafs+1), not nodes
226         short           mins[3];                // for sphere culling
227         short           maxs[3];
228         unsigned short  firstface;
229         unsigned short  numfaces;       // counting both sides
230 } dnode_t;
231
232 typedef struct dclipnode_s
233 {
234         int                     planenum;
235         short           children[2];    // negative numbers are contents
236 } dclipnode_t;
237
238
239 typedef struct texinfo_s
240 {
241         float           vecs[2][4];             // [s/t][xyz offset]
242         int                     miptex;
243         int                     flags;
244 } texinfo_t;
245 #define TEX_SPECIAL             1               // sky or slime, no lightmap or 256 subdivision
246
247 // note that edge 0 is never used, because negative edge nums are used for
248 // counterclockwise use of the edge in a face
249 typedef struct dedge_s
250 {
251         unsigned short  v[2];           // vertex numbers
252 } dedge_t;
253
254 #define MAXLIGHTMAPS    4
255 typedef struct dface_s
256 {
257         // LordHavoc: changed from short to unsigned short for q2 support
258         unsigned short  planenum;
259         short           side;
260
261         int                     firstedge;              // we must support > 64k edges
262         short           numedges;
263         short           texinfo;
264
265 // lighting info
266         unsigned char           styles[MAXLIGHTMAPS];
267         int                     lightofs;               // start of [numstyles*surfsize] samples
268 } dface_t;
269
270
271
272 #define AMBIENT_WATER   0
273 #define AMBIENT_SKY             1
274 #define AMBIENT_SLIME   2
275 #define AMBIENT_LAVA    3
276
277 #define NUM_AMBIENTS                    4               // automatic ambient sounds
278
279 // leaf 0 is the generic CONTENTS_SOLID leaf, used for all solid areas
280 // all other leafs need visibility info
281 typedef struct dleaf_s
282 {
283         int                     contents;
284         int                     visofs;                         // -1 = no visibility info
285
286         short           mins[3];                        // for frustum culling
287         short           maxs[3];
288
289         unsigned short          firstmarksurface;
290         unsigned short          nummarksurfaces;
291
292         unsigned char           ambient_level[NUM_AMBIENTS];
293 } dleaf_t;
294