|
@@ -177,23 +177,23 @@ void Game::processSprites() {
|
177
|
177
|
|
178
|
178
|
printf("Processing sprites: ");
|
179
|
179
|
|
180
|
|
- for (unsigned int i = 0; i < (mTombRaider.NumItems() - 1); i++) {
|
|
180
|
+ for (int i = 0; i < (mTombRaider.NumItems() - 1); i++) {
|
181
|
181
|
if ((mTombRaider.Engine() == TR_VERSION_1) && (item[i].intensity1 == -1))
|
182
|
182
|
continue;
|
183
|
183
|
|
184
|
184
|
int id = item[i].object_id;
|
185
|
|
- for (unsigned int j = 0; j < mTombRaider.NumSpriteSequences(); j++) {
|
|
185
|
+ for (int j = 0; j < mTombRaider.NumSpriteSequences(); j++) {
|
186
|
186
|
if (spriteSequence[j].object_id == id) {
|
187
|
187
|
SpriteSequence &sequence = *new SpriteSequence();
|
188
|
|
- for (unsigned int k = 0; k < (-spriteSequence[j].negative_length); k++) {
|
|
188
|
+ for (int k = 0; k < (-spriteSequence[j].negative_length); k++) {
|
189
|
189
|
tr2_sprite_texture_t *sprite = &spriteTextures[spriteSequence[j].offset];
|
190
|
190
|
|
191
|
191
|
int width = sprite->width >> 8;
|
192
|
192
|
int height = sprite->height >> 8;
|
193
|
193
|
int x = sprite->x;
|
194
|
194
|
int y = sprite->y;
|
195
|
|
- int width2 = width * scale;
|
196
|
|
- int height2 = height * scale;
|
|
195
|
+ int width2 = (int)(width * scale);
|
|
196
|
+ int height2 = (int)(height * scale);
|
197
|
197
|
|
198
|
198
|
vec3_t vertex[4];
|
199
|
199
|
vec2_t texel[4];
|
|
@@ -244,73 +244,64 @@ void Game::processSprites() {
|
244
|
244
|
printf("Done! Found %d sprites.\n", mTombRaider.NumSpriteSequences());
|
245
|
245
|
}
|
246
|
246
|
|
247
|
|
-void Game::processRooms()
|
248
|
|
-{
|
|
247
|
+void Game::processRooms() {
|
249
|
248
|
printf("Processing rooms: ");
|
|
249
|
+
|
250
|
250
|
for (int index = 0; index < mTombRaider.NumRooms(); index++) {
|
251
|
|
- unsigned int i, j, count;
|
252
|
|
- room_mesh_t *r_mesh = NULL;
|
253
|
|
- RenderRoom *rRoom = NULL;
|
254
|
251
|
Matrix transform;
|
|
252
|
+ Room &room = *new Room(index);
|
|
253
|
+ getWorld().addRoom(room);
|
255
|
254
|
|
256
|
|
- if (!mTombRaider.isRoomValid(index))
|
257
|
|
- {
|
|
255
|
+ if (!mTombRaider.isRoomValid(index)) {
|
258
|
256
|
getConsole().print("WARNING: Handling invalid vertex array in room");
|
259
|
|
- getWorld().addRoom(0x0);
|
260
|
|
- getRender().addRoom(0x0);
|
261
|
|
-
|
262
|
257
|
//printf("x");
|
263
|
258
|
//fflush(stdout);
|
264
|
|
- return;
|
|
259
|
+ //return; // ?
|
|
260
|
+ continue;
|
265
|
261
|
}
|
266
|
262
|
|
267
|
|
- rRoom = new RenderRoom();
|
268
|
|
- r_mesh = new room_mesh_t;
|
269
|
|
- r_mesh->id = index;
|
|
263
|
+ unsigned int flags;
|
|
264
|
+ vec3_t pos;
|
|
265
|
+ vec3_t bbox[2];
|
|
266
|
+ mTombRaider.getRoomInfo(index, &flags, pos, bbox[0], bbox[1]);
|
|
267
|
+ room.setFlags(flags);
|
|
268
|
+ room.setPos(pos);
|
270
|
269
|
|
271
|
|
- mTombRaider.getRoomInfo(index, &r_mesh->flags, r_mesh->pos,
|
272
|
|
- r_mesh->bbox_min, r_mesh->bbox_max);
|
|
270
|
+ // Adjust positioning for OR world coordinate translation
|
|
271
|
+ bbox[0][0] += pos[0];
|
|
272
|
+ bbox[1][0] += pos[0];
|
|
273
|
+ bbox[0][2] += pos[2];
|
|
274
|
+ bbox[1][2] += pos[2];
|
273
|
275
|
|
274
|
|
- // Adjust positioning for OR world coord translation
|
275
|
|
- r_mesh->bbox_min[0] += r_mesh->pos[0];
|
276
|
|
- r_mesh->bbox_max[0] += r_mesh->pos[0];
|
277
|
|
- r_mesh->bbox_min[2] += r_mesh->pos[2];
|
278
|
|
- r_mesh->bbox_max[2] += r_mesh->pos[2];
|
|
276
|
+ room.setBoundingBox(bbox);
|
279
|
277
|
|
280
|
|
- // Mongoose 2002.04.03, Setup 3d transform
|
|
278
|
+ // Mongoose 2002.04.03, Setup 3D transform
|
281
|
279
|
transform.setIdentity();
|
282
|
|
- transform.translate(r_mesh->pos);
|
|
280
|
+ transform.translate(pos);
|
283
|
281
|
|
284
|
282
|
// Setup portals
|
285
|
283
|
float portalVertices[12];
|
286
|
|
- count = mTombRaider.getRoomPortalCount(index);
|
287
|
|
-
|
288
|
|
- //! \fixme OR wrongly uses a cached adj room list for rendering vis
|
289
|
|
- r_mesh->adjacentRooms.reserve(count + 1);
|
|
284
|
+ unsigned int count = mTombRaider.getRoomPortalCount(index);
|
290
|
285
|
|
291
|
286
|
// Current room is always first
|
292
|
|
- r_mesh->adjacentRooms.push_back(index);
|
293
|
|
-
|
294
|
|
- for (i = 0; i < count; ++i)
|
295
|
|
- {
|
296
|
|
- portal_t *portal = new portal_t;
|
297
|
|
-
|
298
|
|
- mTombRaider.getRoomPortal(index, i,
|
299
|
|
- &portal->adjoining_room, portal->normal,
|
300
|
|
- portalVertices);
|
301
|
|
-
|
302
|
|
- for (j = 0; j < 4; ++j)
|
303
|
|
- {
|
304
|
|
- portal->vertices[j][0] = portalVertices[j*3];
|
305
|
|
- portal->vertices[j][1] = portalVertices[j*3+1];
|
306
|
|
- portal->vertices[j][2] = portalVertices[j*3+2];
|
|
287
|
+ room.addAdjacentRoom(index);
|
|
288
|
+
|
|
289
|
+ for (unsigned int i = 0; i < count; i++) {
|
|
290
|
+ vec3_t vertices[4];
|
|
291
|
+ vec3_t normal;
|
|
292
|
+ int adjoiningRoom;
|
|
293
|
+ mTombRaider.getRoomPortal(index, i, &adjoiningRoom, normal, portalVertices);
|
|
294
|
+ for (unsigned int j = 0; j < 4; ++j) {
|
|
295
|
+ vertices[j][0] = portalVertices[j*3];
|
|
296
|
+ vertices[j][1] = portalVertices[j*3+1];
|
|
297
|
+ vertices[j][2] = portalVertices[j*3+2];
|
307
|
298
|
|
308
|
299
|
// Relative coors in vis portals
|
309
|
|
- transform.multiply3v(portal->vertices[j], portal->vertices[j]);
|
|
300
|
+ transform.multiply3v(vertices[j], vertices[j]);
|
310
|
301
|
}
|
311
|
|
-
|
312
|
|
- r_mesh->adjacentRooms.push_back(portal->adjoining_room);
|
313
|
|
- r_mesh->portals.push_back(portal);
|
|
302
|
+ Portal &portal = *new Portal(vertices, normal, adjoiningRoom);
|
|
303
|
+ room.addPortal(portal);
|
|
304
|
+ room.addAdjacentRoom(adjoiningRoom);
|
314
|
305
|
}
|
315
|
306
|
|
316
|
307
|
// Physics/gameplay use /////////////////////////////
|
|
@@ -318,76 +309,67 @@ void Game::processRooms()
|
318
|
309
|
//! \fixme Use more of sector structure, boxes, and floordata
|
319
|
310
|
|
320
|
311
|
// List of sectors in this room
|
321
|
|
- unsigned int sectorFlags;
|
322
|
|
- int floorDataIndex, boxIndex, roomBelow, roomAbove;
|
323
|
|
- count = mTombRaider.getRoomSectorCount(index, &r_mesh->numZSectors,
|
324
|
|
- &r_mesh->numXSectors);
|
325
|
|
- r_mesh->sectors.reserve(count);
|
326
|
|
-
|
327
|
|
- for (i = 0; i < count; ++i)
|
328
|
|
- {
|
329
|
|
- sector_t *sector = new sector_t;
|
|
312
|
+ unsigned int numXSectors, numZSectors;
|
|
313
|
+ count = mTombRaider.getRoomSectorCount(index, &numZSectors, &numXSectors);
|
|
314
|
+ room.setNumXSectors(numXSectors);
|
|
315
|
+ room.setNumZSectors(numZSectors);
|
|
316
|
+ for (unsigned int i = 0; i < count; i++) {
|
|
317
|
+ unsigned int sectorFlags;
|
|
318
|
+ int floorDataIndex, boxIndex, roomBelow, roomAbove;
|
|
319
|
+ vec_t floor, ceiling;
|
|
320
|
+ bool wall = false;
|
330
|
321
|
|
331
|
322
|
mTombRaider.getRoomSector(index, i, §orFlags,
|
332
|
|
- §or->ceiling, §or->floor,
|
333
|
|
- &floorDataIndex, &boxIndex, &roomBelow,
|
334
|
|
- &roomAbove);
|
|
323
|
+ &ceiling, &floor, &floorDataIndex, &boxIndex,
|
|
324
|
+ &roomBelow, &roomAbove);
|
335
|
325
|
|
336
|
326
|
if (sectorFlags & tombraiderSector_wall)
|
337
|
|
- {
|
338
|
|
- sector->wall = true;
|
339
|
|
- }
|
340
|
|
- else
|
341
|
|
- {
|
342
|
|
- sector->wall = false;
|
343
|
|
- }
|
|
327
|
+ wall = true;
|
344
|
328
|
|
345
|
|
- r_mesh->sectors.push_back(sector);
|
|
329
|
+ room.addSector(*new Sector(floor, ceiling, wall));
|
346
|
330
|
}
|
347
|
331
|
|
348
|
|
- // Setup collision boxes ( Should use sectors, but this is a test )
|
|
332
|
+ // Setup collision boxes
|
|
333
|
+ //! fixme Should use sectors, but this is a test
|
349
|
334
|
count = mTombRaider.getRoomBoxCount(index);
|
350
|
|
- r_mesh->boxes.reserve(count);
|
351
|
335
|
|
352
|
336
|
//! fixme Only to be done only on room[0]? I don't think so...
|
353
|
|
- for (i = 0; !index && i < count; ++i)
|
354
|
|
- {
|
355
|
|
- box_t *box = new box_t;
|
356
|
|
-
|
357
|
|
- mTombRaider.getRoomBox(index, i,
|
358
|
|
- box->a.pos, box->b.pos, box->c.pos, box->d.pos);
|
359
|
|
-
|
360
|
|
- r_mesh->boxes.push_back(box);
|
|
337
|
+ for (unsigned int i = 0; !index && i < count; i++) {
|
|
338
|
+ vec3_t a, b, c, d;
|
|
339
|
+ mTombRaider.getRoomBox(index, i, a, b, c, d);
|
|
340
|
+ room.addBox(*new Box(a, b, c, d));
|
361
|
341
|
}
|
362
|
342
|
|
363
|
343
|
// Setup room lights /////////////////////////////////////
|
364
|
|
- unsigned int lightFlags, lightType;
|
365
|
344
|
count = mTombRaider.getRoomLightCount(index);
|
366
|
|
- rRoom->lights.reserve(count);
|
367
|
345
|
|
368
|
|
- for (i = 0; i < count; ++i)
|
369
|
|
- {
|
370
|
|
- Light *light = new Light();
|
|
346
|
+ for (unsigned int i = 0; i < count; i++) {
|
|
347
|
+ unsigned int lightFlags, lightType;
|
|
348
|
+ vec4_t position;
|
|
349
|
+ vec3_t dir;
|
|
350
|
+ vec_t att;
|
|
351
|
+ vec4_t color;
|
|
352
|
+ vec_t cutoff;
|
|
353
|
+ Light::LightType type;
|
371
|
354
|
|
372
|
|
- mTombRaider.getRoomLight(index, i,
|
373
|
|
- light->mPos, light->mColor, light->mDir,
|
374
|
|
- &light->mAtt, &light->mCutoff,
|
375
|
|
- &lightType, &lightFlags);
|
|
355
|
+ mTombRaider.getRoomLight(index, i, position, color,
|
|
356
|
+ dir, &att, &cutoff, &lightType, &lightFlags);
|
376
|
357
|
|
377
|
|
- switch (lightType)
|
378
|
|
- {
|
|
358
|
+ switch (lightType) {
|
379
|
359
|
case tombraiderLight_typeDirectional:
|
380
|
|
- light->mType = Light::typeDirectional;
|
|
360
|
+ type = Light::typeDirectional;
|
381
|
361
|
break;
|
382
|
362
|
case tombraiderLight_typeSpot:
|
383
|
|
- light->mType = Light::typeSpot;
|
|
363
|
+ type = Light::typeSpot;
|
384
|
364
|
break;
|
385
|
365
|
case tombraiderLight_typePoint:
|
386
|
366
|
default:
|
387
|
|
- light->mType = Light::typePoint;
|
|
367
|
+ type = Light::typePoint;
|
388
|
368
|
}
|
389
|
369
|
|
390
|
|
- rRoom->lights.push_back(light);
|
|
370
|
+ room.addLight(*new Light(position, dir, att, color, cutoff, type));
|
|
371
|
+
|
|
372
|
+ //! \todo Light flags?
|
391
|
373
|
}
|
392
|
374
|
|
393
|
375
|
// Room geometery //////////////////////////////////
|
|
@@ -407,30 +389,30 @@ void Game::processRooms()
|
407
|
389
|
&normalCount, &normalArray,
|
408
|
390
|
&colorCount, &colorArray);
|
409
|
391
|
|
410
|
|
- rRoom->mesh.bufferVertexArray(vertexCount, (vec_t *)vertexArray);
|
411
|
|
- rRoom->mesh.bufferNormalArray(normalCount, (vec_t *)normalArray);
|
412
|
|
- rRoom->mesh.bufferColorArray(vertexCount, (vec_t *)colorArray);
|
|
392
|
+ room.getMesh().bufferVertexArray(vertexCount, (vec_t *)vertexArray);
|
|
393
|
+ room.getMesh().bufferNormalArray(normalCount, (vec_t *)normalArray);
|
|
394
|
+ room.getMesh().bufferColorArray(vertexCount, (vec_t *)colorArray);
|
413
|
395
|
|
414
|
396
|
mTombRaider.getRoomTriangles(index, mTextureStart,
|
415
|
397
|
&triCount, &indices, &texCoords, &textures,
|
416
|
398
|
&flags);
|
417
|
399
|
|
418
|
|
- rRoom->mesh.bufferTriangles(triCount, indices, texCoords, textures, flags);
|
|
400
|
+ room.getMesh().bufferTriangles(triCount, indices, texCoords, textures, flags);
|
419
|
401
|
#else
|
420
|
402
|
float rgba[4];
|
421
|
403
|
float xyz[3];
|
422
|
404
|
|
423
|
405
|
count = mTombRaider.getRoomVertexCount(index);
|
424
|
|
- rRoom->mesh.allocateVertices(count);
|
425
|
|
- rRoom->mesh.allocateNormals(0); // count
|
426
|
|
- rRoom->mesh.allocateColors(count);
|
|
406
|
+ room.getMesh().allocateVertices(count);
|
|
407
|
+ room.getMesh().allocateNormals(0); // count
|
|
408
|
+ room.getMesh().allocateColors(count);
|
427
|
409
|
|
428
|
|
- for (i = 0; i < count; ++i)
|
|
410
|
+ for (unsigned int i = 0; i < count; ++i)
|
429
|
411
|
{
|
430
|
412
|
mTombRaider.getRoomVertex(index, i, xyz, rgba);
|
431
|
413
|
|
432
|
|
- rRoom->mesh.setVertex(i, xyz[0], xyz[1], xyz[2]);
|
433
|
|
- rRoom->mesh.setColor(i, rgba);
|
|
414
|
+ room.getMesh().setVertex(i, xyz[0], xyz[1], xyz[2]);
|
|
415
|
+ room.getMesh().setColor(i, rgba);
|
434
|
416
|
}
|
435
|
417
|
|
436
|
418
|
// Mongoose 2002.06.09, Setup allocation of meshes and polygons
|
|
@@ -443,7 +425,7 @@ void Game::processRooms()
|
443
|
425
|
int tris_mesh_map[TextureLimit];
|
444
|
426
|
int rect_mesh_map[TextureLimit];
|
445
|
427
|
|
446
|
|
- for (i = 0; i < TextureLimit; ++i)
|
|
428
|
+ for (unsigned int i = 0; i < TextureLimit; ++i)
|
447
|
429
|
{
|
448
|
430
|
triangle_counter[i] = 0;
|
449
|
431
|
triangle_counter_alpha[i] = 0;
|
|
@@ -458,7 +440,7 @@ void Game::processRooms()
|
458
|
440
|
unsigned int numQuads = 0;
|
459
|
441
|
|
460
|
442
|
int texture;
|
461
|
|
- unsigned int r, t, q, v, flags;
|
|
443
|
+ unsigned int r, t, q, v;
|
462
|
444
|
unsigned int indices[4];
|
463
|
445
|
float texCoords[8];
|
464
|
446
|
|
|
@@ -530,10 +512,10 @@ void Game::processRooms()
|
530
|
512
|
}
|
531
|
513
|
|
532
|
514
|
// Allocate indexed polygon meshes
|
533
|
|
- rRoom->mesh.allocateTriangles(numTris);
|
534
|
|
- rRoom->mesh.allocateRectangles(numQuads);
|
|
515
|
+ room.getMesh().allocateTriangles(numTris);
|
|
516
|
+ room.getMesh().allocateRectangles(numQuads);
|
535
|
517
|
|
536
|
|
- for (i = 0, j = 0; i < TextureLimit; ++i)
|
|
518
|
+ for (unsigned int i = 0, j = 0; i < TextureLimit; ++i)
|
537
|
519
|
{
|
538
|
520
|
if (tris_mesh_map[i] > 0)
|
539
|
521
|
{
|
|
@@ -541,35 +523,35 @@ void Game::processRooms()
|
541
|
523
|
|
542
|
524
|
t = triangle_counter[i];
|
543
|
525
|
|
544
|
|
- rRoom->mesh.mTris[j].texture = i;
|
|
526
|
+ room.getMesh().mTris[j].texture = i;
|
545
|
527
|
#ifdef MULTITEXTURE
|
546
|
|
- rRoom->mesh.mTris[j].bumpmap = gMapTex2Bump[i];
|
|
528
|
+ room.getMesh().mTris[j].bumpmap = gMapTex2Bump[i];
|
547
|
529
|
#endif
|
548
|
|
- rRoom->mesh.mTris[j].cnum_triangles = 0;
|
549
|
|
- rRoom->mesh.mTris[j].num_triangles = 0;
|
550
|
|
- rRoom->mesh.mTris[j].cnum_alpha_triangles = 0;
|
551
|
|
- rRoom->mesh.mTris[j].num_alpha_triangles = 0;
|
552
|
|
- rRoom->mesh.mTris[j].triangles = 0x0;
|
553
|
|
- rRoom->mesh.mTris[j].alpha_triangles = 0x0;
|
554
|
|
- rRoom->mesh.mTris[j].texcoors = 0x0;
|
555
|
|
- rRoom->mesh.mTris[j].texcoors2 = 0x0;
|
|
530
|
+ room.getMesh().mTris[j].cnum_triangles = 0;
|
|
531
|
+ room.getMesh().mTris[j].num_triangles = 0;
|
|
532
|
+ room.getMesh().mTris[j].cnum_alpha_triangles = 0;
|
|
533
|
+ room.getMesh().mTris[j].num_alpha_triangles = 0;
|
|
534
|
+ room.getMesh().mTris[j].triangles = 0x0;
|
|
535
|
+ room.getMesh().mTris[j].alpha_triangles = 0x0;
|
|
536
|
+ room.getMesh().mTris[j].texcoors = 0x0;
|
|
537
|
+ room.getMesh().mTris[j].texcoors2 = 0x0;
|
556
|
538
|
|
557
|
539
|
if (t > 0)
|
558
|
540
|
{
|
559
|
|
- rRoom->mesh.mTris[j].num_triangles = t;
|
560
|
|
- rRoom->mesh.mTris[j].triangles = new unsigned int[t*3];
|
561
|
|
- rRoom->mesh.mTris[j].num_texcoors = t * 3;
|
562
|
|
- rRoom->mesh.mTris[j].texcoors = new vec2_t[t * 3];
|
|
541
|
+ room.getMesh().mTris[j].num_triangles = t;
|
|
542
|
+ room.getMesh().mTris[j].triangles = new unsigned int[t*3];
|
|
543
|
+ room.getMesh().mTris[j].num_texcoors = t * 3;
|
|
544
|
+ room.getMesh().mTris[j].texcoors = new vec2_t[t * 3];
|
563
|
545
|
}
|
564
|
546
|
|
565
|
547
|
t = triangle_counter_alpha[i];
|
566
|
548
|
|
567
|
549
|
if (t > 0)
|
568
|
550
|
{
|
569
|
|
- rRoom->mesh.mTris[j].num_alpha_triangles = t;
|
570
|
|
- rRoom->mesh.mTris[j].alpha_triangles = new unsigned int[t*3];
|
571
|
|
- rRoom->mesh.mTris[j].num_texcoors2 = t * 3;
|
572
|
|
- rRoom->mesh.mTris[j].texcoors2 = new vec2_t[t * 3];
|
|
551
|
+ room.getMesh().mTris[j].num_alpha_triangles = t;
|
|
552
|
+ room.getMesh().mTris[j].alpha_triangles = new unsigned int[t*3];
|
|
553
|
+ room.getMesh().mTris[j].num_texcoors2 = t * 3;
|
|
554
|
+ room.getMesh().mTris[j].texcoors2 = new vec2_t[t * 3];
|
573
|
555
|
}
|
574
|
556
|
}
|
575
|
557
|
|
|
@@ -581,35 +563,35 @@ void Game::processRooms()
|
581
|
563
|
|
582
|
564
|
r = rectangle_counter[i];
|
583
|
565
|
|
584
|
|
- rRoom->mesh.mQuads[j].texture = i;
|
|
566
|
+ room.getMesh().mQuads[j].texture = i;
|
585
|
567
|
#ifdef MULTITEXTURE
|
586
|
|
- rRoom->mesh.mQuads[j].bumpmap = gMapTex2Bump[i];
|
|
568
|
+ room.getMesh().mQuads[j].bumpmap = gMapTex2Bump[i];
|
587
|
569
|
#endif
|
588
|
|
- rRoom->mesh.mQuads[j].cnum_quads = 0;
|
589
|
|
- rRoom->mesh.mQuads[j].num_quads = 0;
|
590
|
|
- rRoom->mesh.mQuads[j].cnum_alpha_quads = 0;
|
591
|
|
- rRoom->mesh.mQuads[j].num_alpha_quads = 0;
|
592
|
|
- rRoom->mesh.mQuads[j].quads = 0x0;
|
593
|
|
- rRoom->mesh.mQuads[j].alpha_quads = 0x0;
|
594
|
|
- rRoom->mesh.mQuads[j].texcoors = 0x0;
|
595
|
|
- rRoom->mesh.mQuads[j].texcoors2 = 0x0;
|
|
570
|
+ room.getMesh().mQuads[j].cnum_quads = 0;
|
|
571
|
+ room.getMesh().mQuads[j].num_quads = 0;
|
|
572
|
+ room.getMesh().mQuads[j].cnum_alpha_quads = 0;
|
|
573
|
+ room.getMesh().mQuads[j].num_alpha_quads = 0;
|
|
574
|
+ room.getMesh().mQuads[j].quads = 0x0;
|
|
575
|
+ room.getMesh().mQuads[j].alpha_quads = 0x0;
|
|
576
|
+ room.getMesh().mQuads[j].texcoors = 0x0;
|
|
577
|
+ room.getMesh().mQuads[j].texcoors2 = 0x0;
|
596
|
578
|
|
597
|
579
|
if (r > 0)
|
598
|
580
|
{
|
599
|
|
- rRoom->mesh.mQuads[j].num_quads = r;
|
600
|
|
- rRoom->mesh.mQuads[j].quads = new unsigned int[r*4];
|
601
|
|
- rRoom->mesh.mQuads[j].num_texcoors = r * 4;
|
602
|
|
- rRoom->mesh.mQuads[j].texcoors = new vec2_t[r * 4];
|
|
581
|
+ room.getMesh().mQuads[j].num_quads = r;
|
|
582
|
+ room.getMesh().mQuads[j].quads = new unsigned int[r*4];
|
|
583
|
+ room.getMesh().mQuads[j].num_texcoors = r * 4;
|
|
584
|
+ room.getMesh().mQuads[j].texcoors = new vec2_t[r * 4];
|
603
|
585
|
}
|
604
|
586
|
|
605
|
587
|
r = rectangle_counter_alpha[i];
|
606
|
588
|
|
607
|
589
|
if (r > 0)
|
608
|
590
|
{
|
609
|
|
- rRoom->mesh.mQuads[j].num_alpha_quads = r;
|
610
|
|
- rRoom->mesh.mQuads[j].alpha_quads = new unsigned int[r*4];
|
611
|
|
- rRoom->mesh.mQuads[j].num_texcoors2 = r * 4;
|
612
|
|
- rRoom->mesh.mQuads[j].texcoors2 = new vec2_t[r * 4];
|
|
591
|
+ room.getMesh().mQuads[j].num_alpha_quads = r;
|
|
592
|
+ room.getMesh().mQuads[j].alpha_quads = new unsigned int[r*4];
|
|
593
|
+ room.getMesh().mQuads[j].num_texcoors2 = r * 4;
|
|
594
|
+ room.getMesh().mQuads[j].texcoors2 = new vec2_t[r * 4];
|
613
|
595
|
}
|
614
|
596
|
}
|
615
|
597
|
}
|
|
@@ -626,50 +608,50 @@ void Game::processRooms()
|
626
|
608
|
// correct textures
|
627
|
609
|
texture += mTextureStart;
|
628
|
610
|
|
629
|
|
- j = tris_mesh_map[texture] - 1;
|
|
611
|
+ unsigned int j = tris_mesh_map[texture] - 1;
|
630
|
612
|
|
631
|
613
|
// Setup per vertex
|
632
|
|
- for (i = 0; i < 3; ++i)
|
|
614
|
+ for (unsigned int i = 0; i < 3; ++i)
|
633
|
615
|
{
|
634
|
616
|
// Get vertex index {(0, a), (1, b), (2, c)}
|
635
|
617
|
v = indices[i];
|
636
|
618
|
|
637
|
619
|
if ((flags & tombraiderFace_Alpha ||
|
638
|
620
|
flags & tombraiderFace_PartialAlpha) &&
|
639
|
|
- rRoom->mesh.mTris[j].num_alpha_triangles > 0)
|
|
621
|
+ room.getMesh().mTris[j].num_alpha_triangles > 0)
|
640
|
622
|
{
|
641
|
|
- q = rRoom->mesh.mTris[j].cnum_alpha_triangles*3+i;
|
|
623
|
+ q = room.getMesh().mTris[j].cnum_alpha_triangles*3+i;
|
642
|
624
|
|
643
|
|
- rRoom->mesh.mTris[j].alpha_triangles[q] = v;
|
|
625
|
+ room.getMesh().mTris[j].alpha_triangles[q] = v;
|
644
|
626
|
|
645
|
|
- rRoom->mesh.mTris[j].texcoors2[q][0] = texCoords[i*2];
|
646
|
|
- rRoom->mesh.mTris[j].texcoors2[q][1] = texCoords[i*2+1];
|
|
627
|
+ room.getMesh().mTris[j].texcoors2[q][0] = texCoords[i*2];
|
|
628
|
+ room.getMesh().mTris[j].texcoors2[q][1] = texCoords[i*2+1];
|
647
|
629
|
}
|
648
|
|
- else if (rRoom->mesh.mTris[j].num_triangles > 0)
|
|
630
|
+ else if (room.getMesh().mTris[j].num_triangles > 0)
|
649
|
631
|
{
|
650
|
|
- q = rRoom->mesh.mTris[j].cnum_triangles*3+i;
|
|
632
|
+ q = room.getMesh().mTris[j].cnum_triangles*3+i;
|
651
|
633
|
|
652
|
|
- rRoom->mesh.mTris[j].triangles[q] = v;
|
|
634
|
+ room.getMesh().mTris[j].triangles[q] = v;
|
653
|
635
|
|
654
|
|
- rRoom->mesh.mTris[j].texcoors[q][0] = texCoords[i*2];
|
655
|
|
- rRoom->mesh.mTris[j].texcoors[q][1] = texCoords[i*2+1];
|
|
636
|
+ room.getMesh().mTris[j].texcoors[q][0] = texCoords[i*2];
|
|
637
|
+ room.getMesh().mTris[j].texcoors[q][1] = texCoords[i*2+1];
|
656
|
638
|
}
|
657
|
639
|
|
658
|
640
|
// Partial alpha hack
|
659
|
641
|
if (flags & tombraiderFace_PartialAlpha)
|
660
|
642
|
{
|
661
|
|
- //rRoom->mesh.colors[v].rgba[3] = 0.45;
|
|
643
|
+ //room.getMesh().colors[v].rgba[3] = 0.45;
|
662
|
644
|
}
|
663
|
645
|
}
|
664
|
646
|
|
665
|
647
|
if (flags & tombraiderFace_Alpha ||
|
666
|
648
|
flags & tombraiderFace_PartialAlpha)
|
667
|
649
|
{
|
668
|
|
- rRoom->mesh.mTris[j].cnum_alpha_triangles++;
|
|
650
|
+ room.getMesh().mTris[j].cnum_alpha_triangles++;
|
669
|
651
|
}
|
670
|
652
|
else
|
671
|
653
|
{
|
672
|
|
- rRoom->mesh.mTris[j].cnum_triangles++;
|
|
654
|
+ room.getMesh().mTris[j].cnum_triangles++;
|
673
|
655
|
}
|
674
|
656
|
}
|
675
|
657
|
|
|
@@ -690,37 +672,37 @@ void Game::processRooms()
|
690
|
672
|
texture = TextureLimit - 1;
|
691
|
673
|
}
|
692
|
674
|
|
693
|
|
- j = rect_mesh_map[texture] - 1;
|
|
675
|
+ unsigned int j = rect_mesh_map[texture] - 1;
|
694
|
676
|
|
695
|
|
- if (rRoom->mesh.mQuads[j].num_quads <= 0 &&
|
696
|
|
- rRoom->mesh.mQuads[j].num_alpha_quads <= 0)
|
|
677
|
+ if (room.getMesh().mQuads[j].num_quads <= 0 &&
|
|
678
|
+ room.getMesh().mQuads[j].num_alpha_quads <= 0)
|
697
|
679
|
continue;
|
698
|
680
|
|
699
|
681
|
// Setup per vertex
|
700
|
|
- for (i = 0; i < 4; ++i)
|
|
682
|
+ for (unsigned int i = 0; i < 4; ++i)
|
701
|
683
|
{
|
702
|
684
|
// Get vertex index {(0, a), (1, b), (2, c), (3, d)}
|
703
|
685
|
v = indices[i];
|
704
|
686
|
|
705
|
687
|
if ((flags & tombraiderFace_Alpha ||
|
706
|
688
|
flags & tombraiderFace_PartialAlpha) &&
|
707
|
|
- rRoom->mesh.mQuads[j].num_alpha_quads > 0)
|
|
689
|
+ room.getMesh().mQuads[j].num_alpha_quads > 0)
|
708
|
690
|
{
|
709
|
|
- q = rRoom->mesh.mQuads[j].cnum_alpha_quads*4+i;
|
|
691
|
+ q = room.getMesh().mQuads[j].cnum_alpha_quads*4+i;
|
710
|
692
|
|
711
|
|
- rRoom->mesh.mQuads[j].alpha_quads[q] = v;
|
|
693
|
+ room.getMesh().mQuads[j].alpha_quads[q] = v;
|
712
|
694
|
|
713
|
|
- rRoom->mesh.mQuads[j].texcoors2[q][0] = texCoords[i*2];
|
714
|
|
- rRoom->mesh.mQuads[j].texcoors2[q][1] = texCoords[i*2+1];
|
|
695
|
+ room.getMesh().mQuads[j].texcoors2[q][0] = texCoords[i*2];
|
|
696
|
+ room.getMesh().mQuads[j].texcoors2[q][1] = texCoords[i*2+1];
|
715
|
697
|
}
|
716
|
|
- else if (rRoom->mesh.mQuads[j].num_quads > 0)
|
|
698
|
+ else if (room.getMesh().mQuads[j].num_quads > 0)
|
717
|
699
|
{
|
718
|
|
- q = rRoom->mesh.mQuads[j].cnum_quads*4+i;
|
|
700
|
+ q = room.getMesh().mQuads[j].cnum_quads*4+i;
|
719
|
701
|
|
720
|
|
- rRoom->mesh.mQuads[j].quads[q] = v;
|
|
702
|
+ room.getMesh().mQuads[j].quads[q] = v;
|
721
|
703
|
|
722
|
|
- rRoom->mesh.mQuads[j].texcoors[q][0] = texCoords[i*2];
|
723
|
|
- rRoom->mesh.mQuads[j].texcoors[q][1] = texCoords[i*2+1];
|
|
704
|
+ room.getMesh().mQuads[j].texcoors[q][0] = texCoords[i*2];
|
|
705
|
+ room.getMesh().mQuads[j].texcoors[q][1] = texCoords[i*2+1];
|
724
|
706
|
}
|
725
|
707
|
|
726
|
708
|
// Partial alpha hack
|
|
@@ -733,58 +715,50 @@ void Game::processRooms()
|
733
|
715
|
if (flags & tombraiderFace_Alpha ||
|
734
|
716
|
flags & tombraiderFace_PartialAlpha)
|
735
|
717
|
{
|
736
|
|
- rRoom->mesh.mQuads[j].cnum_alpha_quads++;
|
|
718
|
+ room.getMesh().mQuads[j].cnum_alpha_quads++;
|
737
|
719
|
}
|
738
|
720
|
else
|
739
|
721
|
{
|
740
|
|
- rRoom->mesh.mQuads[j].cnum_quads++;
|
|
722
|
+ room.getMesh().mQuads[j].cnum_quads++;
|
741
|
723
|
}
|
742
|
724
|
}
|
743
|
725
|
#endif
|
744
|
726
|
|
745
|
727
|
// Room models
|
746
|
728
|
count = mTombRaider.getRoomModelCount(index);
|
747
|
|
- r_mesh->models.reserve(count);
|
748
|
|
-
|
749
|
|
- for (i = 0; i < count; ++i)
|
750
|
|
- {
|
751
|
|
- static_model_t *model = new static_model_t;
|
752
|
|
-
|
753
|
|
- mTombRaider.getRoomModel(index, i,
|
754
|
|
- &model->index, model->pos, &model->yaw);
|
755
|
|
-
|
756
|
|
- r_mesh->models.push_back(model);
|
|
729
|
+ for (unsigned int i = 0; i < count; i++) {
|
|
730
|
+ int ind;
|
|
731
|
+ vec_t yaw;
|
|
732
|
+ vec3_t position;
|
|
733
|
+ mTombRaider.getRoomModel(index, i, &ind, position, &yaw);
|
|
734
|
+ room.addModel(*new StaticModel(ind, yaw, position));
|
757
|
735
|
}
|
758
|
736
|
|
759
|
737
|
// Room sprites
|
760
|
|
- float spriteVertices[12];
|
761
|
|
- float spriteTexCoords[8];
|
762
|
738
|
count = mTombRaider.getRoomSpriteCount(index);
|
763
|
|
- r_mesh->sprites.reserve(count);
|
764
|
|
-
|
765
|
|
- for (i = 0; i < count; ++i)
|
766
|
|
- {
|
767
|
|
- sprite_t *sprite = new sprite_t;
|
|
739
|
+ for (unsigned int i = 0; i < count; i++) {
|
|
740
|
+ float spriteVertices[12];
|
|
741
|
+ float spriteTexCoords[8];
|
|
742
|
+ vec3_t vertex[4];
|
|
743
|
+ vec2_t texel[4];
|
|
744
|
+ vec3_t position;
|
|
745
|
+ int tex;
|
768
|
746
|
|
769
|
747
|
mTombRaider.getRoomSprite(index, i,
|
770
|
|
- 10.0f, &sprite->texture, sprite->pos,
|
771
|
|
- spriteVertices, spriteTexCoords);
|
|
748
|
+ 10.0f, &tex, position, spriteVertices, spriteTexCoords);
|
772
|
749
|
|
773
|
|
- sprite->texture += mTextureStart; // OpenRaider preloads some textures
|
|
750
|
+ tex += mTextureStart; // OpenRaider preloads some textures
|
774
|
751
|
|
775
|
|
- for (j = 0; j < 12; j++)
|
776
|
|
- sprite->vertex[j / 3].pos[j % 3] = spriteVertices[j];
|
|
752
|
+ for (unsigned int j = 0; j < 12; j++)
|
|
753
|
+ vertex[j / 3][j % 3] = spriteVertices[j];
|
777
|
754
|
|
778
|
|
- for (j = 0; j < 8; j++)
|
779
|
|
- sprite->texel[j / 2].st[j % 2] = spriteTexCoords[j];
|
|
755
|
+ for (unsigned int j = 0; j < 8; j++)
|
|
756
|
+ texel[j / 2][j % 2] = spriteTexCoords[j];
|
780
|
757
|
|
781
|
|
- r_mesh->sprites.push_back(sprite);
|
|
758
|
+ room.addSprite(*new Sprite(vertex, texel, position, 0.0f, tex)); //! \fixme radius 0??
|
782
|
759
|
}
|
783
|
760
|
|
784
|
|
- getWorld().addRoom(r_mesh);
|
785
|
|
-
|
786
|
|
- rRoom->room = r_mesh;
|
787
|
|
- getRender().addRoom(rRoom);
|
|
761
|
+ getWorld().addRoom(room);
|
788
|
762
|
|
789
|
763
|
//printf(".");
|
790
|
764
|
//fflush(stdout);
|