|
@@ -14,10 +14,23 @@
|
14
|
14
|
#endif
|
15
|
15
|
|
16
|
16
|
#include <algorithm>
|
|
17
|
+#include <assert.h>
|
17
|
18
|
|
18
|
19
|
#include "main.h"
|
19
|
20
|
#include "Room.h"
|
20
|
21
|
|
|
22
|
+Light::Light(vec4_t pos, vec3_t dir, vec_t att, vec4_t color, vec_t cutoff, LightType type) {
|
|
23
|
+ for (unsigned int i = 0; i < 4; i++) {
|
|
24
|
+ mPos[i] = pos[i];
|
|
25
|
+ mColor[i] = color[i];
|
|
26
|
+ if (i < 3)
|
|
27
|
+ mDir[i] = dir[i];
|
|
28
|
+ }
|
|
29
|
+ mAtt = att;
|
|
30
|
+ mCutoff = cutoff;
|
|
31
|
+ mType = type;
|
|
32
|
+}
|
|
33
|
+
|
21
|
34
|
StaticModel::StaticModel(int _index, vec_t _yaw, vec3_t _pos) {
|
22
|
35
|
index = _index;
|
23
|
36
|
yaw = _yaw;
|
|
@@ -62,6 +75,18 @@ Portal::Portal(vec3_t _vertices[4], vec3_t _normal, int _adjoiningRoom) {
|
62
|
75
|
adjoiningRoom = _adjoiningRoom;
|
63
|
76
|
}
|
64
|
77
|
|
|
78
|
+void Portal::getVertices(vec3_t vert[4]) {
|
|
79
|
+ for (unsigned int i = 0; i < 4; i++) {
|
|
80
|
+ for (unsigned int j = 0; j < 3; j++) {
|
|
81
|
+ vert[i][j] = vertices[i][j];
|
|
82
|
+ }
|
|
83
|
+ }
|
|
84
|
+}
|
|
85
|
+
|
|
86
|
+int Portal::getAdjoiningRoom() {
|
|
87
|
+ return adjoiningRoom;
|
|
88
|
+}
|
|
89
|
+
|
65
|
90
|
Box::Box(vec3_t _a, vec3_t _b, vec3_t _c, vec3_t _d) {
|
66
|
91
|
for (unsigned int i = 0; i < 3; i++) {
|
67
|
92
|
a[i] = _a[i];
|
|
@@ -77,6 +102,18 @@ Sector::Sector(vec_t _floor, vec_t _ceiling, bool _wall) {
|
77
|
102
|
wall = _wall;
|
78
|
103
|
}
|
79
|
104
|
|
|
105
|
+vec_t Sector::getFloor() {
|
|
106
|
+ return floor;
|
|
107
|
+}
|
|
108
|
+
|
|
109
|
+vec_t Sector::getCeiling() {
|
|
110
|
+ return ceiling;
|
|
111
|
+}
|
|
112
|
+
|
|
113
|
+bool Sector::isWall() {
|
|
114
|
+ return wall;
|
|
115
|
+}
|
|
116
|
+
|
80
|
117
|
Room::Room(int _id) {
|
81
|
118
|
id = _id;
|
82
|
119
|
flags = 0;
|
|
@@ -110,7 +147,157 @@ Room::~Room() {
|
110
|
147
|
}
|
111
|
148
|
}
|
112
|
149
|
|
|
150
|
+void Room::setFlags(unsigned int f) {
|
|
151
|
+ flags = f;
|
|
152
|
+}
|
|
153
|
+
|
|
154
|
+unsigned int Room::getFlags() {
|
|
155
|
+ return flags;
|
|
156
|
+}
|
|
157
|
+
|
|
158
|
+void Room::setNumXSectors(unsigned int n) {
|
|
159
|
+ numXSectors = n;
|
|
160
|
+}
|
|
161
|
+
|
|
162
|
+unsigned int Room::getNumXSectors() {
|
|
163
|
+ return numXSectors;
|
|
164
|
+}
|
|
165
|
+
|
|
166
|
+void Room::setNumZSectors(unsigned int n) {
|
|
167
|
+ numZSectors = n;
|
|
168
|
+}
|
|
169
|
+
|
|
170
|
+unsigned int Room::getNumZSectors() {
|
|
171
|
+ return numZSectors;
|
|
172
|
+}
|
|
173
|
+
|
|
174
|
+void Room::setPos(vec3_t p) {
|
|
175
|
+ for (unsigned int i = 0; i < 3; i++)
|
|
176
|
+ pos[i] = p[i];
|
|
177
|
+}
|
|
178
|
+
|
|
179
|
+void Room::getPos(vec3_t p) {
|
|
180
|
+ for (unsigned int i = 0; i < 3; i++)
|
|
181
|
+ p[i] = pos[i];
|
|
182
|
+}
|
|
183
|
+
|
|
184
|
+void Room::getBoundingBox(vec3_t box[2]) {
|
|
185
|
+ for (unsigned int i = 0; i < 2; i++)
|
|
186
|
+ for (unsigned int j = 0; j < 3; j++)
|
|
187
|
+ box[i][j] = bbox[i][j];
|
|
188
|
+}
|
|
189
|
+
|
|
190
|
+void Room::setBoundingBox(vec3_t box[2]) {
|
|
191
|
+ for (unsigned int i = 0; i < 2; i++)
|
|
192
|
+ for (unsigned int j = 0; j < 3; j++)
|
|
193
|
+ bbox[i][j] = box[i][j];
|
|
194
|
+}
|
|
195
|
+
|
|
196
|
+bool Room::inBox(vec_t x, vec_t y, vec_t z) {
|
|
197
|
+ return ((y > bbox[0][1]) && (y < bbox[1][1]) && inBoxPlane(x, z));
|
|
198
|
+}
|
|
199
|
+
|
|
200
|
+bool Room::inBoxPlane(vec_t x, vec_t z) {
|
|
201
|
+ return ((x > bbox[0][0]) && (x < bbox[1][0])
|
|
202
|
+ && (z > bbox[0][2]) && (z < bbox[1][2]));
|
|
203
|
+}
|
|
204
|
+
|
|
205
|
+unsigned int Room::sizeAdjacentRooms() {
|
|
206
|
+ return adjacentRooms.size();
|
|
207
|
+}
|
|
208
|
+
|
|
209
|
+int Room::getAdjacentRoom(unsigned int index) {
|
|
210
|
+ assert(index < adjacentRooms.size());
|
|
211
|
+ return adjacentRooms.at(index);
|
|
212
|
+}
|
|
213
|
+
|
|
214
|
+void Room::addAdjacentRoom(int r) {
|
|
215
|
+ adjacentRooms.push_back(r);
|
|
216
|
+}
|
|
217
|
+
|
|
218
|
+unsigned int Room::sizePortals() {
|
|
219
|
+ return portals.size();
|
|
220
|
+}
|
|
221
|
+
|
|
222
|
+Portal &Room::getPortal(unsigned int index) {
|
|
223
|
+ assert(index < portals.size());
|
|
224
|
+ return *portals.at(index);
|
|
225
|
+}
|
|
226
|
+
|
|
227
|
+void Room::addPortal(Portal &p) {
|
|
228
|
+ portals.push_back(&p);
|
|
229
|
+}
|
|
230
|
+
|
|
231
|
+unsigned int Room::sizeSectors() {
|
|
232
|
+ return sectors.size();
|
|
233
|
+}
|
|
234
|
+
|
|
235
|
+Sector &Room::getSector(unsigned int index) {
|
|
236
|
+ assert(index < sectors.size());
|
|
237
|
+ return *sectors.at(index);
|
|
238
|
+}
|
|
239
|
+
|
|
240
|
+void Room::addSector(Sector &s) {
|
|
241
|
+ sectors.push_back(&s);
|
|
242
|
+}
|
|
243
|
+
|
|
244
|
+unsigned int Room::sizeBox() {
|
|
245
|
+ return boxes.size();
|
|
246
|
+}
|
|
247
|
+
|
|
248
|
+Box &Room::getBox(unsigned int index) {
|
|
249
|
+ assert(index < boxes.size());
|
|
250
|
+ return *boxes.at(index);
|
|
251
|
+}
|
|
252
|
+
|
|
253
|
+void Room::addBox(Box &b) {
|
|
254
|
+ boxes.push_back(&b);
|
|
255
|
+}
|
|
256
|
+
|
|
257
|
+unsigned int Room::sizeModels() {
|
|
258
|
+ return models.size();
|
|
259
|
+}
|
|
260
|
+
|
|
261
|
+StaticModel &Room::getModel(unsigned int index) {
|
|
262
|
+ assert(index < models.size());
|
|
263
|
+ return *models.at(index);
|
|
264
|
+}
|
|
265
|
+
|
|
266
|
+void Room::addModel(StaticModel &m) {
|
|
267
|
+ models.push_back(&m);
|
|
268
|
+}
|
|
269
|
+
|
113
|
270
|
void Room::sortModels() {
|
114
|
271
|
std::sort(models.begin(), models.end());
|
115
|
272
|
}
|
116
|
273
|
|
|
274
|
+unsigned int Room::sizeLights() {
|
|
275
|
+ return lights.size();
|
|
276
|
+}
|
|
277
|
+
|
|
278
|
+Light &Room::getLight(unsigned int index) {
|
|
279
|
+ assert(index < lights.size());
|
|
280
|
+ return *lights.at(index);
|
|
281
|
+}
|
|
282
|
+
|
|
283
|
+void Room::addLight(Light &l) {
|
|
284
|
+ lights.push_back(&l);
|
|
285
|
+}
|
|
286
|
+
|
|
287
|
+unsigned int Room::sizeSprites() {
|
|
288
|
+ return sprites.size();
|
|
289
|
+}
|
|
290
|
+
|
|
291
|
+Sprite &Room::getSprite(unsigned int index) {
|
|
292
|
+ assert(index < sprites.size());
|
|
293
|
+ return *sprites.at(index);
|
|
294
|
+}
|
|
295
|
+
|
|
296
|
+void Room::addSprite(Sprite &s) {
|
|
297
|
+ sprites.push_back(&s);
|
|
298
|
+}
|
|
299
|
+
|
|
300
|
+Mesh &Room::getMesh() {
|
|
301
|
+ return mesh;
|
|
302
|
+}
|
|
303
|
+
|