|
@@ -753,6 +753,52 @@ void Render::setMode(int n)
|
753
|
753
|
}
|
754
|
754
|
}
|
755
|
755
|
|
|
756
|
+// Replaced the deprecated gluLookAt with slightly modified code from here:
|
|
757
|
+// http://www.khronos.org/message_boards/showthread.php/4991
|
|
758
|
+void CrossProd(float x1, float y1, float z1, float x2, float y2, float z2, float res[3])
|
|
759
|
+{
|
|
760
|
+ res[0] = y1*z2 - y2*z1;
|
|
761
|
+ res[1] = x2*z1 - x1*z2;
|
|
762
|
+ res[2] = x1*y2 - x2*y1;
|
|
763
|
+}
|
|
764
|
+void deprecated_gluLookAt(float eyeX, float eyeY, float eyeZ, float lookAtX, float lookAtY, float lookAtZ, float upX, float upY, float upZ)
|
|
765
|
+{
|
|
766
|
+ float f[3];
|
|
767
|
+ // calculating the viewing vector
|
|
768
|
+ f[0] = lookAtX - eyeX;
|
|
769
|
+ f[1] = lookAtY - eyeY;
|
|
770
|
+ f[2] = lookAtZ - eyeZ;
|
|
771
|
+ float fMag, upMag;
|
|
772
|
+ fMag = sqrt(f[0]*f[0] + f[1]*f[1] + f[2]*f[2]);
|
|
773
|
+ upMag = sqrt(upX*upX + upY*upY + upZ*upZ);
|
|
774
|
+ // normalizing the viewing vector
|
|
775
|
+ if( fMag != 0)
|
|
776
|
+ {
|
|
777
|
+ f[0] = f[0]/fMag;
|
|
778
|
+ f[1] = f[1]/fMag;
|
|
779
|
+ f[2] = f[2]/fMag;
|
|
780
|
+ }
|
|
781
|
+ // normalising the up vector. no need for this here if you have your
|
|
782
|
+ // up vector already normalised, which is mostly the case.
|
|
783
|
+ if( upMag != 0 )
|
|
784
|
+ {
|
|
785
|
+ upX = upX/upMag;
|
|
786
|
+ upY = upY/upMag;
|
|
787
|
+ upZ = upZ/upMag;
|
|
788
|
+ }
|
|
789
|
+ float s[3], u[3];
|
|
790
|
+ CrossProd(f[0], f[1], f[2], upX, upY, upZ, s);
|
|
791
|
+ CrossProd(s[0], s[1], s[2], f[0], f[1], f[2], u);
|
|
792
|
+ float M[]=
|
|
793
|
+ {
|
|
794
|
+ s[0], u[0], -f[0], 0,
|
|
795
|
+ s[1], u[1], -f[1], 0,
|
|
796
|
+ s[2], u[2], -f[2], 0,
|
|
797
|
+ 0, 0, 0, 1
|
|
798
|
+ };
|
|
799
|
+ glMultMatrixf(M);
|
|
800
|
+ glTranslatef (-eyeX, -eyeY, -eyeZ);
|
|
801
|
+}
|
756
|
802
|
|
757
|
803
|
void Render::Display()
|
758
|
804
|
{
|
|
@@ -848,9 +894,9 @@ void Render::Display()
|
848
|
894
|
mCamera->getPosition(camPos);
|
849
|
895
|
mCamera->getTarget(atPos);
|
850
|
896
|
// Mongoose 2002.08.13, Quick fix to render OpenRaider upside down
|
851
|
|
- gluLookAt(camPos[0], camPos[1], camPos[2],
|
852
|
|
- atPos[0], atPos[1], atPos[2],
|
853
|
|
- 0.0, -1.0, 0.0);
|
|
897
|
+ // gluLookAt(camPos[0], camPos[1], camPos[2], atPos[0], atPos[1], atPos[2], 0.0, -1.0, 0.0);
|
|
898
|
+
|
|
899
|
+ deprecated_gluLookAt(camPos[0], camPos[1], camPos[2], atPos[0], atPos[1], atPos[2], 0.0, -1.0, 0.0);
|
854
|
900
|
|
855
|
901
|
// Update view volume for vising
|
856
|
902
|
updateViewVolume();
|