]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/views.cxx
Mac portability changes.
[flightgear.git] / src / Main / views.cxx
index c6f6eba4f2b9fa4583098f4f0b57e2c115a61398..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.
@@ -742,7 +753,15 @@ void FGView::UpdateViewMath( FGInterface *f ) {
 
     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;