The current chase view respects heading but ignores roll & pitch.
And it follows heading without delay, which makes the viewer behave
quite strange. This change makes the chase view feel more natural.
You aren't fixed behind the plane, but follow all its movements
with a delay. Compare reaction to differential braking or rudder
while taxiing, or banking during flight! The delay is controlled
via property "/sim/view/config/at-model-damping". The attached
preferences patch adds an additional view mode for comparison.
One of the chase views would, of course, have to be removed.

Drawback: 360 degree rolls are a little more difficult.

I'm aware that this change may be controversial, and I can live
with a rejection.  :-)

m.

Index: preferences.xml
===================================================================
RCS file: /var/cvs/FlightGear-0.9/data/preferences.xml,v
retrieving revision 1.111
diff -u -p -r1.111 preferences.xml
--- preferences.xml	1 Jul 2003 20:56:21 -0000	1.111
+++ preferences.xml	9 Jul 2003 17:56:56 -0000
@@ -81,7 +81,7 @@ Started September 2000 by David Megginso
    </selected>
   </input>
 
-  <number-views type="int">5</number-views>
+  <number-views type="int">6</number-views>
 
   <!-- "tower" positioned to right of runway at KSFO -->
   <tower>
@@ -141,6 +141,32 @@ Started September 2000 by David Megginso
     </config>
   </view>
 
+  <view>
+    <name>Chase View [new]</name>
+    <type>lookat</type>
+    <config>
+      <from-model type="bool">false</from-model>
+      <from-model-idx type="int">0</from-model-idx>
+      <eye-lat-deg-path>/position/latitude-deg</eye-lat-deg-path>
+      <eye-lon-deg-path>/position/longitude-deg</eye-lon-deg-path>
+      <eye-alt-ft-path>/position/altitude-ft</eye-alt-ft-path>
+      <eye-pitch-deg-path>/orientation/pitch-deg</eye-pitch-deg-path>
+      <eye-roll-deg-path>/orientation/roll-deg</eye-roll-deg-path>
+      <eye-heading-deg-path>/orientation/heading-deg</eye-heading-deg-path>
+
+      <at-model type="bool">true</at-model>
+      <at-model-idx type="int">0</at-model-idx>
+      <at-model-damping type="double">0.99</at-model-damping>
+      <target-z-offset-m type="double">0</target-z-offset-m>
+
+      <ground-level-nearplane-m type="double">0.5f</ground-level-nearplane-m>
+      <default-field-of-view-deg type="double">55.0</default-field-of-view-deg>
+
+      <x-offset-m type="double">5</x-offset-m>
+      <y-offset-m type="double">0</y-offset-m>
+      <z-offset-m type="double">-25</z-offset-m>
+    </config>
+  </view>
 
   <view>
     <name>Tower View</name>
? core.25008
Index: main.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/FlightGear/src/Main/main.cxx,v
retrieving revision 1.107
diff -u -p -r1.107 main.cxx
--- main.cxx	5 Jul 2003 09:59:03 -0000	1.107
+++ main.cxx	9 Jul 2003 17:50:54 -0000
@@ -1894,6 +1894,8 @@ int main ( int argc, char **argv ) {
         cerr << "Fatal error: " << t.getFormattedMessage()
              << "\n (received from " << t.getOrigin() << ')' << endl;
         exit(1);
+    } catch (...) {
+        cerr << "main: unknown exception; aborting" << endl;
     }
 
     return 0;
Index: viewer.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/FlightGear/src/Main/viewer.cxx,v
retrieving revision 1.7
diff -u -p -r1.7 viewer.cxx
--- viewer.cxx	13 May 2003 03:18:53 -0000	1.7
+++ viewer.cxx	9 Jul 2003 17:50:55 -0000
@@ -132,7 +132,7 @@ static void MakeVIEW_OFFSET( sgMat4 dst,
 
 // Constructor...
 FGViewer::FGViewer( fgViewType Type, bool from_model, int from_model_index, 
-                    bool at_model, int at_model_index,
+                    bool at_model, int at_model_index, double at_model_damping,
                     double x_offset_m, double y_offset_m, double z_offset_m, 
                     double heading_offset_deg, double pitch_offset_deg,
                     double roll_offset_deg, double fov_deg,
@@ -148,6 +148,8 @@ FGViewer::FGViewer( fgViewType Type, boo
     _roll_deg(0),
     _pitch_deg(0),
     _heading_deg(0),
+    _damped_roll_deg(0),
+    _damped_pitch_deg(0),
     _scaling_type(FG_SCALING_MAX)
 {
     sgdZeroVec3(_absolute_view_pos);
@@ -156,6 +158,7 @@ FGViewer::FGViewer( fgViewType Type, boo
     _from_model_index = from_model_index;
     _at_model = at_model;
     _at_model_index = at_model_index;
+    _damp = at_model_damping;
     _x_offset_m = x_offset_m;
     _y_offset_m = y_offset_m;
     _z_offset_m = z_offset_m;
@@ -494,6 +497,32 @@ FGViewer::recalcOurOwnLocation (SGLocati
                         double roll_deg, double pitch_deg, double heading_deg)
 {
   // update from our own data...
+  if (_damp > 0.0) {
+    if (roll_deg - _damped_roll_deg > 180.0)
+      _damped_roll_deg += 360.0;
+    else if (roll_deg - _damped_roll_deg < -180.0)
+      _damped_roll_deg -= 360.0;
+
+    if (pitch_deg - _damped_pitch_deg > 180.0)
+      _damped_pitch_deg += 360.0;
+    else if (pitch_deg - _damped_pitch_deg < -180.0)
+      _damped_pitch_deg -= 360.0;
+
+    if (heading_deg - _damped_heading_deg > 180.0)
+      _damped_heading_deg += 360.0;
+    else if (heading_deg - _damped_heading_deg < -180.0)
+      _damped_heading_deg -= 360.0;
+
+    static bool firstrun = true;
+    if (firstrun) {
+      _damped_heading_deg = _target_location->getHeading_deg();
+      firstrun = false;
+    }
+
+    roll_deg = _damped_roll_deg = roll_deg * (1 - _damp) + _damped_roll_deg * _damp;
+    pitch_deg = _damped_pitch_deg = pitch_deg * (1 - _damp) + _damped_pitch_deg * _damp;
+    heading_deg = _damped_heading_deg = heading_deg * (1 - _damp) + _damped_heading_deg * _damp;
+  }
   location->setPosition( lon_deg, lat_deg, alt_ft );
   location->setOrientation( roll_deg, pitch_deg, heading_deg );
   sgCopyMat4(LOCAL,
@@ -802,6 +831,27 @@ FGViewer::update (double dt)
 	setPitchOffset_deg(90);
       } else if ( _pitch_offset_deg < -90 ) {
 	setPitchOffset_deg( -90 );
+      }
+    }
+  }
+
+  for ( i = 0; i < dt_ms; i++ ) {
+    if ( fabs( _goal_roll_offset_deg - _roll_offset_deg ) < 1 ) {
+      setRollOffset_deg( _goal_roll_offset_deg );
+      break;
+    } else {
+      // move current_view.roll_offset_deg towards
+      // current_view.goal_roll_offset
+      if ( _goal_roll_offset_deg > _roll_offset_deg )
+	{
+	  incRollOffset_deg( 1.0 );
+	} else {
+	    incRollOffset_deg( -1.0 );
+	}
+      if ( _roll_offset_deg > 90 ) {
+	setRollOffset_deg(90);
+      } else if ( _roll_offset_deg < -90 ) {
+	setRollOffset_deg( -90 );
       }
     }
   }
Index: viewer.hxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/FlightGear/src/Main/viewer.hxx,v
retrieving revision 1.4
diff -u -p -r1.4 viewer.hxx
--- viewer.hxx	13 May 2003 03:18:53 -0000	1.4
+++ viewer.hxx	9 Jul 2003 17:50:56 -0000
@@ -62,7 +62,7 @@ public:
 
     // Constructor
     FGViewer( fgViewType Type, bool from_model, int from_model_index,
-              bool at_model, int at_model_index,
+              bool at_model, int at_model_index, double damping,
               double x_offset_m, double y_offset_m, double z_offset_m,
               double heading_offset_deg, double pitch_offset_deg,
               double roll_offset_deg, double fov_deg,
@@ -285,6 +285,11 @@ private:
     double _target_pitch_deg;
     double _target_heading_deg;
 
+    double _damp;
+    double _damped_roll_deg;
+    double _damped_pitch_deg;
+    double _damped_heading_deg;
+
     // Position offsets from FDM origin.  The X axis is positive
     // out the tail, Y is out the right wing, and Z is positive up.
     // distance in meters
@@ -376,6 +381,12 @@ private:
     void updateAtModelLocation (SGLocation * location);
     void recalcOurOwnLocation (SGLocation * location, double lon_deg, double lat_deg, double alt_ft,
                  double roll_deg, double pitch_deg, double heading_deg);
+
+    // add to _roll_offset_deg
+    inline void incRollOffset_deg( double amt ) {
+	set_dirty();
+	_roll_offset_deg += amt;
+    }
 
     // add to _heading_offset_deg
     inline void incHeadingOffset_deg( double amt ) {
Index: viewmgr.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/FlightGear/src/Main/viewmgr.cxx,v
retrieving revision 1.4
diff -u -p -r1.4 viewmgr.cxx
--- viewmgr.cxx	9 May 2003 08:31:56 -0000	1.4
+++ viewmgr.cxx	9 Jul 2003 17:50:56 -0000
@@ -51,6 +51,7 @@ FGViewMgr::init ()
   bool at_model = false;
   int from_model_index = 0;
   int at_model_index = 0;
+  double at_model_damping = 1.0;
   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;
@@ -91,7 +92,11 @@ FGViewMgr::init ()
       if (at_model) {
         nodepath = viewpath;
         nodepath += "/config/at-model-idx";
-        at_model_index = fgGetInt(nodepath.c_str());     
+        at_model_index = fgGetInt(nodepath.c_str());
+
+        nodepath = viewpath;
+        nodepath += "/config/at-model-damping";
+        at_model_damping = fgGetDouble(nodepath.c_str());
       }
     }
 
@@ -138,15 +143,15 @@ 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, x_offset_m,
-                              y_offset_m,z_offset_m,
+                              at_model, at_model_index, at_model_damping,
+                              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 ));
     else
       add_view(new FGViewer ( FG_LOOKFROM, from_model, from_model_index, false,
-                              0, x_offset_m, y_offset_m, z_offset_m,
+                              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 ));
   }
_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel

Reply via email to