| 1 |
|
| 2 |
#include "mathlib.h" |
| 3 |
|
| 4 |
const int LUMP_ENTITIES = 0; |
| 5 |
const int LUMP_SHADERS = 1; |
| 6 |
const int LUMP_PLANES = 2; |
| 7 |
const int LUMP_NODES = 3; |
| 8 |
const int LUMP_LEAFS = 4; |
| 9 |
const int LUMP_LEAFSURFACES = 5; |
| 10 |
const int LUMP_LEAFBRUSHES = 6; |
| 11 |
const int LUMP_MODELS = 7; |
| 12 |
const int LUMP_BRUSHES = 8; |
| 13 |
const int LUMP_BRUSHSIDES = 9; |
| 14 |
const int LUMP_DRAWVERTS = 10; |
| 15 |
const int LUMP_DRAWINDEXES = 11; |
| 16 |
const int LUMP_FOGS = 12; |
| 17 |
const int LUMP_SURFACES = 13; |
| 18 |
const int LUMP_LIGHTMAPS = 14; |
| 19 |
const int LUMP_LIGHTGRID = 15; |
| 20 |
const int LUMP_VISIBILITY = 16; |
| 21 |
const int HEADER_LUMPS = 17; |
| 22 |
|
| 23 |
typedef struct { |
| 24 |
int fileofs, filelen; |
| 25 |
} lump_t; |
| 26 |
|
| 27 |
typedef struct { |
| 28 |
int ident; |
| 29 |
int version; |
| 30 |
|
| 31 |
lump_t lumps[HEADER_LUMPS]; |
| 32 |
} dheader_t; |
| 33 |
|
| 34 |
typedef struct { |
| 35 |
float normal[3]; |
| 36 |
float dist; |
| 37 |
} dplane_t; |
| 38 |
|
| 39 |
typedef struct { |
| 40 |
int planeNum; |
| 41 |
int children[2]; |
| 42 |
int mins[3]; |
| 43 |
int maxs[3]; |
| 44 |
} dnode_t; |
| 45 |
|
| 46 |
typedef struct { |
| 47 |
int cluster; |
| 48 |
int area; |
| 49 |
|
| 50 |
int mins[3]; |
| 51 |
int maxs[3]; |
| 52 |
|
| 53 |
int firstLeafSurface; |
| 54 |
int numLeafSurfaces; |
| 55 |
|
| 56 |
int firstLeafBrush; |
| 57 |
int numLeafBrushes; |
| 58 |
} dleaf_t; |
| 59 |
|
| 60 |
typedef struct { |
| 61 |
vec3_t xyz; |
| 62 |
float st[2]; |
| 63 |
float lightmap[2]; |
| 64 |
vec3_t normal; |
| 65 |
byte color[4]; |
| 66 |
} qdrawVert_t; |
| 67 |
|
| 68 |
typedef struct { |
| 69 |
int shaderNum; |
| 70 |
int fogNum; |
| 71 |
int surfaceType; |
| 72 |
|
| 73 |
int firstVert; |
| 74 |
int numVerts; |
| 75 |
|
| 76 |
int firstIndex; |
| 77 |
int numIndexes; |
| 78 |
|
| 79 |
int lightmapNum; |
| 80 |
int lightmapX, lightmapY; |
| 81 |
int lightmapWidth, lightmapHeight; |
| 82 |
|
| 83 |
vec3_t lightmapOrigin; |
| 84 |
vec3_t lightmapVecs[3]; |
| 85 |
|
| 86 |
int patchWidth; |
| 87 |
int patchHeight; |
| 88 |
} dsurface_t; |
| 89 |
|
| 90 |
typedef struct { |
| 91 |
int planeNum; |
| 92 |
int shaderNum; |
| 93 |
} dbrushside_t; |
| 94 |
|
| 95 |
typedef struct { |
| 96 |
int firstSide; |
| 97 |
int numSides; |
| 98 |
int shaderNum; |
| 99 |
} dbrush_t; |
| 100 |
|
| 101 |
typedef enum { |
| 102 |
MST_BAD, |
| 103 |
MST_PLANAR, |
| 104 |
MST_PATCH, |
| 105 |
MST_TRIANGLE_SOUP, |
| 106 |
MST_FLARE |
| 107 |
} mapSurfaceType_t; |
| 108 |
|
| 109 |
const int MAX_MAP_VISIBILITY = 0x200000; |
| 110 |
const int MAX_MAP_NODES = 0x20000; |
| 111 |
const int MAX_MAP_PLANES = 0x20000; |
| 112 |
const int MAX_MAP_LEAFS = 0x20000; |
| 113 |
|
| 114 |
extern int numVisBytes; |
| 115 |
extern int numleafs; |
| 116 |
extern int numplanes; |
| 117 |
extern int numnodes; |
| 118 |
extern int numDrawVerts; |
| 119 |
extern int numDrawSurfaces; |
| 120 |
extern int numleafsurfaces; |
| 121 |
extern int numbrushes; |
| 122 |
extern int numbrushsides; |
| 123 |
extern int numleafbrushes; |
| 124 |
|
| 125 |
extern dnode_t *dnodes; |
| 126 |
extern dplane_t *dplanes; |
| 127 |
extern dleaf_t *dleafs; |
| 128 |
extern byte *visBytes; |
| 129 |
extern qdrawVert_t *drawVerts; |
| 130 |
extern dsurface_t *drawSurfaces; |
| 131 |
extern int *dleafsurfaces; |
| 132 |
extern dbrush_t *dbrushes; |
| 133 |
extern dbrushside_t *dbrushsides; |
| 134 |
extern int *dleafbrushes; |
| 135 |
|
| 136 |
bool LoadBSPFile( const char *filename ); |
| 137 |
void FreeBSPData(); |