]> git.mxchange.org Git - flightgear.git/commitdiff
Some changes contributed by David Megginson to allow for more interesting
authorcurt <curt>
Wed, 18 Oct 2000 21:19:30 +0000 (21:19 +0000)
committercurt <curt>
Wed, 18 Oct 2000 21:19:30 +0000 (21:19 +0000)
external views.

src/Cockpit/hud_ladr.cxx
src/Cockpit/panel.cxx
src/Cockpit/panel.hxx
src/Main/bfi.cxx
src/Main/fg_init.cxx
src/Main/keyboard.cxx
src/Main/main.cxx
src/Main/views.cxx

index 08cf1980e7e7c8748a9947d5b18ae7d8b4240a13..2a62b4d500e672e30423cde9a0372a18b1f236f9 100644 (file)
@@ -1,5 +1,6 @@
 
 #include "hud.hxx"
+#include "panel.hxx"
 
 #define DO_PANEL_HACK
 
@@ -219,7 +220,7 @@ void HudLadder :: draw( void )
 
        glEnable(GL_LINE_STIPPLE);
 #ifdef DO_PANEL_HACK
-       glLineStipple( 1, current_options.get_panel_status() ? 0x0F0F : 0x00FF );
+       glLineStipple( 1, fgPanelVisible() ? 0x0F0F : 0x00FF );
 #else
        glLineStipple( 1, 0x00FF );
 #endif
index 16168f8c80d7a0d1443072dcb1e87297de08caf0..7de4b43eabd447b888fb5371438e1b2a4d64ce4a 100644 (file)
 #include "panel.hxx"
 
 
+bool
+fgPanelVisible ()
+{
+  return ((current_options.get_panel_status()) &&
+         (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_PILOT) &&
+         (current_view.get_view_offset() == 0.0));
+}
+
+
 \f
 ////////////////////////////////////////////////////////////////////////
 // Implementation of FGTextureManager.
@@ -125,7 +134,7 @@ FGPanel::FGPanel (int window_x, int window_y, int window_w, int window_h)
     _width(_winw), _height(int(_winh * 0.5768 + 1)),
     _x_offset(0), _y_offset(0), _view_height(int(_winh * 0.4232))
 {
-  setVisibility(current_options.get_panel_status());
+  setVisibility(fgPanelVisible());
 }
 
 
@@ -160,7 +169,7 @@ void
 FGPanel::update () const
 {
                                // Do nothing if the panel isn't visible.
-  if (!_visibility)
+  if (!fgPanelVisible())
     return;
 
                                // If the mouse is down, do something
index 25c0037ac5ad87574da1558b634589a99b8d585c..c8e8c606cefb8fa6e514894f3a002bbfab38752c 100644 (file)
@@ -567,6 +567,14 @@ private:
 };
 
 
+\f
+////////////////////////////////////////////////////////////////////////
+// Functions.
+////////////////////////////////////////////////////////////////////////
+
+bool fgPanelVisible ();
+
+
 \f
 ////////////////////////////////////////////////////////////////////////
 // The current panel, if any.
index 886d7d3a884f80165832227be66f5c23e9d75733..89c2b952d53a35b28aee1d0180d89a9deae78b2e 100644 (file)
@@ -111,7 +111,8 @@ FGBFI::init ()
   current_properties.tieDouble("/position/longitude",
                               getLongitude, setLongitude);
   current_properties.tieDouble("/position/altitude",
-                              getAltitude, setAltitude);
+                              // getAltitude, setAltitude);
+                              getAltitude, setAltitude, false);
   current_properties.tieDouble("/position/altitude-agl",
                               getAGL, 0);
 
@@ -234,6 +235,8 @@ FGBFI::init ()
   current_properties.tieDouble("/environment/visibility",
                               getVisibility, setVisibility);
 
+  _needReinit = false;
+
   FG_LOG(FG_GENERAL, FG_INFO, "Ending BFI init");
 }
 
index c89aafab84f1e1c393e2d84b0e5dc3f4ff98f0a8..1027381ccc181ea9004cc4bb25d7eab1ba4d764e 100644 (file)
@@ -346,6 +346,15 @@ bool fgInitPosition( void ) {
     fgFDMSetGroundElevation( current_options.get_flight_model(),
                             f->get_Altitude() * FEET_TO_METER );
 
+#if 0
+    current_properties.setDoubleValue("/position/longitude",
+                                     f->get_Longitude() * RAD_TO_DEG);
+    current_properties.setDoubleValue("/position/latitude",
+                                     f->get_Latitude() * RAD_TO_DEG);
+    current_properties.setDoubleValue("/position/altitude",
+                                     f->get_Altitude() * RAD_TO_DEG);
+#endif
+
     FG_LOG( FG_GENERAL, FG_INFO,
            "Initial position is: ("
            << (f->get_Longitude() * RAD_TO_DEG) << ", "
index 624a087b9558d5716e83fe0cb5f267b14f665751..8606a286401e036bd839bce37e29b13a845a7c9a 100644 (file)
@@ -158,27 +158,59 @@ void GLUTkey(unsigned char k, int x, int y) {
            return;
        case 49: // numeric keypad 1
            v->set_goal_view_offset( FG_PI * 0.75 );
+           if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
+             pilot_view.set_pilot_offset(-25.0, 25.0, 1.0);
+             v->set_view_offset( FG_PI * 0.75 );
+           }
            return;
        case 50: // numeric keypad 2
            v->set_goal_view_offset( FG_PI );
+           if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
+             pilot_view.set_pilot_offset(-25.0, 0.0, 1.0);
+             v->set_view_offset( FG_PI );
+           }
            return;
        case 51: // numeric keypad 3
            v->set_goal_view_offset( FG_PI * 1.25 );
+           if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
+             pilot_view.set_pilot_offset(-25.0, -25.0, 1.0);
+             v->set_view_offset( FG_PI * 1.25 );
+           }
            return;
        case 52: // numeric keypad 4
            v->set_goal_view_offset( FG_PI * 0.50 );
+           if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
+             pilot_view.set_pilot_offset(0.0, 25.0, 1.0);
+             v->set_view_offset( FG_PI * 0.50 );
+           }
            return;
        case 54: // numeric keypad 6
            v->set_goal_view_offset( FG_PI * 1.50 );
+           if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
+             pilot_view.set_pilot_offset(0.0, -25.0, 1.0);
+             v->set_view_offset( FG_PI * 1.50 );
+           }
            return;
        case 55: // numeric keypad 7
            v->set_goal_view_offset( FG_PI * 0.25 );
+           if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
+             pilot_view.set_pilot_offset(25.0, 25.0, 1.0);
+             v->set_view_offset( FG_PI * 0.25 );
+           }
            return;
        case 56: // numeric keypad 8
            v->set_goal_view_offset( 0.00 );
+           if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
+             pilot_view.set_pilot_offset(25.0, 0.0, 1.0);
+             v->set_view_offset( 0.00 );
+           }
            return;
        case 57: // numeric keypad 9
            v->set_goal_view_offset( FG_PI * 1.75 );
+           if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
+             pilot_view.set_pilot_offset(25.0, -25.0, 1.0);
+             v->set_view_offset( FG_PI * 1.75 );
+           }
            return;
        case 65: // A key
            speed = current_options.get_speed_up();
@@ -375,7 +407,20 @@ void GLUTkey(unsigned char k, int x, int y) {
            fgUpdateSkyAndLightingParams();
            return;
        case 118: // v key
-           current_options.cycle_view_mode();
+//         current_options.cycle_view_mode();
+           if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
+             current_options.set_view_mode(fgOPTIONS::FG_VIEW_PILOT);
+             v->set_goal_view_offset( 0.0 );
+             v->set_view_offset( 0.0 );
+           } else if (current_options.get_view_mode() ==
+                      fgOPTIONS::FG_VIEW_PILOT) {
+             current_options.set_view_mode(fgOPTIONS::FG_VIEW_FOLLOW);
+             v->set_goal_view_offset( FG_PI * 1.75 );
+             v->set_view_offset( FG_PI * 1.75 );
+             pilot_view.set_pilot_offset(25.0, -25.0, 1.0);
+           }
+           fgReshape( current_view.get_winWidth(),
+                      current_view.get_winHeight() );
            return;
        case 120: // x key
            fov = current_options.get_fov();
@@ -496,27 +541,59 @@ void GLUTspecialkey(int k, int x, int y) {
        }
        case GLUT_KEY_END: // numeric keypad 1
            v->set_goal_view_offset( FG_PI * 0.75 );
+           if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
+             pilot_view.set_pilot_offset(-25.0, 25.0, 1.0);
+             v->set_view_offset( FG_PI * 0.75 );
+           }
            return;
        case GLUT_KEY_DOWN: // numeric keypad 2
            v->set_goal_view_offset( FG_PI );
+           if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
+             pilot_view.set_pilot_offset(-25.0, 0.0, 1.0);
+             v->set_view_offset( FG_PI );
+           }
            return;
        case GLUT_KEY_PAGE_DOWN: // numeric keypad 3
            v->set_goal_view_offset( FG_PI * 1.25 );
+           if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
+             pilot_view.set_pilot_offset(-25.0, -25.0, 1.0);
+             v->set_view_offset( FG_PI * 1.25 );
+           }
            return;
        case GLUT_KEY_LEFT: // numeric keypad 4
            v->set_goal_view_offset( FG_PI * 0.50 );
+           if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
+             pilot_view.set_pilot_offset(0.0, 25.0, 1.0);
+             v->set_view_offset( FG_PI * 0.50 );
+           }
            return;
        case GLUT_KEY_RIGHT: // numeric keypad 6
            v->set_goal_view_offset( FG_PI * 1.50 );
+           if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
+             pilot_view.set_pilot_offset(0.0, -25.0, 1.0);
+             v->set_view_offset( FG_PI * 1.50 );
+           }
            return;
        case GLUT_KEY_HOME: // numeric keypad 7
            v->set_goal_view_offset( FG_PI * 0.25 );
+           if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
+             pilot_view.set_pilot_offset(25.0, 25.0, 1.0);
+             v->set_view_offset( FG_PI * 0.25 );
+           }
            return;
        case GLUT_KEY_UP: // numeric keypad 8
            v->set_goal_view_offset( 0.00 );
+           if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
+             pilot_view.set_pilot_offset(25.0, 0.0, 1.0);
+             v->set_view_offset( 0.00 );
+           }
            return;
        case GLUT_KEY_PAGE_UP: // numeric keypad 9
            v->set_goal_view_offset( FG_PI * 1.75 );
+           if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
+             pilot_view.set_pilot_offset(25.0, -25.0, 1.0);
+             v->set_view_offset( FG_PI * 1.75 );
+           }
            return;
        }
     } else {
index 67e4aa02cd1564d2ea35b4ef686ba396e297174e..b672be5b831b6af3377fd0f2fbc807eba2e69fdf 100644 (file)
@@ -308,6 +308,12 @@ void fgRenderFrame( void ) {
 
        // update view volume parameters
        // cout << "before pilot_view update" << endl;
+        if ( current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW ) {
+         float * offset = pilot_view.get_pilot_offset();
+         current_view.set_pilot_offset(offset[0], offset[1], offset[2]);
+       } else {
+         current_view.set_pilot_offset(0.0, 0.0, 0.0);
+       }
        pilot_view.UpdateViewParams(*cur_fdm_state);
        // cout << "after pilot_view update" << endl;
        current_view.UpdateViewParams(cur_view_fdm);
@@ -1106,7 +1112,7 @@ static void fgIdleFunction ( void ) {
 // options.cxx needs to see this for toggle_panel()
 // Handle new window size or exposure
 void fgReshape( int width, int height ) {
-    if ( ! current_options.get_panel_status() || idle_state != 1000 ) {
+    if ( ! fgPanelVisible() || idle_state != 1000 ) {
        current_view.set_win_ratio( (float)height / (float)width );
        glViewport(0, 0 , (GLint)(width), (GLint)(height) );
     } else {
@@ -1410,8 +1416,8 @@ int main( int argc, char **argv ) {
     //
 
     FGPath modelpath( current_options.get_fg_root() );
-    modelpath.append( "Models" );
-    modelpath.append( "Geometry" );
+    // modelpath.append( "Models" );
+    // modelpath.append( "Geometry" );
   
     FGPath texturepath( current_options.get_fg_root() );
     texturepath.append( "Models" );
@@ -1466,11 +1472,25 @@ int main( int argc, char **argv ) {
     // temporary visible aircraft "own ship"
     penguin_sel = new ssgSelector;
     penguin_pos = new ssgTransform;
-    // ssgBranch *tux_obj = ssgMakeSphere( 10.0, 10, 10 );
-    ssgEntity *tux_obj = ssgLoadAC( "glider.ac" );
-    // ssgEntity *tux_obj = ssgLoadAC( "Tower1x.ac" );
-
-    penguin_pos->addKid( tux_obj );
+    string tux_path =
+      current_properties.getStringValue("/sim/model/path",
+                                       "Models/Geometry/glider.ac");
+    ssgEntity *tux_obj = ssgLoad((char *)(tux_path.c_str()));
+
+    // align the model properly for FGFS
+    ssgTransform *tux_align = new ssgTransform;
+    tux_align->addKid(tux_obj);
+    sgMat4 tux_matrix;
+    float h_rot =
+      current_properties.getFloatValue("/sim/model/h-rotation", 0.0);
+    float p_rot =
+      current_properties.getFloatValue("/sim/model/p-rotation", 0.0);
+    float r_rot =
+      current_properties.getFloatValue("/sim/model/r-rotation", 0.0);
+    sgMakeRotMat4(tux_matrix, h_rot, h_rot, r_rot);
+    tux_align->setTransform(tux_matrix);
+
+    penguin_pos->addKid( tux_align );
     penguin_sel->addKid( penguin_pos );
     ssgFlatten( tux_obj );
     ssgStripify( penguin_sel );
index 240aefc6e93fb89638325aba752d102eb47ce4c4..91118cf8e3544259d27f88ae51fe8a15021695bb 100644 (file)
@@ -166,7 +166,7 @@ inline static void fgMakeLOCAL( sgMat4 dst, const double Theta,
 void FGView::UpdateViewParams( const FGInterface& f ) {
     UpdateViewMath(f);
     
-    if ( ! current_options.get_panel_status() ) {
+    if ( ! fgPanelVisible() ) {
        xglViewport(0, 0 , (GLint)(winWidth), (GLint)(winHeight) );
     } else {
         int view_h =