2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 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 GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "q_typedef.h"
28 // qfiles.h: quake file formats
29 // This file must be identical in the quake and utils directories
33 ========================================================================
35 The .pak files are just a linear collapse of a directory tree
37 ========================================================================
40 #define IDPAKHEADER ( ( 'K' << 24 ) + ( 'C' << 16 ) + ( 'A' << 8 ) + 'P' )
50 int ident; // == IDPAKHEADER
55 #define MAX_FILES_IN_PACK 4096
59 ========================================================================
61 PCX files are used for as many images as possible
63 ========================================================================
72 unsigned short xmin,ymin,xmax,ymax;
73 unsigned short hres,vres;
74 unsigned char palette[48];
77 unsigned short bytes_per_line;
78 unsigned short palette_type;
80 unsigned char data; // unbounded
85 ========================================================================
87 .MD2 compressed triangle model file format
89 ========================================================================
91 #define IDJOINTEDALIASHEADER ( ( '2' << 24 ) + ( 'J' << 16 ) + ( 'D' << 8 ) + 'I' )
94 ========================================================================
96 .MD2 triangle model file format
98 ========================================================================
101 #define IDALIASHEADER ( ( '2' << 24 ) + ( 'P' << 16 ) + ( 'D' << 8 ) + 'I' )
102 #define ALIAS_VERSION 8
104 #define MAX_TRIANGLES 2048
105 #define MAX_VERTS 2048
106 #define MAX_FRAMES 512
107 #define MAX_MD2SKINS 64
108 #define MAX_SKINNAME 64
124 byte v[3]; // scaled byte to fit in frame mins/maxs
125 byte lightnormalindex;
128 #define DTRIVERTX_V0 0
129 #define DTRIVERTX_V1 1
130 #define DTRIVERTX_V2 2
131 #define DTRIVERTX_LNI 3
132 #define DTRIVERTX_SIZE 4
136 float scale[3]; // multiply byte verts by this
137 float translate[3]; // then add this
138 char name[16]; // frame name from grabbing
139 dtrivertx_t verts[1]; // variable sized
144 // a positive integer starts a tristrip command, followed by that many
145 // vertex structures.
146 // a negative integer starts a trifan command, followed by -x vertexes
147 // a zero indicates the end of the command list.
148 // a vertex consists of a floating point s, a floating point t,
149 // and an integer vertex index.
159 int framesize; // byte size of each frame
163 int num_st; // greater than num_xyz for seams
165 int num_glcmds; // dwords in strip/fan command list
168 int ofs_skins; // each skin is a MAX_SKINNAME string
169 int ofs_st; // byte offset from start for stverts
170 int ofs_tris; // offset for dtriangles
171 int ofs_frames; // offset for first frame
173 int ofs_end; // end of file
178 ========================================================================
182 ========================================================================
185 #define IDBOOKHEADER ( ( 'K' << 24 ) + ( 'O' << 16 ) + ( 'O' << 8 ) + 'B' )
186 #define BOOK_VERSION 2
188 typedef struct bookframe_s
194 char name[MAX_SKINNAME]; // name of gfx file
197 typedef struct bookheader_s
200 unsigned int version;
206 typedef struct book_s
208 bookheader_t bheader;
209 bookframe_t bframes[MAX_MD2SKINS];
213 ========================================================================
215 .SP2 sprite file format
217 ========================================================================
220 #define IDSPRITEHEADER ( ( '2' << 24 ) + ( 'S' << 16 ) + ( 'D' << 8 ) + 'I' )
221 // little-endian "IDS2"
222 #define SPRITE_VERSION 2
227 int origin_x, origin_y; // raster coordinates inside pic
228 char name[MAX_SKINNAME]; // name of pcx file
235 dsprframe_t frames[1]; // variable sized
239 ==============================================================================
241 .M8 texture file format
243 ==============================================================================
246 typedef struct palette_s
257 #define MIP_VERSION 2
261 typedef struct miptex_s
265 unsigned width[MIPLEVELS], height[MIPLEVELS];
266 unsigned offsets[MIPLEVELS]; // four mip maps stored
267 char animname[32]; // next frame in animation chain
268 palette_t palette[PAL_SIZE];
275 #define MIP32_VERSION 4
277 #define MIP32_NOMIP_FLAG2 0x00000001
278 #define MIP32_DETAILER_FLAG2 0x00000002
280 typedef struct miptex32_s
284 char altname[128]; // texture substitution
285 char animname[128]; // next frame in animation chain
286 char damagename[128]; // image that should be shown when damaged
287 unsigned width[MIPLEVELS], height[MIPLEVELS];
288 unsigned offsets[MIPLEVELS];
292 float scale_x, scale_y;
295 // detail texturing info
296 char dt_name[128]; // detailed texture name
297 float dt_scale_x, dt_scale_y;
300 int dt_src_blend_mode, dt_dst_blend_mode;
303 int unused[19]; // future expansion to maintain compatibility with h2
309 ==============================================================================
313 ==============================================================================
316 #define IDBSPHEADER ( ( 'P' << 24 ) + ( 'S' << 16 ) + ( 'B' << 8 ) + 'I' )
317 // little-endian "IBSP"
319 #define BSPVERSION 38
322 // upper design bounds
323 // leaffaces, leafbrushes, planes, and verts are still bounded by
324 // 16 bit short limits
325 #define MAX_MAP_MODELS 1024
326 #define MAX_MAP_BRUSHES 8192
327 #define MAX_MAP_ENTITIES 2048
328 #define MAX_MAP_ENTSTRING 0x40000
329 #define MAX_MAP_TEXINFO 8192
331 #define MAX_MAP_AREAS 256
332 #define MAX_MAP_AREAPORTALS 1024
333 #define MAX_MAP_PLANES 65536
334 #define MAX_MAP_NODES 65536
335 #define MAX_MAP_BRUSHSIDES 65536
336 #define MAX_MAP_LEAFS 65536
337 #define MAX_MAP_VERTS 65536
338 #define MAX_MAP_FACES 65536
339 #define MAX_MAP_LEAFFACES 65536
340 #define MAX_MAP_LEAFBRUSHES 65536
341 #define MAX_MAP_PORTALS 65536
342 #define MAX_MAP_EDGES 128000
343 #define MAX_MAP_SURFEDGES 256000
344 #define MAX_MAP_LIGHTING 0x200000
345 #define MAX_MAP_VISIBILITY 0x180000
347 // key / value pair sizes
350 #define MAX_VALUE 1024
352 //=============================================================================
356 int fileofs, filelen;
359 #define LUMP_ENTITIES 0
360 #define LUMP_PLANES 1
361 #define LUMP_VERTEXES 2
362 #define LUMP_VISIBILITY 3
364 #define LUMP_TEXINFO 5
366 #define LUMP_LIGHTING 7
368 #define LUMP_LEAFFACES 9
369 #define LUMP_LEAFBRUSHES 10
370 #define LUMP_EDGES 11
371 #define LUMP_SURFEDGES 12
372 #define LUMP_MODELS 13
373 #define LUMP_BRUSHES 14
374 #define LUMP_BRUSHSIDES 15
376 #define LUMP_AREAS 17
377 #define LUMP_AREAPORTALS 18
378 #define HEADER_LUMPS 19
384 lump_t lumps[HEADER_LUMPS];
389 float mins[3], maxs[3];
390 float origin[3]; // for sounds or lights
392 int firstface, numfaces; // submodels just draw faces
393 // without walking the bsp tree
403 // 0-2 are axial planes
408 // 3-5 are non-axial planes snapped to the nearest
413 // planes (x&~1) and (x&~1)+1 are allways opposites
419 int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
423 // contents flags are seperate bits
424 // a given brush can contribute multiple content bits
425 // multiple brushes can be in a single leaf
427 // these definitions also need to be in q_shared.h!
429 // lower bits are stronger, and will eat weaker brushes completely
430 #define CONTENTS_SOLID 0x00000001 // an eye is never valid in a solid
431 #define CONTENTS_WINDOW 0x00000002 // translucent, but not watery
432 #define CONTENTS_PUSHPULL 0x00000004
433 #define CONTENTS_LAVA 0x00000008
434 #define CONTENTS_SLIME 0x00000010
435 #define CONTENTS_WATER 0x00000020
436 #define CONTENTS_MIST 0x00000040 // 64
437 #define LAST_VISIBLE_CONTENTS 64 // this one worries me a bit JKH
439 // remaining contents are non-visible, and don't eat brushes
441 #define CONTENTS_AREAPORTAL 0x00008000
443 #define CONTENTS_PLAYERCLIP 0x00010000
444 #define CONTENTS_MONSTERCLIP 0x00020000
446 // currents can be added to any other contents, and may be mixed
447 #define CONTENTS_CURRENT_0 0x00040000
448 #define CONTENTS_CURRENT_90 0x00080000
449 #define CONTENTS_CURRENT_180 0x00100000
450 #define CONTENTS_CURRENT_270 0x00200000
451 #define CONTENTS_CURRENT_UP 0x00400000
452 #define CONTENTS_CURRENT_DOWN 0x00800000
454 #define CONTENTS_ORIGIN 0x01000000 // removed before bsping an entity
456 #define CONTENTS_MONSTER 0x02000000 // should never be on a brush, only in game
457 #define CONTENTS_DEADMONSTER 0x04000000
458 #define CONTENTS_DETAIL 0x08000000 // brushes to be added after vis leafs
459 #define CONTENTS_TRANSLUCENT 0x10000000 // auto set if any surface has trans
460 #define CONTENTS_LADDER 0x20000000
464 #define SURF_LIGHT 0x00000001 // value will hold the light strength
466 #define SURF_SLICK 0x00000002 // effects game physics
468 #define SURF_SKY 0x00000004 // don't draw, but add to skybox
469 #define SURF_WARP 0x00000008 // turbulent water warp
470 #define SURF_TRANS33 0x00000010
471 #define SURF_TRANS66 0x00000020
472 #define SURF_FLOWING 0x00000040 // scroll towards angle
473 #define SURF_NODRAW 0x00000080 // don't bother referencing the texture
475 #define SURF_HINT 0x00000100 // make a primary bsp splitter
476 #define SURF_SKIP 0x00000200 // completely ignore, allowing non-closed brushes
477 #define SURF_TALL_WALL 0x00000400 // face doesn't get broken up as normal
479 #define SURF_ALPHA_TEXTURE 0x00000800 // texture has alpha in it, and should show through in bsp process
480 #define SURF_ANIMSPEED 0x00001000 // value will hold the anim speed in fps
482 #define SURF_UNDULATE 0x00002000 // rock surface up and down...
483 #define SURF_SKYREFLECT 0x00004000 // liquid will somewhat reflect the sky - not quite finished....
485 #define SURF_TYPE_GRAVEL 0x00000000
486 #define SURF_TYPE_METAL 0x01000000
487 #define SURF_TYPE_STONE 0x02000000
488 #define SURF_TYPE_WOOD 0x03000000
489 #define SURF_MATERIAL 0xFF000000
496 int children[2]; // negative numbers are -(leafs+1), not nodes
497 short mins[3]; // for frustom culling
499 unsigned short firstface;
500 unsigned short numfaces; // counting both sides
504 typedef struct texinfo_s
506 float vecs[2][4]; // [s/t][xyz offset]
507 int flags; // miptex flags + overrides
508 int value; // light emission, etc
509 char texture[32]; // texture name (textures/*.wal)
510 int nexttexinfo; // for animations, -1 = end of chain
514 // note that edge 0 is never used, because negative edge nums are used for
515 // counterclockwise use of the edge in a face
518 unsigned short v[2]; // vertex numbers
521 #define MAXLIGHTMAPS 4
524 unsigned short planenum;
527 int firstedge; // we must support > 64k edges
533 byte styles[MAXLIGHTMAPS];
534 paletteRGBA_t lighting;
536 int lightofs; // start of [numstyles*surfsize] samples
541 int contents; // OR of all brushes (not needed?)
546 short mins[3]; // for frustum culling
549 unsigned short firstleafface;
550 unsigned short numleaffaces;
552 unsigned short firstleafbrush;
553 unsigned short numleafbrushes;
558 unsigned short planenum; // facing out of the leaf
570 #define ANGLE_DOWN -2
573 // the visibility lump consists of a header with a count, then
574 // byte offsets for the PVS and PHS of each cluster, then the raw
575 // compressed bit vectors
581 int bitofs[8][2]; // bitofs[numclusters][2]
584 // each area has a list of portals that lead into other areas
585 // when portals are closed, other areas may not be visible or
586 // hearable even if the vis info says that it should be
614 materialtype_t *materialtypes;
616 void QFile_ReadMaterialTypes( char* filename );