]> git.xonotic.org Git - xonotic/darkplaces.git/blob - bspfile.h
model: Recognize Valve BSP format. Add file format headers.
[xonotic/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 #ifndef BSPFILE_H
22 #define BSPFILE_H
23
24 #define MAX_MAP_HULLS 16 // Q1BSP has 4, Hexen2 Q1BSP has 8, MCBSP has 16
25
26 //=============================================================================
27
28
29 #define BSPVERSION      29
30 #define HLBSPVERSION 30
31 #define _2PSBVERSION ('2' + 'P' * 256 + 'S' * 65536 + 'B' * 16777216)
32 #define BSP2VERSION ('B' + 'S' * 256 + 'P' * 65536 + '2' * 16777216)
33 #define VBSPVERSION ('V' + 'B' * 256 + 'S' * 65536 + 'P' * 16777216)
34
35 typedef struct lump_s
36 {
37         int             fileofs, filelen;
38 } lump_t;
39
40 #define LUMP_ENTITIES   0
41 #define LUMP_PLANES             1
42 #define LUMP_TEXTURES   2
43 #define LUMP_VERTEXES   3
44 #define LUMP_VISIBILITY 4
45 #define LUMP_NODES              5
46 #define LUMP_TEXINFO    6
47 #define LUMP_FACES              7
48 #define LUMP_LIGHTING   8
49 #define LUMP_CLIPNODES  9
50 #define LUMP_LEAFS              10
51 #define LUMP_MARKSURFACES 11
52 #define LUMP_EDGES              12
53 #define LUMP_SURFEDGES  13
54 #define LUMP_MODELS             14
55 #define HEADER_LUMPS    15
56
57 typedef struct hullinfo_s
58 {
59         int                     filehulls;
60         float           hullsizes[MAX_MAP_HULLS][2][3];
61 } hullinfo_t;
62
63 typedef struct mmodel_s
64 {
65         float           mins[3], maxs[3];
66         float           origin[3];
67         int                     headnode[MAX_MAP_HULLS];
68         int                     visleafs;               // not including the solid leaf 0
69         int                     firstface, numfaces;
70 } mmodel_t;
71
72 /*
73 // 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
74 typedef struct dmodel_s
75 {
76         float           mins[3], maxs[3];
77         float           origin[3];
78         int                     headnode[MAX_MAP_HULLS];
79         int                     visleafs;               // not including the solid leaf 0
80         int                     firstface, numfaces;
81 } dmodel_t;
82
83 typedef struct dheader_s
84 {
85         int                     version;
86         lump_t          lumps[HEADER_LUMPS];
87 } dheader_t;
88
89 typedef struct dmiptexlump_s
90 {
91         int                     nummiptex;
92         int                     dataofs[4];             // [nummiptex]
93 } dmiptexlump_t;
94 */
95
96 #define MIPLEVELS       4
97 /*
98 typedef struct miptex_s
99 {
100         char            name[16];
101         unsigned        width, height;
102         unsigned        offsets[MIPLEVELS];             // four mip maps stored
103 } miptex_t;
104
105
106 typedef struct dvertex_s
107 {
108         float   point[3];
109 } dvertex_t;
110 */
111
112
113 // 0-2 are axial planes
114 #define PLANE_X                 0
115 #define PLANE_Y                 1
116 #define PLANE_Z                 2
117
118 // 3-5 are non-axial planes snapped to the nearest
119 #define PLANE_ANYX              3
120 #define PLANE_ANYY              4
121 #define PLANE_ANYZ              5
122
123 /*
124 typedef struct dplane_s
125 {
126         float   normal[3];
127         float   dist;
128         int             type;           // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
129 } dplane_t;
130 */
131
132
133 // contents values in Q1 maps
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 // these were #ifdef QUAKE2 in the quake source
141 #define CONTENTS_ORIGIN                 -7 // removed at csg time
142 #define CONTENTS_CLIP                           -8 // changed to contents_solid
143 #define CONTENTS_CURRENT_0              -9
144 #define CONTENTS_CURRENT_90             -10
145 #define CONTENTS_CURRENT_180            -11
146 #define CONTENTS_CURRENT_270            -12
147 #define CONTENTS_CURRENT_UP             -13
148 #define CONTENTS_CURRENT_DOWN           -14
149
150 //contents flags in Q2 maps
151 #define CONTENTSQ2_SOLID                        0x00000001 // an eye is never valid in a solid
152 #define CONTENTSQ2_WINDOW                       0x00000002 // translucent, but not watery
153 #define CONTENTSQ2_AUX                          0x00000004
154 #define CONTENTSQ2_LAVA                         0x00000008
155 #define CONTENTSQ2_SLIME                        0x00000010
156 #define CONTENTSQ2_WATER                        0x00000020
157 #define CONTENTSQ2_MIST                         0x00000040
158 #define CONTENTSQ2_AREAPORTAL           0x00008000
159 #define CONTENTSQ2_PLAYERCLIP           0x00010000
160 #define CONTENTSQ2_MONSTERCLIP          0x00020000
161 #define CONTENTSQ2_CURRENT_0            0x00040000
162 #define CONTENTSQ2_CURRENT_90           0x00080000
163 #define CONTENTSQ2_CURRENT_180          0x00100000
164 #define CONTENTSQ2_CURRENT_270          0x00200000
165 #define CONTENTSQ2_CURRENT_UP           0x00400000
166 #define CONTENTSQ2_CURRENT_DOWN         0x00800000
167 #define CONTENTSQ2_ORIGIN                       0x01000000 // removed before bsping an entity
168 #define CONTENTSQ2_MONSTER                      0x02000000 // should never be on a brush, only in game
169 #define CONTENTSQ2_DEADMONSTER          0x04000000
170 #define CONTENTSQ2_DETAIL                       0x08000000 // brushes to be added after vis leafs
171 #define CONTENTSQ2_TRANSLUCENT          0x10000000 // auto set if any surface has trans
172 #define CONTENTSQ2_LADDER                       0x20000000
173
174 //contents flags in Q3 maps
175 #define CONTENTSQ3_SOLID                        0x00000001 // solid (opaque and transparent)
176 #define CONTENTSQ3_LAVA                         0x00000008 // lava
177 #define CONTENTSQ3_SLIME                        0x00000010 // slime
178 #define CONTENTSQ3_WATER                        0x00000020 // water
179 #define CONTENTSQ3_FOG                          0x00000040 // unused?
180 #define CONTENTSQ3_AREAPORTAL           0x00008000 // areaportal (separates areas)
181 #define CONTENTSQ3_PLAYERCLIP           0x00010000 // block players
182 #define CONTENTSQ3_MONSTERCLIP          0x00020000 // block monsters
183 #define CONTENTSQ3_TELEPORTER           0x00040000 // hint for Q3's bots
184 #define CONTENTSQ3_JUMPPAD                      0x00080000 // hint for Q3's bots
185 #define CONTENTSQ3_CLUSTERPORTAL        0x00100000 // hint for Q3's bots
186 #define CONTENTSQ3_DONOTENTER           0x00200000 // hint for Q3's bots
187 #define CONTENTSQ3_BOTCLIP                      0x00400000 // hint for Q3's bots
188 #define CONTENTSQ3_ORIGIN                       0x01000000 // used by origin brushes to indicate origin of bmodel (removed by map compiler)
189 #define CONTENTSQ3_BODY                         0x02000000 // used by bbox entities (should never be on a brush)
190 #define CONTENTSQ3_CORPSE                       0x04000000 // used by dead bodies (SOLID_CORPSE in darkplaces)
191 #define CONTENTSQ3_DETAIL                       0x08000000 // brushes that do not split the bsp tree (decorations)
192 #define CONTENTSQ3_STRUCTURAL           0x10000000 // brushes that split the bsp tree
193 #define CONTENTSQ3_TRANSLUCENT          0x20000000 // leaves surfaces that are inside for rendering
194 #define CONTENTSQ3_TRIGGER                      0x40000000 // used by trigger entities
195 #define CONTENTSQ3_NODROP                       0x80000000 // remove items that fall into this brush
196
197 #define SUPERCONTENTS_SOLID                     0x00000001
198 #define SUPERCONTENTS_WATER                     0x00000002
199 #define SUPERCONTENTS_SLIME                     0x00000004
200 #define SUPERCONTENTS_LAVA                      0x00000008
201 #define SUPERCONTENTS_SKY                       0x00000010
202 #define SUPERCONTENTS_BODY                      0x00000020
203 #define SUPERCONTENTS_CORPSE            0x00000040
204 #define SUPERCONTENTS_NODROP            0x00000080
205 #define SUPERCONTENTS_PLAYERCLIP        0x00000100
206 #define SUPERCONTENTS_MONSTERCLIP       0x00000200
207 #define SUPERCONTENTS_DONOTENTER        0x00000400
208 #define SUPERCONTENTS_BOTCLIP           0x00000800
209 #define SUPERCONTENTS_OPAQUE            0x00001000
210 // TODO: is there any reason to define:
211 //   fog?
212 //   areaportal?
213 //   teleporter?
214 //   jumppad?
215 //   clusterportal?
216 //   detail?         (div0) no, game code should not be allowed to differentiate between structural and detail
217 //   structural?     (div0) no, game code should not be allowed to differentiate between structural and detail
218 //   trigger?        (div0) no, as these are always solid anyway, and that's all that matters for trigger brushes
219 #define SUPERCONTENTS_LIQUIDSMASK       (SUPERCONTENTS_LAVA | SUPERCONTENTS_SLIME | SUPERCONTENTS_WATER)
220 #define SUPERCONTENTS_VISBLOCKERMASK    SUPERCONTENTS_OPAQUE
221
222 /*
223 #define SUPERCONTENTS_DEADMONSTER       0x00000000
224 #define SUPERCONTENTS_CURRENT_0         0x00000000
225 #define SUPERCONTENTS_CURRENT_90        0x00000000
226 #define SUPERCONTENTS_CURRENT_180       0x00000000
227 #define SUPERCONTENTS_CURRENT_270       0x00000000
228 #define SUPERCONTENTS_CURRENT_DOWN      0x00000000
229 #define SUPERCONTENTS_CURRENT_UP        0x00000000
230 #define SUPERCONTENTS_AREAPORTAL        0x00000000
231 #define SUPERCONTENTS_AUX                       0x00000000
232 #define SUPERCONTENTS_CLUSTERPORTAL     0x00000000
233 #define SUPERCONTENTS_DETAIL            0x00000000
234 #define SUPERCONTENTS_STRUCTURAL        0x00000000
235 #define SUPERCONTENTS_DONOTENTER        0x00000000
236 #define SUPERCONTENTS_JUMPPAD           0x00000000
237 #define SUPERCONTENTS_LADDER            0x00000000
238 #define SUPERCONTENTS_MONSTER           0x00000000
239 #define SUPERCONTENTS_MONSTERCLIP       0x00000000
240 #define SUPERCONTENTS_PLAYERCLIP        0x00000000
241 #define SUPERCONTENTS_TELEPORTER        0x00000000
242 #define SUPERCONTENTS_TRANSLUCENT       0x00000000
243 #define SUPERCONTENTS_TRIGGER           0x00000000
244 #define SUPERCONTENTS_WINDOW            0x00000000
245 */
246
247 /*
248 typedef struct dnode_s
249 {
250         int                     planenum;
251         short           children[2];    // negative numbers are -(leafs+1), not nodes
252         short           mins[3];                // for sphere culling
253         short           maxs[3];
254         unsigned short  firstface;
255         unsigned short  numfaces;       // counting both sides
256 } dnode_t;
257
258 typedef struct dclipnode_s
259 {
260         int                     planenum;
261         short           children[2];    // negative numbers are contents
262 } dclipnode_t;
263
264
265 typedef struct texinfo_s
266 {
267         float           vecs[2][4];             // [s/t][xyz offset]
268         int                     miptex;
269         int                     flags;
270 } texinfo_t;
271 */
272 #define TEX_SPECIAL             1               // sky or slime, no lightmap or 256 subdivision
273
274 // note that edge 0 is never used, because negative edge nums are used for
275 // counterclockwise use of the edge in a face
276 /*
277 typedef struct dedge_s
278 {
279         unsigned short  v[2];           // vertex numbers
280 } dedge_t;
281 */
282
283 #define MAXLIGHTMAPS    4
284 /*
285 typedef struct dface_s
286 {
287         // LadyHavoc: changed from short to unsigned short for q2 support
288         unsigned short  planenum;
289         short           side;
290
291         int                     firstedge;              // we must support > 64k edges
292         short           numedges;
293         short           texinfo;
294
295 // lighting info
296         unsigned char           styles[MAXLIGHTMAPS];
297         int                     lightofs;               // start of [numstyles*surfsize] samples
298 } dface_t;
299 */
300
301
302
303 #define AMBIENT_WATER   0
304 #define AMBIENT_SKY             1
305 #define AMBIENT_SLIME   2
306 #define AMBIENT_LAVA    3
307
308 #define NUM_AMBIENTS                    4               // automatic ambient sounds
309
310 // leaf 0 is the generic CONTENTS_SOLID leaf, used for all solid areas
311 // all other leafs need visibility info
312 /*
313 typedef struct dleaf_s
314 {
315         int                     contents;
316         int                     visofs;                         // -1 = no visibility info
317
318         short           mins[3];                        // for frustum culling
319         short           maxs[3];
320
321         unsigned short          firstmarksurface;
322         unsigned short          nummarksurfaces;
323
324         unsigned char           ambient_level[NUM_AMBIENTS];
325 } dleaf_t;
326 */
327
328 #endif