X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=src%2FModel%2Fmodelmgr.cxx;h=72d257368421b74b0041f3bd3aeb1ffa985c4bb9;hb=575b3ac98c2aad3fd80375cdfbe49c9180b8788e;hp=3507cc4f6e36839709acc9d87fc1dd246e51173b;hpb=ea981119267ddfe5b6fc3527738e88a80d8b9536;p=flightgear.git diff --git a/src/Model/modelmgr.cxx b/src/Model/modelmgr.cxx index 3507cc4f6..72d257368 100644 --- a/src/Model/modelmgr.cxx +++ b/src/Model/modelmgr.cxx @@ -8,8 +8,10 @@ #include
#include -#include "modelmgr.hxx" #include "model.hxx" +#include "placement.hxx" + +#include "modelmgr.hxx" FGModelMgr::FGModelMgr () @@ -36,9 +38,15 @@ FGModelMgr::init () 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 @@ -120,7 +128,7 @@ FGModelMgr::update (double dt) if (instance->heading_deg_node != 0) model->setHeadingDeg(instance->heading_deg_node->getDoubleValue()); - instance->model->update(); + instance->model->update( globals->get_scenery()->get_center() ); } } @@ -133,8 +141,14 @@ FGModelMgr::add_instance (Instance * instance) void FGModelMgr::remove_instance (Instance * instance) { - _instances.erase(find(_instances.begin(), _instances.end(), instance)); - delete instance; + vector::iterator it; + for (it = _instances.begin(); it != _instances.end(); it++) { + if (*it == instance) { + _instances.erase(it); + delete instance; + return; + } + } } void