+ //cout << "release id " << sm->id
+ // << " name " << sm->name
+ // << " first time " << sm->first_time
+ // << " repeat " << sm->repeat
+ // << " slaved " << sm->slaved
+ // << endl;
+
+ // only run if first time or repeat is set to true
+ if (!sm->first_time && !sm->repeat) {
+ //cout<< "returning: "<< sm->name
+ // << " not first time " << sm->first_time
+ // << " repeat " << sm->repeat
+ // << " slaved " << sm->slaved
+ // << endl;
+ return false;
+ }
+
+ sm->timer += dt;
+
+ if (sm->timer < sm->delay) {
+ //cout << "not yet: timer " << sm->timer << " delay " << sm->delay << endl;
+ return false;
+ }
+
+ //cout << "released timer: " << sm->timer << " delay " << sm->delay << endl;
+
+ sm->timer = 0.0;
+
+ if (sm->first_time) {
+ dt = 0.0;
+ sm->first_time = false;
+ }
+
+ transform(sm); // calculate submodel's initial conditions in world-coordinates
+
+ FGAIBallistic* ballist = new FGAIBallistic;
+ ballist->setPath(sm->model.c_str());
+ ballist->setName(sm->name);
+ ballist->setSlaved(sm->slaved);
+ ballist->setRandom(sm->random);
+ ballist->setRandomness(sm->randomness);
+ ballist->setLatitude(offsetpos.getLatitudeDeg());
+ ballist->setLongitude(offsetpos.getLongitudeDeg());
+ ballist->setAltitude(offsetpos.getElevationFt());
+ ballist->setAzimuth(IC.azimuth);
+ ballist->setElevation(IC.elevation);
+ ballist->setRoll(IC.roll);
+ ballist->setSpeed(IC.speed / SG_KT_TO_FPS);
+ ballist->setWind_from_east(IC.wind_from_east);
+ ballist->setWind_from_north(IC.wind_from_north);
+ ballist->setMass(IC.mass);
+ ballist->setDragArea(sm->drag_area);
+ ballist->setLife(sm->life);
+ ballist->setBuoyancy(sm->buoyancy);
+ ballist->setWind(sm->wind);
+ ballist->setCd(sm->cd);
+ ballist->setStabilisation(sm->aero_stabilised);
+ ballist->setNoRoll(sm->no_roll);
+ ballist->setCollision(sm->collision);
+ ballist->setExpiry(sm->expiry);
+ ballist->setImpact(sm->impact);
+ ballist->setImpactReportNode(sm->impact_report);
+ ballist->setFuseRange(sm->fuse_range);
+ ballist->setSubmodel(sm->submodel.c_str());
+ ballist->setSubID(sm->sub_id);
+ ballist->setForceStabilisation(sm->force_stabilised);
+ ballist->setExternalForce(sm->ext_force);
+ ballist->setForcePath(sm->force_path.c_str());
+ ballist->setXoffset(sm->x_offset);
+ ballist->setYoffset(sm->y_offset);
+ ballist->setZoffset(sm->z_offset);
+ ballist->setPitchoffset(sm->pitch_offset);
+ ballist->setYawoffset(sm->yaw_offset);
+ ballist->setParentNodes(_selected_ac);
+ ballist->setContentsNode(sm->contents_node);
+ ballist->setWeight(sm->weight);
+
+ aiManager()->attach(ballist);
+
+ if (sm->count > 0)
+ sm->count--;
+ return true;
+}
+
+void FGSubmodelMgr::load()
+{
+ SGPropertyNode *path = fgGetNode("/sim/submodels/path");
+
+ if (path) {
+ const int id = 0;
+ string Path = path->getStringValue();
+ bool Seviceable =_serviceable_node->getBoolValue();
+ setData(id, Path, Seviceable);
+ }
+}
+
+void FGSubmodelMgr::transform(submodel *sm)
+{
+ // set initial conditions
+ if (sm->contents_node != 0 && !sm->slaved) {
+ // get the weight of the contents (lbs) and convert to mass (slugs)
+ 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->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;
+
+ int id = sm->id;
+ //int sub_id = sm->sub_id;
+ string name = sm->name;
+
+
+ if (sm->speed_node != 0)
+ sm->speed = sm->speed_node->getDoubleValue();
+
+
+ //cout << " name " << name << " id " << id << " sub id" << sub_id << endl;
+
+ // set the Initial Conditions for the types of submodel parent
+
+ if (_impact || _hit || _expiry) {
+ // set the data for a submodel tied to a submodel
+
+ _count++;
+
+ IC.lat = _parent_lat;
+ IC.lon = _parent_lon;
+ IC.alt = _parent_elev;
+ IC.roll = _parent_roll; // rotation about x axis
+ IC.elevation = _parent_pitch; // rotation about y axis
+ IC.azimuth = _parent_hdg; // rotation about z axis
+ IC.speed = _parent_speed;
+ IC.speed_down_fps = 0;
+ IC.speed_east_fps = 0;
+ IC.speed_north_fps = 0;
+
+ } else if (id == 0) {
+ //set the data for a submodel tied to the main model
+
+ IC.lat = _user_lat_node->getDoubleValue();
+ IC.lon = _user_lon_node->getDoubleValue();
+ IC.alt = _user_alt_node->getDoubleValue();
+ IC.roll = _user_roll_node->getDoubleValue(); // rotation about x axis
+ IC.elevation = _user_pitch_node->getDoubleValue(); // rotation about y axis
+ IC.azimuth = _user_heading_node->getDoubleValue(); // rotation about z axis
+ IC.speed = _user_speed_node->getDoubleValue();
+ IC.speed_down_fps = _user_speed_down_fps_node->getDoubleValue();
+ IC.speed_east_fps = _user_speed_east_fps_node->getDoubleValue();
+ IC.speed_north_fps = _user_speed_north_fps_node->getDoubleValue();
+