X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2Fmodelmgr.cxx;h=f3f7cc8e4f83468743796b888063a759354fa6f0;hb=832d514d059a8248d8864f0bd317be2fcb5b59df;hp=e25884c30ee34965e5d162d5ad9cc2494e6535e1;hpb=8bed5a8cf465190897b6ab7d6f8dcad34e655ce5;p=flightgear.git diff --git a/src/Model/modelmgr.cxx b/src/Model/modelmgr.cxx index e25884c30..f3f7cc8e4 100644 --- a/src/Model/modelmgr.cxx +++ b/src/Model/modelmgr.cxx @@ -3,37 +3,40 @@ // // This file is in the Public Domain, and comes with no warranty. -#include "modelmgr.hxx" +#include #include
+#include + +#include "modelmgr.hxx" +#include "model.hxx" FGModelMgr::FGModelMgr () - : _scene(new ssgRoot), - _nearplane(0.5f), - _farplane(120000.0f) + : _selector(new ssgSelector) { } FGModelMgr::~FGModelMgr () { - for (int i = 0; i < _instances.size(); i++) { + for (unsigned int i = 0; i < _instances.size(); i++) { + globals->get_scenery()->get_models_branch() + ->removeKid(_instances[i]->model->getSceneGraph()); delete _instances[i]; } - delete _scene; } void FGModelMgr::init () { - vector model_nodes = + vector model_nodes = fgGetNode("/models", true)->getChildren("model"); - for (int i = 0; i < model_nodes.size(); i++) { + for (unsigned int i = 0; i < model_nodes.size(); i++) { SGPropertyNode * node = model_nodes[i]; SG_LOG(SG_GENERAL, SG_INFO, "Adding model " << node->getStringValue("name", "[unnamed]")); Instance * instance = new Instance; - FG3DModel * model = new FG3DModel; + FGModelPlacement * model = new FGModelPlacement; instance->model = model; model->init(node->getStringValue("path", "Models/Geometry/glider.ac")); @@ -42,7 +45,7 @@ FGModelMgr::init () // or directly with static values. SGPropertyNode * child = node->getChild("longitude-deg-prop"); if (child != 0) - instance->lon_deg_node = child; + instance->lon_deg_node = fgGetNode(child->getStringValue(), true); else model->setLongitudeDeg(node->getDoubleValue("longitude-deg")); @@ -76,8 +79,8 @@ FGModelMgr::init () else model->setHeadingDeg(node->getDoubleValue("heading-deg")); - // Add this model to the scene graph - _scene->addKid(model->getSceneGraph()); + // Add this model to the global scene graph + globals->get_scenery()->get_scene_graph()->addKid(model->getSceneGraph()); // Save this instance for updating _instances.push_back(instance); @@ -95,13 +98,11 @@ FGModelMgr::unbind () } void -FGModelMgr::update (int dt) +FGModelMgr::update (double dt) { - for (int i = 0; i < _instances.size(); i++) { + for (unsigned int i = 0; i < _instances.size(); i++) { Instance * instance = _instances[i]; - FG3DModel * model = instance->model; - - instance->model->update(dt); + FGModelPlacement * model = instance->model; // Optionally set position from properties if (instance->lon_deg_node != 0) @@ -119,14 +120,15 @@ FGModelMgr::update (int dt) if (instance->heading_deg_node != 0) model->setHeadingDeg(instance->heading_deg_node->getDoubleValue()); + instance->model->update(); } } void FGModelMgr::draw () { - ssgSetNearFar(_nearplane, _farplane); - ssgCullAndDraw(_scene); +// ssgSetNearFar(_nearplane, _farplane); +// ssgCullAndDraw(_scene); }