// 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
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)
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)
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);
// 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();
FGAircraftModel::FGAircraftModel ()
: _aircraft(0),
- _velocity(SGVec3f::zeros()),
+ _velocity(SGVec3d::zeros()),
_fx(0),
_lon(0),
_lat(0),
_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");
_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
_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 );
}
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;
SGPropertyNode * _pitch;
SGPropertyNode * _roll;
SGPropertyNode * _heading;
- SGPropertyNode * _speed;
-
+ SGPropertyNode * _speed_n;
+ SGPropertyNode * _speed_e;
+ SGPropertyNode * _speed_d;
};
#endif // __ACMODEL_HXX