|
@@ -16,6 +16,114 @@
|
16
|
16
|
#include "main.h"
|
17
|
17
|
#include "RoomData.h"
|
18
|
18
|
|
|
19
|
+BoundingBox::BoundingBox() {
|
|
20
|
+ a[0] = a[1] = a[2] = 0;
|
|
21
|
+ b[0] = b[1] = b[2] = 0;
|
|
22
|
+}
|
|
23
|
+
|
|
24
|
+void BoundingBox::getBoundingBox(vec3_t box[2]) {
|
|
25
|
+ box[0][0] = a[0];
|
|
26
|
+ box[1][0] = b[0];
|
|
27
|
+ box[0][1] = a[1];
|
|
28
|
+ box[1][1] = b[1];
|
|
29
|
+ box[0][2] = a[2];
|
|
30
|
+ box[1][2] = b[2];
|
|
31
|
+}
|
|
32
|
+
|
|
33
|
+void BoundingBox::setBoundingBox(vec3_t min, vec3_t max) {
|
|
34
|
+ a[0] = min[0];
|
|
35
|
+ b[0] = max[0];
|
|
36
|
+ a[1] = min[1];
|
|
37
|
+ b[1] = max[1];
|
|
38
|
+ a[2] = min[2];
|
|
39
|
+ b[2] = max[2];
|
|
40
|
+}
|
|
41
|
+
|
|
42
|
+bool BoundingBox::inBox(vec_t x, vec_t y, vec_t z) {
|
|
43
|
+ return ((y > a[1]) && (y < b[1]) && inBoxPlane(x, z));
|
|
44
|
+}
|
|
45
|
+
|
|
46
|
+bool BoundingBox::inBoxPlane(vec_t x, vec_t z) {
|
|
47
|
+ return ((x > a[0]) && (x < b[0])
|
|
48
|
+ && (z > a[2]) && (z < b[2]));
|
|
49
|
+}
|
|
50
|
+
|
|
51
|
+void BoundingBox::display(bool points, const vec4_t c1, const vec4_t c2) {
|
|
52
|
+ // Bind before entering now
|
|
53
|
+ //glBindTexture(GL_TEXTURE_2D, 1);
|
|
54
|
+ glPointSize(4.0);
|
|
55
|
+ //glLineWidth(1.25);
|
|
56
|
+
|
|
57
|
+ //! \fixme Need to make custom color key for this
|
|
58
|
+ glColor3fv(c1);
|
|
59
|
+
|
|
60
|
+ glBegin(GL_POINTS);
|
|
61
|
+ glVertex3f(b[0], b[1], b[2]);
|
|
62
|
+ glVertex3f(a[0], a[1], a[2]);
|
|
63
|
+
|
|
64
|
+ if (points)
|
|
65
|
+ {
|
|
66
|
+ glVertex3f(b[0], a[1], b[2]);
|
|
67
|
+ glVertex3f(a[0], b[1], b[2]);
|
|
68
|
+ glVertex3f(b[0], b[1], a[2]);
|
|
69
|
+ glVertex3f(a[0], a[1], b[2]);
|
|
70
|
+ glVertex3f(a[0], b[1], a[2]);
|
|
71
|
+ glVertex3f(b[0], a[1], a[2]);
|
|
72
|
+ }
|
|
73
|
+
|
|
74
|
+ glEnd();
|
|
75
|
+
|
|
76
|
+ glColor3fv(c2);
|
|
77
|
+
|
|
78
|
+ glBegin(GL_LINES);
|
|
79
|
+ // max, top quad
|
|
80
|
+ glVertex3f(b[0], b[1], b[2]);
|
|
81
|
+ glVertex3f(b[0], a[1], b[2]);
|
|
82
|
+
|
|
83
|
+ glVertex3f(b[0], b[1], b[2]);
|
|
84
|
+ glVertex3f(a[0], b[1], b[2]);
|
|
85
|
+
|
|
86
|
+ glVertex3f(b[0], b[1], b[2]);
|
|
87
|
+ glVertex3f(b[0], b[1], a[2]);
|
|
88
|
+
|
|
89
|
+ // max-min, vertical quads
|
|
90
|
+ glVertex3f(a[0], b[1], b[2]);
|
|
91
|
+ glVertex3f(a[0], b[1], a[2]);
|
|
92
|
+
|
|
93
|
+ glVertex3f(b[0], a[1], b[2]);
|
|
94
|
+ glVertex3f(b[0], a[1], a[2]);
|
|
95
|
+
|
|
96
|
+ glVertex3f(b[0], a[1], b[2]);
|
|
97
|
+ glVertex3f(a[0], a[1], b[2]);
|
|
98
|
+
|
|
99
|
+ // min-max, vertical quads
|
|
100
|
+ glVertex3f(b[0], b[1], a[2]);
|
|
101
|
+ glVertex3f(b[0], a[1], a[2]);
|
|
102
|
+
|
|
103
|
+ glVertex3f(b[0], b[1], a[2]);
|
|
104
|
+ glVertex3f(a[0], b[1], a[2]);
|
|
105
|
+
|
|
106
|
+ glVertex3f(a[0], b[1], b[2]);
|
|
107
|
+ glVertex3f(a[0], a[1], b[2]);
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+ // min, bottom quad
|
|
111
|
+ glVertex3f(a[0], a[1], a[2]);
|
|
112
|
+ glVertex3f(a[0], b[1], a[2]);
|
|
113
|
+
|
|
114
|
+ glVertex3f(a[0], a[1], a[2]);
|
|
115
|
+ glVertex3f(b[0], a[1], a[2]);
|
|
116
|
+
|
|
117
|
+ glVertex3f(a[0], a[1], a[2]);
|
|
118
|
+ glVertex3f(a[0], a[1], b[2]);
|
|
119
|
+ glEnd();
|
|
120
|
+
|
|
121
|
+ glPointSize(1.0);
|
|
122
|
+ //glLineWidth(1.0);
|
|
123
|
+}
|
|
124
|
+
|
|
125
|
+// ----------------------------------------------------------------------------
|
|
126
|
+
|
19
|
127
|
Light::Light(TombRaider &tr, unsigned int room, unsigned int index) {
|
20
|
128
|
unsigned int lightFlags, lightType;
|
21
|
129
|
|
|
@@ -130,112 +238,6 @@ int Portal::getAdjoiningRoom() {
|
130
|
238
|
|
131
|
239
|
// ----------------------------------------------------------------------------
|
132
|
240
|
|
133
|
|
-Box::Box() {
|
134
|
|
- a[0] = a[1] = a[2] = 0;
|
135
|
|
- b[0] = b[1] = b[2] = 0;
|
136
|
|
-}
|
137
|
|
-
|
138
|
|
-void Box::getBoundingBox(vec3_t box[2]) {
|
139
|
|
- box[0][0] = a[0];
|
140
|
|
- box[1][0] = b[0];
|
141
|
|
- box[0][1] = a[1];
|
142
|
|
- box[1][1] = b[1];
|
143
|
|
- box[0][2] = a[2];
|
144
|
|
- box[1][2] = b[2];
|
145
|
|
-}
|
146
|
|
-
|
147
|
|
-void Box::setBoundingBox(vec3_t min, vec3_t max) {
|
148
|
|
- a[0] = min[0];
|
149
|
|
- b[0] = max[0];
|
150
|
|
- a[1] = min[1];
|
151
|
|
- b[1] = max[1];
|
152
|
|
- a[2] = min[2];
|
153
|
|
- b[2] = max[2];
|
154
|
|
-}
|
155
|
|
-
|
156
|
|
-bool Box::inBox(vec_t x, vec_t y, vec_t z) {
|
157
|
|
- return ((y > a[1]) && (y < b[1]) && inBoxPlane(x, z));
|
158
|
|
-}
|
159
|
|
-
|
160
|
|
-bool Box::inBoxPlane(vec_t x, vec_t z) {
|
161
|
|
- return ((x > a[0]) && (x < b[0])
|
162
|
|
- && (z > a[2]) && (z < b[2]));
|
163
|
|
-}
|
164
|
|
-
|
165
|
|
-void Box::display(bool points, const vec4_t c1, const vec4_t c2) {
|
166
|
|
- // Bind before entering now
|
167
|
|
- //glBindTexture(GL_TEXTURE_2D, 1);
|
168
|
|
- glPointSize(4.0);
|
169
|
|
- //glLineWidth(1.25);
|
170
|
|
-
|
171
|
|
- //! \fixme Need to make custom color key for this
|
172
|
|
- glColor3fv(c1);
|
173
|
|
-
|
174
|
|
- glBegin(GL_POINTS);
|
175
|
|
- glVertex3f(b[0], b[1], b[2]);
|
176
|
|
- glVertex3f(a[0], a[1], a[2]);
|
177
|
|
-
|
178
|
|
- if (points)
|
179
|
|
- {
|
180
|
|
- glVertex3f(b[0], a[1], b[2]);
|
181
|
|
- glVertex3f(a[0], b[1], b[2]);
|
182
|
|
- glVertex3f(b[0], b[1], a[2]);
|
183
|
|
- glVertex3f(a[0], a[1], b[2]);
|
184
|
|
- glVertex3f(a[0], b[1], a[2]);
|
185
|
|
- glVertex3f(b[0], a[1], a[2]);
|
186
|
|
- }
|
187
|
|
-
|
188
|
|
- glEnd();
|
189
|
|
-
|
190
|
|
- glColor3fv(c2);
|
191
|
|
-
|
192
|
|
- glBegin(GL_LINES);
|
193
|
|
- // max, top quad
|
194
|
|
- glVertex3f(b[0], b[1], b[2]);
|
195
|
|
- glVertex3f(b[0], a[1], b[2]);
|
196
|
|
-
|
197
|
|
- glVertex3f(b[0], b[1], b[2]);
|
198
|
|
- glVertex3f(a[0], b[1], b[2]);
|
199
|
|
-
|
200
|
|
- glVertex3f(b[0], b[1], b[2]);
|
201
|
|
- glVertex3f(b[0], b[1], a[2]);
|
202
|
|
-
|
203
|
|
- // max-min, vertical quads
|
204
|
|
- glVertex3f(a[0], b[1], b[2]);
|
205
|
|
- glVertex3f(a[0], b[1], a[2]);
|
206
|
|
-
|
207
|
|
- glVertex3f(b[0], a[1], b[2]);
|
208
|
|
- glVertex3f(b[0], a[1], a[2]);
|
209
|
|
-
|
210
|
|
- glVertex3f(b[0], a[1], b[2]);
|
211
|
|
- glVertex3f(a[0], a[1], b[2]);
|
212
|
|
-
|
213
|
|
- // min-max, vertical quads
|
214
|
|
- glVertex3f(b[0], b[1], a[2]);
|
215
|
|
- glVertex3f(b[0], a[1], a[2]);
|
216
|
|
-
|
217
|
|
- glVertex3f(b[0], b[1], a[2]);
|
218
|
|
- glVertex3f(a[0], b[1], a[2]);
|
219
|
|
-
|
220
|
|
- glVertex3f(a[0], b[1], b[2]);
|
221
|
|
- glVertex3f(a[0], a[1], b[2]);
|
222
|
|
-
|
223
|
|
-
|
224
|
|
- // min, bottom quad
|
225
|
|
- glVertex3f(a[0], a[1], a[2]);
|
226
|
|
- glVertex3f(a[0], b[1], a[2]);
|
227
|
|
-
|
228
|
|
- glVertex3f(a[0], a[1], a[2]);
|
229
|
|
- glVertex3f(b[0], a[1], a[2]);
|
230
|
|
-
|
231
|
|
- glVertex3f(a[0], a[1], a[2]);
|
232
|
|
- glVertex3f(a[0], a[1], b[2]);
|
233
|
|
- glEnd();
|
234
|
|
-
|
235
|
|
- glPointSize(1.0);
|
236
|
|
- //glLineWidth(1.0);
|
237
|
|
-}
|
238
|
|
-
|
239
|
241
|
Box::Box(TombRaider &tr, unsigned int room, unsigned int index) {
|
240
|
242
|
tr.getRoomBox(room, index, a, b, c, d);
|
241
|
243
|
}
|