qfiles.h 15.3 KB
Newer Older
rpolzer's avatar
rpolzer committed
1
/*
2
   Copyright (C) 1999-2007 id Software, Inc. and contributors.
Rudolf Polzer's avatar
Rudolf Polzer committed
3
   For a list of contributors, see the accompanying CONTRIBUTORS file.
rpolzer's avatar
rpolzer committed
4

Rudolf Polzer's avatar
Rudolf Polzer committed
5
   This file is part of GtkRadiant.
rpolzer's avatar
rpolzer committed
6

Rudolf Polzer's avatar
Rudolf Polzer committed
7 8 9 10
   GtkRadiant is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
rpolzer's avatar
rpolzer committed
11

Rudolf Polzer's avatar
Rudolf Polzer committed
12 13 14 15
   GtkRadiant is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
rpolzer's avatar
rpolzer committed
16

Rudolf Polzer's avatar
Rudolf Polzer committed
17 18 19 20
   You should have received a copy of the GNU General Public License
   along with GtkRadiant; if not, write to the Free Software
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
rpolzer's avatar
rpolzer committed
21 22 23 24 25 26 27 28 29 30 31 32

#ifndef _QFILES_H
#define _QFILES_H

#include "q_typedef.h"

//
// qfiles.h: quake file formats
// This file must be identical in the quake and utils directories
//

/*
Rudolf Polzer's avatar
Rudolf Polzer committed
33
   ========================================================================
rpolzer's avatar
rpolzer committed
34

Rudolf Polzer's avatar
Rudolf Polzer committed
35
   The .pak files are just a linear collapse of a directory tree
rpolzer's avatar
rpolzer committed
36

Rudolf Polzer's avatar
Rudolf Polzer committed
37 38
   ========================================================================
 */
rpolzer's avatar
rpolzer committed
39

Rudolf Polzer's avatar
Rudolf Polzer committed
40
#define IDPAKHEADER     ( ( 'K' << 24 ) + ( 'C' << 16 ) + ( 'A' << 8 ) + 'P' )
rpolzer's avatar
rpolzer committed
41 42 43

typedef struct
{
Rudolf Polzer's avatar
Rudolf Polzer committed
44 45
	char name[56];
	int filepos, filelen;
rpolzer's avatar
rpolzer committed
46 47 48 49
} dpackfile_t;

typedef struct
{
Rudolf Polzer's avatar
Rudolf Polzer committed
50 51 52
	int ident;          // == IDPAKHEADER
	int dirofs;
	int dirlen;
rpolzer's avatar
rpolzer committed
53 54
} dpackheader_t;

Rudolf Polzer's avatar
Rudolf Polzer committed
55
#define MAX_FILES_IN_PACK   4096
rpolzer's avatar
rpolzer committed
56 57 58


/*
Rudolf Polzer's avatar
Rudolf Polzer committed
59
   ========================================================================
rpolzer's avatar
rpolzer committed
60

Rudolf Polzer's avatar
Rudolf Polzer committed
61
   PCX files are used for as many images as possible
rpolzer's avatar
rpolzer committed
62

Rudolf Polzer's avatar
Rudolf Polzer committed
63 64
   ========================================================================
 */
rpolzer's avatar
rpolzer committed
65 66 67

typedef struct
{
Rudolf Polzer's avatar
Rudolf Polzer committed
68 69 70 71 72 73 74 75 76 77 78 79 80
	char manufacturer;
	char version;
	char encoding;
	char bits_per_pixel;
	unsigned short xmin,ymin,xmax,ymax;
	unsigned short hres,vres;
	unsigned char palette[48];
	char reserved;
	char color_planes;
	unsigned short bytes_per_line;
	unsigned short palette_type;
	char filler[58];
	unsigned char data;             // unbounded
rpolzer's avatar
rpolzer committed
81 82 83 84
} pcx_t;


/*
Rudolf Polzer's avatar
Rudolf Polzer committed
85
   ========================================================================
rpolzer's avatar
rpolzer committed
86

Rudolf Polzer's avatar
Rudolf Polzer committed
87
   .MD2 compressed triangle model file format
rpolzer's avatar
rpolzer committed
88

Rudolf Polzer's avatar
Rudolf Polzer committed
89 90 91
   ========================================================================
 */
#define IDJOINTEDALIASHEADER    ( ( '2' << 24 ) + ( 'J' << 16 ) + ( 'D' << 8 ) + 'I' )
rpolzer's avatar
rpolzer committed
92 93

/*
Rudolf Polzer's avatar
Rudolf Polzer committed
94
   ========================================================================
rpolzer's avatar
rpolzer committed
95

Rudolf Polzer's avatar
Rudolf Polzer committed
96
   .MD2 triangle model file format
rpolzer's avatar
rpolzer committed
97

Rudolf Polzer's avatar
Rudolf Polzer committed
98 99
   ========================================================================
 */
rpolzer's avatar
rpolzer committed
100

Rudolf Polzer's avatar
Rudolf Polzer committed
101 102
#define IDALIASHEADER       ( ( '2' << 24 ) + ( 'P' << 16 ) + ( 'D' << 8 ) + 'I' )
#define ALIAS_VERSION   8
rpolzer's avatar
rpolzer committed
103

Rudolf Polzer's avatar
Rudolf Polzer committed
104 105 106 107 108
#define MAX_TRIANGLES   2048
#define MAX_VERTS       2048
#define MAX_FRAMES      512
#define MAX_MD2SKINS    64
#define MAX_SKINNAME    64
rpolzer's avatar
rpolzer committed
109 110 111

typedef struct
{
Rudolf Polzer's avatar
Rudolf Polzer committed
112 113
	short s;
	short t;
rpolzer's avatar
rpolzer committed
114 115
} dstvert_t;

Rudolf Polzer's avatar
Rudolf Polzer committed
116
typedef struct
rpolzer's avatar
rpolzer committed
117
{
Rudolf Polzer's avatar
Rudolf Polzer committed
118 119
	short index_xyz[3];
	short index_st[3];
rpolzer's avatar
rpolzer committed
120 121 122 123
} dtriangle_t;

typedef struct
{
Rudolf Polzer's avatar
Rudolf Polzer committed
124 125
	byte v[3];              // scaled byte to fit in frame mins/maxs
	byte lightnormalindex;
rpolzer's avatar
rpolzer committed
126 127 128 129 130 131 132 133 134 135
} dtrivertx_t;

#define DTRIVERTX_V0   0
#define DTRIVERTX_V1   1
#define DTRIVERTX_V2   2
#define DTRIVERTX_LNI  3
#define DTRIVERTX_SIZE 4

typedef struct
{
Rudolf Polzer's avatar
Rudolf Polzer committed
136 137 138 139
	float scale[3];         // multiply byte verts by this
	float translate[3];         // then add this
	char name[16];          // frame name from grabbing
	dtrivertx_t verts[1];   // variable sized
rpolzer's avatar
rpolzer committed
140 141 142 143 144 145 146 147 148 149 150 151 152 153
} daliasframe_t;


// the glcmd format:
// a positive integer starts a tristrip command, followed by that many
// vertex structures.
// a negative integer starts a trifan command, followed by -x vertexes
// a zero indicates the end of the command list.
// a vertex consists of a floating point s, a floating point t,
// and an integer vertex index.


typedef struct
{
Rudolf Polzer's avatar
Rudolf Polzer committed
154 155
	int ident;
	int version;
rpolzer's avatar
rpolzer committed
156

Rudolf Polzer's avatar
Rudolf Polzer committed
157 158 159
	int skinwidth;
	int skinheight;
	int framesize;              // byte size of each frame
rpolzer's avatar
rpolzer committed
160

Rudolf Polzer's avatar
Rudolf Polzer committed
161 162 163 164 165 166
	int num_skins;
	int num_xyz;
	int num_st;                 // greater than num_xyz for seams
	int num_tris;
	int num_glcmds;             // dwords in strip/fan command list
	int num_frames;
rpolzer's avatar
rpolzer committed
167

Rudolf Polzer's avatar
Rudolf Polzer committed
168 169 170 171 172 173
	int ofs_skins;              // each skin is a MAX_SKINNAME string
	int ofs_st;                 // byte offset from start for stverts
	int ofs_tris;               // offset for dtriangles
	int ofs_frames;             // offset for first frame
	int ofs_glcmds;
	int ofs_end;                // end of file
rpolzer's avatar
rpolzer committed
174 175 176 177

} dmdl_t;

/*
Rudolf Polzer's avatar
Rudolf Polzer committed
178
   ========================================================================
rpolzer's avatar
rpolzer committed
179

Rudolf Polzer's avatar
Rudolf Polzer committed
180
   .BK file format
rpolzer's avatar
rpolzer committed
181

Rudolf Polzer's avatar
Rudolf Polzer committed
182 183
   ========================================================================
 */
rpolzer's avatar
rpolzer committed
184

Rudolf Polzer's avatar
Rudolf Polzer committed
185 186
#define IDBOOKHEADER    ( ( 'K' << 24 ) + ( 'O' << 16 ) + ( 'O' << 8 ) + 'B' )
#define BOOK_VERSION    2
rpolzer's avatar
rpolzer committed
187 188 189

typedef struct bookframe_s
{
Rudolf Polzer's avatar
Rudolf Polzer committed
190 191 192 193 194
	int x;
	int y;
	int w;
	int h;
	char name[MAX_SKINNAME];            // name of gfx file
rpolzer's avatar
rpolzer committed
195 196 197 198
} bookframe_t;

typedef struct bookheader_s
{
Rudolf Polzer's avatar
Rudolf Polzer committed
199 200 201 202 203
	unsigned int ident;
	unsigned int version;
	int num_segments;
	int total_w;
	int total_h;
rpolzer's avatar
rpolzer committed
204 205 206 207 208
} bookheader_t;

typedef struct book_s
{
	bookheader_t bheader;
Rudolf Polzer's avatar
Rudolf Polzer committed
209
	bookframe_t bframes[MAX_MD2SKINS];
rpolzer's avatar
rpolzer committed
210 211 212
} book_t;

/*
Rudolf Polzer's avatar
Rudolf Polzer committed
213
   ========================================================================
rpolzer's avatar
rpolzer committed
214

Rudolf Polzer's avatar
Rudolf Polzer committed
215
   .SP2 sprite file format
rpolzer's avatar
rpolzer committed
216

Rudolf Polzer's avatar
Rudolf Polzer committed
217 218
   ========================================================================
 */
rpolzer's avatar
rpolzer committed
219

Rudolf Polzer's avatar
Rudolf Polzer committed
220 221 222
#define IDSPRITEHEADER  ( ( '2' << 24 ) + ( 'S' << 16 ) + ( 'D' << 8 ) + 'I' )
// little-endian "IDS2"
#define SPRITE_VERSION  2
rpolzer's avatar
rpolzer committed
223 224 225

typedef struct
{
Rudolf Polzer's avatar
Rudolf Polzer committed
226 227 228
	int width, height;
	int origin_x, origin_y;         // raster coordinates inside pic
	char name[MAX_SKINNAME];        // name of pcx file
rpolzer's avatar
rpolzer committed
229 230 231
} dsprframe_t;

typedef struct {
Rudolf Polzer's avatar
Rudolf Polzer committed
232 233 234 235
	int ident;
	int version;
	int numframes;
	dsprframe_t frames[1];          // variable sized
rpolzer's avatar
rpolzer committed
236 237 238
} dsprite_t;

/*
Rudolf Polzer's avatar
Rudolf Polzer committed
239
   ==============================================================================
rpolzer's avatar
rpolzer committed
240

Rudolf Polzer's avatar
Rudolf Polzer committed
241
   .M8 texture file format
rpolzer's avatar
rpolzer committed
242

Rudolf Polzer's avatar
Rudolf Polzer committed
243 244
   ==============================================================================
 */
rpolzer's avatar
rpolzer committed
245 246 247 248 249 250 251 252 253 254 255 256

typedef struct palette_s
{
	union
	{
		struct
		{
			byte r,g,b;
		};
	};
} palette_t;

Rudolf Polzer's avatar
Rudolf Polzer committed
257 258 259
#define MIP_VERSION     2
#define PAL_SIZE        256
#define MIPLEVELS       16
rpolzer's avatar
rpolzer committed
260 261 262

typedef struct miptex_s
{
Rudolf Polzer's avatar
Rudolf Polzer committed
263 264 265 266 267 268 269 270 271
	int version;
	char name[32];
	unsigned width[MIPLEVELS], height[MIPLEVELS];
	unsigned offsets[MIPLEVELS];        // four mip maps stored
	char animname[32];                  // next frame in animation chain
	palette_t palette[PAL_SIZE];
	int flags;
	int contents;
	int value;
rpolzer's avatar
rpolzer committed
272 273 274
} miptex_t;


Rudolf Polzer's avatar
Rudolf Polzer committed
275
#define MIP32_VERSION   4
rpolzer's avatar
rpolzer committed
276

Rudolf Polzer's avatar
Rudolf Polzer committed
277 278
#define MIP32_NOMIP_FLAG2           0x00000001
#define MIP32_DETAILER_FLAG2        0x00000002
rpolzer's avatar
rpolzer committed
279 280 281

typedef struct miptex32_s
{
Rudolf Polzer's avatar
Rudolf Polzer committed
282 283 284 285 286 287 288 289 290 291 292 293
	int version;
	char name[128];
	char altname[128];                  // texture substitution
	char animname[128];                 // next frame in animation chain
	char damagename[128];               // image that should be shown when damaged
	unsigned width[MIPLEVELS], height[MIPLEVELS];
	unsigned offsets[MIPLEVELS];
	int flags;
	int contents;
	int value;
	float scale_x, scale_y;
	int mip_scale;
rpolzer's avatar
rpolzer committed
294 295

	// detail texturing info
Rudolf Polzer's avatar
Rudolf Polzer committed
296 297 298 299 300 301 302 303
	char dt_name[128];              // detailed texture name
	float dt_scale_x, dt_scale_y;
	float dt_u, dt_v;
	float dt_alpha;
	int dt_src_blend_mode, dt_dst_blend_mode;

	int flags2;
	int unused[19];                     // future expansion to maintain compatibility with h2
rpolzer's avatar
rpolzer committed
304 305 306 307 308
} miptex32_t;



/*
Rudolf Polzer's avatar
Rudolf Polzer committed
309
   ==============================================================================
rpolzer's avatar
rpolzer committed
310

Rudolf Polzer's avatar
Rudolf Polzer committed
311
   .BSP file format
rpolzer's avatar
rpolzer committed
312

Rudolf Polzer's avatar
Rudolf Polzer committed
313 314
   ==============================================================================
 */
rpolzer's avatar
rpolzer committed
315

Rudolf Polzer's avatar
Rudolf Polzer committed
316 317
#define IDBSPHEADER ( ( 'P' << 24 ) + ( 'S' << 16 ) + ( 'B' << 8 ) + 'I' )
// little-endian "IBSP"
rpolzer's avatar
rpolzer committed
318

Rudolf Polzer's avatar
Rudolf Polzer committed
319
#define BSPVERSION  38
rpolzer's avatar
rpolzer committed
320 321 322 323 324


// upper design bounds
// leaffaces, leafbrushes, planes, and verts are still bounded by
// 16 bit short limits
Rudolf Polzer's avatar
Rudolf Polzer committed
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345
#define MAX_MAP_MODELS      1024
#define MAX_MAP_BRUSHES     8192
#define MAX_MAP_ENTITIES    2048
#define MAX_MAP_ENTSTRING   0x40000
#define MAX_MAP_TEXINFO     8192

#define MAX_MAP_AREAS       256
#define MAX_MAP_AREAPORTALS 1024
#define MAX_MAP_PLANES      65536
#define MAX_MAP_NODES       65536
#define MAX_MAP_BRUSHSIDES  65536
#define MAX_MAP_LEAFS       65536
#define MAX_MAP_VERTS       65536
#define MAX_MAP_FACES       65536
#define MAX_MAP_LEAFFACES   65536
#define MAX_MAP_LEAFBRUSHES 65536
#define MAX_MAP_PORTALS     65536
#define MAX_MAP_EDGES       128000
#define MAX_MAP_SURFEDGES   256000
#define MAX_MAP_LIGHTING    0x200000
#define MAX_MAP_VISIBILITY  0x180000
rpolzer's avatar
rpolzer committed
346 347 348

// key / value pair sizes

Rudolf Polzer's avatar
Rudolf Polzer committed
349 350
#define MAX_KEY     32
#define MAX_VALUE   1024
rpolzer's avatar
rpolzer committed
351 352 353 354 355

//=============================================================================

typedef struct
{
Rudolf Polzer's avatar
Rudolf Polzer committed
356
	int fileofs, filelen;
rpolzer's avatar
rpolzer committed
357 358
} lump_t;

Rudolf Polzer's avatar
Rudolf Polzer committed
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378
#define LUMP_ENTITIES       0
#define LUMP_PLANES         1
#define LUMP_VERTEXES       2
#define LUMP_VISIBILITY     3
#define LUMP_NODES          4
#define LUMP_TEXINFO        5
#define LUMP_FACES          6
#define LUMP_LIGHTING       7
#define LUMP_LEAFS          8
#define LUMP_LEAFFACES      9
#define LUMP_LEAFBRUSHES    10
#define LUMP_EDGES          11
#define LUMP_SURFEDGES      12
#define LUMP_MODELS         13
#define LUMP_BRUSHES        14
#define LUMP_BRUSHSIDES     15
#define LUMP_POP            16
#define LUMP_AREAS          17
#define LUMP_AREAPORTALS    18
#define HEADER_LUMPS        19
rpolzer's avatar
rpolzer committed
379 380 381

typedef struct
{
Rudolf Polzer's avatar
Rudolf Polzer committed
382 383 384
	int ident;
	int version;
	lump_t lumps[HEADER_LUMPS];
rpolzer's avatar
rpolzer committed
385 386 387 388
} dheader_t;

typedef struct
{
Rudolf Polzer's avatar
Rudolf Polzer committed
389 390 391 392 393
	float mins[3], maxs[3];
	float origin[3];            // for sounds or lights
	int headnode;
	int firstface, numfaces;            // submodels just draw faces
	                                    // without walking the bsp tree
rpolzer's avatar
rpolzer committed
394 395 396 397 398
} dmodel_t;


typedef struct
{
Rudolf Polzer's avatar
Rudolf Polzer committed
399
	float point[3];
rpolzer's avatar
rpolzer committed
400 401 402 403
} dvertex_t;


// 0-2 are axial planes
Rudolf Polzer's avatar
Rudolf Polzer committed
404 405 406
#define PLANE_X         0
#define PLANE_Y         1
#define PLANE_Z         2
rpolzer's avatar
rpolzer committed
407 408

// 3-5 are non-axial planes snapped to the nearest
Rudolf Polzer's avatar
Rudolf Polzer committed
409 410 411
#define PLANE_ANYX      3
#define PLANE_ANYY      4
#define PLANE_ANYZ      5
rpolzer's avatar
rpolzer committed
412 413 414 415 416

// planes (x&~1) and (x&~1)+1 are allways opposites

typedef struct
{
Rudolf Polzer's avatar
Rudolf Polzer committed
417 418 419
	float normal[3];
	float dist;
	int type;           // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
rpolzer's avatar
rpolzer committed
420 421 422 423 424 425 426 427 428 429
} dplane_t;


// contents flags are seperate bits
// a given brush can contribute multiple content bits
// multiple brushes can be in a single leaf

// these definitions also need to be in q_shared.h!

// lower bits are stronger, and will eat weaker brushes completely
Rudolf Polzer's avatar
Rudolf Polzer committed
430 431 432 433 434 435 436 437
#define CONTENTS_SOLID          0x00000001      // an eye is never valid in a solid
#define CONTENTS_WINDOW         0x00000002      // translucent, but not watery
#define CONTENTS_PUSHPULL       0x00000004
#define CONTENTS_LAVA           0x00000008
#define CONTENTS_SLIME          0x00000010
#define CONTENTS_WATER          0x00000020
#define CONTENTS_MIST           0x00000040      // 64
#define LAST_VISIBLE_CONTENTS   64              // this one worries me a bit JKH
rpolzer's avatar
rpolzer committed
438 439 440

// remaining contents are non-visible, and don't eat brushes

Rudolf Polzer's avatar
Rudolf Polzer committed
441
#define CONTENTS_AREAPORTAL     0x00008000
rpolzer's avatar
rpolzer committed
442

Rudolf Polzer's avatar
Rudolf Polzer committed
443 444
#define CONTENTS_PLAYERCLIP     0x00010000
#define CONTENTS_MONSTERCLIP    0x00020000
rpolzer's avatar
rpolzer committed
445 446

// currents can be added to any other contents, and may be mixed
Rudolf Polzer's avatar
Rudolf Polzer committed
447 448 449 450 451 452
#define CONTENTS_CURRENT_0      0x00040000
#define CONTENTS_CURRENT_90     0x00080000
#define CONTENTS_CURRENT_180    0x00100000
#define CONTENTS_CURRENT_270    0x00200000
#define CONTENTS_CURRENT_UP     0x00400000
#define CONTENTS_CURRENT_DOWN   0x00800000
rpolzer's avatar
rpolzer committed
453

Rudolf Polzer's avatar
Rudolf Polzer committed
454
#define CONTENTS_ORIGIN         0x01000000  // removed before bsping an entity
rpolzer's avatar
rpolzer committed
455

Rudolf Polzer's avatar
Rudolf Polzer committed
456 457 458 459 460
#define CONTENTS_MONSTER        0x02000000  // should never be on a brush, only in game
#define CONTENTS_DEADMONSTER    0x04000000
#define CONTENTS_DETAIL         0x08000000  // brushes to be added after vis leafs
#define CONTENTS_TRANSLUCENT    0x10000000  // auto set if any surface has trans
#define CONTENTS_LADDER         0x20000000
rpolzer's avatar
rpolzer committed
461 462 463



Rudolf Polzer's avatar
Rudolf Polzer committed
464
#define SURF_LIGHT              0x00000001      // value will hold the light strength
rpolzer's avatar
rpolzer committed
465

Rudolf Polzer's avatar
Rudolf Polzer committed
466
#define SURF_SLICK              0x00000002      // effects game physics
rpolzer's avatar
rpolzer committed
467

Rudolf Polzer's avatar
Rudolf Polzer committed
468 469 470 471 472 473
#define SURF_SKY                0x00000004      // don't draw, but add to skybox
#define SURF_WARP               0x00000008      // turbulent water warp
#define SURF_TRANS33            0x00000010
#define SURF_TRANS66            0x00000020
#define SURF_FLOWING            0x00000040  // scroll towards angle
#define SURF_NODRAW             0x00000080  // don't bother referencing the texture
rpolzer's avatar
rpolzer committed
474

Rudolf Polzer's avatar
Rudolf Polzer committed
475 476 477
#define SURF_HINT               0x00000100  // make a primary bsp splitter
#define SURF_SKIP               0x00000200  // completely ignore, allowing non-closed brushes
#define SURF_TALL_WALL          0x00000400  // face doesn't get broken up as normal
rpolzer's avatar
rpolzer committed
478

Rudolf Polzer's avatar
Rudolf Polzer committed
479 480
#define SURF_ALPHA_TEXTURE      0x00000800  // texture has alpha in it, and should show through in bsp process
#define SURF_ANIMSPEED          0x00001000      // value will hold the anim speed in fps
rpolzer's avatar
rpolzer committed
481

Rudolf Polzer's avatar
Rudolf Polzer committed
482 483
#define SURF_UNDULATE           0x00002000  // rock surface up and down...
#define SURF_SKYREFLECT         0x00004000  // liquid will somewhat reflect the sky - not quite finished....
rpolzer's avatar
rpolzer committed
484

Rudolf Polzer's avatar
Rudolf Polzer committed
485 486 487 488 489
#define SURF_TYPE_GRAVEL        0x00000000
#define SURF_TYPE_METAL         0x01000000
#define SURF_TYPE_STONE         0x02000000
#define SURF_TYPE_WOOD          0x03000000
#define SURF_MATERIAL           0xFF000000
rpolzer's avatar
rpolzer committed
490 491 492 493 494



typedef struct
{
Rudolf Polzer's avatar
Rudolf Polzer committed
495 496 497 498 499 500
	int planenum;
	int children[2];            // negative numbers are -(leafs+1), not nodes
	short mins[3];              // for frustom culling
	short maxs[3];
	unsigned short firstface;
	unsigned short numfaces;    // counting both sides
rpolzer's avatar
rpolzer committed
501 502 503 504 505
} dnode_t;


typedef struct texinfo_s
{
Rudolf Polzer's avatar
Rudolf Polzer committed
506 507 508 509 510
	float vecs[2][4];           // [s/t][xyz offset]
	int flags;                  // miptex flags + overrides
	int value;                  // light emission, etc
	char texture[32];           // texture name (textures/*.wal)
	int nexttexinfo;            // for animations, -1 = end of chain
rpolzer's avatar
rpolzer committed
511 512 513 514 515 516 517
} texinfo_t;


// note that edge 0 is never used, because negative edge nums are used for
// counterclockwise use of the edge in a face
typedef struct
{
Rudolf Polzer's avatar
Rudolf Polzer committed
518
	unsigned short v[2];        // vertex numbers
rpolzer's avatar
rpolzer committed
519 520
} dedge_t;

Rudolf Polzer's avatar
Rudolf Polzer committed
521
#define MAXLIGHTMAPS    4
rpolzer's avatar
rpolzer committed
522 523
typedef struct
{
Rudolf Polzer's avatar
Rudolf Polzer committed
524 525
	unsigned short planenum;
	short side;
rpolzer's avatar
rpolzer committed
526

Rudolf Polzer's avatar
Rudolf Polzer committed
527 528 529
	int firstedge;              // we must support > 64k edges
	short numedges;
	short texinfo;
rpolzer's avatar
rpolzer committed
530 531 532

// lighting info
	union {
Rudolf Polzer's avatar
Rudolf Polzer committed
533 534
		byte styles[MAXLIGHTMAPS];
		paletteRGBA_t lighting;
rpolzer's avatar
rpolzer committed
535
	};
Rudolf Polzer's avatar
Rudolf Polzer committed
536
	int lightofs;               // start of [numstyles*surfsize] samples
rpolzer's avatar
rpolzer committed
537 538 539 540
} dface_t;

typedef struct
{
Rudolf Polzer's avatar
Rudolf Polzer committed
541
	int contents;                       // OR of all brushes (not needed?)
rpolzer's avatar
rpolzer committed
542

Rudolf Polzer's avatar
Rudolf Polzer committed
543 544
	short cluster;
	short area;
rpolzer's avatar
rpolzer committed
545

Rudolf Polzer's avatar
Rudolf Polzer committed
546 547
	short mins[3];                      // for frustum culling
	short maxs[3];
rpolzer's avatar
rpolzer committed
548

Rudolf Polzer's avatar
Rudolf Polzer committed
549 550
	unsigned short firstleafface;
	unsigned short numleaffaces;
rpolzer's avatar
rpolzer committed
551

Rudolf Polzer's avatar
Rudolf Polzer committed
552 553
	unsigned short firstleafbrush;
	unsigned short numleafbrushes;
rpolzer's avatar
rpolzer committed
554 555 556 557
} dleaf_t;

typedef struct
{
Rudolf Polzer's avatar
Rudolf Polzer committed
558 559
	unsigned short planenum;        // facing out of the leaf
	short texinfo;
rpolzer's avatar
rpolzer committed
560 561 562 563
} dbrushside_t;

typedef struct
{
Rudolf Polzer's avatar
Rudolf Polzer committed
564 565 566
	int firstside;
	int numsides;
	int contents;
rpolzer's avatar
rpolzer committed
567 568
} dbrush_t;

Rudolf Polzer's avatar
Rudolf Polzer committed
569 570
#define ANGLE_UP    -1
#define ANGLE_DOWN  -2
rpolzer's avatar
rpolzer committed
571 572 573 574 575


// the visibility lump consists of a header with a count, then
// byte offsets for the PVS and PHS of each cluster, then the raw
// compressed bit vectors
Rudolf Polzer's avatar
Rudolf Polzer committed
576 577
#define DVIS_PVS    0
#define DVIS_PHS    1
rpolzer's avatar
rpolzer committed
578 579
typedef struct
{
Rudolf Polzer's avatar
Rudolf Polzer committed
580 581
	int numclusters;
	int bitofs[8][2];           // bitofs[numclusters][2]
rpolzer's avatar
rpolzer committed
582 583 584 585 586 587 588
} dvis_t;

// each area has a list of portals that lead into other areas
// when portals are closed, other areas may not be visible or
// hearable even if the vis info says that it should be
typedef struct
{
Rudolf Polzer's avatar
Rudolf Polzer committed
589 590
	int portalnum;
	int otherarea;
rpolzer's avatar
rpolzer committed
591 592 593 594 595
} dareaportal_t;


typedef struct
{
Rudolf Polzer's avatar
Rudolf Polzer committed
596 597
	int numareaportals;
	int firstareaportal;
rpolzer's avatar
rpolzer committed
598 599 600 601
} darea_t;

typedef struct
{
Rudolf Polzer's avatar
Rudolf Polzer committed
602 603
	char    *name;
	int value;
rpolzer's avatar
rpolzer committed
604 605 606 607 608 609 610 611 612 613
} materialtype_t;

enum
{
	MATERIAL_GRAVEL,
	MATERIAL_METAL,
	MATERIAL_STONE,
	MATERIAL_WOOD,
};

Rudolf Polzer's avatar
Rudolf Polzer committed
614
materialtype_t  *materialtypes;
rpolzer's avatar
rpolzer committed
615

Rudolf Polzer's avatar
Rudolf Polzer committed
616
void QFile_ReadMaterialTypes( char* filename );
rpolzer's avatar
rpolzer committed
617 618 619


#endif //_QFILES_H