DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
 
model_q3bsp.h
Go to the documentation of this file.
1#ifndef MODEL_Q3BSP_H
2#define MODEL_Q3BSP_H
3
4#include "bspfile.h"
5#include "r_qshader.h"
6#include "r_textures.h"
7#include "matrixlib.h"
8
9//Q3 bsp stuff
10
11#define Q3BSPVERSION 46
12#define Q3BSPVERSION_LIVE 47
13#define Q3BSPVERSION_IG 48
14
15#define Q3LUMP_ENTITIES 0 // entities to spawn (used by server and client)
16#define Q3LUMP_TEXTURES 1 // textures used (used by faces)
17#define Q3LUMP_PLANES 2 // planes used (used by bsp nodes)
18#define Q3LUMP_NODES 3 // bsp nodes (used by bsp nodes, bsp leafs, rendering, collisions)
19#define Q3LUMP_LEAFS 4 // bsp leafs (used by bsp nodes)
20#define Q3LUMP_LEAFFACES 5 // array of ints indexing faces (used by leafs)
21#define Q3LUMP_LEAFBRUSHES 6 // array of ints indexing brushes (used by leafs)
22#define Q3LUMP_MODELS 7 // models (used by rendering, collisions)
23#define Q3LUMP_BRUSHES 8 // brushes (used by effects, collisions)
24#define Q3LUMP_BRUSHSIDES 9 // brush faces (used by brushes)
25#define Q3LUMP_VERTICES 10 // mesh vertices (used by faces)
26#define Q3LUMP_TRIANGLES 11 // mesh triangles (used by faces)
27#define Q3LUMP_EFFECTS 12 // fog (used by faces)
28#define Q3LUMP_FACES 13 // surfaces (used by leafs)
29#define Q3LUMP_LIGHTMAPS 14 // lightmap textures (used by faces)
30#define Q3LUMP_LIGHTGRID 15 // lighting as a voxel grid (used by rendering)
31#define Q3LUMP_PVS 16 // potentially visible set; bit[clusters][clusters] (used by rendering)
32#define Q3HEADER_LUMPS 17
33#define Q3LUMP_ADVERTISEMENTS 17 // quake live stuff written by zeroradiant's q3map2 (ignored by DP)
34#define Q3HEADER_LUMPS_LIVE 18
35#define Q3HEADER_LUMPS_MAX 18
36
37typedef struct q3dheader_s
38{
39 int ident;
43
44typedef struct q3dtexture_s
45{
49}
51
52// note: planes are paired, the pair of planes with i and i ^ 1 are opposites.
53typedef struct q3dplane_s
54{
55 float normal[3];
56 float dist;
57}
59
60typedef struct q3dnode_s
61{
63 int childrenindex[2];
64 int mins[3];
65 int maxs[3];
66}
68
69typedef struct q3dleaf_s
70{
71 int clusterindex; // pvs index
72 int areaindex; // area index
73 int mins[3];
74 int maxs[3];
79}
81
82typedef struct q3dmodel_s
83{
84 float mins[3];
85 float maxs[3];
90}
92
93typedef struct q3dbrush_s
94{
98}
100
101typedef struct q3dbrushside_s
102{
105}
107
108typedef struct q3dbrushside_ig_s
109{
113}
115
116typedef struct q3dvertex_s
117{
118 float origin3f[3];
119 float texcoord2f[2];
120 float lightmap2f[2];
121 float normal3f[3];
122 unsigned char color4ub[4];
123}
125
126typedef struct q3dmeshvertex_s
127{
128 int offset; // first vertex index of mesh
129}
131
132typedef struct q3deffect_s
133{
134 char shadername[Q3PATHLENGTH];
136 int unknown; // I read this is always 5 except in q3dm8 which has one effect with -1
137}
139
140#define Q3FACETYPE_FLAT 1 // common
141#define Q3FACETYPE_PATCH 2 // common
142#define Q3FACETYPE_MESH 3 // common
143#define Q3FACETYPE_FLARE 4 // rare (is this ever used?)
144
145typedef struct q3dface_s
146{
148 int effectindex; // -1 if none
149 int type; // Q3FACETYPE
154 int lightmapindex; // -1 if none
155 int lightmap_base[2];
156 int lightmap_size[2];
157 union
158 {
159 struct
160 {
161 // corrupt or don't care
162 int blah[14];
163 }
165 struct
166 {
167 // Q3FACETYPE_FLAT
168 // mesh is a collection of triangles on a plane, renderable as a mesh (NOT a polygon)
169 float lightmap_origin[3];
170 float lightmap_vectors[2][3];
171 float normal[3];
172 int unused1[2];
173 }
175 struct
176 {
177 // Q3FACETYPE_PATCH
178 // patch renders as a bezier mesh, with adjustable tesselation
179 // level (optionally based on LOD using the bbox and polygon
180 // count to choose a tesselation level)
181 // note: multiple patches may have the same bbox to cause them to
182 // be LOD adjusted together as a group
183 int unused1[3];
184 float mins[3]; // LOD bbox
185 float maxs[3]; // LOD bbox
186 int unused2[3];
187 int patchsize[2]; // dimensions of vertex grid
188 }
190 struct
191 {
192 // Q3FACETYPE_MESH
193 // mesh renders as simply a triangle mesh
194 int unused1[3];
195 float mins[3];
196 float maxs[3];
197 int unused2[5];
198 }
200 struct
201 {
202 // Q3FACETYPE_FLARE
203 // flare renders as a simple sprite at origin, no geometry
204 // exists, nor does it have a radius, a cvar controls the radius
205 // and another cvar controls distance fade
206 // (they were not used in Q3 I'm told)
207 float origin[3];
208 int unused1[11];
209 }
211 }
213}
215
216typedef struct q3dlightmap_s
217{
218 unsigned char rgb[128*128*3];
219}
221
222typedef struct q3dlightgrid_s
223{
224 unsigned char ambientrgb[3];
225 unsigned char diffusergb[3];
226 unsigned char diffusepitch;
227 unsigned char diffuseyaw;
228}
230
231typedef struct q3dpvs_s
232{
235 // unsigned char chains[];
236 // containing bits in 0-7 order (not 7-0 order),
237 // pvschains[mycluster * chainlength + (thatcluster >> 3)] & (1 << (thatcluster & 7))
238}
240
241// surfaceflags from bsp
242#define Q3SURFACEFLAG_NODAMAGE 1
243#define Q3SURFACEFLAG_SLICK 2
244#define Q3SURFACEFLAG_SKY 4
245#define Q3SURFACEFLAG_LADDER 8 // has no surfaceparm
246#define Q3SURFACEFLAG_NOIMPACT 16
247#define Q3SURFACEFLAG_NOMARKS 32
248#define Q3SURFACEFLAG_FLESH 64 // has no surfaceparm
249#define Q3SURFACEFLAG_NODRAW 128
250#define Q3SURFACEFLAG_HINT 256
251#define Q3SURFACEFLAG_SKIP 512 // has no surfaceparm
252#define Q3SURFACEFLAG_NOLIGHTMAP 1024
253#define Q3SURFACEFLAG_POINTLIGHT 2048
254#define Q3SURFACEFLAG_METALSTEPS 4096
255#define Q3SURFACEFLAG_NOSTEPS 8192 // has no surfaceparm
256#define Q3SURFACEFLAG_NONSOLID 16384
257#define Q3SURFACEFLAG_LIGHTFILTER 32768
258#define Q3SURFACEFLAG_ALPHASHADOW 65536
259#define Q3SURFACEFLAG_NODLIGHT 131072
260#define Q3SURFACEFLAG_DUST 262144
261
262// surfaceparms from shaders
263#define Q3SURFACEPARM_ALPHASHADOW 1
264#define Q3SURFACEPARM_AREAPORTAL 2
265#define Q3SURFACEPARM_CLUSTERPORTAL 4
266#define Q3SURFACEPARM_DETAIL 8
267#define Q3SURFACEPARM_DONOTENTER 16
268#define Q3SURFACEPARM_FOG 32
269#define Q3SURFACEPARM_LAVA 64
270#define Q3SURFACEPARM_LIGHTFILTER 128
271#define Q3SURFACEPARM_METALSTEPS 256
272#define Q3SURFACEPARM_NODAMAGE 512
273#define Q3SURFACEPARM_NODLIGHT 1024
274#define Q3SURFACEPARM_NODRAW 2048
275#define Q3SURFACEPARM_NODROP 4096
276#define Q3SURFACEPARM_NOIMPACT 8192
277#define Q3SURFACEPARM_NOLIGHTMAP 16384
278#define Q3SURFACEPARM_NOMARKS 32768
279#define Q3SURFACEPARM_NOMIPMAPS 65536
280#define Q3SURFACEPARM_NONSOLID 131072
281#define Q3SURFACEPARM_ORIGIN 262144
282#define Q3SURFACEPARM_PLAYERCLIP 524288
283#define Q3SURFACEPARM_SKY 1048576
284#define Q3SURFACEPARM_SLICK 2097152
285#define Q3SURFACEPARM_SLIME 4194304
286#define Q3SURFACEPARM_STRUCTURAL 8388608
287#define Q3SURFACEPARM_TRANS 16777216
288#define Q3SURFACEPARM_WATER 33554432
289#define Q3SURFACEPARM_POINTLIGHT 67108864
290#define Q3SURFACEPARM_HINT 134217728
291#define Q3SURFACEPARM_DUST 268435456
292#define Q3SURFACEPARM_BOTCLIP 536870912
293#define Q3SURFACEPARM_LIGHTGRID 1073741824
294#define Q3SURFACEPARM_ANTIPORTAL 2147483648u
295
296typedef struct q3mbrush_s
297{
298 struct colbrushf_s *colbrushf;
300 struct q3mbrushside_s *firstbrushside;
301 struct texture_s *texture;
302}
304
305typedef struct q3mbrushside_s
306{
307 struct mplane_s *plane;
308 struct texture_s *texture;
309}
311
312typedef struct model_brushq3_s
313{
316
317 // used only during loading - freed after loading!
324
325 // freed after loading!
328
331
332 // lightmap textures
341
342 // voxel light data with directional shading - data for cpu sampling of it...
345 // size of each cell (may vary by map, typically 64 64 128)
346 float num_lightgrid_cellsize[3];
347 // 1.0 / num_lightgrid_cellsize
348 float num_lightgrid_scale[3];
349 // dimensions of the world model in lightgrid cells
350 int num_lightgrid_imins[3];
351 int num_lightgrid_imaxs[3];
352 int num_lightgrid_isize[3];
353 // transform modelspace coordinates to lightgrid index
355 // parameters for fragment shader to sample the texture version of it:
356 int lightgridtexturesize[3]; // 3 layers tall (ambient, lightcolor, lightdir)
359
360 // true if this q3bsp file has been detected as using deluxemapping
361 // (lightmap texture pairs, every odd one is never directly refernced,
362 // and contains lighting normals, not colors)
364 // true if the detected deluxemaps are the modelspace kind, rather than
365 // the faster tangentspace kind
367 // size of lightmaps (128 by default, but may be another poweroftwo if
368 // external lightmaps are used (q3map2 -lightmapsize)
370}
372
373#endif
vector mins
vector maxs
vector origin
const GLchar * name
Definition glquake.h:601
#define Q3HEADER_LUMPS_MAX
Definition model_q3bsp.h:35
bool qbool
Definition qtypes.h:9
#define Q3PATHLENGTH
Definition r_qshader.h:17
vec3 normal
dp_FragColor rgb
float * data_texcoordtexture2f
matrix4x4_t num_lightgrid_indexfromworld
float * data_normal3f
float * data_texcoordlightmap2f
int num_lightmapmergedwidthpower
q3dmodel_t * data_models
rtexture_t ** data_lightmaps
q3deffect_t * data_effects
float * data_vertex3f
matrix4x4_t lightgridworldtotexturematrix
q3dlightgrid_t * data_lightgrid
float * data_color4f
rtexture_t ** data_deluxemaps
qbool deluxemapping_modelspace
int num_lightmapmergedheightpower
rtexture_t * lightgridtexture
int num_lightmapmergedwidthheightdeluxepower
int textureindex
Definition model_q3bsp.h:97
int firstbrushside
Definition model_q3bsp.h:95
int numbrushsides
Definition model_q3bsp.h:96
struct q3dface_t::@23::@24 unknown
union q3dface_t::@23 specific
int numelements
struct q3dface_t::@23::@26 patch
struct q3dface_t::@23::@27 mesh
int effectindex
int firstvertex
struct q3dface_t::@23::@25 flat
struct q3dface_t::@23::@28 flare
int lightmapindex
int textureindex
int firstelement
int numvertices
int firstleafbrush
Definition model_q3bsp.h:77
int areaindex
Definition model_q3bsp.h:72
int firstleafface
Definition model_q3bsp.h:75
int numleafbrushes
Definition model_q3bsp.h:78
int clusterindex
Definition model_q3bsp.h:71
int numleaffaces
Definition model_q3bsp.h:76
unsigned char diffuseyaw
unsigned char diffusepitch
int planeindex
Definition model_q3bsp.h:62
int chainlength
int numclusters
int numbrushsides
struct colbrushf_s * colbrushf
struct q3mbrushside_s * firstbrushside
struct texture_s * texture
struct mplane_s * plane
struct texture_s * texture