]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/views.cxx
Network updates contributed by Oliver Delise.
[flightgear.git] / src / Main / views.cxx
index 98c9b53cd52aa5e546d21187319573aa4c7946bc..23945180bee808eb29e24855dbbd10cb2fd408a5 100644 (file)
@@ -76,6 +76,7 @@ FGView::FGView( void ) {
 void FGView::Init( void ) {
     FG_LOG( FG_VIEW, FG_INFO, "Initializing View parameters" );
 
+    view_mode = FG_VIEW_FIRST_PERSON;
     view_offset = 0.0;
     goal_view_offset = 0.0;
 
@@ -131,6 +132,16 @@ void FGView::UpdateFOV( const fgOPTIONS& o ) {
 }
 
 
+// Cycle view mode
+void FGView::cycle_view_mode() {
+    if ( view_mode == FG_VIEW_FIRST_PERSON ) {
+       view_mode = FG_VIEW_FOLLOW;
+    } else if ( view_mode == FG_VIEW_FOLLOW ) {
+       view_mode = FG_VIEW_FIRST_PERSON;
+    }
+}
+
+
 // Basically, this is a modified version of the Mesa gluLookAt()
 // function that's been modified slightly so we can capture the
 // result before sending it off to OpenGL land.
@@ -239,10 +250,10 @@ void FGView::UpdateViewParams( void ) {
     xglMatrixMode(GL_PROJECTION);
     xglLoadIdentity();
     if ( f->get_Altitude() * FEET_TO_METER - scenery.cur_elev > 10.0 ) {
-       ssgSetNearFar( 10.0, 100000.0 );
+       // ssgSetNearFar( 10.0, 100000.0 );
        gluPerspective(current_options.get_fov(), win_ratio, 10.0, 100000.0);
     } else {
-       ssgSetNearFar( 0.5, 100000.0 );
+       // ssgSetNearFar( 0.5, 100000.0 );
        gluPerspective(current_options.get_fov(), win_ratio, 0.5, 100000.0);
        // printf("Near ground, minimizing near clip plane\n");
     }
@@ -378,7 +389,6 @@ void FGView::UpdateViewParams( void ) {
        xglLoadMatrixf( m );
     }
 #endif // FG_VIEW_INLINE_OPTIMIZATIONS
-       
 
     panel_hist = current_options.get_panel_status();
 }
@@ -614,6 +624,7 @@ void FGView::UpdateViewMath( FGInterface *f ) {
 
        sgMultMat4( sgLARC_TO_SSG, mat1, mat2 );
 
+       /*
        cout << "LaRCsim to SSG:" << endl;
        MAT3mat print;
        int i;
@@ -624,6 +635,7 @@ void FGView::UpdateViewMath( FGInterface *f ) {
            }
        }
        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
@@ -736,13 +748,22 @@ void FGView::UpdateViewMath( FGInterface *f ) {
 
     // Calculate the VIEW matrix
     MAT3mult(VIEW, LOCAL, UP);
-    cout << "VIEW matrix" << endl;;
-    MAT3print(VIEW, stdout);
+    // cout << "VIEW matrix" << endl;;
+    // MAT3print(VIEW, stdout);
 
     sgMat4 sgTMP;
     sgMultMat4( sgTMP, sgLOCAL, sgUP );
-    sgMultMat4( sgVIEW, sgLARC_TO_SSG, sgTMP );
+    sgMultMat4( sgVIEW_ROT, sgLARC_TO_SSG, sgTMP );
+
+    sgMakeTransMat4( sgTRANS, view_pos.x(), view_pos.y(), view_pos.z() );
+
+    sgMultMat4( sgVIEW, sgVIEW_ROT, sgTRANS );
 
+    FGMat4Wrapper tmp;
+    sgCopyMat4( tmp.m, sgVIEW );
+    follow.push_back( tmp );
+
+    /*
     cout << "FG derived VIEW matrix using sg routines" << endl;
     MAT3mat print;
     int i;
@@ -753,6 +774,7 @@ void FGView::UpdateViewMath( FGInterface *f ) {
        }
     }
     MAT3print( print, stdout);
+    */
 
 
     // generate the current up, forward, and fwrd-view vectors