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 The .pak files are just a linear collapse of a directory tree
33 ========================================================================
36 #define IDPAKHEADER (('K'<<24)+('C'<<16)+('A'<<8)+'P')
46 int ident; // == IDPAKHEADER
51 #define MAX_FILES_IN_PACK 4096
55 ========================================================================
57 PCX files are used for as many images as possible
59 ========================================================================
68 unsigned short xmin,ymin,xmax,ymax;
69 unsigned short hres,vres;
70 unsigned char palette[48];
73 unsigned short bytes_per_line;
74 unsigned short palette_type;
76 unsigned char data; // unbounded
81 ========================================================================
83 .MD2 triangle model file format
85 ========================================================================
88 #define IDALIASHEADER (('2'<<24)+('P'<<16)+('D'<<8)+'I')
89 #define ALIAS_VERSION 8
91 #define MAX_TRIANGLES 4096
92 #define MAX_VERTS 2048
93 #define MAX_FRAMES 512
94 #define MAX_MD2SKINS 32
95 #define MAX_SKINNAME 64
111 byte v[3]; // scaled byte to fit in frame mins/maxs
112 byte lightnormalindex;
115 #define DTRIVERTX_V0 0
116 #define DTRIVERTX_V1 1
117 #define DTRIVERTX_V2 2
118 #define DTRIVERTX_LNI 3
119 #define DTRIVERTX_SIZE 4
123 float scale[3]; // multiply byte verts by this
124 float translate[3]; // then add this
125 char name[16]; // frame name from grabbing
126 dtrivertx_t verts[1]; // variable sized
131 // a positive integer starts a tristrip command, followed by that many
132 // vertex structures.
133 // a negative integer starts a trifan command, followed by -x vertexes
134 // a zero indicates the end of the command list.
135 // a vertex consists of a floating point s, a floating point t,
136 // and an integer vertex index.
146 int framesize; // byte size of each frame
150 int num_st; // greater than num_xyz for seams
152 int num_glcmds; // dwords in strip/fan command list
155 int ofs_skins; // each skin is a MAX_SKINNAME string
156 int ofs_st; // byte offset from start for stverts
157 int ofs_tris; // offset for dtriangles
158 int ofs_frames; // offset for first frame
160 int ofs_end; // end of file
165 ========================================================================
167 .SP2 sprite file format
169 ========================================================================
172 #define IDSPRITEHEADER (('2'<<24)+('S'<<16)+('D'<<8)+'I')
173 // little-endian "IDS2"
174 #define SPRITE_VERSION 2
179 int origin_x, origin_y; // raster coordinates inside pic
180 char name[MAX_SKINNAME]; // name of pcx file
187 dsprframe_t frames[1]; // variable sized
191 ==============================================================================
193 .WAL texture file format
195 ==============================================================================
200 typedef struct miptex_s
203 unsigned width, height;
204 unsigned offsets[MIPLEVELS]; // four mip maps stored
205 char animname[32]; // next frame in animation chain
214 ==============================================================================
218 ==============================================================================
221 #define IDBSPHEADER (('P'<<24)+('S'<<16)+('B'<<8)+'I')
222 // little-endian "IBSP"
224 #define BSPVERSION 38
227 // upper design bounds
228 // leaffaces, leafbrushes, planes, and verts are still bounded by
229 // 16 bit short limits
230 #define MAX_MAP_MODELS 1024
231 #define MAX_MAP_BRUSHES 8192
232 #define MAX_MAP_ENTITIES 2048
233 #define MAX_MAP_ENTSTRING 0x40000
234 #define MAX_MAP_TEXINFO 8192
236 #define MAX_MAP_AREAS 256
237 #define MAX_MAP_AREAPORTALS 1024
238 #define MAX_MAP_PLANES 65536
239 #define MAX_MAP_NODES 65536
240 #define MAX_MAP_BRUSHSIDES 65536
241 #define MAX_MAP_LEAFS 65536
242 #define MAX_MAP_VERTS 65536
243 #define MAX_MAP_FACES 65536
244 #define MAX_MAP_LEAFFACES 65536
245 #define MAX_MAP_LEAFBRUSHES 65536
246 #define MAX_MAP_PORTALS 65536
247 #define MAX_MAP_EDGES 128000
248 #define MAX_MAP_SURFEDGES 256000
249 #define MAX_MAP_LIGHTING 0x200000
250 #define MAX_MAP_VISIBILITY 0x100000
252 // key / value pair sizes
255 #define MAX_VALUE 1024
257 //=============================================================================
261 int fileofs, filelen;
264 #define LUMP_ENTITIES 0
265 #define LUMP_PLANES 1
266 #define LUMP_VERTEXES 2
267 #define LUMP_VISIBILITY 3
269 #define LUMP_TEXINFO 5
271 #define LUMP_LIGHTING 7
273 #define LUMP_LEAFFACES 9
274 #define LUMP_LEAFBRUSHES 10
275 #define LUMP_EDGES 11
276 #define LUMP_SURFEDGES 12
277 #define LUMP_MODELS 13
278 #define LUMP_BRUSHES 14
279 #define LUMP_BRUSHSIDES 15
281 #define LUMP_AREAS 17
282 #define LUMP_AREAPORTALS 18
283 #define HEADER_LUMPS 19
289 lump_t lumps[HEADER_LUMPS];
294 float mins[3], maxs[3];
295 float origin[3]; // for sounds or lights
297 int firstface, numfaces; // submodels just draw faces
298 // without walking the bsp tree
308 // 0-2 are axial planes
313 // 3-5 are non-axial planes snapped to the nearest
318 // planes (x&~1) and (x&~1)+1 are allways opposites
324 int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
328 // contents flags are seperate bits
329 // a given brush can contribute multiple content bits
330 // multiple brushes can be in a single leaf
332 // these definitions also need to be in q_shared.h!
334 // lower bits are stronger, and will eat weaker brushes completely
335 #define CONTENTS_SOLID 1 // an eye is never valid in a solid
336 #define CONTENTS_WINDOW 2 // translucent, but not watery
337 #define CONTENTS_AUX 4
338 #define CONTENTS_LAVA 8
339 #define CONTENTS_SLIME 16
340 #define CONTENTS_WATER 32
341 #define CONTENTS_MIST 64
342 #define LAST_VISIBLE_CONTENTS 64
344 // remaining contents are non-visible, and don't eat brushes
346 #define CONTENTS_AREAPORTAL 0x8000
348 #define CONTENTS_PLAYERCLIP 0x10000
349 #define CONTENTS_MONSTERCLIP 0x20000
351 // currents can be added to any other contents, and may be mixed
352 #define CONTENTS_CURRENT_0 0x40000
353 #define CONTENTS_CURRENT_90 0x80000
354 #define CONTENTS_CURRENT_180 0x100000
355 #define CONTENTS_CURRENT_270 0x200000
356 #define CONTENTS_CURRENT_UP 0x400000
357 #define CONTENTS_CURRENT_DOWN 0x800000
359 #define CONTENTS_ORIGIN 0x1000000 // removed before bsping an entity
361 #define CONTENTS_MONSTER 0x2000000 // should never be on a brush, only in game
362 #define CONTENTS_DEADMONSTER 0x4000000
363 #define CONTENTS_DETAIL 0x8000000 // brushes to be added after vis leafs
364 #define CONTENTS_TRANSLUCENT 0x10000000 // auto set if any surface has trans
365 #define CONTENTS_LADDER 0x20000000
369 #define SURF_LIGHT 0x1 // value will hold the light strength
371 #define SURF_SLICK 0x2 // effects game physics
373 #define SURF_SKY 0x4 // don't draw, but add to skybox
374 #define SURF_WARP 0x8 // turbulent water warp
375 #define SURF_TRANS33 0x10
376 #define SURF_TRANS66 0x20
377 #define SURF_FLOWING 0x40 // scroll towards angle
378 #define SURF_NODRAW 0x80 // don't bother referencing the texture
380 #define SURF_HINT 0x100 // make a primary bsp splitter
381 #define SURF_SKIP 0x200 // completely ignore, allowing non-closed brushes
388 int children[2]; // negative numbers are -(leafs+1), not nodes
389 short mins[3]; // for frustom culling
391 unsigned short firstface;
392 unsigned short numfaces; // counting both sides
396 typedef struct texinfo_s
398 float vecs[2][4]; // [s/t][xyz offset]
399 int flags; // miptex flags + overrides
400 int value; // light emission, etc
401 char texture[32]; // texture name (textures/*.wal)
402 int nexttexinfo; // for animations, -1 = end of chain
406 // note that edge 0 is never used, because negative edge nums are used for
407 // counterclockwise use of the edge in a face
410 unsigned short v[2]; // vertex numbers
413 #define MAXLIGHTMAPS 4
416 unsigned short planenum;
419 int firstedge; // we must support > 64k edges
424 byte styles[MAXLIGHTMAPS];
425 int lightofs; // start of [numstyles*surfsize] samples
430 int contents; // OR of all brushes (not needed?)
435 short mins[3]; // for frustum culling
438 unsigned short firstleafface;
439 unsigned short numleaffaces;
441 unsigned short firstleafbrush;
442 unsigned short numleafbrushes;
447 unsigned short planenum; // facing out of the leaf
459 #define ANGLE_DOWN -2
462 // the visibility lump consists of a header with a count, then
463 // byte offsets for the PVS and PHS of each cluster, then the raw
464 // compressed bit vectors
470 int bitofs[8][2]; // bitofs[numclusters][2]
473 // each area has a list of portals that lead into other areas
474 // when portals are closed, other areas may not be visible or
475 // hearable even if the vis info says that it should be