]> git.mxchange.org Git - flightgear.git/commitdiff
move some of the sound postion and orientation calculations over to the sample class...
authorehofman <ehofman>
Thu, 15 Oct 2009 09:20:03 +0000 (09:20 +0000)
committerTim Moore <timoore@redhat.com>
Fri, 16 Oct 2009 09:24:10 +0000 (11:24 +0200)
src/Instrumentation/mk_viii.cxx
src/Instrumentation/mk_viii.hxx
src/Main/viewmgr.cxx
src/Model/acmodel.cxx
src/Model/acmodel.hxx

index e484127f79189e9417eb1609a3cdf4fdedce9740..340c4bf1162861c50c11a0901572c146fa888752 100755 (executable)
@@ -2106,16 +2106,6 @@ MK_VIII::VoicePlayer::Speaker::bind (SGPropertyNode *node)
   // uses xmlsound property names
   tie(node, "volume", &volume);
   tie(node, "pitch", &pitch);
-  tie(node, "position/x", &position[0]);
-  tie(node, "position/y", &position[1]);
-  tie(node, "position/z", &position[2]);
-  tie(node, "orientation/x", &orientation[0]);
-  tie(node, "orientation/y", &orientation[1]);
-  tie(node, "orientation/z", &orientation[2]);
-  tie(node, "orientation/inner-cone", &inner_cone);
-  tie(node, "orientation/outer-cone", &outer_cone);
-  tie(node, "reference-dist", &reference_dist);
-  tie(node, "max-dist", &max_dist);
 }
 
 void
@@ -2127,11 +2117,6 @@ MK_VIII::VoicePlayer::Speaker::update_configuration ()
       SGSoundSample *sample = (*iter).second;
 
       sample->set_pitch(pitch);
-      sample->set_base_position(position); // TODO: tie to listener pos
-      sample->set_orientation(orientation);
-      sample->set_audio_cone(inner_cone, outer_cone, outer_gain);
-      sample->set_reference_dist(reference_dist);
-      sample->set_max_dist(max_dist);
     }
 
   if (player->voice)
index 27cf023fabafd9999e18848562790952584a05bd..077ea52aba5e575590dbe7bc034f28a8ba599280 100755 (executable)
@@ -889,13 +889,6 @@ public:
       VoicePlayer *player;
 
       double   pitch;
-      SGVec3d  position;
-      SGVec3f  orientation;
-      float    inner_cone;
-      float    outer_cone;
-      float    outer_gain;
-      float    reference_dist;
-      float    max_dist;
 
       template <class T>
       inline void tie (SGPropertyNode *node, const char *name, T *ptr)
@@ -920,15 +913,8 @@ public:
       inline Speaker (VoicePlayer *_player)
        : player(_player),
          pitch(1),
-         inner_cone(360),
-         outer_cone(360),
-         outer_gain(0),
-         reference_dist(3),
-         max_dist(10),
          volume(1)
       {
-       position[0] = 0; position[1] = 0; position[2] = 0;
-       orientation[0] = 0; orientation[1] = 0; orientation[2] = 0;
       }
 
       void bind (SGPropertyNode *node);
index 18b16a6a29ec243cb50c8553fd09c83483c75d30..a23a28d795d630e6d6747859b1dff6ee8d237abb 100644 (file)
@@ -298,11 +298,11 @@ 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_position( abs_viewer_position );
   smgr->set_orientation(loop_view->getViewOrientation());
 
   // get the model velocity for the in-cockpit view
-  SGVec3f velocity = SGVec3f(0,0,0);
+  SGVec3d velocity = SGVec3d(0,0,0);
   if ( !stationary() ) {
     FGAircraftModel *aircraft = globals->get_aircraft_model();
     velocity = aircraft->getVelocity();
index ff2c81aa076f1bc1bd9234c6e03d496f475717ec..b4fda2e871dffb01587a154c84dbbf84669696a0 100644 (file)
@@ -36,7 +36,7 @@
 
 FGAircraftModel::FGAircraftModel ()
   : _aircraft(0),
-    _velocity(SGVec3f::zeros()),
+    _velocity(SGVec3d::zeros()),
     _fx(0),
     _lon(0),
     _lat(0),
@@ -44,7 +44,9 @@ FGAircraftModel::FGAircraftModel ()
     _pitch(0),
     _roll(0),
     _heading(0),
-    _speed(0)
+    _speed_n(0),
+    _speed_e(0),
+    _speed_d(0)
 {
     SGSoundMgr *smgr;
     smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr");
@@ -91,7 +93,9 @@ FGAircraftModel::bind ()
    _pitch = fgGetNode("orientation/pitch-deg", true);
    _roll = fgGetNode("orientation/roll-deg", true);
    _heading = fgGetNode("orientation/heading-deg", true);
-   _speed = fgGetNode("velocities/groundspeed-kt", true);
+   _speed_n = fgGetNode("velocities/speed-north-fps", true);
+   _speed_e = fgGetNode("velocities/speed-east-fps", true);
+   _speed_d = fgGetNode("velocities/speed-down-fps", true);
 }
 
 void
@@ -121,21 +125,16 @@ FGAircraftModel::update (double dt)
   _aircraft->update();
 
   // update model's audio sample values
-  // Get the Cartesian coordinates in meters
-  SGVec3d pos = SGVec3d::fromGeod(_aircraft->getPosition());
-  _fx->set_position( -pos );
-
-  SGQuatd orient_m = SGQuatd::fromLonLat(_aircraft->getPosition());
-  orient_m *= SGQuatd::fromYawPitchRollDeg(_heading->getDoubleValue(),
-                                           _pitch->getDoubleValue(),
-                                           _roll->getDoubleValue());
-  SGVec3d orient = -orient_m.rotate(SGVec3d::e1());
-  _fx->set_orientation( toVec3f( orient ) );
+  _fx->set_position( _aircraft->getPosition() );
+
+  SGQuatd orient = SGQuatd::fromYawPitchRollDeg(_heading->getDoubleValue(),
+                                                  _pitch->getDoubleValue(),
+                                                  _roll->getDoubleValue());
+  _fx->set_orientation( orient );
  
-  // For now assume the aircraft speed is always along the longitudinal
-  // axis, so sideslipping is not taken into account. This should be fine
-  // for audio.
-  _velocity = toVec3f(orient * _speed->getDoubleValue() * SG_KT_TO_MPS);
+  _velocity = SGVec3d( -_speed_n->getDoubleValue(),
+                       -_speed_e->getDoubleValue(),
+                       -_speed_d->getDoubleValue());
   _fx->set_velocity( _velocity );
 }
 
index dd6e3b01f705bbcc74fd1f45e94cbcf71b435a6d..c751b699c6a54b68ee4c3ea501da390dd6c37c39 100644 (file)
@@ -39,12 +39,12 @@ public:
   virtual void unbind ();
   virtual void update (double dt);
   virtual SGModelPlacement * get3DModel() { return _aircraft; }
-  virtual SGVec3f getVelocity() { return _velocity; }
+  virtual SGVec3d getVelocity() { return _velocity; }
 
 private:
 
   SGModelPlacement * _aircraft;
-  SGVec3f _velocity;
+  SGVec3d _velocity;
   FGFX * _fx;
 
   SGPropertyNode * _lon;
@@ -53,8 +53,9 @@ private:
   SGPropertyNode * _pitch;
   SGPropertyNode * _roll;
   SGPropertyNode * _heading;
-  SGPropertyNode * _speed;
-
+  SGPropertyNode * _speed_n;
+  SGPropertyNode * _speed_e;
+  SGPropertyNode * _speed_d;
 };
 
 #endif // __ACMODEL_HXX