|
@@ -28,10 +28,6 @@ TexturedTriangle::TexturedTriangle(int i[3], vec_t s[6], int tex, unsigned short
|
28
|
28
|
transparency = trans;
|
29
|
29
|
}
|
30
|
30
|
|
31
|
|
-bool TexturedTriangle::operator< (TexturedTriangle &t) {
|
32
|
|
- return texture < t.texture;
|
33
|
|
-}
|
34
|
|
-
|
35
|
31
|
void TexturedTriangle::display(vec_t *vertices, vec_t *colors, vec_t *normals) {
|
36
|
32
|
assert(vertices != NULL);
|
37
|
33
|
|
|
@@ -167,7 +163,7 @@ StaticMesh::StaticMesh(TombRaider &tr, unsigned int index) {
|
167
|
163
|
tr.getMeshTexturedTriangle(index, i,
|
168
|
164
|
vertexIndices, st,
|
169
|
165
|
&texture, &transparency);
|
170
|
|
- texturedTriangles.push_back(
|
|
166
|
+ triangles.push_back(
|
171
|
167
|
new TexturedTriangle(vertexIndices, st, texture + getGame().getTextureStart(), transparency));
|
172
|
168
|
}
|
173
|
169
|
|
|
@@ -190,7 +186,7 @@ StaticMesh::StaticMesh(TombRaider &tr, unsigned int index) {
|
190
|
186
|
#endif
|
191
|
187
|
transparency = 0;
|
192
|
188
|
|
193
|
|
- coloredTriangles.push_back(
|
|
189
|
+ triangles.push_back(
|
194
|
190
|
new TexturedTriangle(vertexIndices, st, texture + getGame().getTextureStart(), transparency));
|
195
|
191
|
}
|
196
|
192
|
|
|
@@ -200,9 +196,9 @@ StaticMesh::StaticMesh(TombRaider &tr, unsigned int index) {
|
200
|
196
|
tr.getMeshTexturedRectangle(index, i,
|
201
|
197
|
vertexIndices, st,
|
202
|
198
|
&texture, &transparency);
|
203
|
|
- texturedRectangles.push_back(
|
|
199
|
+ triangles.push_back(
|
204
|
200
|
new TexturedTriangle(vertexIndices, st, texture + getGame().getTextureStart(), transparency));
|
205
|
|
- texturedRectangles.push_back(
|
|
201
|
+ triangles.push_back(
|
206
|
202
|
new TexturedTriangle(vertexIndices + 3, st + 6, texture + getGame().getTextureStart(), transparency));
|
207
|
203
|
}
|
208
|
204
|
|
|
@@ -226,38 +222,17 @@ StaticMesh::StaticMesh(TombRaider &tr, unsigned int index) {
|
226
|
222
|
#endif
|
227
|
223
|
transparency = 0;
|
228
|
224
|
|
229
|
|
- coloredRectangles.push_back(
|
|
225
|
+ triangles.push_back(
|
230
|
226
|
new TexturedTriangle(vertexIndices, st, texture + getGame().getTextureStart(), transparency));
|
231
|
|
- coloredRectangles.push_back(
|
|
227
|
+ triangles.push_back(
|
232
|
228
|
new TexturedTriangle(vertexIndices + 3, st, texture + getGame().getTextureStart(), transparency));
|
233
|
229
|
}
|
234
|
|
-
|
235
|
|
- // Sort faces by texture
|
236
|
|
- std::sort(texturedTriangles.begin(), texturedTriangles.end());
|
237
|
|
- std::sort(coloredTriangles.begin(), coloredTriangles.end());
|
238
|
|
- std::sort(texturedRectangles.begin(), texturedRectangles.end());
|
239
|
|
- std::sort(coloredRectangles.begin(), coloredRectangles.end());
|
240
|
230
|
}
|
241
|
231
|
|
242
|
232
|
StaticMesh::~StaticMesh() {
|
243
|
|
- while (!texturedTriangles.empty()) {
|
244
|
|
- delete texturedTriangles.back();
|
245
|
|
- texturedTriangles.pop_back();
|
246
|
|
- }
|
247
|
|
-
|
248
|
|
- while (!coloredTriangles.empty()) {
|
249
|
|
- delete coloredTriangles.back();
|
250
|
|
- coloredTriangles.pop_back();
|
251
|
|
- }
|
252
|
|
-
|
253
|
|
- while (!texturedRectangles.empty()) {
|
254
|
|
- delete texturedRectangles.back();
|
255
|
|
- texturedRectangles.pop_back();
|
256
|
|
- }
|
257
|
|
-
|
258
|
|
- while (!coloredRectangles.empty()) {
|
259
|
|
- delete coloredRectangles.back();
|
260
|
|
- coloredRectangles.pop_back();
|
|
233
|
+ while (!triangles.empty()) {
|
|
234
|
+ delete triangles.back();
|
|
235
|
+ triangles.pop_back();
|
261
|
236
|
}
|
262
|
237
|
|
263
|
238
|
delete [] vertices;
|
|
@@ -280,17 +255,8 @@ void StaticMesh::display() {
|
280
|
255
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
281
|
256
|
glBindTexture(GL_TEXTURE_2D, 1); // White texture for colors
|
282
|
257
|
|
283
|
|
- for (unsigned int i = 0; i < coloredTriangles.size(); i++)
|
284
|
|
- coloredTriangles.at(i)->display(vertices, colors, normals);
|
285
|
|
-
|
286
|
|
- for (unsigned int i = 0; i < coloredRectangles.size(); i++)
|
287
|
|
- coloredRectangles.at(i)->display(vertices, colors, normals);
|
288
|
|
-
|
289
|
|
- for (unsigned int i = 0; i < texturedTriangles.size(); i++)
|
290
|
|
- texturedTriangles.at(i)->display(vertices, colors, normals);
|
291
|
|
-
|
292
|
|
- for (unsigned int i = 0; i < texturedRectangles.size(); i++)
|
293
|
|
- texturedRectangles.at(i)->display(vertices, colors, normals);
|
|
258
|
+ for (unsigned int i = 0; i < triangles.size(); i++)
|
|
259
|
+ triangles.at(i)->display(vertices, colors, normals);
|
294
|
260
|
}
|
295
|
261
|
}
|
296
|
262
|
|