-
Notifications
You must be signed in to change notification settings - Fork 1
/
bspfile.cpp
95 lines (76 loc) · 1.75 KB
/
bspfile.cpp
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
#include "bspfile.h"
bool BSPFile::isSupportedFile()
{
return this->version == 29;
}
BSPModel *BSPFile::getModels()
{
return (BSPModel *)((char *)this + this->models.offset);
}
int BSPFile::countOfModels()
{
return this->models.size / sizeof(BSPModel);
}
char *BSPFile::getEntities()
{
return (char *)this + this->entities.offset;
}
int BSPFile::entityStringSize()
{
return this->entities.size;
}
Vec3 *BSPFile::getVertices()
{
return (Vec3 *)((char *)this + this->vertices.offset);
}
int BSPFile::countOfVertices()
{
return this->vertices.size / sizeof(Vec3);
}
BSPEdge *BSPFile::getEdges()
{
return (BSPEdge *)((char *)this + this->edges.offset);
}
int BSPFile::countOfEdges()
{
return this->edges.size / sizeof(BSPEdge);
}
BSPFace *BSPFile::getFaces()
{
return (BSPFace *)((char *)this + this->faces.offset);
}
int BSPFile::countOfFaces()
{
return this->faces.size / sizeof(BSPFace);
}
BSPTextureInfo *BSPFile::getTextureInfos()
{
return (BSPTextureInfo *)((char *)this + this->texinfo.offset);
}
int BSPFile::countOfTextureInfos()
{
return this->texinfo.size / sizeof(BSPTextureInfo);
}
int *BSPFile::getEdgeList()
{
return (int *)((char *)this + this->listOfEdges.offset);
}
short BSPFace::getEdge(int edge)
{
short first = firstEdge;
if (0 > first) {
// reverse edge direction if negative values
return (countOfEdges - 1) - edge - first;
} else {
return first + edge;
}
}
BSPMipTexEntries *BSPFile::getTexturesEntries()
{
return (BSPMipTexEntries *)((char *)this + this->miptex.offset);
}
BSPMipTex *BSPFile::getMipTexture(int texture)
{
BSPMipTexEntries *entries = this->getTexturesEntries();
return (BSPMipTex *)((char *)entries + entries->dataofs[texture]);
}