-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkmap2.h
2558 lines (1977 loc) · 78.7 KB
/
kmap2.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* -------------------------------------------------------------------------------
Copyright (C) 1999-2006 Id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
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.
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.
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
----------------------------------------------------------------------------------
This code has been altered significantly from its original form, to support
several games based on the Quake III Arena engine, in the form of "Q3Map2."
------------------------------------------------------------------------------- */
/* marker */
#ifndef KMAP2_H
#define KMAP2_H
#define KMAP2_NO_TYPE_PUNNING
/* version */
#define XMAP_VERSION "2.5.17"
#if 0
#ifdef PRODUCT_VERSION
# define KMAP_VERSION PRODUCT_VERSION""
#else
# define KMAP_VERSION "2.5.17.14"
#endif
#endif
//FIXME (0xA5EA):
# define KMAP_VERSION "2.5.17.21"
typedef union {
float f;
int i;
unsigned int ui;
} floatint_t;
typedef union {
unsigned char b[4];
int i;
unsigned int ui;
} byte4int_t;
typedef union {
char c[4];
int i;
unsigned int ui;
} char4int_t;
/* -------------------------------------------------------------------------------
dependencies
------------------------------------------------------------------------------- */
/* platform-specific */
#if defined( __linux__ ) || defined( __APPLE__ )
#define Q_UNIX
#endif
#ifdef Q_UNIX
#include <unistd.h>
#include <pwd.h>
#include <limits.h>
#endif
#ifdef WIN32
#include <windows.h>
#endif
#include <glib.h>
/* general */
//#include "version.h" /* ttimo: might want to guard that if built outside of the GtkRadiant tree */
#include "cmdlib.h"
#include "mathlib.h"
//#include "ddslib.h"
#include "picomodel.h"
#include "scriplib.h"
#include "polylib.h"
#include "imagelib.h"
#include "threads.h"
#include "inout.h"
#include "vfs.h"
#include "png.h"
//#include "mhash.h"
#include <stdlib.h>
/* -------------------------------------------------------------------------------
port-related hacks
------------------------------------------------------------------------------- */
#define MAC_STATIC_HACK 0
#if defined( __APPLE__ ) && MAC_STATIC_HACK
#define MAC_STATIC static
#else
#define MAC_STATIC
#endif
#if 1
#ifdef WIN32
#define Q_stricmp stricmp
#define Q_strncasecmp strnicmp
#else
#define Q_stricmp strcasecmp
#define Q_strncasecmp strncasecmp
#endif
#endif
/* -------------------------------------------------------------------------------
constants
------------------------------------------------------------------------------- */
/* general */
//#define MAX_QPATH 64
#define MAX_IMAGES 512
#define DEFAULT_IMAGE "*default"
#define MAX_MODELS 512
#define DEF_BACKSPLASH_FRACTION 0.05f /* 5% backsplash by default */
#define DEF_BACKSPLASH_DISTANCE 23
#define DEF_RADIOSITY_BOUNCE 1.0f /* ydnar: default to 100% re-emitted light */
#define MAX_SHADER_INFO 8192
#define MAX_CUST_SURFACEPARMS 64
#define SHADER_MAX_VERTEXES 1000
#define SHADER_MAX_INDEXES (6 * SHADER_MAX_VERTEXES)
#define MAX_JITTERS 256
#define PREFIX_LEN 5 // len of kmap_ and xmap_
/* epair parsing (note case-sensitivity directive) */
#define CASE_INSENSITIVE_EPAIRS 1
#if CASE_INSENSITIVE_EPAIRS
#define EPAIR_STRCMP Q_stricmp
#else
#define EPAIR_STRCMP strcmp
#endif
/* ydnar: compiler flags, because games have widely varying content/surface flags */
#define C_SOLID 0x00000001 //CONTENTS_SOLID 0x00000001 /*1*/
#define C_TRANSLUCENT 0x00000002 //CONTENTS_TRANSLUCENT 0x20000000 /*536870912*/
#define C_STRUCTURAL 0x00000004 //CONTENTS_STRUCTURAL 0x10000000 /*268435456*/
#define C_HINT 0x00000008 //SURF_HINT 0x00000100
#define C_NODRAW 0x00000010 //SURF_NODRAW 0x00000080
#define C_LIGHTGRID 0x00000020 //CONTENTS_LIGHTGRID 0x00000004
#define C_ALPHASHADOW 0x00000040 //SURF_ALPHASHADOW 0x00010000
#define C_LIGHTFILTER 0x00000080 //SURF_LIGHTFILTER 0x00008000
#define C_VERTEXLIT 0x00000100 //SURF_VERTEXLIT (SURF_POINTLIGHT | SURF_NOLIGHTMAP)
#define C_LIQUID 0x00000200 //CONTENTS_WATER 0x00000020 /*32*/
#define C_FOG 0x00000400 //CONTENTS_FOG 0x00000040 /*64*/
#define C_SKY 0x00000800 //SURF_SKY 0x00000004
#define C_ORIGIN 0x00001000 //CONTENTS_ORIGIN 0x01000000 /*16777216*/
#define C_AREAPORTAL 0x00002000 //CONTENTS_AREAPORTAL 0x00008000 /*32768*/
#define C_ANTIPORTAL 0x00004000 // /* like hint, but doesn't generate portals */
#define C_SKIP 0x00008000 //SURF_SKIP 0x00000200 /* like hint, but skips this face (doesn't split bsp) */
#define C_NOMARKS 0x00010000 //SURF_NOMARKS 0x00000020 /* no decals */
#define C_COLLISION 0x00020000 //SURF_COLLISION 0x00020000
#define C_DETAIL 0x08000000 //CONTENTS_DETAIL 0x08000000 /*134217728*/ /* THIS MUST BE THE SAME AS IN RADIANT! */
/* shadow flags */
#define WORLDSPAWN_CAST_SHADOWS 1
#define WORLDSPAWN_RECV_SHADOWS 1
#define ENTITY_CAST_SHADOWS 0
#define ENTITY_RECV_SHADOWS 1
/* bsp */
#define MAX_PATCH_SIZE 64 /* Tr3B: was 32 in Q3A */
#define MAX_BRUSH_SIDES 1024
#define MAX_BUILD_SIDES 1024
#define MAX_EXPANDED_AXIS 128
#define CLIP_EPSILON 0.1f
#define PLANESIDE_EPSILON 0.001f
#define PLANENUM_LEAF -1
#define HINT_PRIORITY 1000 /* ydnar: force hint splits first and antiportal/areaportal splits last */
#define ANTIPORTAL_PRIORITY -1000
#define AREAPORTAL_PRIORITY -1000
#define DETAIL_PRIORITY -3000
#define PSIDE_FRONT 1
#define PSIDE_BACK 2
#define PSIDE_BOTH (PSIDE_FRONT | PSIDE_BACK)
#define PSIDE_FACING 4
#define BPRIMIT_UNDEFINED 0
#define BPRIMIT_OLDBRUSHES 1
#define BPRIMIT_NEWBRUSHES 2
#define BPRIMIT_D3BRUSHES 3
#define BPRIMIT_Q4BRUSHES 4
/* vis */
#define VIS_HEADER_SIZE 8
#define SEPERATORCACHE /* seperator caching helps a bit */
#define PORTALFILE "PRT1"
#define MAX_PORTALS 0x20000 /* same as MAX_MAP_PORTALS */
#define MAX_SEPERATORS MAX_POINTS_ON_WINDING
#define MAX_POINTS_ON_FIXED_WINDING 24 /* ydnar: increased this from 12 at the expense of more memory */
#define MAX_PORTALS_ON_LEAF 1024
/* light */
#define EMIT_POINT 0
#define EMIT_AREA 1
#define EMIT_SPOT 2
#define EMIT_SUN 3
#define LIGHT_ATTEN_LINEAR 1
#define LIGHT_ATTEN_ANGLE 2
#define LIGHT_ATTEN_DISTANCE 4
#define LIGHT_TWOSIDED 8
#define LIGHT_GRID 16
#define LIGHT_SURFACES 32
#define LIGHT_DARK 64 /* probably never use this */
#define LIGHT_FAST 256
#define LIGHT_FAST_TEMP 512
#define LIGHT_FAST_ACTUAL (LIGHT_FAST | LIGHT_FAST_TEMP)
#define LIGHT_NEGATIVE 1024
#define LIGHT_UNNORMALIZED 2048 /* vortex: do not normalize _color */
#define LIGHT_SUN_DEFAULT (LIGHT_ATTEN_ANGLE | LIGHT_GRID | LIGHT_SURFACES)
#define LIGHT_AREA_DEFAULT (LIGHT_ATTEN_ANGLE | LIGHT_ATTEN_DISTANCE | LIGHT_GRID | LIGHT_SURFACES) /* q3a and wolf are the same */
#define LIGHT_Q3A_DEFAULT (LIGHT_ATTEN_ANGLE | LIGHT_ATTEN_DISTANCE | LIGHT_GRID | LIGHT_SURFACES | LIGHT_FAST)
#define LIGHT_WOLF_DEFAULT (LIGHT_ATTEN_LINEAR | LIGHT_ATTEN_DISTANCE | LIGHT_GRID | LIGHT_SURFACES | LIGHT_FAST)
#define MAX_TRACE_TEST_NODES 256
#define DEFAULT_INHIBIT_RADIUS 1.5f
#define LUXEL_EPSILON 0.125f
#define VERTEX_EPSILON -0.125f
#define GRID_EPSILON 0.0f
#define DEFAULT_LIGHTMAP_SAMPLE_SIZE 16
#define DEFAULT_LIGHTMAP_MIN_SAMPLE_SIZE 0
#define DEFAULT_LIGHTMAP_SAMPLE_OFFSET 1.0f
#define DEFAULT_SUBDIVIDE_THRESHOLD 1.0f
#define EXTRA_SCALE 2 /* -extrawide = -super 2 */
#define EXTRAWIDE_SCALE 2 /* -extrawide = -super 2 -filter */
#define CLUSTER_UNMAPPED -1
#define CLUSTER_OCCLUDED -2
#define CLUSTER_FLOODED -3
#define VERTEX_LUXEL_SIZE 3
#define VERTEX_DELUXEL_SIZE 3
#define BSP_LUXEL_SIZE 3
#define RAD_LUXEL_SIZE 3
#define SUPER_LUXEL_SIZE 4
#define SUPER_ORIGIN_SIZE 3
#define SUPER_NORMAL_SIZE 4
#define SUPER_DELUXEL_SIZE 3
#define BSP_DELUXEL_SIZE 3
#define SUPER_FLOODLIGHT_SIZE 4
#define VERTEX_LUXEL( s, v ) (vertexLuxels[ s ] + ((v) * VERTEX_LUXEL_SIZE))
#define RAD_VERTEX_LUXEL( s, v )(radVertexLuxels[ s ] + ((v) * VERTEX_LUXEL_SIZE))
#define VERTEX_DELUXEL( s, v ) (vertexDeluxels[ s ] + ((v) * VERTEX_DELUXEL_SIZE))
#define BSP_LUXEL( s, x, y ) (lm->bspLuxels[ s ] + ((((y) * lm->w) + (x)) * BSP_LUXEL_SIZE))
#define RAD_LUXEL( s, x, y ) (lm->radLuxels[ s ] + ((((y) * lm->w) + (x)) * RAD_LUXEL_SIZE))
#define SUPER_LUXEL( s, x, y ) (lm->superLuxels[ s ] + ((((y) * lm->sw) + (x)) * SUPER_LUXEL_SIZE))
#define SUPER_DELUXEL( x, y ) (lm->superDeluxels + ((((y) * lm->sw) + (x)) * SUPER_DELUXEL_SIZE))
#define BSP_DELUXEL( x, y ) (lm->bspDeluxels + ((((y) * lm->w) + (x)) * BSP_DELUXEL_SIZE))
#define SUPER_CLUSTER( x, y ) (lm->superClusters + (((y) * lm->sw) + (x)))
#define SUPER_ORIGIN( x, y ) (lm->superOrigins + ((((y) * lm->sw) + (x)) * SUPER_ORIGIN_SIZE))
#define SUPER_NORMAL( x, y ) (lm->superNormals + ((((y) * lm->sw) + (x)) * SUPER_NORMAL_SIZE))
#define SUPER_DIRT( x, y ) (lm->superNormals + ((((y) * lm->sw) + (x)) * SUPER_NORMAL_SIZE) + 3) /* stash dirtyness in normal[ 3 ] */
#define SUPER_FLOODLIGHT( x, y ) (lm->superFloodLight + ((((y) * lm->sw) + (x)) * SUPER_FLOODLIGHT_SIZE) )
#define RGBTOGRAY(v) ( (v)[0] * 0.3f + (v)[1] * 0.59f + (v)[2] * 0.11f)
#define RGBTOLUMINANCE(v) ( (v)[0] * 0.2125f + (v)[1] * 0.7154f + (v)[2] * 0.0721f)
/* -------------------------------------------------------------------------------
abstracted bsp file
------------------------------------------------------------------------------- */
#define EXTERNAL_OLDLIGHTMAP "lm_%04d.tga"
#define EXTERNAL_LIGHTMAP "lm_%04d.png"
#define EXTERNAL_HDRLIGHTMAP "lm_%04d.hdr"
#define USE_TGA_LIGHTMAP
//#define USE_PNG_LIGHTMAP //hypov8 enable?
#if defined (USE_PNG_LIGHTMAP)
# define EXTERN_LIGHTMAP_FILE EXTERNAL_LIGHTMAP
#elif defined (USE_TGA_LIGHTMAP)
# define EXTERN_LIGHTMAP_FILE EXTERNAL_OLDLIGHTMAP
#elif defined (USE_HDR_LIGHTMAP)
# define EXTERN_LIGHTMAP_FILE EXTERNAL_HDRLIGHTMAP
#else
# error "no lightmap type defined"
#endif
#define MAX_LIGHTMAPS 4 /* RBSP */
#define MAX_LIGHT_STYLES 64
#define MAX_SWITCHED_LIGHTS 32
#define LS_NORMAL 0x00
#define LS_UNUSED 0xFE
#define LS_NONE 0xFF
#define MAX_LIGHTMAP_SHADERS 256
/* ok to increase these at the expense of more memory */
#define MAX_MAP_ENTITIES 0x3000 // Tr3B: old 0x1000 //% 0x800 /* ydnar */
#define MAX_MAP_ENTSTRING 0x80000 //% 0x40000 /* ydnar */
#define MAX_MAP_AREAS 0x100 /* MAX_MAP_AREA_BYTES in q_shared must match! */
#define MAX_MAP_FOGS 30 //& 0x100 /* RBSP (32 - world fog - goggles) */
#define MAX_MAP_LEAFS 0x20000
#define MAX_MAP_PORTALS 0x20000
#define MAX_MAP_LIGHTING 0x800000
#define MAX_MAP_LIGHTGRID 0x100000 //% 0x800000 /* ydnar: set to points, not bytes */
#define MAX_MAP_VISCLUSTERS 0x4000 // <= MAX_MAP_LEAFS
#define MAX_MAP_VISIBILITY (VIS_HEADER_SIZE + MAX_MAP_VISCLUSTERS * (((MAX_MAP_VISCLUSTERS + 63) & ~63) >> 3))
#define MAX_MAP_DRAW_SURFS 0x20000
#define MAX_MAP_DRAW_VERTS 0x200000 //% 0x80000 /* Tr3B */
#define MAX_MAP_DRAW_INDEXES 0x200000 //% 0x80000 /* Tr3B */
#define MAX_MAP_ADVERTISEMENTS 30
/* key / value pair sizes in the entities lump */
#define MAX_KEY 32
#define MAX_VALUE 1024
/* the editor uses these predefined yaw angles to orient entities up or down */
#define ANGLE_UP -1
#define ANGLE_DOWN -2
#define LIGHTMAP_WIDTH 1024 // was 128 hypov8 changed default
#define LIGHTMAP_HEIGHT 1024 // was 128 hypov8 changed default
#define MIN_WORLD_COORD (-65536)
#define MAX_WORLD_COORD (65536)
#define WORLD_SIZE (MAX_WORLD_COORD - MIN_WORLD_COORD)
typedef void (*bspFunc) (const char *);
typedef struct
{
int offset, length;
}
bspLump_t;
typedef struct
{
char ident[4];
int version;
bspLump_t lumps[100]; /* theoretical maximum # of bsp lumps */
}
bspHeader_t;
typedef struct
{
float mins[3], maxs[3];
int firstBSPSurface, numBSPSurfaces;
int firstBSPBrush, numBSPBrushes;
}
bspModel_t;
typedef struct
{
char shader[64];
int surfaceFlags;
int contentFlags;
}
bspShader_t;
/* planes x^1 is allways the opposite of plane x */
typedef struct
{
float normal[3];
float dist;
}
bspPlane_t;
typedef struct
{
int planeNum;
int children[2]; /* negative numbers are -(leafs+1), not nodes */
int mins[3]; /* for frustom culling */
int maxs[3];
}
bspNode_t;
typedef struct
{
int cluster; /* -1 = opaque cluster (do I still store these?) */
int area;
int mins[3]; /* for frustum culling */
int maxs[3];
int firstBSPLeafSurface;
int numBSPLeafSurfaces;
int firstBSPLeafBrush;
int numBSPLeafBrushes;
}
bspLeaf_t;
typedef struct
{
int planeNum; /* positive plane side faces out of the leaf */
int shaderNum;
int surfaceNum; /* RBSP */ //discarded in XBSP
}
bspBrushSide_t;
typedef struct
{
int firstSide;
int numSides;
int shaderNum; /* the shader that determines the content flags */
}
bspBrush_t;
typedef struct
{
char shader[64];
int brushNum;
int visibleSide; /* the brush side that ray tests need to clip against (-1 == none) */
}
bspFog_t;
typedef struct
{
vec3_t xyz;
float st[2];
float lightmap[MAX_LIGHTMAPS][2]; /* RBSP */ //[LM] discarded in XBSP
vec3_t normal;
float paintColor[4]; /* XBSP */ //vertex paintColor (+alpha)
float lightColor[MAX_LIGHTMAPS][4]; /* RBSP/XBSP */ //[LM] discarded in XBSP
float lightDirection[MAX_LIGHTMAPS][3]; /* RBSP/XBSP */ //[LM] discarded in XBSP
}
bspDrawVert_t;
typedef enum
{
MST_BAD,
MST_PLANAR,
MST_PATCH,
MST_TRIANGLE_SOUP,
MST_FLARE,
MST_FOLIAGE
}
bspSurfaceType_t;
typedef struct bspGridPoint_s
{
vec3_t ambient[MAX_LIGHTMAPS]; //light color?
vec3_t directed[MAX_LIGHTMAPS]; //light angle?
byte styles[MAX_LIGHTMAPS]; //not used in kpq3
byte latLong[2];
}
bspGridPoint_t;
typedef struct
{
int shaderNum;
int fogNum;
int surfaceType;
int firstVert;
int numVerts;
int firstIndex;
int numIndexes;
byte lightmapStyles[MAX_LIGHTMAPS]; /* RBSP */
byte vertexStyles[MAX_LIGHTMAPS]; /* RBSP */
int lightmapNum[MAX_LIGHTMAPS]; /* RBSP */
int lightmapX[MAX_LIGHTMAPS], lightmapY[MAX_LIGHTMAPS]; /* RBSP */
int lightmapWidth, lightmapHeight;
vec3_t lightmapOrigin;
vec3_t lightmapVecs[3]; /* on patches, [ 0 ] and [ 1 ] are lodbounds */
int patchWidth;
int patchHeight;
}
bspDrawSurface_t;
/* advertisements */
typedef struct
{
int cellId;
vec3_t normal;
vec3_t rect[4];
char model[MAX_QPATH];
} bspAdvertisement_t;
/* -------------------------------------------------------------------------------
general types
------------------------------------------------------------------------------- */
/* ydnar: for smaller structs */
typedef char qb_t;
/* ydnar: for kmap_tcMod */
typedef float tcMod_t[3][3];
/* ydnar: for multiple game support */
typedef struct surfaceParm_s
{
char *name;
int contentFlags, contentFlagsClear;
int surfaceFlags, surfaceFlagsClear;
int compileFlags, compileFlagsClear;
}
surfaceParm_t;
typedef enum
{
MINIMAP_MODE_BLACK,
MINIMAP_MODE_WHITE
}
miniMapMode_t;
typedef struct game_s
{
char *arg; /* -game matches this */
char *gamePath; /* main game data dir */
char *homeBasePath; /* home sub-dir on unix */
char *magic; /* magic word for figuring out base path */
char *shaderPath; /* shader directory */
int maxLMSurfaceVerts; /* default maximum meta surface verts */
int maxSurfaceVerts; /* default maximum surface verts */
int maxSurfaceIndexes; /* default maximum surface indexes (tris * 3) */
qboolean emitFlares; /* when true, emit flare surfaces */
char *flareShader; /* default flare shader (MUST BE SET) */
qboolean wolfLight; /* when true, lights work like wolf q3map */
int lightmapSize; /* bsp lightmap width/height */
float lightmapGamma; /* default lightmap gamma */
float lightmapExposure; /* default lightmap exposure */
float lightmapCompensate; /* default lightmap compensate value */
float gridScale; /* vortex: default lightgrid scale (affects both directional and ambient spectres) */
float gridAmbientScale; /* vortex: default lightgrid ambient spectre scale */
qboolean lightAngleHL; /* jal: use half-lambert curve for light angle attenuation */
qboolean noStyles; /* use lightstyles hack or not */
qboolean keepLights; /* keep light entities on bsp */
int patchSubdivisions; /* default patch subdivisions tolerance */
qboolean patchShadows; /* patch casting enabled */
qboolean deluxeMap; /* compile deluxemaps */
int deluxeMode; /* deluxemap mode (0 - modelspace, 1 - tangentspace with renormalization, 2 - tangentspace without renormalization) */
int miniMapSize; /* minimap size */
float miniMapSharpen; /* minimap sharpening coefficient */
float miniMapBorder; /* minimap border amount */
qboolean miniMapKeepAspect; /* minimap keep aspect ratio by letterboxing */
miniMapMode_t miniMapMode; /* minimap mode */
char *miniMapNameFormat; /* minimap name format */
char *bspIdent; /* 4-letter bsp file prefix */
int bspVersion; /* bsp version to use */
qboolean lumpSwap; /* cod-style len/ofs order */
bspFunc load, write; /* load/write function pointers */
surfaceParm_t surfaceParms[128]; /* surfaceparm array */
}
game_t;
typedef struct image_s
{
char *name, *filename;
int refCount;
int width, height;
byte *pixels;
}
image_t;
typedef struct sun_s
{
struct sun_s *next;
vec3_t direction, color;
float photons, deviance, filterRadius;
int numSamples, style;
}
sun_t;
typedef struct surfaceModel_s
{
struct surfaceModel_s *next;
char model[MAX_QPATH];
float density, odds;
float minScale, maxScale;
float minAngle, maxAngle;
qboolean oriented;
}
surfaceModel_t;
/* ydnar/sd: foliage stuff for wolf et (engine-supported optimization of the above) */
typedef struct foliage_s
{
struct foliage_s *next;
char model[MAX_QPATH];
float scale, density, odds;
qboolean inverseAlpha;
}
foliage_t;
typedef struct foliageInstance_s
{
vec3_t xyz, normal;
}
foliageInstance_t;
typedef struct remap_s
{
struct remap_s *next;
char from[1024];
char to[MAX_QPATH];
}
remap_t;
/* wingdi.h hack, it's the same: 0 */
#undef CM_NONE
typedef enum
{
CM_NONE,
CM_VOLUME,
CM_COLOR_SET,
CM_ALPHA_SET,
CM_COLOR_SCALE,
CM_ALPHA_SCALE,
CM_COLOR_DOT_PRODUCT,
CM_ALPHA_DOT_PRODUCT,
CM_COLOR_DOT_PRODUCT_SCALE,
CM_ALPHA_DOT_PRODUCT_SCALE,
CM_COLOR_DOT_PRODUCT_2,
CM_ALPHA_DOT_PRODUCT_2,
CM_COLOR_DOT_PRODUCT_2_SCALE,
CM_ALPHA_DOT_PRODUCT_2_SCALE
}
colorModType_t;
typedef struct colorMod_s
{
struct colorMod_s *next;
colorModType_t type;
vec_t data[16];
}
colorMod_t;
typedef enum
{
IM_NONE,
IM_OPAQUE,
IM_MASKED,
IM_BLEND
}
implicitMap_t;
typedef struct shaderInfo_s
{
char shader[MAX_QPATH];
int surfaceFlags;
int contentFlags;
int compileFlags;
float value; /* light value */
char *flareShader; /* for light flares */
char *damageShader; /* ydnar: sof2 damage shader name */
char *backShader; /* for surfaces that generate different front and back passes */
char *cloneShader; /* ydnar: for cloning of a surface */
char *remapShader; /* ydnar: remap a shader in final stage */
char *deprecateShader; /* vortex: shader is deprecated and replaced by this on use */
surfaceModel_t *surfaceModel; /* ydnar: for distribution of models */
foliage_t *foliage; /* ydnar/splash damage: wolf et foliage */
float subdivisions; /* from a "tesssize xxx" */
float backsplashFraction; /* floating point value, usually 0.05 */
float backsplashDistance; /* default 16 */
float lightSubdivide; /* default 999 */
float lightFilterRadius; /* ydnar: lightmap filtering/blurring radius for lights created by this shader (default: 0) */
int lightmapSampleSize; /* lightmap sample size */
float lightmapSampleOffset; /* ydnar: lightmap sample offset (default: 1.0) */
float bounceScale; /* ydnar: radiosity re-emission [0,1.0+] */
float offset; /* ydnar: offset in units */
float shadeAngleDegrees; /* ydnar: breaking angle for smooth shading (degrees) */
vec3_t mins, maxs; /* ydnar: for particle studio vertexDeform move support */
qb_t legacyTerrain; /* ydnar: enable legacy terrain crutches */
qb_t indexed; /* ydnar: attempt to use indexmap (terrain alphamap style) */
qb_t forceMeta; /* ydnar: force metasurface path */
qb_t noClip; /* ydnar: don't clip into bsp, preserve original face winding */
qb_t noFast; /* ydnar: supress fast lighting for surfaces with this shader */
qb_t invert; /* ydnar: reverse facing */
qb_t nonplanar; /* ydnar: for nonplanar meta surface merging */
qb_t tcGen; /* ydnar: has explicit texcoord generation */
vec3_t vecs[2]; /* ydnar: explicit texture vectors for [0,1] texture space */
tcMod_t mod; /* ydnar: xmap_tcMod matrix for djbob :) */
vec3_t lightmapAxis; /* ydnar: explicit lightmap axis projection */
colorMod_t *colorMod; /* ydnar: xmap_rgb/color/alpha/Set/Mod support */
int furNumLayers; /* ydnar: number of fur layers */
float furOffset; /* ydnar: offset of each layer */
float furFade; /* ydnar: alpha fade amount per layer */
qb_t splotchFix; /* ydnar: filter splotches on lightmaps */
qb_t hasPasses; /* false if the shader doesn't define any rendering passes */
qb_t globalTexture; /* don't normalize texture repeats */
qb_t twoSided; /* cull none */
qb_t forceOpaque; /* Tr3B: don't make this translucent if shader has no passes */
qb_t autosprite; /* autosprite shaders will become point lights instead of area lights */
qb_t polygonOffset; /* ydnar: don't face cull this or against this */
qb_t patchShadows; /* have patches casting shadows when using -light for this surface */
qb_t vertexShadows; /* shadows will be casted at this surface even when vertex lit */
qb_t forceSunlight; /* force sun light at this surface even tho we might not calculate shadows in vertex lighting */
qb_t notjunc; /* don't use this surface for tjunction fixing */
qb_t fogParms; /* ydnar: has fogparms */
qb_t noFog; /* ydnar: supress fogging */
qb_t clipModel; /* ydnar: solid model hack */
qb_t noVertexLight; /* ydnar: leave vertex color alone */
qb_t noDirty; /* jal: do not apply the dirty pass to this surface */
byte styleMarker; /* ydnar: light styles hack */
float vertexScale; /* vertex light scale */
char skyParmsImageBase[MAX_QPATH]; /* ydnar: for skies */
char editorImagePath[MAX_QPATH]; /* use this image to generate texture coordinates */
char lightImagePath[MAX_QPATH]; /* use this image to generate color / averageColor */
char normalImagePath[MAX_QPATH]; /* ydnar: normalmap image for bumpmapping */
char diffuseImagePath[MAX_QPATH]; /* hypov8 add diffuse to path for light */
implicitMap_t implicitMap; /* ydnar: enemy territory implicit shaders */
char implicitImagePath[MAX_QPATH];
image_t *shaderImage;
image_t *lightImage;
image_t *normalImage;
float skyLightValue; /* ydnar */
int skyLightIterations; /* ydnar */
sun_t *sun; /* ydnar */
vec3_t color; /* normalized color */
vec3_t averageColor;
byte lightStyle;
/* vortex: per-surface floodlight */
float floodlightDirectionScale;
vec3_t floodlightRGB;
float floodlightIntensity;
float floodlightDistance;
qb_t lmMergable; /* ydnar */
int lmCustomWidth, lmCustomHeight; /* ydnar */
float lmBrightness; /* ydnar */
float lmFilterRadius; /* ydnar: lightmap filtering/blurring radius for this shader (default: 0) */
int shaderWidth, shaderHeight; /* ydnar */
float stFlat[2];
vec3_t fogDir; /* ydnar */
char *shaderText; /* ydnar */
qb_t explicitDef; /* Tr3B: .mtr material was found */ /* hypov8 was 'explicit'*/
qb_t custom;
qb_t finished;
}
shaderInfo_t;
/* -------------------------------------------------------------------------------
bsp structures
------------------------------------------------------------------------------- */
typedef struct face_s
{
struct face_s *next;
int planenum;
int priority;
//qboolean checked;
int compileFlags;
winding_t *w;
}
face_t;
typedef struct plane_s
{
vec3_t normal;
vec_t dist;
int type;
int counter;
int hash_chain;
}
plane_t;
typedef struct side_s
{
int planenum;
int outputNum; /* set when the side is written to the file list */
float texMat[2][3]; /* brush primitive texture matrix */
float vecs[2][4]; /* old-style texture coordinate mapping */
winding_t *winding;
winding_t *visibleHull; /* convex hull of all visible fragments */
shaderInfo_t *shaderInfo;
int contentFlags; /* from shaderInfo */
int surfaceFlags; /* from shaderInfo */
int compileFlags; /* from shaderInfo */
int value; /* from shaderInfo */
qboolean visible; /* choose visble planes first */
qboolean bevel; /* don't ever use for bsp splitting, and don't bother making windings for it */
qboolean culled; /* ydnar: face culling */
}
side_t;
typedef struct sideRef_s
{
struct sideRef_s *next;
side_t *side;
}
sideRef_t;
/* ydnar: generic index mapping for entities (natural extension of terrain texturing) */
typedef struct indexMap_s
{
int w, h, numLayers;
char name[MAX_QPATH], shader[MAX_QPATH];
float offsets[256];
byte *pixels;
}
indexMap_t;
typedef struct brush_s
{
struct brush_s *next;
struct brush_s *nextColorModBrush; /* ydnar: colorMod volume brushes go here */
struct brush_s *original; /* chopped up brushes will reference the originals */
int entityNum, brushNum; /* editor numbering */
int outputNum; /* set when the brush is written to the file list */
/* ydnar: for shadowcasting entities */
int castShadows;
int recvShadows;
shaderInfo_t *contentShader;
shaderInfo_t *celShader; /* :) */
/* ydnar: gs mods */
int lightmapSampleSize; /* jal : entity based _lightmapsamplesize */
float lightmapScale;
float shadeAngleDegrees; /* jal : entity based _shadeangle */
vec3_t eMins, eMaxs;
indexMap_t *im;
int contentFlags;
int compileFlags; /* ydnar */
qboolean detail;
qboolean opaque;
int portalareas[2];
vec3_t mins, maxs;
int numsides;
qboolean generatedClipBrush; // Tr3B: created by a custom model and clipModel 1
side_t sides[6]; /* variably sized */
}
brush_t;
typedef struct fog_s
{
shaderInfo_t *si;
brush_t *brush;
int visibleSide; /* the brush side that ray tests need to clip against (-1 == none) */
}
fog_t;
typedef struct
{
int width, height;
bspDrawVert_t *verts;
}
mesh_t;
typedef struct parseMesh_s
{
struct parseMesh_s *next;
int entityNum, brushNum; /* ydnar: editor numbering */
/* ydnar: for shadowcasting entities */
int castShadows;
int recvShadows;
mesh_t mesh;
shaderInfo_t *shaderInfo;
shaderInfo_t *celShader; /* :) */
/* ydnar: gs mods */
int lightmapSampleSize; /* jal : entity based _lightmapsamplesize */
float lightmapScale;
vec3_t eMins, eMaxs;
indexMap_t *im;
/* grouping */
qboolean grouped;
float longestCurve;