# include <config.h>
#endif
+#include <string.h>
+
#include <simgear/compiler.h>
#include <string>
_refID( _newAIModelID() ),
_otype(ot),
_initialized(false),
+ _aimodel(0),
+ _fxpath(""),
_fx(0)
{
if (parent)
model_removed->setStringValue(props->getPath());
}
- delete _fx;
- _fx = 0;
delete fp;
fp = 0;
+
+// delete _fx;
+// _fx = 0;
}
/** Cleanly remove the model
velocity = SGVec3d( speed_north_deg_sec, speed_east_deg_sec, pitch*speed );
_fx->set_velocity( velocity );
}
+ else if (_aimodel)
+ {
+ string fxpath = _aimodel->get_sound_path();
+ if (fxpath != "")
+ {
+ _fxpath = fxpath;
+ props->setStringValue("sim/sound/path", _fxpath.c_str());
+
+ // initialize the sound configuration
+ SGSoundMgr *smgr = globals->get_soundmgr();
+ _fx = new FGFX(smgr, "aifx:"+_name+"-"+_callsign, props);
+ _fx->init();
+ }
+ }
}
/** update LOD properties of the model */
else
_installed = true;
- osg::Node * mdl = SGModelLib::loadDeferredModel(f, props, new FGNasalModelData(props));
+ _aimodel = new FGAIModelData(props);
+ osg::Node * mdl = SGModelLib::loadDeferredModel(f, props, _aimodel);
if (_model.valid())
{
// Get the sound-path tag from the configuration file and store it
// in the property tree.
- string fxpath = props->getStringValue("sim/sound/path");
- if ( !fxpath.empty() )
- {
- props->setStringValue("sim/sound/path", fxpath.c_str());
-
- // initialize the sound configuration
- SGSoundMgr *smgr = globals->get_soundmgr();
- _fx = new FGFX(smgr, "aifx:"+f, props);
- _fx->init();
- }
-
_initialized = true;
} else if (!model_path.empty()) {
return id;
}
+
+void FGAIModelData::modelLoaded(const string& path, SGPropertyNode *prop, osg::Node *n)
+{
+ const char* fxpath = prop->getStringValue("sound/path");
+ if (fxpath) {
+ string sound_path = string(fxpath);
+ if (sound_path != "") {
+ _path = "/AI/"+sound_path;
+ }
+ }
+ _nasal->modelLoaded(path, prop, n);
+}
#include <simgear/math/sg_geodesy.hxx>
+#include <Scripting/NasalSys.hxx>
#include <Main/fg_props.hxx>
class FGAIManager;
class FGAIFlightPlan;
class FGFX;
+class FGAIModelData; // define dblow
+
class FGAIBase : public SGReferenced {
object_type _otype;
bool _initialized;
osg::ref_ptr<osg::LOD> _model; //The 3D model LOD object
+
+ FGAIModelData* _aimodel;
+
+ string _fxpath;
SGSharedPtr<FGFX> _fx;
public:
_max_speed = m;
}
+
+class FGAIModelData : public simgear::SGModelData {
+public:
+ FGAIModelData(SGPropertyNode *root = 0)
+ : _nasal( new FGNasalModelData(root) ),
+ _path("") {};
+ ~FGAIModelData() {
+ delete _nasal;
+ };
+ void modelLoaded(const string& path, SGPropertyNode *prop, osg::Node *n);
+ inline string& get_sound_path() { return _path; };
+
+private:
+ FGNasalModelData *_nasal;
+ string _path;
+};
+
#endif // _FG_AIBASE_HXX