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 ===========================================================================
24 // qfiles.h: quake file formats
25 // This file must be identical in the quake and utils directories
29 ========================================================================
31 .MD2 triangle model file format
33 ========================================================================
36 #define IDALIASHEADER (('2'<<24)+('P'<<16)+('D'<<8)+'I')
37 #define ALIAS_VERSION 8
39 #define MAX_TRIANGLES 4096
40 #define MAX_VERTS 2048
41 #define MAX_FRAMES 512
42 #define MAX_MD2SKINS 32
43 #define MAX_SKINNAME 64
59 byte v[3]; // scaled byte to fit in frame mins/maxs
60 byte lightnormalindex;
65 float scale[3]; // multiply byte verts by this
66 float translate[3]; // then add this
67 char name[16]; // frame name from grabbing
68 dtrivertx_t verts[1]; // variable sized
73 // a positive integer starts a tristrip command, followed by that many
75 // a negative integer starts a trifan command, followed by -x vertexes
76 // a zero indicates the end of the command list.
77 // a vertex consists of a floating point s, a floating point t,
78 // and an integer vertex index.
88 int framesize; // byte size of each frame
92 int num_st; // greater than num_xyz for seams
94 int num_glcmds; // dwords in strip/fan command list
97 int ofs_skins; // each skin is a MAX_SKINNAME string
98 int ofs_st; // byte offset from start for stverts
99 int ofs_tris; // offset for dtriangles
100 int ofs_frames; // offset for first frame
102 int ofs_end; // end of file
107 ========================================================================
109 .SP2 sprite file format
111 ========================================================================
114 #define IDSPRITEHEADER (('2'<<24)+('S'<<16)+('D'<<8)+'I')
115 // little-endian "IDS2"
116 #define SPRITE_VERSION 2
121 int origin_x, origin_y; // raster coordinates inside pic
122 char name[MAX_SKINNAME]; // name of pcx file
129 dsprframe_t frames[1]; // variable sized
133 ==============================================================================
135 .WAL texture file format
137 ==============================================================================
142 typedef struct miptex_s
145 unsigned width, height;
146 unsigned offsets[MIPLEVELS]; // four mip maps stored
147 char animname[32]; // next frame in animation chain
156 ==============================================================================
160 ==============================================================================
163 #define IDBSPHEADER (('P'<<24)+('S'<<16)+('B'<<8)+'I')
164 // little-endian "IBSP"
166 #define BSPVERSION 36
169 // upper design bounds
170 // leaffaces, leafbrushes, planes, and verts are still bounded by
171 // 16 bit short limits
172 #define MAX_MAP_MODELS 1024
173 #define MAX_MAP_BRUSHES 8192
174 #define MAX_MAP_ENTITIES 2048
175 #define MAX_MAP_ENTSTRING 0x20000
176 #define MAX_MAP_TEXINFO 8192
178 #define MAX_MAP_PLANES 65536
179 #define MAX_MAP_NODES 65536
180 #define MAX_MAP_BRUSHSIDES 65536
181 #define MAX_MAP_LEAFS 65536
182 #define MAX_MAP_VERTS 65536
183 #define MAX_MAP_FACES 65536
184 #define MAX_MAP_LEAFFACES 65536
185 #define MAX_MAP_LEAFBRUSHES 65536
186 #define MAX_MAP_PORTALS 65536
187 #define MAX_MAP_EDGES 128000
188 #define MAX_MAP_SURFEDGES 256000
189 #define MAX_MAP_LIGHTING 0x200000
190 #define MAX_MAP_VISIBILITY 0x100000
192 // key / value pair sizes
195 #define MAX_VALUE 1024
197 //=============================================================================
201 int fileofs, filelen;
204 #define LUMP_ENTITIES 0
205 #define LUMP_PLANES 1
206 #define LUMP_VERTEXES 2
207 #define LUMP_VISIBILITY 3
209 #define LUMP_TEXINFO 5
211 #define LUMP_LIGHTING 7
213 #define LUMP_LEAFFACES 9
214 #define LUMP_LEAFBRUSHES 10
215 #define LUMP_EDGES 11
216 #define LUMP_SURFEDGES 12
217 #define LUMP_MODELS 13
218 #define LUMP_BRUSHES 14
219 #define LUMP_BRUSHSIDES 15
222 #define HEADER_LUMPS 17
228 lump_t lumps[HEADER_LUMPS];
233 float mins[3], maxs[3];
234 float origin[3]; // for sounds or lights
236 int firstface, numfaces; // submodels just draw faces
237 // without walking the bsp tree
247 // 0-2 are axial planes
252 // 3-5 are non-axial planes snapped to the nearest
257 // planes (x&~1) and (x&~1)+1 are allways opposites
263 int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
267 // contents flags are seperate bits
268 // a given brush can contribute multiple content bits
269 // multiple brushes can be in a single leaf
271 // lower bits are stronger, and will eat weaker brushes completely
272 #define CONTENTS_SOLID 1 // an eye is never valid in a solid
273 #define CONTENTS_WINDOW 2 // translucent, but not watery
274 #define CONTENTS_AUX 4
275 #define CONTENTS_LAVA 8
276 #define CONTENTS_SLIME 16
277 #define CONTENTS_WATER 32
278 #define CONTENTS_MIST 64
279 #define LAST_VISIBLE_CONTENTS 64
281 // remaining contents are non-visible, and don't eat brushes
282 #define CONTENTS_PLAYERCLIP 0x10000
283 #define CONTENTS_MONSTERCLIP 0x20000
285 // currents can be added to any other contents, and may be mixed
286 #define CONTENTS_CURRENT_0 0x40000
287 #define CONTENTS_CURRENT_90 0x80000
288 #define CONTENTS_CURRENT_180 0x100000
289 #define CONTENTS_CURRENT_270 0x200000
290 #define CONTENTS_CURRENT_UP 0x400000
291 #define CONTENTS_CURRENT_DOWN 0x800000
293 #define CONTENTS_ORIGIN 0x1000000 // removed before bsping an entity
295 #define CONTENTS_MONSTER 0x2000000 // should never be on a brush, only in game
296 #define CONTENTS_DEADMONSTER 0x4000000
297 #define CONTENTS_DETAIL 0x8000000 // brushes to be added after vis leafs
298 #define CONTENTS_TRANSLUCENT 0x10000000 // auto set if any surface has trans
305 int children[2]; // negative numbers are -(leafs+1), not nodes
306 short mins[3]; // for frustom culling
308 unsigned short firstface;
309 unsigned short numfaces; // counting both sides
313 typedef struct texinfo_s
315 float vecs[2][4]; // [s/t][xyz offset]
316 int flags; // miptex flags + overrides
317 int value; // light emission, etc
318 char texture[32]; // texture name (textures/*.wal)
319 int nexttexinfo; // for animations, -1 = end of chain
323 #define SURF_LIGHT 0x1 // value will hold the light strength
325 #define SURF_SLICK 0x2 // effects game physics
327 #define SURF_SKY 0x4 // don't draw, but add to skybox
328 #define SURF_WARP 0x8 // turbulent water warp
329 #define SURF_TRANS33 0x10
330 #define SURF_TRANS66 0x20
331 #define SURF_FLOWING 0x40 // scroll towards angle
332 #define SURF_NODRAW 0x80 // don't bother referencing the texture
335 // note that edge 0 is never used, because negative edge nums are used for
336 // counterclockwise use of the edge in a face
339 unsigned short v[2]; // vertex numbers
342 #define MAXLIGHTMAPS 4
345 unsigned short planenum;
348 int firstedge; // we must support > 64k edges
353 byte styles[MAXLIGHTMAPS];
354 int lightofs; // start of [numstyles*surfsize] samples
359 int contents; // OR of all brushes (not needed?)
361 int pvsofs; // -1 = no info
362 int phsofs; // -1 = no info
364 short mins[3]; // for frustum culling
367 unsigned short firstleafface;
368 unsigned short numleaffaces;
370 unsigned short firstleafbrush;
371 unsigned short numleafbrushes;
376 unsigned short planenum; // facing out of the leaf
388 #define ANGLE_DOWN -2