#include <Main/fg_props.hxx>
#include <Scenery/scenery.hxx>
-#include "modelmgr.hxx"
#include "model.hxx"
+#include "placement.hxx"
+
+#include "modelmgr.hxx"
FGModelMgr::FGModelMgr ()
SG_LOG(SG_GENERAL, SG_INFO,
"Adding model " << node->getStringValue("name", "[unnamed]"));
Instance * instance = new Instance;
- FGModelPlacement * model = new FGModelPlacement;
+ FGModelPlacement *model = new FGModelPlacement;
instance->model = model;
- model->init(node->getStringValue("path", "Models/Geometry/glider.ac"));
+ ssgBranch *object
+ = fgLoad3DModel( globals->get_fg_root(),
+ node->getStringValue("path",
+ "Models/Geometry/glider.ac"),
+ globals->get_props(),
+ globals->get_sim_time_sec() );
+ model->init( object );
// Set position and orientation either
// indirectly through property refs
if (instance->heading_deg_node != 0)
model->setHeadingDeg(instance->heading_deg_node->getDoubleValue());
- instance->model->update();
+ instance->model->update( globals->get_scenery()->get_center() );
}
}
void
FGModelMgr::remove_instance (Instance * instance)
{
- _instances.erase(find(_instances.begin(), _instances.end(), instance));
- delete instance;
+ vector<Instance *>::iterator it;
+ for (it = _instances.begin(); it != _instances.end(); it++) {
+ if (*it == instance) {
+ _instances.erase(it);
+ delete instance;
+ return;
+ }
+ }
}
void