|
@@ -26,9 +26,7 @@ Render::Render() {
|
26
|
26
|
mSkyMeshRotation = false;
|
27
|
27
|
mMode = Render::modeDisabled;
|
28
|
28
|
mLock = 0;
|
29
|
|
- mFlags = (fRoomAlpha | fViewModel |
|
30
|
|
- fEntityModels | fRenderPonytail |
|
31
|
|
- fUsePortals | fUpdateRoomListPerFrame);
|
|
29
|
+ mFlags = (fRoomAlpha | fEntityModels | fRenderPonytail);
|
32
|
30
|
}
|
33
|
31
|
|
34
|
32
|
|
|
@@ -78,48 +76,6 @@ unsigned int Render::getFlags() {
|
78
|
76
|
}
|
79
|
77
|
|
80
|
78
|
|
81
|
|
-// Texture must be set to WHITE solid color texture
|
82
|
|
-void renderTrace(int color, vec3_t start, vec3_t end)
|
83
|
|
-{
|
84
|
|
- const float widthStart = 10.0f; //5.0f;
|
85
|
|
- const float widthEnd = 10.0f;
|
86
|
|
- float delta = randomNum(0.01f, 0.16f); // for flicker fx
|
87
|
|
-
|
88
|
|
-
|
89
|
|
- // Draw two long quads that skrink and fade the they go further out
|
90
|
|
- glBegin(GL_QUADS);
|
91
|
|
-
|
92
|
|
- switch (color)
|
93
|
|
- {
|
94
|
|
- case 0:
|
95
|
|
- glColor3f(0.9f - delta, 0.2f, 0.2f);
|
96
|
|
- break;
|
97
|
|
- case 1:
|
98
|
|
- glColor3f(0.2f, 0.9f - delta, 0.2f);
|
99
|
|
- break;
|
100
|
|
- case 2:
|
101
|
|
- default:
|
102
|
|
- glColor3f(0.2f, 0.2f, 0.9f - delta);
|
103
|
|
- }
|
104
|
|
-
|
105
|
|
- glVertex3f(start[0], start[1], start[2]);
|
106
|
|
- glVertex3f(start[0], start[1] + widthStart, start[2] + widthStart);
|
107
|
|
- glVertex3f(end[0], end[1] + widthEnd, end[2] + widthEnd);
|
108
|
|
- glVertex3f(end[0], end[1], end[2]);
|
109
|
|
-
|
110
|
|
- glVertex3f(start[0], start[1], start[2]);
|
111
|
|
- glVertex3f(start[0], start[1] + widthStart, start[2] - widthStart);
|
112
|
|
- glVertex3f(end[0], end[1] + widthEnd, end[2] - widthEnd);
|
113
|
|
- glVertex3f(end[0], end[1], end[2]);
|
114
|
|
-
|
115
|
|
- glVertex3f(start[0], start[1] + widthStart, start[2] + widthStart);
|
116
|
|
- glVertex3f(start[0], start[1] + widthStart, start[2] - widthStart);
|
117
|
|
- glVertex3f(end[0], end[1] + widthEnd, end[2] - widthEnd);
|
118
|
|
- glVertex3f(end[0], end[1] + widthEnd, end[2] + widthEnd);
|
119
|
|
- glEnd();
|
120
|
|
-}
|
121
|
|
-
|
122
|
|
-
|
123
|
79
|
void setLighting(bool on)
|
124
|
80
|
{
|
125
|
81
|
if (on)
|
|
@@ -270,33 +226,31 @@ void Render::setMode(int n)
|
270
|
226
|
// Replaced the deprecated gluLookAt with slightly modified code from here:
|
271
|
227
|
// http://www.khronos.org/message_boards/showthread.php/4991
|
272
|
228
|
void gluLookAt(float eyeX, float eyeY, float eyeZ,
|
273
|
|
- float lookAtX, float lookAtY, float lookAtZ,
|
274
|
|
- float upX, float upY, float upZ) {
|
275
|
|
- float f[3];
|
276
|
|
-
|
|
229
|
+ float lookAtX, float lookAtY, float lookAtZ,
|
|
230
|
+ float upX, float upY, float upZ) {
|
277
|
231
|
// calculating the viewing vector
|
278
|
|
- f[0] = lookAtX - eyeX;
|
279
|
|
- f[1] = lookAtY - eyeY;
|
280
|
|
- f[2] = lookAtZ - eyeZ;
|
281
|
|
-
|
282
|
|
- float fMag = sqrtf(f[0] * f[0] + f[1] * f[1] + f[2] * f[2]);
|
283
|
|
- //float upMag = sqrtf(upX * upX + upY * upY + upZ * upZ);
|
|
232
|
+ float f[3] = {
|
|
233
|
+ lookAtX - eyeX,
|
|
234
|
+ lookAtY - eyeY,
|
|
235
|
+ lookAtZ - eyeZ
|
|
236
|
+ };
|
284
|
237
|
|
285
|
238
|
// normalizing the viewing vector
|
286
|
|
- f[0] = f[0] / fMag;
|
287
|
|
- f[1] = f[1] / fMag;
|
288
|
|
- f[2] = f[2] / fMag;
|
|
239
|
+ float fMag = sqrtf(f[0] * f[0] + f[1] * f[1] + f[2] * f[2]);
|
|
240
|
+ f[0] /= fMag;
|
|
241
|
+ f[1] /= fMag;
|
|
242
|
+ f[2] /= fMag;
|
289
|
243
|
|
290
|
244
|
float s[3] = {
|
291
|
|
- f[1] * upZ - upY * f[2],
|
292
|
|
- upX * f[2] - f[0] * upZ,
|
293
|
|
- f[0] * upY - upX * f[1]
|
|
245
|
+ (f[1] * upZ) - (upY * f[2]),
|
|
246
|
+ (upX * f[2]) - (f[0] * upZ),
|
|
247
|
+ (f[0] * upY) - (upX * f[1])
|
294
|
248
|
};
|
295
|
249
|
|
296
|
250
|
float u[3] = {
|
297
|
|
- s[1] * f[2] - f[1] * s[2],
|
298
|
|
- f[0] * s[2] - s[0] * f[2],
|
299
|
|
- s[0] * f[1] - f[0] * s[1]
|
|
251
|
+ (s[1] * f[2]) - (f[1] * s[2]),
|
|
252
|
+ (f[0] * s[2]) - (s[0] * f[2]),
|
|
253
|
+ (s[0] * f[1]) - (f[0] * s[1])
|
300
|
254
|
};
|
301
|
255
|
|
302
|
256
|
float m[16] = {
|
|
@@ -433,8 +387,7 @@ void Render::display()
|
433
|
387
|
glPushMatrix();
|
434
|
388
|
|
435
|
389
|
// Draw lara or other player model ( move to entity rendering method )
|
436
|
|
- if (mFlags & Render::fViewModel)
|
437
|
|
- getGame().getLara().display();
|
|
390
|
+ getGame().getLara().display();
|
438
|
391
|
|
439
|
392
|
// Draw sprites after player to handle alpha
|
440
|
393
|
for (unsigned int i = 0; i < getWorld().sizeSprite(); i++) {
|
|
@@ -445,9 +398,8 @@ void Render::display()
|
445
|
398
|
|
446
|
399
|
glPopMatrix();
|
447
|
400
|
|
448
|
|
- // Depth sort entityRenderList with qsort
|
|
401
|
+ // Depth sort entityRenderList and display each entity
|
449
|
402
|
std::sort(entityRenderList.begin(), entityRenderList.end());
|
450
|
|
-
|
451
|
403
|
for (unsigned int i = 0; i < entityRenderList.size(); i++) {
|
452
|
404
|
entityRenderList[i]->display();
|
453
|
405
|
}
|
|
@@ -514,37 +466,17 @@ void Render::newRoomRenderList(int index)
|
514
|
466
|
{
|
515
|
467
|
static int currentRoomId = -1;
|
516
|
468
|
|
517
|
|
- if (mFlags & Render::fUsePortals)
|
|
469
|
+ if (index == -1) // -1 is error, so draw room 0, for the hell of it
|
518
|
470
|
{
|
519
|
|
- if (index == -1) // -1 is error, so draw room 0, for the hell of it
|
520
|
|
- {
|
521
|
|
- mRoomRenderList.clear();
|
522
|
|
- mRoomRenderList.push_back(&getWorld().getRoom(0));
|
523
|
|
- }
|
524
|
|
- else
|
525
|
|
- {
|
526
|
|
- // Update room render list if needed
|
527
|
|
- if (mFlags & Render::fUpdateRoomListPerFrame ||
|
528
|
|
- currentRoomId != index)
|
529
|
|
- {
|
530
|
|
- buildRoomRenderList(getWorld().getRoom(index));
|
531
|
|
- }
|
532
|
|
- }
|
|
471
|
+ mRoomRenderList.clear();
|
|
472
|
+ mRoomRenderList.push_back(&getWorld().getRoom(0));
|
533
|
473
|
}
|
534
|
|
- else // Render all rooms pretty much
|
|
474
|
+ else
|
535
|
475
|
{
|
536
|
|
- if (currentRoomId != index || index == -1)
|
|
476
|
+ // Update room render list if needed
|
|
477
|
+ if (currentRoomId != index)
|
537
|
478
|
{
|
538
|
|
- printf("*** Room render list -> %i\n", index);
|
539
|
|
- mRoomRenderList.clear();
|
540
|
|
-
|
541
|
|
- for (unsigned int i = 0; i < getWorld().sizeRoom(); i++)
|
542
|
|
- {
|
543
|
|
- if (!isVisible(getWorld().getRoom(i).getBoundingBox()))
|
544
|
|
- continue;
|
545
|
|
-
|
546
|
|
- mRoomRenderList.push_back(&getWorld().getRoom(i));
|
547
|
|
- }
|
|
479
|
+ buildRoomRenderList(getWorld().getRoom(index));
|
548
|
480
|
}
|
549
|
481
|
}
|
550
|
482
|
|
|
@@ -563,34 +495,15 @@ void Render::buildRoomRenderList(Room &room)
|
563
|
495
|
// Must not already be cached
|
564
|
496
|
for (unsigned int i = 0; i < mRoomRenderList.size(); i++)
|
565
|
497
|
{
|
566
|
|
- Room &room2 = *mRoomRenderList[i];
|
|
498
|
+ Room *room2 = mRoomRenderList[i];
|
567
|
499
|
|
568
|
|
- if (&room2 == &room)
|
|
500
|
+ if (room2 == &room)
|
569
|
501
|
return;
|
570
|
502
|
}
|
571
|
503
|
|
572
|
504
|
/* Add current room to list */
|
573
|
505
|
mRoomRenderList.push_back(&room);
|
574
|
506
|
|
575
|
|
- if (mFlags & Render::fOneRoom)
|
576
|
|
- {
|
577
|
|
- return;
|
578
|
|
- }
|
579
|
|
- else if (mFlags & Render::fAllRooms) /* Are you serious? */
|
580
|
|
- {
|
581
|
|
- for (unsigned int i = 0; i < getWorld().sizeRoom(); i++)
|
582
|
|
- {
|
583
|
|
- Room &room2 = getWorld().getRoom(i);
|
584
|
|
-
|
585
|
|
- if (&room2 != &room)
|
586
|
|
- {
|
587
|
|
- buildRoomRenderList(room2);
|
588
|
|
- }
|
589
|
|
- }
|
590
|
|
-
|
591
|
|
- return;
|
592
|
|
- }
|
593
|
|
-
|
594
|
507
|
// Try to add adj rooms and their adj rooms, skip this room
|
595
|
508
|
for (unsigned int i = 1; i < room.sizeAdjacentRooms(); i++)
|
596
|
509
|
{
|
|
@@ -599,12 +512,10 @@ void Render::buildRoomRenderList(Room &room)
|
599
|
512
|
|
600
|
513
|
Room &room2 = getWorld().getRoom(room.getAdjacentRoom(i));
|
601
|
514
|
|
602
|
|
- // Mongoose 2002.03.22, Add portal visibility check here
|
|
515
|
+ //! \fixme Add portal visibility check here
|
603
|
516
|
|
604
|
517
|
if (&room2 != &room)
|
605
|
|
- {
|
606
|
518
|
buildRoomRenderList(room2);
|
607
|
|
- }
|
608
|
519
|
}
|
609
|
520
|
}
|
610
|
521
|
|