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
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 6144
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
80 ========================================================================
82 .MD2 compressed triangle model file format
84 ========================================================================
86 #define IDCOMPRESSEDALIASHEADER ( ( '2' << 24 ) + ( 'C' << 16 ) + ( 'D' << 8 ) + 'I' )
89 ========================================================================
91 .MD2 compressed triangle model file format
93 ========================================================================
95 #define IDJOINTEDALIASHEADER ( ( '2' << 24 ) + ( 'J' << 16 ) + ( 'D' << 8 ) + 'I' )
98 ========================================================================
100 .MD2 triangle model file format
102 ========================================================================
105 #define IDALIASHEADER ( ( '2' << 24 ) + ( 'P' << 16 ) + ( 'D' << 8 ) + 'I' )
106 #define ALIAS_VERSION 8
108 #define MAX_TRIANGLES 4096
109 #define MAX_VERTS 2048
110 #define MAX_FRAMES 512
111 #define MAX_MD2SKINS 64
112 #define MAX_SKINNAME 64
132 byte v[3]; // scaled byte to fit in frame mins/maxs
133 byte lightnormalindex;
140 #define DTRIVERTX_V0 0
141 #define DTRIVERTX_V1 1
142 #define DTRIVERTX_V2 2
143 #define DTRIVERTX_LNI 3
144 #define DTRIVERTX_SIZE 4
148 float scale[3]; // multiply byte verts by this
149 float translate[3]; // then add this
150 char name[16]; // frame name from grabbing
151 dtrivertx_t verts[1]; // variable sized
156 // a positive integer starts a tristrip command, followed by that many
157 // vertex structures.
158 // a negative integer starts a trifan command, followed by -x vertexes
159 // a zero indicates the end of the command list.
160 // a vertex consists of a floating point s, a floating point t,
161 // and an integer vertex index.
171 int framesize; // byte size of each frame
175 int num_st; // greater than num_xyz for seams
177 int num_glcmds; // dwords in strip/fan command list
180 int ofs_skins; // each skin is a MAX_SKINNAME string
181 int ofs_st; // byte offset from start for stverts
182 int ofs_tris; // offset for dtriangles
183 int ofs_frames; // offset for first frame
185 int ofs_end; // end of file
190 typedef struct dcompmdl_s
193 short CompressedFrameSize;
196 float *translate; // then add this
197 float *scale; // multiply byte verts by this
208 dcompmdl_t compModInfo;
211 struct ModelSkeleton_s *skeletons;
215 ========================================================================
219 ========================================================================
222 #define IDBOOKHEADER ( ( 'K' << 24 ) + ( 'O' << 16 ) + ( 'O' << 8 ) + 'B' )
223 #define BOOK_VERSION 2
225 typedef struct bookframe_s
231 char name[MAX_SKINNAME]; // name of gfx file
234 typedef struct bookheader_s
237 unsigned int version;
243 typedef struct book_s
245 bookheader_t bheader;
246 bookframe_t bframes[MAX_MD2SKINS];
250 ========================================================================
252 .SP2 sprite file format
254 ========================================================================
257 #define IDSPRITEHEADER ( ( '2' << 24 ) + ( 'S' << 16 ) + ( 'D' << 8 ) + 'I' )
258 // little-endian "IDS2"
259 #define SPRITE_VERSION 2
264 int origin_x, origin_y; // raster coordinates inside pic
265 char name[MAX_SKINNAME]; // name of pcx file
272 dsprframe_t frames[1]; // variable sized
276 ==============================================================================
278 .M8 texture file format
280 ==============================================================================
283 typedef struct palette_s
294 #define MIP_VERSION 2
298 typedef struct miptex_s
302 unsigned width[MIPLEVELS], height[MIPLEVELS];
303 unsigned offsets[MIPLEVELS]; // four mip maps stored
304 char animname[32]; // next frame in animation chain
305 palette_t palette[PAL_SIZE];
313 #define MIP32_VERSION 4
315 typedef struct miptex32_s
319 char altname[128]; // texture substitution
320 char animname[128]; // next frame in animation chain
321 char damagename[128]; // image that should be shown when damaged
322 unsigned width[MIPLEVELS], height[MIPLEVELS];
323 unsigned offsets[MIPLEVELS];
327 float scale_x, scale_y;
330 // detail texturing info
331 char dt_name[128]; // detailed texture name
332 float dt_scale_x, dt_scale_y;
335 int dt_src_blend_mode, dt_dst_blend_mode;
337 int unused[20]; // future expansion to maintain compatibility with h2
342 ==============================================================================
346 ==============================================================================
349 #define IDBSPHEADER ( ( 'P' << 24 ) + ( 'S' << 16 ) + ( 'B' << 8 ) + 'I' )
350 // little-endian "IBSP"
352 #define BSPVERSION 38
355 // upper design bounds
356 // leaffaces, leafbrushes, planes, and verts are still bounded by
357 // 16 bit short limits
358 #define MAX_MAP_MODELS 1024
359 //#define MAX_MAP_BRUSHES 8192 // Quake 2 original
360 #define MAX_MAP_BRUSHES 10240
361 #define MAX_MAP_ENTITIES 2048
362 #define MAX_MAP_ENTSTRING 0x40000
363 #define MAX_MAP_TEXINFO 8192
365 #define MAX_MAP_AREAS 256
366 #define MAX_MAP_AREAPORTALS 1024
367 #define MAX_MAP_PLANES 65536
368 #define MAX_MAP_NODES 65536
369 #define MAX_MAP_BRUSHSIDES 65536
370 #define MAX_MAP_LEAFS 65536
371 #define MAX_MAP_VERTS 65536
372 #define MAX_MAP_FACES 65536
373 #define MAX_MAP_LEAFFACES 65536
374 #define MAX_MAP_LEAFBRUSHES 65536
375 #define MAX_MAP_PORTALS 65536
376 #define MAX_MAP_EDGES 128000
377 #define MAX_MAP_SURFEDGES 256000
378 #define MAX_MAP_LIGHTING 0x200000
379 #define MAX_MAP_VISIBILITY 0x180000
381 // key / value pair sizes
384 #define MAX_VALUE 1024
386 //=============================================================================
390 int fileofs, filelen;
393 #define LUMP_ENTITIES 0
394 #define LUMP_PLANES 1
395 #define LUMP_VERTEXES 2
396 #define LUMP_VISIBILITY 3
398 #define LUMP_TEXINFO 5
400 #define LUMP_LIGHTING 7
402 #define LUMP_LEAFFACES 9
403 #define LUMP_LEAFBRUSHES 10
404 #define LUMP_EDGES 11
405 #define LUMP_SURFEDGES 12
406 #define LUMP_MODELS 13
407 #define LUMP_BRUSHES 14
408 #define LUMP_BRUSHSIDES 15
410 #define LUMP_AREAS 17
411 #define LUMP_AREAPORTALS 18
412 #define HEADER_LUMPS 19
418 lump_t lumps[HEADER_LUMPS];
423 float mins[3], maxs[3];
424 float origin[3]; // for sounds or lights
426 int firstface, numfaces; // submodels just draw faces
427 // without walking the bsp tree
437 // 0-2 are axial planes
442 // 3-5 are non-axial planes snapped to the nearest
447 // planes (x&~1) and (x&~1)+1 are allways opposites
453 int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
457 // contents flags are seperate bits
458 // a given brush can contribute multiple content bits
459 // multiple brushes can be in a single leaf
461 // These definitions also need to be in q_shared.h!
463 // ************************************************************************************************
467 // ************************************************************************************************
469 // Lower bits are stronger, and will eat weaker brushes completely.
471 #define CONTENTS_SOLID 0x00000001 // An eye is never valid in a solid.
472 #define CONTENTS_WINDOW 0x00000002 // Translucent, but not watery.
473 #define CONTENTS_AUX 0x00000004
474 #define CONTENTS_LAVA 0x00000008
475 #define CONTENTS_SLIME 0x00000010
476 #define CONTENTS_WATER 0x00000020
477 #define CONTENTS_MIST 0x00000040
478 #define LAST_VISIBLE_CONTENTS CONTENTS_MIST
480 // Remaining contents are non-visible, and don't eat brushes.
482 #define CONTENTS_AREAPORTAL 0x00008000
483 #define CONTENTS_PLAYERCLIP 0x00010000
484 #define CONTENTS_MONSTERCLIP 0x00020000
486 // Currents can be added to any other contents, and may be mixed.
488 #define CONTENTS_CURRENT_0 0x00040000
489 #define CONTENTS_CURRENT_90 0x00080000
490 #define CONTENTS_CURRENT_180 0x00100000
491 #define CONTENTS_CURRENT_270 0x00200000
492 #define CONTENTS_CURRENT_UP 0x00400000
493 #define CONTENTS_CURRENT_DOWN 0x00800000
494 #define CONTENTS_ORIGIN 0x01000000 // Removed before bsping an entity.
495 #define CONTENTS_MONSTER 0x02000000 // Should never be on a brush, only in game.
496 #define CONTENTS_DEADMONSTER 0x04000000
497 #define CONTENTS_DETAIL 0x08000000 // Brushes to be added after vis leaves.
498 #define CONTENTS_TRANSLUCENT 0x10000000 // Auto set if any surface has transparency.
499 #define CONTENTS_LADDER 0x20000000
500 #define CONTENTS_CAMERANOBLOCK 0x40000000 // Camera LOS ignores any brushes with this flag.
505 int children[2]; // negative numbers are -(leafs+1), not nodes
506 short mins[3]; // for frustom culling
508 unsigned short firstface;
509 unsigned short numfaces; // counting both sides
513 typedef struct texinfo_s
515 float vecs[2][4]; // [s/t][xyz offset]
516 int flags; // miptex flags + overrides
517 int value; // light emission, etc
518 char texture[32]; // texture name (textures/*.wal)
519 int nexttexinfo; // for animations, -1 = end of chain
523 // note that edge 0 is never used, because negative edge nums are used for
524 // counterclockwise use of the edge in a face
527 unsigned short v[2]; // vertex numbers
530 #define MAXLIGHTMAPS 4
533 unsigned short planenum;
536 int firstedge; // we must support > 64k edges
541 byte styles[MAXLIGHTMAPS];
542 int lightofs; // start of [numstyles*surfsize] samples
547 int contents; // OR of all brushes (not needed?)
552 short mins[3]; // for frustum culling
555 unsigned short firstleafface;
556 unsigned short numleaffaces;
558 unsigned short firstleafbrush;
559 unsigned short numleafbrushes;
564 unsigned short planenum; // facing out of the leaf
576 #define ANGLE_DOWN -2
579 // the visibility lump consists of a header with a count, then
580 // byte offsets for the PVS and PHS of each cluster, then the raw
581 // compressed bit vectors
587 int bitofs[8][2]; // bitofs[numclusters][2]
590 // each area has a list of portals that lead into other areas
591 // when portals are closed, other areas may not be visible or
592 // hearable even if the vis info says that it should be