//
// This file is in the Public Domain and comes with no warranty.
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include "submodel.hxx"
#include <simgear/structure/exception.hxx>
#include <Main/fg_props.hxx>
#include <Main/util.hxx>
#include <AIModel/AIManager.hxx>
+#include <AIModel/AIBallistic.hxx>
const double FGSubmodelMgr::lbs_to_slugs = 0.031080950172;
if (!(_serviceable_node->getBoolValue())) return;
int i=-1;
- if (_user_alt_node->getDoubleValue() > contrail_altitude) {
- _contrail_trigger->setBoolValue(true);
- }
+ _contrail_trigger->setBoolValue(_user_alt_node->getDoubleValue() > contrail_altitude);
submodel_iterator = submodels.begin();
while(submodel_iterator != submodels.end()) {
bool
FGSubmodelMgr::release (submodel* sm, double dt)
{
+ // only run if first time or repeat is set to true
+ if (!sm->first_time && !sm->repeat) return false;
+
sm->timer += dt;
if (sm->timer < sm->delay) return false;
sm->timer = 0.0;
transform(sm); // calculate submodel's initial conditions in world-coordinates
- FGAIModelEntity entity;
-
- entity.path = sm->model.c_str();
- entity.latitude = IC.lat;
- entity.longitude = IC.lon;
- entity.altitude = IC.alt;
- entity.azimuth = IC.azimuth;
- entity.elevation = IC.elevation;
- entity.roll = IC.roll;
- entity.speed = IC.speed;
- entity.eda = sm->drag_area;
- entity.life = sm->life;
- entity.buoyancy = sm->buoyancy;
- entity.wind_from_east = IC.wind_from_east;
- entity.wind_from_north = IC.wind_from_north;
- entity.wind = sm->wind;
- entity.cd = sm->cd;
- entity.mass = IC.mass;
- entity.aero_stabilised = sm->aero_stabilised;
- ai->createBallistic( &entity );
+ FGAIBallistic* ballist = new FGAIBallistic;
+ ballist->setPath(sm->model.c_str());
+ ballist->setLatitude(IC.lat);
+ ballist->setLongitude(IC.lon);
+ ballist->setAltitude(IC.alt);
+ ballist->setAzimuth(IC.azimuth);
+ ballist->setElevation(IC.elevation);
+ ballist->setRoll(IC.roll);
+ ballist->setSpeed(IC.speed);
+ ballist->setDragArea(sm->drag_area);
+ ballist->setLife(sm->life);
+ ballist->setBuoyancy(sm->buoyancy);
+ ballist->setWind_from_east(IC.wind_from_east);
+ ballist->setWind_from_north(IC.wind_from_north);
+ ballist->setWind(sm->wind);
+ ballist->setCd(sm->cd);
+ ballist->setMass(IC.mass);
+ ballist->setStabilisation(sm->aero_stabilised);
+ ai->attach(ballist);
if (sm->count > 0) (sm->count)--;
void
FGSubmodelMgr::load ()
{
-
- int i;
SGPropertyNode *path = fgGetNode("/sim/submodels/path");
SGPropertyNode root;
}
}
- int count = root.nChildren();
- for (i = 0; i < count; i++) {
- // cout << "Reading submodel " << i << endl;
- SGPropertyNode *prop;
+ vector<SGPropertyNode_ptr> children = root.getChildren("submodel");
+ vector<SGPropertyNode_ptr>::iterator it = children.begin();
+ vector<SGPropertyNode_ptr>::iterator end = children.end();
+ for (int i = 0; it != end; ++it, i++) {
+
+ // cout << "Reading submodel " << (*it)->getPath() << endl;
submodel* sm = new submodel;
- SGPropertyNode * entry_node = root.getChild(i);
+ SGPropertyNode * entry_node = *it;
sm->trigger = fgGetNode(entry_node->getStringValue("trigger", "none"), true);
sm->name = entry_node->getStringValue("name", "none_defined");
sm->model = entry_node->getStringValue("model", "Models/Geometry/rocket.ac");
sm->prop = fgGetNode("/ai/submodels/submodel", i, true);
sm->prop->tie("count", SGRawValuePointer<int>(&(sm->count)));
+ sm->prop->tie("repeat", SGRawValuePointer<bool>(&(sm->repeat)));
// sm->prop->tie("contents", SGRawValuePointer<double>(&(sm->contents)));
// sm->prop->tie("contents path", SGRawValuePointer<const char *>(&(sm->contents_node)));