-
-
-void FGViewer::fgMakeLookAtMat4 ( sgMat4 dst, const sgVec3 eye, const sgVec3 center,
- const sgVec3 up )
-{
- // Caveats:
- // 1) In order to compute the line of sight, the eye point must not be equal
- // to the center point.
- // 2) The up vector must not be parallel to the line of sight from the eye
- // to the center point.
-
- /* Compute the direction vectors */
- sgVec3 x,y,z;
-
- /* Y vector = center - eye */
- sgSubVec3 ( y, center, eye ) ;
-
- /* Z vector = up */
- sgCopyVec3 ( z, up ) ;
-
- /* X vector = Y cross Z */
- sgVectorProductVec3 ( x, y, z ) ;
-
- /* Recompute Z = X cross Y */
- sgVectorProductVec3 ( z, x, y ) ;
-
- /* Normalize everything */
- sgNormaliseVec3 ( x ) ;
- sgNormaliseVec3 ( y ) ;
- sgNormaliseVec3 ( z ) ;
-
- /* Build the matrix */
-#define M(row,col) dst[row][col]
- M(0,0) = x[0]; M(0,1) = x[1]; M(0,2) = x[2]; M(0,3) = 0.0;
- M(1,0) = y[0]; M(1,1) = y[1]; M(1,2) = y[2]; M(1,3) = 0.0;
- M(2,0) = z[0]; M(2,1) = z[1]; M(2,2) = z[2]; M(2,3) = 0.0;
- M(3,0) = eye[0]; M(3,1) = eye[1]; M(3,2) = eye[2]; M(3,3) = 1.0;
-#undef M
-}
-/* end from lookat */
-
-/* from rph */
-// VIEW_ROT = LARC_TO_SSG * ( VIEWo * VIEW_OFFSET )
-// This takes advantage of the fact that VIEWo and VIEW_OFFSET
-// only have entries in the upper 3x3 block
-// and that LARC_TO_SSG is just a shift of rows NHV
-void FGViewer::fgMakeViewRot( sgMat4 dst, const sgMat4 m1, const sgMat4 m2 )
-{
- for ( int j = 0 ; j < 3 ; j++ ) {
- dst[2][j] = m2[0][0] * m1[0][j] +
- m2[0][1] * m1[1][j] +
- m2[0][2] * m1[2][j];
-
- dst[0][j] = m2[1][0] * m1[0][j] +
- m2[1][1] * m1[1][j] +
- m2[1][2] * m1[2][j];
-
- dst[1][j] = m2[2][0] * m1[0][j] +
- m2[2][1] * m1[1][j] +
- m2[2][2] * m1[2][j];
- }
- dst[0][3] =
- dst[1][3] =
- dst[2][3] =
- dst[3][0] =
- dst[3][1] =
- dst[3][2] = SG_ZERO;
- dst[3][3] = SG_ONE;
-}
-
-
-void FGViewer::fgMakeLOCAL( sgMat4 dst, const double Theta,
- const double Phi, const double Psi)
-{
- SGfloat cosTheta = (SGfloat) cos(Theta);
- SGfloat sinTheta = (SGfloat) sin(Theta);
- SGfloat cosPhi = (SGfloat) cos(Phi);
- SGfloat sinPhi = (SGfloat) sin(Phi);
- SGfloat sinPsi = (SGfloat) sin(Psi) ;
- SGfloat cosPsi = (SGfloat) cos(Psi) ;
-
- dst[0][0] = cosPhi * cosTheta;
- dst[0][1] = sinPhi * cosPsi + cosPhi * -sinTheta * -sinPsi;
- dst[0][2] = sinPhi * sinPsi + cosPhi * -sinTheta * cosPsi;
- dst[0][3] = SG_ZERO;
-
- dst[1][0] = -sinPhi * cosTheta;
- dst[1][1] = cosPhi * cosPsi + -sinPhi * -sinTheta * -sinPsi;
- dst[1][2] = cosPhi * sinPsi + -sinPhi * -sinTheta * cosPsi;
- dst[1][3] = SG_ZERO ;
-
- dst[2][0] = sinTheta;
- dst[2][1] = cosTheta * -sinPsi;
- dst[2][2] = cosTheta * cosPsi;
- dst[2][3] = SG_ZERO;
-
- dst[3][0] = SG_ZERO;
- dst[3][1] = SG_ZERO;
- dst[3][2] = SG_ZERO;
- dst[3][3] = SG_ONE ;
-}
-
-/* end from rph */
-
-