initlialize _playing for FGATC. Proper listerner orientation based on view offset. proper velocity orientation
This commit is contained in:
parent
ad020f5fb5
commit
c56c520ab5
6 changed files with 19 additions and 16 deletions
src
|
@ -36,6 +36,7 @@
|
|||
|
||||
FGATC::FGATC() :
|
||||
_voiceOK(false),
|
||||
_playing(false),
|
||||
_sgr(NULL),
|
||||
freqClear(true),
|
||||
receiving(false),
|
||||
|
|
|
@ -460,8 +460,8 @@ static void fgMainLoop( void ) {
|
|||
// we may want to move this to its own class at some point
|
||||
//
|
||||
double visibility_meters = fgGetDouble("/environment/visibility-m");
|
||||
|
||||
globals->get_tile_mgr()->prep_ssg_nodes( visibility_meters );
|
||||
|
||||
// update tile manager for view...
|
||||
SGVec3d viewPos = globals->get_current_view()->get_view_pos();
|
||||
SGGeod geodViewPos = SGGeod::fromCart(viewPos);
|
||||
|
@ -477,13 +477,10 @@ static void fgMainLoop( void ) {
|
|||
// update the view angle as late as possible, but before sound calculations
|
||||
globals->get_viewmgr()->update(real_delta_time_sec);
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Update the sound manager last so it can use the CPU while the GPU
|
||||
// is processing the scenery (doubled the frame-rate for me) -EMH-
|
||||
////////////////////////////////////////////////////////////////////
|
||||
#ifdef ENABLE_AUDIO_SUPPORT
|
||||
static SGSoundMgr *smgr = globals->get_soundmgr();
|
||||
smgr->update_late(delta_time_sec);
|
||||
globals->get_soundmgr()->update(delta_time_sec);
|
||||
#endif
|
||||
|
||||
// END Tile Manager udpates
|
||||
|
@ -493,11 +490,12 @@ static void fgMainLoop( void ) {
|
|||
fgSetBool("sim/sceneryloaded",true);
|
||||
#ifdef ENABLE_AUDIO_SUPPORT
|
||||
if (fgGetBool("/sim/sound/enabled") == true) {
|
||||
smgr->set_volume(fgGetFloat("/sim/sound/volume"));
|
||||
smgr->activate();
|
||||
float volume = fgGetFloat("/sim/sound/volume");
|
||||
globals->get_soundmgr()->set_volume(volume);
|
||||
globals->get_soundmgr()->activate();
|
||||
}
|
||||
else
|
||||
smgr->stop();
|
||||
globals->get_soundmgr()->stop();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -380,7 +380,7 @@ FGViewer::recalcLookFrom ()
|
|||
SGQuatd hlToBody = SGQuatd::fromYawPitchRollDeg(head, pitch, roll);
|
||||
|
||||
// The rotation offset, don't know why heading is negative here ...
|
||||
SGQuatd viewOffsetOr
|
||||
mViewOffsetOr
|
||||
= SGQuatd::fromYawPitchRollDeg(-_heading_offset_deg, _pitch_offset_deg,
|
||||
_roll_offset_deg);
|
||||
|
||||
|
@ -396,7 +396,7 @@ FGViewer::recalcLookFrom ()
|
|||
SGQuatd q(-0.5, -0.5, 0.5, 0.5);
|
||||
|
||||
_absolute_view_pos = position + (ec2body*q).backTransform(_offset_m);
|
||||
mViewOrientation = ec2body*viewOffsetOr*q;
|
||||
mViewOrientation = ec2body*mViewOffsetOr*q;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -437,7 +437,7 @@ FGViewer::recalcLookAt ()
|
|||
SGQuatd geodEyeHlOr = SGQuatd::fromLonLat(_position);
|
||||
|
||||
// the rotation offset, don't know why heading is negative here ...
|
||||
SGQuatd eyeOffsetOr =
|
||||
mViewOffsetOr =
|
||||
SGQuatd::fromYawPitchRollDeg(-_heading_offset_deg + 180, _pitch_offset_deg,
|
||||
_roll_offset_deg);
|
||||
|
||||
|
@ -445,7 +445,7 @@ FGViewer::recalcLookAt ()
|
|||
SGVec3d eyeOff(-_offset_m.z(), _offset_m.x(), -_offset_m.y());
|
||||
SGQuatd ec2eye = geodEyeHlOr*geodEyeOr;
|
||||
SGVec3d eyeCart = SGVec3d::fromGeod(_position);
|
||||
eyeCart += (ec2eye*eyeOffsetOr).backTransform(eyeOff);
|
||||
eyeCart += (ec2eye*mViewOffsetOr).backTransform(eyeOff);
|
||||
|
||||
SGVec3d atCart = SGVec3d::fromGeod(_target);
|
||||
|
||||
|
|
|
@ -201,6 +201,7 @@ public:
|
|||
const SGVec3d& get_view_pos() { if ( _dirty ) { recalc(); } return _absolute_view_pos; }
|
||||
const SGVec3d& getViewPosition() { if ( _dirty ) { recalc(); } return _absolute_view_pos; }
|
||||
const SGQuatd& getViewOrientation() { if ( _dirty ) { recalc(); } return mViewOrientation; }
|
||||
const SGQuatd& getViewOrientationOffset() { if ( _dirty ) { recalc(); } return mViewOffsetOr; }
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Part 4: View and frustrum data setters and getters
|
||||
|
@ -247,6 +248,7 @@ private:
|
|||
bool _dirty;
|
||||
|
||||
SGQuatd mViewOrientation;
|
||||
SGQuatd mViewOffsetOr;
|
||||
SGVec3d _absolute_view_pos;
|
||||
|
||||
SGGeod _position;
|
||||
|
|
|
@ -299,7 +299,8 @@ 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());
|
||||
smgr->set_orientation(loop_view->getViewOrientation(),
|
||||
loop_view->getViewOrientationOffset());
|
||||
|
||||
// get the model velocity for the in-cockpit view
|
||||
SGVec3d velocity = SGVec3d(0,0,0);
|
||||
|
|
|
@ -131,9 +131,10 @@ FGAircraftModel::update (double dt)
|
|||
_roll->getDoubleValue());
|
||||
_fx->set_orientation( orient );
|
||||
|
||||
_velocity = SGVec3d( -_speed_n->getDoubleValue(),
|
||||
_speed_e->getDoubleValue(),
|
||||
_speed_d->getDoubleValue());
|
||||
SGQuatd q(-0.5, -0.5, 0.5, 0.5);
|
||||
_velocity = q.backTransform( SGVec3d( _speed_n->getDoubleValue(),
|
||||
_speed_e->getDoubleValue(),
|
||||
_speed_d->getDoubleValue()) );
|
||||
_fx->set_velocity( _velocity );
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue