]> git.mxchange.org Git - flightgear.git/commitdiff
Working on getting ssg integrated.
authorcurt <curt>
Sat, 19 Jun 1999 04:48:07 +0000 (04:48 +0000)
committercurt <curt>
Sat, 19 Jun 1999 04:48:07 +0000 (04:48 +0000)
src/Main/main.cxx
src/Main/views.cxx
src/Main/views.hxx

index 75acc429ae4e4ad114b7cfffe9572719102b9646..719c1442c35152d8ef192cfe4542cafc2fd308a5 100644 (file)
@@ -401,24 +401,33 @@ static void fgRenderFrame( void ) {
        xglLoadIdentity();
        ssgSetFOV(60.0f, 0.0f);
        ssgSetNearFar(1.0f, 700.0f);
+       sgMat4 sgTRANS;
+
+       sgMakeTransMat4( sgTRANS, 
+                        current_view.view_pos.x() 
+                        + current_view.view_forward[0] * 20,
+                        current_view.view_pos.y() 
+                        + current_view.view_forward[1] * 20,
+                        current_view.view_pos.z() 
+                        + current_view.view_forward[2] * 20 );
+
+       sgMat4 sgTMP;
+       sgMat4 sgTUX;
+       sgMultMat4( sgTMP, current_view.sgUP, sgTRANS );
+       sgMultMat4( sgTUX, current_view.sgLARC_TO_SSG, sgTMP );
+       
        sgCoord tuxpos;
-       sgSetCoord( &tuxpos, 
-                   current_view.view_pos.x() + current_view.view_forward[0] 
-                   * 20, 
-                   current_view.view_pos.y() + current_view.view_forward[1]
-                   * 20,
-                   current_view.view_pos.z() + current_view.view_forward[2]
-                   * 20, 
-                   0.0, 0.0, 0.0 );
+       sgSetCoord( &tuxpos, sgTUX );
        penguin->setTransform( &tuxpos );
 
-       sgCoord campos;
-       sgSetCoord( &campos, 
-                   current_view.view_pos.x(), 
-                   current_view.view_pos.y(),
-                   current_view.view_pos.z(), 
-                   0, 0, 0 );
-       ssgSetCamera( &campos );
+       sgMakeTransMat4( sgTRANS, 
+                        current_view.view_pos.x(),
+                        current_view.view_pos.y(),
+                        current_view.view_pos.z() );
+       sgMat4 sgVIEW;
+       sgMultMat4( sgVIEW, current_view.sgVIEW, sgTRANS );
+       ssgSetCamera( sgVIEW );
+       // ssgSetCamera( current_view.sgVIEW );
        ssgCullAndDraw( scene );
 
     }
@@ -1058,8 +1067,8 @@ int main( int argc, char **argv ) {
     // distribution) specifically from the ssg tux example
     //
 
-    ssgModelPath( "/stage/pinky01/src/Libs/plib-1.0.12/examples/ssg/tux/data/" );
-    ssgTexturePath( "/stage/pinky01/src/Libs/plib-1.0.12/examples/ssg/tux/data/" );
+    ssgModelPath( "/h/curt/src/Libs/plib-1.0.12/examples/ssg/tux/data/" );
+    ssgTexturePath( "/h/curt/src/Libs/plib-1.0.12/examples/ssg/tux/data/" );
 
     scene = new ssgRoot;
     penguin = new ssgTransform;
index d7f692add7700ccd791a16bdfedc475226063b8d..98c9b53cd52aa5e546d21187319573aa4c7946bc 100644 (file)
@@ -508,8 +508,6 @@ void FGView::UpdateViewMath( FGInterface *f ) {
     MAT3mat R, TMP, UP, LOCAL, VIEW;
     double ntmp;
 
-    sgMat4 sgLOCAL, sgUP, sgVIEW;
-
     if ( update_fov ) {
        // printf("Updating fov\n");
        UpdateFOV( current_options );
@@ -603,38 +601,79 @@ void FGView::UpdateViewMath( FGInterface *f ) {
 
     } else {
 
+       // calculate the transformation matrix to go from LaRCsim to ssg
+       sgVec3 vec1;
+       sgSetVec3( vec1, 0.0, 1.0, 0.0 );
+       sgMat4 mat1;
+       sgMakeRotMat4( mat1, 90, vec1 );
+
+       sgVec3 vec2;
+       sgSetVec3( vec2, 1.0, 0.0, 0.0 );
+       sgMat4 mat2;
+       sgMakeRotMat4( mat2, 90, vec2 );
+
+       sgMultMat4( sgLARC_TO_SSG, mat1, mat2 );
+
+       cout << "LaRCsim to SSG:" << endl;
+       MAT3mat print;
+       int i;
+       int j;
+       for ( i = 0; i < 4; i++ ) {
+           for ( j = 0; j < 4; j++ ) {
+               print[i][j] = sgLARC_TO_SSG[i][j];
+           }
+       }
+       MAT3print( print, stdout);
+
        // code to calculate LOCAL matrix calculated from Phi, Theta, and
        // Psi (roll, pitch, yaw) in case we aren't running LaRCsim as our
        // flight model
 
        MAT3_SET_VEC(vec, 0.0, 0.0, 1.0);
        MAT3rotate(R, vec, f->get_Phi());
-       /* printf("Roll matrix\n"); */
-       /* MAT3print(R, stdout); */
+       // cout << "Roll matrix" << endl;
+       // MAT3print(R, stdout);
+
+       sgVec3 sgrollvec;
+       sgSetVec3( sgrollvec, 0.0, 0.0, 1.0 );
+       sgMat4 sgPHI;           // roll
+       sgMakeRotMat4( sgPHI, f->get_Phi() * RAD_TO_DEG, sgrollvec );
+
 
        MAT3_SET_VEC(vec, 0.0, 1.0, 0.0);
-       /* MAT3mult_vec(vec, vec, R); */
        MAT3rotate(TMP, vec, f->get_Theta());
-       /* printf("Pitch matrix\n"); */
-       /* MAT3print(TMP, stdout); */
+       // cout << "Pitch matrix" << endl;;
+       // MAT3print(TMP, stdout);
        MAT3mult(R, R, TMP);
+       // cout << "tmp rotation matrix, R:" << endl;;
+       // MAT3print(R, stdout);
+
+       sgVec3 sgpitchvec;
+       sgSetVec3( sgpitchvec, 0.0, 1.0, 0.0 );
+       sgMat4 sgTHETA;         // pitch
+       sgMakeRotMat4( sgTHETA, f->get_Theta() * RAD_TO_DEG,
+                      sgpitchvec );
+
+       sgMat4 sgROT;
+       sgMultMat4( sgROT, sgPHI, sgTHETA );
+
 
        MAT3_SET_VEC(vec, 1.0, 0.0, 0.0);
-       /* MAT3mult_vec(vec, vec, R); */
-       /* MAT3rotate(TMP, vec, FG_Psi - FG_PI_2); */
        MAT3rotate(TMP, vec, -f->get_Psi());
-       /* printf("Yaw matrix\n");
-          MAT3print(TMP, stdout); */
+       // cout << "Yaw matrix" << endl;
+       // MAT3print(TMP, stdout);
        MAT3mult(LOCAL, R, TMP);
-       // cout << "FG derived LOCAL matrix using MAT3 routines" << endl;
+       // cout << "LOCAL matrix:" << endl;
        // MAT3print(LOCAL, stdout);
 
-       sgMakeRotMat4( sgLOCAL, 
-                      f->get_Psi() * RAD_TO_DEG,
-                      f->get_Phi() * RAD_TO_DEG,
-                      f->get_Theta() * RAD_TO_DEG );
+       sgVec3 sgyawvec;
+       sgSetVec3( sgyawvec, 1.0, 0.0, 0.0 );
+       sgMat4 sgPSI;           // pitch
+       sgMakeRotMat4( sgPSI, -f->get_Psi() * RAD_TO_DEG, sgyawvec );
+
+       sgMultMat4( sgLOCAL, sgROT, sgPSI );
+
        /*
-       cout << "FG derived LOCAL matrix using sg routines" << endl;
        MAT3mat print;
        int i;
        int j;
@@ -644,15 +683,6 @@ void FGView::UpdateViewMath( FGInterface *f ) {
            }
        }
        MAT3print( print, stdout);
-
-       sgMat4 sgIDENT;
-       sgMakeIdentMat4( sgIDENT );
-       for ( i = 0; i < 4; i++ ) {
-           for ( j = 0; j < 4; j++ ) {
-               print[i][j] = sgIDENT[i][j];
-           }
-       }
-       MAT3print( print, stdout);
        */
     } // if ( use_larcsim_local_to_body ) 
 
@@ -709,7 +739,10 @@ void FGView::UpdateViewMath( FGInterface *f ) {
     cout << "VIEW matrix" << endl;;
     MAT3print(VIEW, stdout);
 
-    sgMultMat4( sgVIEW, sgLOCAL, sgUP );
+    sgMat4 sgTMP;
+    sgMultMat4( sgTMP, sgLOCAL, sgUP );
+    sgMultMat4( sgVIEW, sgLARC_TO_SSG, sgTMP );
+
     cout << "FG derived VIEW matrix using sg routines" << endl;
     MAT3mat print;
     int i;
@@ -721,6 +754,7 @@ void FGView::UpdateViewMath( FGInterface *f ) {
     }
     MAT3print( print, stdout);
 
+
     // generate the current up, forward, and fwrd-view vectors
     MAT3_SET_VEC(vec, 1.0, 0.0, 0.0);
     MAT3mult_vec(view_up, vec, VIEW);
index 332176bb3379b98cd9184eee535a919d1c7cc1c4..378bf587617e1695353ce4c4c98fd0aaf57cc8da 100644 (file)
@@ -29,6 +29,7 @@
 # error This library requires C++
 #endif                                   
 
+#include <sg.h>                        // plib include
 
 #include <FDM/flight.hxx>
 #include <Math/mat3.h>
@@ -152,6 +153,8 @@ public:
     // Current model view matrix;
     GLfloat MODEL_VIEW[16];
 
+    sgMat4 sgLOCAL, sgUP, sgVIEW, sgLARC_TO_SSG;
+
 public:
 
     // Constructor