altEngine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
bspTypes.h
Go to the documentation of this file.
1 typedef unsigned char byte;
2 
3 #define LUMP_ENTITIES 0
4 #define LUMP_SHADERS 1
5 #define LUMP_PLANES 2
6 #define LUMP_NODES 3
7 #define LUMP_LEAFS 4
8 #define LUMP_LEAFSURFACES 5
9 #define LUMP_LEAFBRUSHES 6
10 #define LUMP_MODELS 7
11 #define LUMP_BRUSHES 8
12 #define LUMP_BRUSHSIDES 9
13 #define LUMP_DRAWVERTS 10
14 #define LUMP_DRAWINDEXES 11
15 #define LUMP_FOGS 12
16 #define LUMP_SURFACES 13
17 #define LUMP_LIGHTMAPS 14
18 #define LUMP_LIGHTGRID 15
19 #define LUMP_VISIBILITY 16
20 #define HEADER_LUMPS 17
21 
22 // 'Unknown' surface flags pulled from q3map source
23 #define SURF_NODAMAGE 0x1 // never give falling damage
24 #define SURF_SLICK 0x2 // effects game physics
25 #define SURF_SKY 0x4 // lighting from environment map
26 #define SURF_LADDER 0x8
27 #define SURF_NOIMPACT 0x10 // don't make missile explosions
28 #define SURF_NOMARKS 0x20 // don't leave missile marks
29 #define SURF_FLESH 0x40 // make flesh sounds and effects
30 #define SURF_NODRAW 0x80 // don't generate a drawsurface at all
31 #define SURF_HINT 0x100 // make a primary bsp splitter
32 #define SURF_SKIP 0x200 // completely ignore, allowing non-closed brushes
33 #define SURF_NOLIGHTMAP 0x400 // surface doesn't need a lightmap
34 #define SURF_POINTLIGHT 0x800 // generate lighting info at vertexes
35 #define SURF_METALSTEPS 0x1000 // clanking footsteps
36 #define SURF_NOSTEPS 0x2000 // no footstep sounds
37 #define SURF_NONSOLID 0x4000 // don't collide against curves with this set
38 #define SURF_LIGHTFILTER 0x8000 // act as a light filter during q3map -light
39 #define SURF_ALPHASHADOW 0x10000 // do per-pixel light shadow casting in q3map
40 #define SURF_NODLIGHT 0x20000 // don't dlight even if solid (solid lava, skies)
41 #define SURF_DUST 0x40000 // leave a dust trail when walking on this surface
42 
43 // 'Unknown' content flags pulled from q3map source
44 #define CONTENTS_SOLID 1 // an eye is never valid in a solid
45 #define CONTENTS_LAVA 8
46 #define CONTENTS_SLIME 16
47 #define CONTENTS_WATER 32
48 #define CONTENTS_FOG 64
49 
50 #define CONTENTS_NOTTEAM1 0x0080
51 #define CONTENTS_NOTTEAM2 0x0100
52 #define CONTENTS_NOBOTCLIP 0x0200
53 #define CONTENTS_AREAPORTAL 0x8000
54 #define CONTENTS_PLAYERCLIP 0x10000
55 #define CONTENTS_MONSTERCLIP 0x20000
56 //bot specific contents types
57 #define CONTENTS_TELEPORTER 0x40000
58 #define CONTENTS_JUMPPAD 0x80000
59 #define CONTENTS_CLUSTERPORTAL 0x100000
60 #define CONTENTS_DONOTENTER 0x200000
61 #define CONTENTS_BOTCLIP 0x400000
62 #define CONTENTS_MOVER 0x800000
63 #define CONTENTS_ORIGIN 0x1000000 // removed before bsping an entity
64 #define CONTENTS_BODY 0x2000000 // should never be on a brush, only in game
65 #define CONTENTS_CORPSE 0x4000000
66 #define CONTENTS_DETAIL 0x8000000 // brushes not used for the bsp
67 #define CONTENTS_STRUCTURAL 0x10000000 // brushes used for the bsp
68 #define CONTENTS_TRANSLUCENT 0x20000000 // don't consume surface fragments inside
69 #define CONTENTS_TRIGGER 0x40000000
70 #define CONTENTS_NODROP 0x80000000
71 
72 typedef enum
73 {
74  Entities = 0, // Stores player/object positions, etc...
75  Materials, // Stores texture information
76  Planes, // Stores the splitting planes
77  Nodes, // Stores the BSP nodes
78  Leafs, // Stores the leafs of the nodes
79  LeafFaces, // Stores the leaf's indices into the faces
80  LeafBrushes, // Stores the leaf's indices into the brushes
81  Models, // Stores the info of world models
82  Brushes, // Stores the brushes info (brushes are a set of planes defining solid volume)
83  BrushSides, // Stores the brush surfaces info
84  VertexArray, // Stores the level vertices
85  IndexArray, // Stores the model vertices offsets - this is just wrong, these are the indicies for the face verticies. Try rendering q3map2 bsps.
86  Fog, // Stores the shader files (blending, anims..)
87  Faces, // Stores the faces for the level
88  LightMaps, // Stores the lightmaps for the level
89  LightGrids, // Stores extra world lighting information
90  VisData, // Stores PVS cluster info (visibility)
91  MaxLumps // A constant to store the number of lumps
92 } lumps;
93 
94 typedef struct
95 {
96  vec3 position; // (x, y, z) position.
97  vec2 texCoord0; // (u, v) texture coordinate
98  vec2 texCoord1; // (u, v) lightmap coordinate
99  vec3 normal; // (x, y, z) normal vector
100  int color; // RGBA color for the vertex
101 } bspvertex_t;
102 
103 typedef struct
104 {
105  char material[64];
107  int visible_side; // the brush side that ray tests need to clip against (-1 == none)
108 } fog_t;
109 
110 typedef enum
111 {
117 } facetype_t;
118 
119 typedef struct
120 {
121  int material;
122  int fog_num;
123  int type;
124 
125  int vertex;
127 
128  int index;
130 
131  int lightmap;
132  int lightmapX, lightmapY;
133  int lightmapWidth, lightmapHeight;
134 
136  vec3 lightmapVecs[3]; // for patches, [0] and [1] are lodbounds
137 
140 } face_t;
141 
142 typedef struct
143 {
144  char name[64]; // The name of the texture w/o the extension
145  int surface; // The surface flags (unknown)
146  int contents; // The content flags (unknown)
147 } material_t;
148 
149 typedef struct
150 {
151  char image[128][128][3]; // The RGB data in a 128x128 image
152 } lightmap_t;
153 
154 typedef struct
155 {
156  int plane; // The index into the planes array
157  int front; // The child index for the front node
158  int back; // The child index for the back node
159  int min[3]; // The bounding box min position.
160  int max[3]; // The bounding box max position.
161 } node_t;
162 
163 typedef struct
164 {
165  int cluster; // The visibility cluster
166  int area; // The area portal
167  int min[3]; // The bounding box min position
168  int max[3]; // The bounding box max position
169  int leaf_face; // The first index into the leafface array
170  int num_faces; // The number of faces for this leaf
171  int leaf_brush; // The first index for into the leafbrush array
172  int num_brushes; // The number of brushes for this leaf
173 } leaf_t;
174 
175 typedef struct
176 {
177  vec3 normal; // Plane normal.
178  float d; // The plane distance from origin
179 } plane_t;
180 
181 typedef struct
182 {
183  int num_vectors; // This stores the number of bit-vectors
184  int vector_size; // The size of bit-vectors in bytes
185  byte pVecs; // This holds all of the cluster bits
186 } visData_t;
187 
188 typedef struct
189 {
190  int first_side; // The starting brush side for the brush
191  int num_sides; // Number of brush sides for the brush
192  int material; // the shader that determines the contents flags
193 } brush_t;
194 
195 typedef struct
196 {
197  int plane; // The plane index
198  int material; // The texture index
199 } brushSide_t;
200 
201 typedef struct
202 {
203  float min[3]; // The min position for the bounding box
204  float max[3]; // The max position for the bounding box.
205  int face_index; // The first face index in the model
206  int num_faces; // The number of faces in the model
207  int brush_index; // The first brush index in the model
208  int num_brushes; // The number brushes for the model
209 } model_t;
210 
211 typedef struct
212 {
213  byte ambient[3]; // This is the ambient color in RGB
214  byte directional[3]; // This is the directional color in RGB
215  byte direction[2]; // The direction of the light: [phi,theta]
216 } lightgrid_t;
217 
218 typedef struct
219 {
220  int offset; // Offset to start of lump, relative to beginning of file.
221  int length; // Length of lump. Always a multiple of 4.
222 } lump_t;
223 
224 typedef struct
225 {
226  byte strId[4]; // IBSP
227  int version; // 0x2e
228  lump_t directory[17];
229 } bsp_t;
230 
231 typedef struct
232 {
239  int *LeafFace;
240  int *LeafBrush;
250 
251  unsigned int num_ents;
252  unsigned int num_materials;
253  unsigned int num_planes;
254  unsigned int num_nodes;
255  unsigned int num_leafs;
256  unsigned int num_LeafFaces;
257  unsigned int num_LeafBrushes;
258  unsigned int num_model;
259  unsigned int num_brushes;
260  unsigned int num_BrushSides;
261  unsigned int num_verts;
262  unsigned int num_faces;
263  unsigned int num_vis;
264  unsigned int num_index;
265  unsigned int num_lightmaps;
266  unsigned int num_fog;
267 } bspData_t;