]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/viewmgr.cxx
Add David Culp's AI model manager code which is derived from David Luff's AI/ATC...
[flightgear.git] / src / Main / viewmgr.cxx
index 9b14bcd906109a361def2e75e32f0afe28fb2fbb..39e7ac95bd5a893e0498c02efa2ec4722c5f22c4 100644 (file)
@@ -51,11 +51,12 @@ FGViewMgr::init ()
   bool at_model = false;
   int from_model_index = 0;
   int at_model_index = 0;
-  double at_model_damping = 0.0;
+  double damp_alt, damp_roll, damp_pitch, damp_heading;
   double x_offset_m, y_offset_m, z_offset_m, fov_deg;
   double heading_offset_deg, pitch_offset_deg, roll_offset_deg;
   double target_x_offset_m, target_y_offset_m, target_z_offset_m;
   double near_m;
+  bool internal;
 
   for (int i = 0; i < fgGetInt("/sim/number-views"); i++) {
     viewpath = "/sim/view";
@@ -67,6 +68,12 @@ FGViewMgr::init ()
     nodepath += "/type";
     strdata = fgGetString(nodepath.c_str());
 
+    // find out if this is an internal view (e.g. in cockpit, low near plane)
+    internal = false; // default
+    nodepath = viewpath;
+    nodepath += "/internal";
+    internal = fgGetBool(nodepath.c_str());
+
     // FIXME:
     // this is assumed to be an aircraft model...we will need to read
     // model-from-type as well.
@@ -95,10 +102,14 @@ FGViewMgr::init ()
         at_model_index = fgGetInt(nodepath.c_str());
 
         nodepath = viewpath;
-        nodepath += "/config/at-model-damping";
-        at_model_damping = 1 - 1.0 / pow(10, fgGetDouble(nodepath.c_str()));
-        if (at_model_damping < 0.0)
-          at_model_damping = 0.0;
+        nodepath += "/config/at-model-roll-damping";
+        damp_roll = fgGetDouble(nodepath.c_str(), 0.0);
+        nodepath = viewpath;
+        nodepath += "/config/at-model-pitch-damping";
+        damp_pitch = fgGetDouble(nodepath.c_str(), 0.0);
+        nodepath = viewpath;
+        nodepath += "/config/at-model-heading-damping";
+        damp_heading = fgGetDouble(nodepath.c_str(), 0.0);
       }
     }
 
@@ -145,17 +156,20 @@ FGViewMgr::init ()
     // supporting two types now "lookat" = 1 and "lookfrom" = 0
     if ( strcmp("lookat",strdata.c_str()) == 0 )
       add_view(new FGViewer ( FG_LOOKAT, from_model, from_model_index,
-                              at_model, at_model_index, at_model_damping,
+                              at_model, at_model_index,
+                              damp_roll, damp_pitch, damp_heading,
                               x_offset_m, y_offset_m,z_offset_m,
                               heading_offset_deg, pitch_offset_deg,
                               roll_offset_deg, fov_deg,
                               target_x_offset_m, target_y_offset_m,
-                              target_z_offset_m, near_m ));
+                              target_z_offset_m, near_m, internal ));
     else
-      add_view(new FGViewer ( FG_LOOKFROM, from_model, from_model_index, false,
-                              0, 0.0, x_offset_m, y_offset_m, z_offset_m,
+      add_view(new FGViewer ( FG_LOOKFROM, from_model, from_model_index,
+                              false, 0, 0.0, 0.0, 0.0,
+                              x_offset_m, y_offset_m, z_offset_m,
                               heading_offset_deg, pitch_offset_deg,
-                              roll_offset_deg, fov_deg, 0, 0, 0, near_m ));
+                              roll_offset_deg, fov_deg, 0, 0, 0, near_m,
+                              internal ));
   }
 
   copyToCurrent();
@@ -368,8 +382,8 @@ FGViewMgr::update (double dt)
       nodepath = viewpath;
       nodepath += "/config/target-heading-deg-path";
       heading_deg = fgGetDouble(fgGetString(nodepath.c_str()));
-  
-      loop_view ->setTargetPosition(lon_deg, lat_deg, alt_ft);
+
+      loop_view->setTargetPosition(lon_deg, lat_deg, alt_ft);
       loop_view->setTargetOrientation(roll_deg, pitch_deg, heading_deg);
     } else {
       loop_view->set_dirty();