FGAIBase::FGAIBase() {
_self = this;
+ _type_str = "model";
}
FGAIBase::~FGAIBase() {
bool FGAIBase::init() {
- props = globals->get_props()->getNode("ai/model", true);
+ SGPropertyNode *root = globals->get_props()->getNode("ai/models", true);
+ vector<SGPropertyNode_ptr> p_vec = root->getChildren(_type_str);
+ unsigned num = p_vec.size();
+ p_vec.clear();
+ props = root->getNode(_type_str, num, true);
ssgBranch *model = sgLoad3DModel( globals->get_fg_root(),
model_path.c_str(),
props,
tgt_roll = tgt_pitch = tgt_yaw = tgt_vs = vs = roll = pitch = 0.0;
setDie(false);
+
+ return true;
}
void FGAIBase::bind() {
props->tie("velocities/airspeed-kt", SGRawValuePointer<double>(&speed));
- props->tie("velocities/vertical-speed-fps", SGRawValuePointer<double>(&vs));
+ props->tie("velocities/vertical-speed-fps",
+ SGRawValueFunctions<double>(FGAIBase::_getVS_fps,
+ FGAIBase::_setVS_fps));
- props->tie("position/altitude-ft", SGRawValuePointer<double>(&altitude));
+ props->tie("position/altitude-ft",
+ SGRawValueFunctions<double>(FGAIBase::_getAltitude,
+ FGAIBase::_setAltitude));
props->tie("position/latitude-deg",
SGRawValueFunctions<double>(FGAIBase::_getLatitude,
FGAIBase::_setLatitude));
SGRawValueFunctions<double>(FGAIBase::_getLongitude,
FGAIBase::_setLongitude));
- props->tie("orientation/pitch-deg", SGRawValuePointer<double>(&pitch));
- props->tie("orientation/roll-deg", SGRawValuePointer<double>(&roll));
+ props->tie("orientation/pitch-deg", SGRawValuePointer<double>(&pitch));
+ props->tie("orientation/roll-deg", SGRawValuePointer<double>(&roll));
props->tie("orientation/heading-deg", SGRawValuePointer<double>(&hdg));
+
+ props->tie("controls/lighting/nav-lights",
+ SGRawValueFunctions<bool>(FGAIBase::_isNight));
+ props->setBoolValue("controls/lighting/beacon", true);
+ props->setBoolValue("controls/lighting/strobe", true);
}
void FGAIBase::unbind() {
props->untie("orientation/pitch-deg");
props->untie("orientation/roll-deg");
props->untie("orientation/heading-deg");
-}
-
-void FGAIBase::_setLongitude( double longitude ) {
- _self->pos.setlon(longitude);
+ props->untie("controls/controls/lighting/nav-lights");
}
-void FGAIBase::_setLatitude ( double latitude ) {
- _self->pos.setlat(latitude);
-}
-
-double FGAIBase::_getLongitude() { return _self->pos.lon(); }
-
-double FGAIBase::_getLatitude () { return _self->pos.lat(); }