]> git.xonotic.org Git - xonotic/darkplaces.git/blob - model_q2bsp.h
cvar: Rename Cvar_RegisterAlias to Cvar_RegisterVirtual
[xonotic/darkplaces.git] / model_q2bsp.h
1 #ifndef MODEL_Q2BSP_H
2 #define MODEL_Q2BSP_H
3
4 #include "bspfile.h"
5
6 #define Q2BSPMAGIC ('I' + 'B' * 256 + 'S' * 65536 + 'P' * 16777216)
7 #define Q2BSPVERSION    38
8
9 // leaffaces, leafbrushes, planes, and verts are still bounded by
10 // 16 bit short limits
11
12 //=============================================================================
13
14 #define Q2LUMP_ENTITIES         0
15 #define Q2LUMP_PLANES                   1
16 #define Q2LUMP_VERTEXES         2
17 #define Q2LUMP_VISIBILITY               3
18 #define Q2LUMP_NODES                    4
19 #define Q2LUMP_TEXINFO          5
20 #define Q2LUMP_FACES                    6
21 #define Q2LUMP_LIGHTING         7
22 #define Q2LUMP_LEAFS                    8
23 #define Q2LUMP_LEAFFACES                9
24 #define Q2LUMP_LEAFBRUSHES      10
25 #define Q2LUMP_EDGES                    11
26 #define Q2LUMP_SURFEDGES                12
27 #define Q2LUMP_MODELS                   13
28 #define Q2LUMP_BRUSHES          14
29 #define Q2LUMP_BRUSHSIDES               15
30 #define Q2LUMP_POP                      16
31 #define Q2LUMP_AREAS                    17
32 #define Q2LUMP_AREAPORTALS      18
33 #define Q2HEADER_LUMPS          19
34
35 typedef struct q2dheader_s
36 {
37         int                     ident;
38         int                     version;
39         lump_t          lumps[Q2HEADER_LUMPS];
40 } q2dheader_t;
41
42 typedef struct q2dmodel_s
43 {
44         float           mins[3], maxs[3];
45         float           origin[3];              // for sounds or lights
46         int                     headnode;
47         int                     firstface, numfaces;    // submodels just draw faces
48                                                                                 // without walking the bsp tree
49 } q2dmodel_t;
50
51 // planes (x&~1) and (x&~1)+1 are always opposites
52
53 // contents flags are seperate bits
54 // a given brush can contribute multiple content bits
55 // multiple brushes can be in a single leaf
56
57 // these definitions also need to be in q_shared.h!
58
59 // lower bits are stronger, and will eat weaker brushes completely
60 #define Q2CONTENTS_SOLID                        1               // an eye is never valid in a solid
61 #define Q2CONTENTS_WINDOW                       2               // translucent, but not watery
62 #define Q2CONTENTS_AUX                  4
63 #define Q2CONTENTS_LAVA                 8
64 #define Q2CONTENTS_SLIME                        16
65 #define Q2CONTENTS_WATER                        32
66 #define Q2CONTENTS_MIST                 64
67 #define Q2LAST_VISIBLE_CONTENTS 64
68
69 // remaining contents are non-visible, and don't eat brushes
70
71 #define Q2CONTENTS_AREAPORTAL           0x8000
72
73 #define Q2CONTENTS_PLAYERCLIP           0x10000
74 #define Q2CONTENTS_MONSTERCLIP  0x20000
75
76 // currents can be added to any other contents, and may be mixed
77 #define Q2CONTENTS_CURRENT_0            0x40000
78 #define Q2CONTENTS_CURRENT_90           0x80000
79 #define Q2CONTENTS_CURRENT_180  0x100000
80 #define Q2CONTENTS_CURRENT_270  0x200000
81 #define Q2CONTENTS_CURRENT_UP           0x400000
82 #define Q2CONTENTS_CURRENT_DOWN 0x800000
83
84 #define Q2CONTENTS_ORIGIN                       0x1000000       // removed before bsping an entity
85
86 #define Q2CONTENTS_MONSTER              0x2000000       // should never be on a brush, only in game
87 #define Q2CONTENTS_DEADMONSTER  0x4000000
88 #define Q2CONTENTS_DETAIL                       0x8000000       // brushes to be added after vis leafs
89 #define Q2CONTENTS_TRANSLUCENT  0x10000000      // auto set if any surface has trans
90 #define Q2CONTENTS_LADDER                       0x20000000
91
92
93
94 #define Q2SURF_LIGHT            0x1             // value will hold the light strength
95
96 #define Q2SURF_SLICK            0x2             // effects game physics
97
98 #define Q2SURF_SKY              0x4             // don't draw, but add to skybox
99 #define Q2SURF_WARP             0x8             // turbulent water warp
100 #define Q2SURF_TRANS33  0x10
101 #define Q2SURF_TRANS66  0x20
102 #define Q2SURF_FLOWING  0x40    // scroll towards angle
103 #define Q2SURF_NODRAW           0x80    // don't bother referencing the texture
104
105 #define Q2SURF_HINT             0x100   // make a primary bsp splitter
106 #define Q2SURF_SKIP             0x200   // completely ignore, allowing non-closed brushes
107
108 #define Q2SURF_ALPHATEST 0x02000000     // alpha test masking of color 255 in wal textures (supported by modded engines)
109
110
111 /*
112 typedef struct q2dnode_s
113 {
114         int                     planenum;
115         int                     children[2];    // negative numbers are -(leafs+1), not nodes
116         short           mins[3];                // for frustom culling
117         short           maxs[3];
118         unsigned short  firstface;
119         unsigned short  numfaces;       // counting both sides
120 } q2dnode_t;
121
122 typedef struct q2texinfo_s
123 {
124         float           vecs[2][4];             // [s/t][xyz offset]
125         int                     flags;                  // miptex flags + overrides
126         int                     value;                  // light emission, etc
127         char            texture[32];    // texture name (textures/something.wal)
128         int                     nexttexinfo;    // for animations, -1 = end of chain
129 } q2texinfo_t;
130
131 typedef struct q2dleaf_s
132 {
133         int                             contents;                       // OR of all brushes (not needed?)
134
135         short                   cluster;
136         short                   area;
137
138         short                   mins[3];                        // for frustum culling
139         short                   maxs[3];
140
141         unsigned short  firstleafface;
142         unsigned short  numleaffaces;
143
144         unsigned short  firstleafbrush;
145         unsigned short  numleafbrushes;
146 } q2dleaf_t;
147
148 typedef struct q2dbrushside_s
149 {
150         unsigned short  planenum;               // facing out of the leaf
151         short   texinfo;
152 } q2dbrushside_t;
153
154 typedef struct q2dbrush_s
155 {
156         int                     firstside;
157         int                     numsides;
158         int                     contents;
159 } q2dbrush_t;
160
161
162 // the visibility lump consists of a header with a count, then
163 // byte offsets for the PVS and PHS of each cluster, then the raw
164 // compressed bit vectors
165 #define Q2DVIS_PVS      0
166 #define Q2DVIS_PHS      1
167 typedef struct q2dvis_s
168 {
169         int                     numclusters;
170         int                     bitofs[8][2];   // bitofs[numclusters][2]
171 } q2dvis_t;
172
173 // each area has a list of portals that lead into other areas
174 // when portals are closed, other areas may not be visible or
175 // hearable even if the vis info says that it should be
176 typedef struct q2dareaportal_s
177 {
178         int             portalnum;
179         int             otherarea;
180 } q2dareaportal_t;
181
182 typedef struct q2darea_s
183 {
184         int             numareaportals;
185         int             firstareaportal;
186 } q2darea_t;
187 */
188
189 #endif