|
@@ -255,6 +255,37 @@ void LoaderTR2::loadRoomVertex(RoomVertexTR2& vert) {
|
255
|
255
|
vert.light2 = file.read16();
|
256
|
256
|
}
|
257
|
257
|
|
|
258
|
+void LoaderTR2::loadRoomMesh(std::vector<IndexedRectangle>& rectangles,
|
|
259
|
+ std::vector<IndexedRectangle>& triangles,
|
|
260
|
+ uint16_t& numRectangles, uint16_t& numTriangles) {
|
|
261
|
+ numRectangles = file.readU16();
|
|
262
|
+ for (unsigned int r = 0; r < numRectangles; r++) {
|
|
263
|
+ // Indices into the vertex list read just before
|
|
264
|
+ uint16_t vertex1 = file.readU16();
|
|
265
|
+ uint16_t vertex2 = file.readU16();
|
|
266
|
+ uint16_t vertex3 = file.readU16();
|
|
267
|
+ uint16_t vertex4 = file.readU16();
|
|
268
|
+
|
|
269
|
+ // Index into the object-texture list
|
|
270
|
+ uint16_t texture = file.readU16();
|
|
271
|
+
|
|
272
|
+ rectangles.emplace_back(texture, vertex1, vertex2, vertex3, vertex4);
|
|
273
|
+ }
|
|
274
|
+
|
|
275
|
+ numTriangles = file.readU16();
|
|
276
|
+ for (unsigned int t = 0; t < numTriangles; t++) {
|
|
277
|
+ // Indices into the room vertex list
|
|
278
|
+ uint16_t vertex1 = file.readU16();
|
|
279
|
+ uint16_t vertex2 = file.readU16();
|
|
280
|
+ uint16_t vertex3 = file.readU16();
|
|
281
|
+
|
|
282
|
+ // Index into the object-texture list
|
|
283
|
+ uint16_t texture = file.readU16();
|
|
284
|
+
|
|
285
|
+ triangles.emplace_back(texture, vertex1, vertex2, vertex3);
|
|
286
|
+ }
|
|
287
|
+}
|
|
288
|
+
|
258
|
289
|
void LoaderTR2::loadRooms() {
|
259
|
290
|
uint16_t numRooms = file.readU16();
|
260
|
291
|
for (unsigned int i = 0; i < numRooms; i++) {
|
|
@@ -307,34 +338,10 @@ void LoaderTR2::loadRooms() {
|
307
|
338
|
bbox[0] += pos;
|
308
|
339
|
bbox[1] += pos;
|
309
|
340
|
|
310
|
|
- uint16_t numRectangles = file.readU16();
|
311
|
341
|
std::vector<IndexedRectangle> rectangles;
|
312
|
|
- for (unsigned int r = 0; r < numRectangles; r++) {
|
313
|
|
- // Indices into the vertex list read just before
|
314
|
|
- uint16_t vertex1 = file.readU16();
|
315
|
|
- uint16_t vertex2 = file.readU16();
|
316
|
|
- uint16_t vertex3 = file.readU16();
|
317
|
|
- uint16_t vertex4 = file.readU16();
|
318
|
|
-
|
319
|
|
- // Index into the object-texture list
|
320
|
|
- uint16_t texture = file.readU16();
|
321
|
|
-
|
322
|
|
- rectangles.emplace_back(texture, vertex1, vertex2, vertex3, vertex4);
|
323
|
|
- }
|
324
|
|
-
|
325
|
|
- uint16_t numTriangles = file.readU16();
|
326
|
342
|
std::vector<IndexedRectangle> triangles;
|
327
|
|
- for (unsigned int t = 0; t < numTriangles; t++) {
|
328
|
|
- // Indices into the room vertex list
|
329
|
|
- uint16_t vertex1 = file.readU16();
|
330
|
|
- uint16_t vertex2 = file.readU16();
|
331
|
|
- uint16_t vertex3 = file.readU16();
|
332
|
|
-
|
333
|
|
- // Index into the object-texture list
|
334
|
|
- uint16_t texture = file.readU16();
|
335
|
|
-
|
336
|
|
- triangles.emplace_back(texture, vertex1, vertex2, vertex3);
|
337
|
|
- }
|
|
343
|
+ uint16_t numRectangles, numTriangles;
|
|
344
|
+ loadRoomMesh(rectangles, triangles, numRectangles, numTriangles);
|
338
|
345
|
|
339
|
346
|
uint16_t numSprites = file.readU16();
|
340
|
347
|
std::vector<RoomSprite*> roomSprites;
|