|
@@ -10,10 +10,8 @@
|
10
|
10
|
|
11
|
11
|
#ifdef __APPLE__
|
12
|
12
|
#include <OpenGL/gl.h>
|
13
|
|
-#include <OpenGL/glu.h>
|
14
|
13
|
#else
|
15
|
14
|
#include <GL/gl.h>
|
16
|
|
-#include <GL/glu.h>
|
17
|
15
|
#endif
|
18
|
16
|
|
19
|
17
|
#include <stdlib.h>
|
|
@@ -439,43 +437,44 @@ void Render::setMode(int n)
|
439
|
437
|
|
440
|
438
|
// Replaced the deprecated gluLookAt with slightly modified code from here:
|
441
|
439
|
// http://www.khronos.org/message_boards/showthread.php/4991
|
442
|
|
-void CrossProd(float x1, float y1, float z1, float x2, float y2, float z2, float res[3])
|
443
|
|
-{
|
444
|
|
- res[0] = y1*z2 - y2*z1;
|
445
|
|
- res[1] = x2*z1 - x1*z2;
|
446
|
|
- res[2] = x1*y2 - x2*y1;
|
447
|
|
-}
|
448
|
|
-void deprecated_gluLookAt(float eyeX, float eyeY, float eyeZ, float lookAtX, float lookAtY, float lookAtZ, float upX, float upY, float upZ)
|
449
|
|
-{
|
|
440
|
+void gluLookAt(float eyeX, float eyeY, float eyeZ,
|
|
441
|
+ float lookAtX, float lookAtY, float lookAtZ,
|
|
442
|
+ float upX, float upY, float upZ) {
|
450
|
443
|
float f[3];
|
|
444
|
+
|
451
|
445
|
// calculating the viewing vector
|
452
|
446
|
f[0] = lookAtX - eyeX;
|
453
|
447
|
f[1] = lookAtY - eyeY;
|
454
|
448
|
f[2] = lookAtZ - eyeZ;
|
455
|
449
|
float fMag, upMag;
|
456
|
|
- fMag = sqrtf(f[0]*f[0] + f[1]*f[1] + f[2]*f[2]);
|
457
|
|
- upMag = sqrtf(upX*upX + upY*upY + upZ*upZ);
|
|
450
|
+ fMag = sqrtf(f[0] * f[0] + f[1] * f[1] + f[2] * f[2]);
|
|
451
|
+ upMag = sqrtf(upX * upX + upY * upY + upZ * upZ);
|
|
452
|
+
|
458
|
453
|
// normalizing the viewing vector
|
459
|
|
- f[0] = f[0]/fMag;
|
460
|
|
- f[1] = f[1]/fMag;
|
461
|
|
- f[2] = f[2]/fMag;
|
462
|
|
- // normalising the up vector. no need for this here if you have your
|
463
|
|
- // up vector already normalised, which is mostly the case.
|
464
|
|
- upX = upX/upMag;
|
465
|
|
- upY = upY/upMag;
|
466
|
|
- upZ = upZ/upMag;
|
467
|
|
- float s[3], u[3];
|
468
|
|
- CrossProd(f[0], f[1], f[2], upX, upY, upZ, s);
|
469
|
|
- CrossProd(s[0], s[1], s[2], f[0], f[1], f[2], u);
|
470
|
|
- float M[]=
|
471
|
|
- {
|
|
454
|
+ f[0] = f[0] / fMag;
|
|
455
|
+ f[1] = f[1] / fMag;
|
|
456
|
+ f[2] = f[2] / fMag;
|
|
457
|
+
|
|
458
|
+ float s[3] = {
|
|
459
|
+ f[1] * upZ - upY * f[2],
|
|
460
|
+ upX * f[2] - f[0] * upZ,
|
|
461
|
+ f[0] * upY - upX * f[1]
|
|
462
|
+ };
|
|
463
|
+
|
|
464
|
+ float u[3] = {
|
|
465
|
+ s[1] * f[2] - f[1] * s[2],
|
|
466
|
+ f[0] * s[2] - s[0] * f[2],
|
|
467
|
+ s[0] * f[1] - f[0] * s[1]
|
|
468
|
+ };
|
|
469
|
+
|
|
470
|
+ float m[16] = {
|
472
|
471
|
s[0], u[0], -f[0], 0,
|
473
|
472
|
s[1], u[1], -f[1], 0,
|
474
|
473
|
s[2], u[2], -f[2], 0,
|
475
|
|
- 0, 0, 0, 1
|
|
474
|
+ 0, 0, 0, 1
|
476
|
475
|
};
|
477
|
|
- glMultMatrixf(M);
|
478
|
|
- glTranslatef (-eyeX, -eyeY, -eyeZ);
|
|
476
|
+ glMultMatrixf(m);
|
|
477
|
+ glTranslatef(-eyeX, -eyeY, -eyeZ);
|
479
|
478
|
}
|
480
|
479
|
|
481
|
480
|
void Render::Display()
|
|
@@ -566,9 +565,8 @@ void Render::Display()
|
566
|
565
|
gOpenRaider->mGame->mCamera->getPosition(camPos);
|
567
|
566
|
gOpenRaider->mGame->mCamera->getTarget(atPos);
|
568
|
567
|
// Mongoose 2002.08.13, Quick fix to render OpenRaider upside down
|
569
|
|
- // gluLookAt(camPos[0], camPos[1], camPos[2], atPos[0], atPos[1], atPos[2], 0.0, -1.0, 0.0);
|
570
|
568
|
|
571
|
|
- deprecated_gluLookAt(camPos[0], camPos[1], camPos[2], atPos[0], atPos[1], atPos[2], 0.0f, -1.0f, 0.0f);
|
|
569
|
+ gluLookAt(camPos[0], camPos[1], camPos[2], atPos[0], atPos[1], atPos[2], 0.0f, -1.0f, 0.0f);
|
572
|
570
|
|
573
|
571
|
// Update view volume for vising
|
574
|
572
|
updateViewVolume();
|