Correct (and verrified) position, orientation and velocity vector. Todo: proper sound orientation (the all face forward using the airplane orientation now) and disabling doppler effect when tied to the listener
This commit is contained in:
parent
33e816abb9
commit
b582c118bd
5 changed files with 29 additions and 16 deletions
src
|
@ -248,7 +248,6 @@ FGViewMgr::update (double dt)
|
|||
FGViewer *loop_view = (FGViewer *)get_view(current);
|
||||
SGPropertyNode *n = config_list[current];
|
||||
double lon_deg, lat_deg, alt_ft, roll_deg, pitch_deg, heading_deg;
|
||||
SGVec3f velocity = SGVec3f(0,0,0);
|
||||
|
||||
// Set up view location and orientation
|
||||
|
||||
|
@ -265,10 +264,6 @@ FGViewMgr::update (double dt)
|
|||
} else {
|
||||
// force recalc in viewer
|
||||
loop_view->set_dirty();
|
||||
|
||||
// get the model velocity for the in-cockpit view
|
||||
FGAircraftModel *aircraft = globals->get_aircraft_model();
|
||||
velocity = aircraft->getVelocity();
|
||||
}
|
||||
|
||||
// if lookat (type 1) then get target data...
|
||||
|
@ -303,8 +298,15 @@ 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);
|
||||
if ( !stationary() ) {
|
||||
FGAircraftModel *aircraft = globals->get_aircraft_model();
|
||||
velocity = aircraft->getVelocity();
|
||||
}
|
||||
smgr->set_velocity(velocity);
|
||||
}
|
||||
|
||||
|
@ -575,6 +577,20 @@ FGViewMgr::setViewZOffset_m (double z)
|
|||
}
|
||||
}
|
||||
|
||||
bool
|
||||
FGViewMgr::stationary () const
|
||||
{
|
||||
const FGViewer * view = get_current_view();
|
||||
if (view != 0) {
|
||||
if (((FGViewer *)view)->getXOffset_m() == 0.0 &&
|
||||
((FGViewer *)view)->getYOffset_m() == 0.0 &&
|
||||
((FGViewer *)view)->getZOffset_m() == 0.0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
double
|
||||
FGViewMgr::getViewTargetXOffset_m () const
|
||||
{
|
||||
|
|
|
@ -116,6 +116,7 @@ private:
|
|||
void setViewAxisLat (double axis);
|
||||
int getView () const;
|
||||
void setView (int newview);
|
||||
bool stationary () const;
|
||||
|
||||
SGPropertyNode_ptr view_number;
|
||||
vector<SGPropertyNode_ptr> config_list;
|
||||
|
|
|
@ -44,8 +44,7 @@ FGAircraftModel::FGAircraftModel ()
|
|||
_pitch(0),
|
||||
_roll(0),
|
||||
_heading(0),
|
||||
_speed(0),
|
||||
_speed_up(0)
|
||||
_speed(0)
|
||||
{
|
||||
SGSoundMgr *smgr;
|
||||
smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr");
|
||||
|
@ -92,8 +91,7 @@ FGAircraftModel::bind ()
|
|||
_pitch = fgGetNode("orientation/pitch-deg", true);
|
||||
_roll = fgGetNode("orientation/roll-deg", true);
|
||||
_heading = fgGetNode("orientation/heading-deg", true);
|
||||
_speed = fgGetNode("velocities/true-airspeed-kt", true);
|
||||
_speed_up = fgGetNode("velocities/vertical-speed-fps", true);
|
||||
_speed = fgGetNode("velocities/groundspeed-kt", true);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -125,7 +123,7 @@ FGAircraftModel::update (double dt)
|
|||
// update model's audio sample values
|
||||
// Get the Cartesian coordinates in meters
|
||||
SGVec3d pos = SGVec3d::fromGeod(_aircraft->getPosition());
|
||||
_fx->set_position( pos );
|
||||
_fx->set_position( -pos );
|
||||
|
||||
SGQuatd orient_m = SGQuatd::fromLonLat(_aircraft->getPosition());
|
||||
orient_m *= SGQuatd::fromYawPitchRollDeg(_heading->getDoubleValue(),
|
||||
|
@ -137,9 +135,7 @@ FGAircraftModel::update (double dt)
|
|||
// 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_FPS);
|
||||
// _velocity[2] = _speed_up->getFloatValue();
|
||||
_velocity *= SG_FEET_TO_METER;
|
||||
_velocity = toVec3f(orient * _speed->getDoubleValue() * SG_KT_TO_MPS);
|
||||
_fx->set_velocity( _velocity );
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,6 @@ private:
|
|||
SGPropertyNode * _roll;
|
||||
SGPropertyNode * _heading;
|
||||
SGPropertyNode * _speed;
|
||||
SGPropertyNode * _speed_up;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ FGFX::FGFX ( SGSoundMgr *smgr, const string &refname ) :
|
|||
_volume( fgGetNode("/sim/sound/volume") )
|
||||
{
|
||||
SGSampleGroup::_smgr = smgr;
|
||||
SGSampleGroup::_refname = refname;
|
||||
SGSampleGroup::_smgr->add(this, refname);
|
||||
SGSampleGroup::_active = _smgr->is_working();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue