From b22960ffff34f368ad5e6029da2acbaa31fb50e0 Mon Sep 17 00:00:00 2001 From: Vivian Meazza Date: Wed, 8 Sep 2010 18:09:03 +0100 Subject: [PATCH] Associate submodels with parent AI Objects. Signed-off-by: Vivian Meazza --- src/AIModel/submodel.cxx | 44 +++++++++++++--------------------------- 1 file changed, 14 insertions(+), 30 deletions(-) diff --git a/src/AIModel/submodel.cxx b/src/AIModel/submodel.cxx index 8963be719..d1b792563 100644 --- a/src/AIModel/submodel.cxx +++ b/src/AIModel/submodel.cxx @@ -78,9 +78,6 @@ void FGSubmodelMgr::init() load(); - //_model_added_node = fgGetNode("ai/models/model-added", true); - //_model_added_node->addChangeListener(this, false); - } void FGSubmodelMgr::postinit() { @@ -300,7 +297,7 @@ bool FGSubmodelMgr::release(submodel *sm, double dt) ballist->setZoffset(sm->z_offset); ballist->setPitchoffset(sm->pitch_offset); ballist->setYawoffset(sm->yaw_offset); - ballist->setParentNode(_selected_ac); + ballist->setParentNodes(_selected_ac); ballist->setContentsNode(sm->contents_node); ballist->setWeight(sm->weight); ai->attach(ballist); @@ -821,48 +818,35 @@ void FGSubmodelMgr::setOffsetPos(){ void FGSubmodelMgr::valueChanged(SGPropertyNode *prop) { -// cout << "LISTENER: " << endl; + return; // this isn't working atm const char* _model_added = _model_added_node->getStringValue(); basic_string ::size_type indexCh2b; string str2 = _model_added; - const char *cstr2b = "ballistic"; + const char *cstr2b = "multiplayer"; 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); + + //cout << "Submodels: model added - " << str2 <<" read path "<< endl; + //return; + SGPropertyNode *a_node = fgGetNode(_model_added, true); + SGPropertyNode *sub_node = a_node->getChild("sim", 0, true); SGPropertyNode_ptr path_node = sub_node->getChild("path", 0, true); + SGPropertyNode_ptr callsign_node = a_node->getChild("callsign", 0, true); - string path = path_node->getStringValue(); + string callsign = callsign_node->getStringValue(); - if (path.empty()){ - // nothing to do - return - //cout << "subpath empty - return" << endl << endl; + //cout << "Submodels: model added - " << callsign <<" read callsign "<< 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(); + } else { + cout << "model added - " << str2 <<" returning "<< endl; + return; } - } - } void FGSubmodelMgr::setParentNode(int id) { -- 2.39.5