X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FAIModel%2Fsubmodel.cxx;h=a7c79f4a46028292ff8ba08fef7329ab8156a454;hb=301054204e0412eb31f06477e32cfe6f1fcb0792;hp=9d9c1e94cb5c8ba604cc61e5244bc2e88886433b;hpb=7d94177636c6719d667c5cbf09f7ffd08f28c1d5;p=flightgear.git diff --git a/src/AIModel/submodel.cxx b/src/AIModel/submodel.cxx index 9d9c1e94c..a7c79f4a4 100644 --- a/src/AIModel/submodel.cxx +++ b/src/AIModel/submodel.cxx @@ -13,6 +13,7 @@ #include #include #include +#include #include
#include
@@ -33,7 +34,6 @@ FGSubmodelMgr::FGSubmodelMgr() yaw_offset = 0.0; out[0] = out[1] = out[2] = 0; - in[3] = out[3] = 1; string contents_node; contrail_altitude = 30000; _count = 0; @@ -185,11 +185,11 @@ void FGSubmodelMgr::update(double dt) sm_list_iterator end = sm_list.end(); while (sm_list_itr != end) { + in_range = true; if (id == 0) { SG_LOG(SG_GENERAL, SG_DEBUG, "Submodels: continuing: " << id << " name " << name ); - in_range = true; ++sm_list_itr; continue; } @@ -199,15 +199,16 @@ void FGSubmodelMgr::update(double dt) if (parent_id == id) { double parent_lat = (*sm_list_itr)->_getLatitude(); double parent_lon = (*sm_list_itr)->_getLongitude(); + string parent_name = (*sm_list_itr)->_getName(); double own_lat = _user_lat_node->getDoubleValue(); double own_lon = _user_lon_node->getDoubleValue(); double range_nm = getRange(parent_lat, parent_lon, own_lat, own_lon); - // cout << "parent " << parent_id << ", "<< parent_lat << ", " << parent_lon << endl; - //cout << "own " << own_lat << ", " << own_lon << " range " << range_nm << endl; + //cout << "parent name " << parent_name << ", "<< parent_id << ", "<< parent_lat << ", " << parent_lon << endl; + //cout << "own name " << own_lat << ", " << own_lon << " range " << range_nm << endl; if (range_nm > 15) { SG_LOG(SG_GENERAL, SG_DEBUG, - "Submodels: skipping release: " << id); + "Submodels: skipping release, out of range: " << id); in_range = false; } } @@ -285,6 +286,8 @@ bool FGSubmodelMgr::release(submodel *sm, double dt) ballist->setFuseRange(sm->fuse_range); ballist->setSubmodel(sm->submodel.c_str()); ballist->setSubID(sm->sub_id); + ballist->setExternalForce(sm->ext_force); + ballist->setForcePath(sm->force_path.c_str()); ai->attach(ballist); if (sm->count > 0) @@ -310,14 +313,18 @@ void FGSubmodelMgr::transform(submodel *sm) // set initial conditions if (sm->contents_node != 0) { // get the weight of the contents (lbs) and convert to mass (slugs) - sm->contents = sm->contents_node->getDoubleValue(); + sm->contents = sm->contents_node->getChild("level-lbs",0,1)->getDoubleValue(); + //cout << "transform: contents " << sm->contents << endl; IC.mass = (sm->weight + sm->contents) * lbs_to_slugs; + //cout << "mass inc contents" << IC.mass << endl; // set contents to 0 in the parent - sm->contents_node->setDoubleValue(0); - } else { + sm->contents_node->getChild("level-gal_us",0,1)->setDoubleValue(0); + /*cout << "contents " << sm->contents_node->getChild("level-gal_us")->getDoubleValue() + << " " << sm->contents_node->getChild("level-lbs",0,1)->getDoubleValue() + << endl;*/ + } else IC.mass = sm->weight * lbs_to_slugs; - } // cout << "mass " << IC.mass << endl; @@ -552,7 +559,7 @@ void FGSubmodelMgr::setData(int id, string& path, bool serviceable) SG_LOG(SG_GENERAL, SG_DEBUG, "Submodels: Trying to read AI submodels file: " << config.str()); readProperties(config.str(), &root); - } catch (const sg_exception &e) { + } catch (const sg_exception &) { SG_LOG(SG_GENERAL, SG_DEBUG, "Submodels: Unable to read AI submodels file: " << config.str()); return; @@ -593,7 +600,8 @@ void FGSubmodelMgr::setData(int id, string& path, bool serviceable) sm->contents_node = fgGetNode(entry_node->getStringValue("contents", "none"), false); sm->speed_node = fgGetNode(entry_node->getStringValue("speed-node", "none"), false); sm->submodel = entry_node->getStringValue("submodel-path", ""); - + sm->ext_force = entry_node->getBoolValue("external-force", false); + sm->force_path = entry_node->getStringValue("force-path", ""); //cout << "sm->contents_node " << sm->contents_node << endl; if (sm->contents_node != 0) sm->contents = sm->contents_node->getDoubleValue(); @@ -607,6 +615,7 @@ void FGSubmodelMgr::setData(int id, string& path, bool serviceable) } SG_LOG(SG_GENERAL, SG_DEBUG, "Submodels: trigger " << sm->trigger_node->getBoolValue() ); + if (sm->speed_node != 0) sm->speed = sm->speed_node->getDoubleValue(); @@ -630,6 +639,10 @@ void FGSubmodelMgr::setData(int id, string& path, bool serviceable) sm->prop->setStringValue("submodel", submodel.c_str()); //cout << " set submodel path " << submodel << endl; + string force_path = sm->force_path; + sm->prop->setStringValue("force_path", force_path.c_str()); + //cout << "set force_path " << force_path << endl; + if (sm->contents_node != 0) sm->prop->tie("contents-lbs", SGRawValuePointer(&(sm->contents))); @@ -651,7 +664,7 @@ void FGSubmodelMgr::setSubData(int id, string& path, bool serviceable) "Submodels: Trying to read AI submodels file: " << config.str()); readProperties(config.str(), &root); - } catch (const sg_exception &e) { + } catch (const sg_exception &) { SG_LOG(SG_GENERAL, SG_DEBUG, "Submodels: Unable to read AI submodels file: " << config.str()); return; @@ -692,6 +705,8 @@ void FGSubmodelMgr::setSubData(int id, string& path, bool serviceable) sm->contents_node = fgGetNode(entry_node->getStringValue("contents", "none"), false); sm->speed_node = fgGetNode(entry_node->getStringValue("speed-node", "none"), false); sm->submodel = entry_node->getStringValue("submodel-path", ""); + sm->ext_force = entry_node->getBoolValue("external-force", false); + sm->force_path = entry_node->getStringValue("force-path", ""); //cout << "sm->contents_node " << sm->contents_node << endl; if (sm->contents_node != 0) @@ -727,6 +742,10 @@ void FGSubmodelMgr::setSubData(int id, string& path, bool serviceable) sm->prop->setStringValue("submodel", submodel.c_str()); // cout << " set submodel path " << submodel<< endl; + string force_path = sm->force_path; + sm->prop->setStringValue("force_path", force_path.c_str()); + //cout << "set force_path " << force_path << endl; + if (sm->contents_node != 0) sm->prop->tie("contents-lbs", SGRawValuePointer(&(sm->contents))); @@ -769,7 +788,7 @@ void FGSubmodelMgr::loadSubmodels() while (submodel_iterator != submodels.end()) { int id = (*submodel_iterator)->id; - SG_LOG(SG_GENERAL, SG_DEBUG,"after pusback " + SG_LOG(SG_GENERAL, SG_DEBUG,"after pushback " << " id " << id << " name " << (*submodel_iterator)->name << " sub id " << (*submodel_iterator)->sub_id);