-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbspfile.h
More file actions
146 lines (121 loc) · 3.55 KB
/
bspfile.h
File metadata and controls
146 lines (121 loc) · 3.55 KB
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
#ifndef BSPFILE_H
#define BSPFILE_H
#include "basictypes.h"
typedef struct // Bounding Box, Float values
{
Vec3 min; // minimum values of X,Y,Z
Vec3 max; // maximum values of X,Y,Z
} BoundBox;
typedef struct // Bounding Box, Short values
{
short min; // minimum values of X,Y,Z
short max; // maximum values of X,Y,Z
} BBoxShort;
struct BSPEntry
{
/** Offset to this entry, in bytes, from the start of the file. */
int offset;
/** Size of this entry in bytes. */
int size;
};
struct BSPEdge
{
unsigned short vertex1;
unsigned short vertex2;
};
#define MAX_LIGHTMAPS 4
struct BSPFace
{
short planeNumber;
short side;
int firstEdge;
short countOfEdges;
short textureInfo;
// lighting info
unsigned char styles[MAX_LIGHTMAPS];
int lightOffset; // start of [numstyles*surfsize] samples
short getEdge(int edge);
};
struct BSPTextureInfo
{
Vec3 vectorS; // S vector, horizontal in texture space)
scalar distS; // horizontal offset in texture space
Vec3 vectorT; // T vector, vertical in texture space
scalar distT; // vertical offset in texture space
int textureId; // Index of MipTexExtries
int animated; // 0 for ordinary textures, 1 for water
};
#define MIPLEVELS 4
struct BSPMipTex {
char name[16];
unsigned width;
unsigned height;
unsigned offsets[MIPLEVELS]; // four mip maps stored
};
struct BSPMipTexEntries {
int numMipTex;
int dataofs[]; // [nummiptex]
};
#define MAX_MAP_HULLS 4
struct BSPModel
{
BoundBox bounds;
Vec3 origin;
int headnode[MAX_MAP_HULLS];
int numLeaves; // number of BSP leaves
int faceId;
int numFaces;
};
struct BSPFile
{
/** BSP File Version number. */
int version; // Model version, must be 0x17 (23).
/** List of Entities. */
BSPEntry entities;
/** Planes: numplanes = size/sizeof(plane_t) */
BSPEntry planes;
/** Textures. */
BSPEntry miptex;
/** Vertices: numvertices = size/sizeof(vertex_t) */
BSPEntry vertices;
/** Visibility lists. */
BSPEntry visilist;
/** BSP Nodes: numnodes = size/sizeof(node_t) */
BSPEntry nodes;
/** Surface Texture Information: numtexinfo = size/sizeof(texinfo_t) */
BSPEntry texinfo;
/** Surface Faces: numfaces = size/sizeof(face_t) */
BSPEntry faces;
/** Lightmaps. */
BSPEntry lightmaps;
/** Clipnodes: numclips = size/sizeof(clipnode_t) */
BSPEntry clipnodes;
/** BSP Leaves: numlaves = size/sizeof(leaf_t) */
BSPEntry leaves;
/** List of faces. */
BSPEntry listOfFaces;
/** Edges: numedges = Size/sizeof(edge_t) */
BSPEntry edges;
/** List of edges. */
BSPEntry listOfEdges;
/** Sub-Models: List of Models: nummodels = Size/sizeof(model_t) */
BSPEntry models;
/** Checks the version number of this file vs the list of versions we support. */
bool isSupportedFile();
BSPModel *getModels();
int countOfModels();
char *getEntities();
int entityStringSize();
Vec3 *getVertices();
int countOfVertices();
BSPEdge *getEdges();
int countOfEdges();
BSPFace *getFaces();
int countOfFaces();
BSPTextureInfo *getTextureInfos();
int countOfTextureInfos();
int *getEdgeList();
BSPMipTexEntries *getTexturesEntries();
BSPMipTex *getMipTexture(int texture);
};
#endif // BSPFILE_H