From: ehofman Date: Wed, 28 Oct 2009 14:29:38 +0000 (+0000) Subject: initlialize _playing for FGATC. Proper listerner orientation based on view offset... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=c56c520ab5baa9e5cb1c651bc0ac887aab1637f0;p=flightgear.git initlialize _playing for FGATC. Proper listerner orientation based on view offset. proper velocity orientation --- diff --git a/src/ATCDCL/ATC.cxx b/src/ATCDCL/ATC.cxx index 7e17f1da7..b4a17ae97 100644 --- a/src/ATCDCL/ATC.cxx +++ b/src/ATCDCL/ATC.cxx @@ -36,6 +36,7 @@ FGATC::FGATC() : _voiceOK(false), + _playing(false), _sgr(NULL), freqClear(true), receiving(false), diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 4ab21a885..66bf3c6d8 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -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 } diff --git a/src/Main/viewer.cxx b/src/Main/viewer.cxx index 2e34db687..8dcfb982d 100644 --- a/src/Main/viewer.cxx +++ b/src/Main/viewer.cxx @@ -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); diff --git a/src/Main/viewer.hxx b/src/Main/viewer.hxx index 965e8569a..aa5fb1212 100644 --- a/src/Main/viewer.hxx +++ b/src/Main/viewer.hxx @@ -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; diff --git a/src/Main/viewmgr.cxx b/src/Main/viewmgr.cxx index 6074dcf95..cc254991b 100644 --- a/src/Main/viewmgr.cxx +++ b/src/Main/viewmgr.cxx @@ -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); diff --git a/src/Model/acmodel.cxx b/src/Model/acmodel.cxx index 65104a990..1a93a49ab 100644 --- a/src/Model/acmodel.cxx +++ b/src/Model/acmodel.cxx @@ -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 ); }