1
0
Fork 0

Position and orientation fixes for the sound code, thanks to Tim Moore

This commit is contained in:
ehofman 2009-11-02 10:31:42 +00:00 committed by Tim Moore
parent 7efed53475
commit 6e5673de21
2 changed files with 5 additions and 12 deletions

View file

@ -298,14 +298,8 @@ FGViewMgr::update (double dt)
// update audio listener values // update audio listener values
// set the viewer posotion in Cartesian coordinates in meters // set the viewer posotion in Cartesian coordinates in meters
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() ); smgr->set_position_geod( loop_view->getPosition() );
smgr->set_orientation( loop_view->getViewOrientation() );
smgr->set_orientation( loop_view->getViewOrientation(),
loop_view->getViewOrientationOffset() );
// get the model velocity // get the model velocity
SGVec3f velocity = SGVec3f::zeros(); SGVec3f velocity = SGVec3f::zeros();

View file

@ -124,24 +124,23 @@ FGAircraftModel::update (double dt)
_aircraft->update(); _aircraft->update();
// update model's audio sample values // update model's audio sample values
_fx->set_position_geod( _aircraft->getPosition() ); SGGeod position = _aircraft->getPosition();
_fx->set_position_geod( position );
SGQuatd orient = SGQuatd::fromYawPitchRollDeg(_heading->getDoubleValue(), SGQuatd orient = SGQuatd::fromYawPitchRollDeg(_heading->getDoubleValue(),
_pitch->getDoubleValue(), _pitch->getDoubleValue(),
_roll->getDoubleValue()); _roll->getDoubleValue());
_fx->set_orientation( orient ); _fx->set_orientation( orient );
#if 0
SGVec3d vel = SGVec3d( _speed_n->getFloatValue(), SGVec3d vel = SGVec3d( _speed_n->getFloatValue(),
_speed_e->getFloatValue(), _speed_e->getFloatValue(),
_speed_d->getFloatValue() ); _speed_d->getFloatValue() );
if ( vel[0] || vel[1] || vel[2] ) { if ( vel[0] || vel[1] || vel[2] ) {
SGQuatd q(-0.5, -0.5, 0.5, 0.5); SGQuatd hlOr = SGQuatd::fromLonLat(position);
_velocity = toVec3f( q.backTransform( vel ) ); _velocity = toVec3f( hlOr.backTransform( vel * SG_FEET_TO_METER ) );
} }
else else
_velocity = SGVec3f::zeros(); _velocity = SGVec3f::zeros();
#endif
_fx->set_velocity( _velocity ); _fx->set_velocity( _velocity );
} }