_subID = s;
}
-void FGAIBase::setParentNode() {
-// cout << "AIBase: setParentNode " << _parent << endl;
+bool FGAIBase::setParentNode() {
+
+ if (_parent == ""){
+ SG_LOG(SG_GENERAL, SG_ALERT, "AIBase: " << _name
+ << " parent not set ");
+ return false;
+ }
const SGPropertyNode_ptr ai = fgGetNode("/ai/models", true);
if (_selected_ac != 0){
const string name = _selected_ac->getStringValue("name");
- //setParent();
-
+ return true;
} else {
- SG_LOG(SG_GENERAL, SG_ALERT, "AIEscort: " << _name
+ SG_LOG(SG_GENERAL, SG_ALERT, "AIBase: " << _name
<< " parent not found: dying ");
setDie(true);
+ return false;
}
}
+
double FGAIBase::_getLongitude() const {
return pos.getLongitudeDeg();
}
_pitch(0),
_pitch_deg(0),
_speed_kt(0),
-_selected_ac(0),
_range_ft(0),
_relbrg (0),
_parent_speed(0),
{
invisible = false;
+ _parent = "";
}
FGAIGroundVehicle::~FGAIGroundVehicle() {}
no_roll = true;
props->setStringValue("controls/parent-name", _parent.c_str());
- setParentNode();
+
+ if (setParentNode()){
+ _parent_x_offset = _selected_ac->getDoubleValue("hitch/x-offset-ft");
+ _parent_y_offset = _selected_ac->getDoubleValue("hitch/y-offset-ft");
+ _parent_z_offset = _selected_ac->getDoubleValue("hitch/z-offset-ft");
+ _hitch_x_offset_m = _selected_ac->getDoubleValue("hitch/x-offset-ft")
+ * SG_FEET_TO_METER;
+ _hitch_y_offset_m = _selected_ac->getDoubleValue("hitch/y-offset-ft")
+ * SG_FEET_TO_METER;
+ _hitch_z_offset_m = _selected_ac->getDoubleValue("hitch/z-offset-ft")
+ * SG_FEET_TO_METER;
+ setParent();
+ }
return true;
}
return true;
}
-void FGAIGroundVehicle::setParentNode() {
-
- if(_parent == "")
- return;
-
- const SGPropertyNode_ptr ai = fgGetNode("/ai/models", true);
-
- for (int i = ai->nChildren() - 1; i >= -1; i--) {
- SGPropertyNode_ptr model;
-
- if (i < 0) { // last iteration: selected model
- model = _selected_ac;
- } else {
- model = ai->getChild(i);
- string path = ai->getPath();
- const string name = model->getStringValue("name");
-
- if (!model->nChildren()){
- continue;
- }
- if (name == _parent) {
- _selected_ac = model; // save selected model for last iteration
- break;
- }
-
- }
- if (!model)
- continue;
-
- }// end for loop
-
- if (_selected_ac != 0){
- const string name = _selected_ac->getStringValue("name");
- _parent_x_offset = _selected_ac->getDoubleValue("hitch/x-offset-ft");
- _parent_y_offset = _selected_ac->getDoubleValue("hitch/y-offset-ft");
- _parent_z_offset = _selected_ac->getDoubleValue("hitch/z-offset-ft");
- _hitch_x_offset_m = _selected_ac->getDoubleValue("hitch/x-offset-ft")
- * SG_FEET_TO_METER;
- _hitch_y_offset_m = _selected_ac->getDoubleValue("hitch/y-offset-ft")
- * SG_FEET_TO_METER;
- _hitch_z_offset_m = _selected_ac->getDoubleValue("hitch/z-offset-ft")
- * SG_FEET_TO_METER;
- setParent();
- } else {
- SG_LOG(SG_GENERAL, SG_ALERT, "AIGroundVeh1cle: " << _name
- << " parent not found: dying ");
- setDie(true);
- }
-
-}
+//void FGAIGroundVehicle::setParentNode() {
+//
+// if(_parent == "")
+// return;
+//
+// const SGPropertyNode_ptr ai = fgGetNode("/ai/models", true);
+//
+// for (int i = ai->nChildren() - 1; i >= -1; i--) {
+// SGPropertyNode_ptr model;
+//
+// if (i < 0) { // last iteration: selected model
+// model = _selected_ac;
+// } else {
+// model = ai->getChild(i);
+// string path = ai->getPath();
+// const string name = model->getStringValue("name");
+//
+// if (!model->nChildren()){
+// continue;
+// }
+// if (name == _parent) {
+// _selected_ac = model; // save selected model for last iteration
+// break;
+// }
+//
+// }
+// if (!model)
+// continue;
+//
+// }// end for loop
+//
+// if (_selected_ac != 0){
+// const string name = _selected_ac->getStringValue("name");
+// //_parent_x_offset = _selected_ac->getDoubleValue("hitch/x-offset-ft");
+// //_parent_y_offset = _selected_ac->getDoubleValue("hitch/y-offset-ft");
+// //_parent_z_offset = _selected_ac->getDoubleValue("hitch/z-offset-ft");
+// //_hitch_x_offset_m = _selected_ac->getDoubleValue("hitch/x-offset-ft")
+// // * SG_FEET_TO_METER;
+// //_hitch_y_offset_m = _selected_ac->getDoubleValue("hitch/y-offset-ft")
+// // * SG_FEET_TO_METER;
+// //_hitch_z_offset_m = _selected_ac->getDoubleValue("hitch/z-offset-ft")
+// // * SG_FEET_TO_METER;
+// //setParent();
+// } else {
+// SG_LOG(SG_GENERAL, SG_ALERT, "AIGroundVeh1cle: " << _name
+// << " parent not found: dying ");
+// setDie(true);
+// }
+//
+//}
void FGAIGroundVehicle::setParent(){
void setElevation(double _elevation, double dt, double _elevation_coeff);
void setPitch(double _pitch, double dt, double _pitch_coeff);
void setTowAngle(double _relbrg, double dt, double _towangle_coeff);
-// void setParentName(const string& p);
void setTrainSpeed(double s, double dt, double coeff);
void setParent();
- void setParentNode();
void AdvanceFP();
void setTowSpeed();
void RunGroundVehicle(double dt);
double _dt_count, _next_run, _break_count;
const SGMaterial* _material;
- SGPropertyNode_ptr _selected_ac;
-
-// string _parent;
};