]> git.mxchange.org Git - flightgear.git/commitdiff
another attempt at getting something useful without any result.
authorehofman <ehofman>
Sat, 31 Oct 2009 14:20:14 +0000 (14:20 +0000)
committerTim Moore <timoore@redhat.com>
Sat, 31 Oct 2009 21:57:27 +0000 (22:57 +0100)
src/Main/viewmgr.cxx
src/Model/acmodel.cxx

index b31b9912b3a6dca715b2a26ede8fac70bcacefca..5a9b7a20f281a011e15641fe387e145a13961527 100644 (file)
@@ -298,9 +298,16 @@ FGViewMgr::update (double dt)
 
   // update audio listener values
   // set the viewer posotion in Cartesian coordinates in meters
-  smgr->set_position( abs_viewer_position );
-  smgr->set_orientation(loop_view->getViewOrientation(), 
-                        loop_view->getViewOrientationOffset());
+  SGVec3d offs = SGVec3d( loop_view->getXOffset_m(),
+                          loop_view->getYOffset_m(),
+                          loop_view->getZOffset_m());
+  smgr->set_position_offset( offs );
+  smgr->set_position_geod( loop_view->getPosition() );
+
+  SGQuatd orient = SGQuatd::fromYawPitchRollDeg( loop_view->getHeading_deg(),
+                                                 loop_view->getPitch_deg(),
+                                                 loop_view->getRoll_deg() );
+  smgr->set_orientation( orient, loop_view->getViewOrientationOffset() );
 
   // get the model velocity
   SGVec3f velocity = SGVec3f::zeros();
index 305c1fbeb87b7b7dfb884bac0e4d2402f60f6a3f..6d0d32049aeb955e46be14c6a3b1d502598e7a70 100644 (file)
@@ -124,17 +124,23 @@ FGAircraftModel::update (double dt)
   _aircraft->update();
 
   // update model's audio sample values
-  _fx->set_position( _aircraft->getPosition() );
+  _fx->set_position_geod( _aircraft->getPosition() );
 
-  SGQuatd orient = SGQuatd::fromYawPitchRollDeg(_heading->getDoubleValue(),
+  SGQuatd orient = SGQuatd::fromYawPitchRollDeg(-_heading->getDoubleValue(),
                                                 _pitch->getDoubleValue(),
                                                 _roll->getDoubleValue());
   _fx->set_orientation( orient );
  
-   SGQuatf q(-0.5, -0.5, 0.5, 0.5);
-  _velocity =  q.backTransform( SGVec3f(_speed_n->getFloatValue(),
-                                        _speed_e->getFloatValue(),
-                                        _speed_d->getFloatValue()) );
+  SGVec3d vel = SGVec3d( _speed_n->getFloatValue(),
+                         _speed_e->getFloatValue(),
+                         _speed_d->getFloatValue() );
+  if ( vel[0] || vel[1] || vel[2] ) {
+    SGQuatd hlOr = SGQuatd::fromLonLat( _aircraft->getPosition() );
+    SGQuatd q(-0.5, -0.5, 0.5, 0.5);
+    _velocity = toVec3f( (hlOr*q).backTransform( vel ) );
+  }
+  else
+      _velocity = SGVec3f::zeros();
   _fx->set_velocity( _velocity );
 }