]> git.mxchange.org Git - flightgear.git/blobdiff - src/AIModel/AIBase.cxx
ignore resets for now because every z/Z key press would trigger a call to NOAA. We...
[flightgear.git] / src / AIModel / AIBase.cxx
index baa5cc52f6c5f6298ac7f1b41ead2aafab699d87..0ee8c8d9528d2df793cdb3a7c2d53fd7763dfa96 100644 (file)
@@ -46,6 +46,7 @@ FGAIBase *FGAIBase::_self = NULL;
 
 FGAIBase::FGAIBase() {
     _self = this;
+    _type_str = "model";
 }
 
 FGAIBase::~FGAIBase() {
@@ -65,12 +66,12 @@ void FGAIBase::Transform() {
 
 bool FGAIBase::init() {
 
-   SGPropertyNode *root = globals->get_props()->getNode("ai/modeles", true);
-   vector<SGPropertyNode_ptr> p_vec = root->getChildren("model");
+   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("model", num, true);
+   props = root->getNode(_type_str, num, true);
    ssgBranch *model = sgLoad3DModel( globals->get_fg_root(),
                                     model_path.c_str(),
                                      props,
@@ -85,13 +86,19 @@ bool FGAIBase::init() {
 
    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));
@@ -99,9 +106,14 @@ void FGAIBase::bind() {
                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() {
@@ -115,17 +127,7 @@ 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(); }