+
+ if ( _fx )
+ {
+ // update model's audio sample values
+ _fx->set_position_geod( pos );
+
+ SGQuatd orient = SGQuatd::fromYawPitchRollDeg(hdg, pitch, roll);
+ _fx->set_orientation( orient );
+
+ SGVec3d velocity;
+ velocity = SGVec3d( speed_north_deg_sec, speed_east_deg_sec,
+ pitch*speed );
+ _fx->set_velocity( velocity );
+ }
+ else if ((_modeldata)&&(_modeldata->needInitilization()))
+ {
+ // process deferred nasal initialization,
+ // which must be done in main thread
+ _modeldata->init();
+
+ // sound initialization
+ if (fgGetBool("/sim/sound/aimodels/enabled",false))
+ {
+ string fxpath = _modeldata->get_sound_path();
+ if (fxpath != "")
+ {
+ props->setStringValue("sim/sound/path", fxpath.c_str());
+
+ // initialize the sound configuration
+ SGSoundMgr *smgr = globals->get_soundmgr();
+ stringstream name;
+ name << "aifx:";
+ name << _refID;
+ _fx = new FGFX(smgr, name.str(), props);
+ _fx->init();
+ }
+ }
+ }
+}
+
+/** update LOD properties of the model */
+void FGAIBase::updateLOD()
+{
+ double maxRangeDetail = fgGetDouble("/sim/rendering/static-lod/ai-detailed", 10000.0);
+ double maxRangeBare = fgGetDouble("/sim/rendering/static-lod/ai-bare", 20000.0);
+ if (_model.valid())
+ {
+ if( maxRangeDetail == 0.0 )
+ {
+ // disable LOD
+ _model->setRange(0, 0.0, FLT_MAX);
+ _model->setRange(1, FLT_MAX, FLT_MAX);
+ }
+ else
+ {
+ _model->setRange(0, 0.0, maxRangeDetail);
+ _model->setRange(1, maxRangeDetail,maxRangeBare);
+ }
+ }