SGVec3d cartoffsetPos = getCartOffsetPos();
SGGeodesy::SGCartToGeod(cartoffsetPos, offsetpos);
- }// end for loop
+
+ //cout << "OFFSET POS" << offsetpos.getElevationFt();
+
+}
+
+void FGSubmodelMgr::valueChanged(SGPropertyNode *prop)
+{
+// cout << "LISTENER: " << endl;
+
+ const char* _model_added = _model_added_node->getStringValue();
+
+ basic_string <char>::size_type indexCh2b;
+
+ string str2 = _model_added;
+ const char *cstr2b = "ballistic";
+ indexCh2b = str2.find( cstr2b, 0 );
+
+// cout << "model added - " << str2 <<" now do something "<< endl;
+
+ if (indexCh2b != string::npos ){ // we will ignore Ballistic Objects - there are potentially too many
+ return;
+ } else {
+
+ SGPropertyNode *a_node = fgGetNode(_model_added, true );
+ SGPropertyNode *sub_node = a_node->getChild("submodels", 0, true);
+ SGPropertyNode_ptr path_node = sub_node->getChild("path", 0, true);
+
+ string path = path_node->getStringValue();
+
+ if (path.empty()){
+ // nothing to do - return
+ //cout << "subpath empty - return" << endl << endl;
+ return;
+ } else {
+ //cout << "subpath found - loading" << endl << endl;
+ SGPropertyNode_ptr ident_node = a_node->getChild("id", 0, true);
+ int id = ident_node->getIntValue();
+
+ setData(id, path, true);
+
+ _found_sub = true;
+
+ while (_found_sub)
+ loadSubmodels();
+
+ }
+
+ }
+
+}
+
+void FGSubmodelMgr::setParentNode(int id) {
+
+ 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");
+ int parent_id = model->getIntValue("id");
+ if (!model->nChildren()){
+ continue;
+ }
+ if (parent_id == id) {
+ _selected_ac = model; // save selected model for last iteration
+ break;
+ }
+
+ }
+ if (!model)
+ continue;
+
++ }// end for loop
+
+ if (_selected_ac != 0){
+
+ //cout << " parent node found"<< endl;
+
+ const string name = _selected_ac->getStringValue("name");
+ IC.lat = _selected_ac->getDoubleValue("position/latitude-deg");
+ IC.lon = _selected_ac->getDoubleValue("position/longitude-deg");
+ IC.alt = _selected_ac->getDoubleValue("position/altitude-ft");
+ IC.roll = _selected_ac->getDoubleValue("orientation/roll-deg");
+ IC.elevation = _selected_ac->getDoubleValue("orientation/pitch-deg");
+ IC.azimuth = _selected_ac->getDoubleValue("orientation/true-heading-deg");
+ IC.speed = _selected_ac->getDoubleValue("velocities/true-airspeed-kt") * SG_KT_TO_FPS;
+ IC.speed_down_fps = -_selected_ac->getDoubleValue("velocities/vertical-speed-fps");
+ IC.speed_east_fps = _selected_ac->getDoubleValue("velocities/speed-east-fps");
+ IC.speed_north_fps = _selected_ac->getDoubleValue("velocities/speed-north-fps");
+
+ //cout << name << " IC.speed " << IC.speed << endl;
+
+ } else {
+ SG_LOG(SG_GENERAL, SG_ALERT, "AISubmodel: parent node not found ");
+ }
+
}
// end of submodel.cxx