]> git.mxchange.org Git - flightgear.git/blobdiff - src/Model/modelmgr.cxx
Added explicit std:: prefix to map to work-around MSVC6 bug reported
[flightgear.git] / src / Model / modelmgr.cxx
index 90fd78cc229aa04f76a07b4046062226b449d1ef..f3f7cc8e4f83468743796b888063a759354fa6f0 100644 (file)
@@ -3,37 +3,40 @@
 //
 // This file is in the Public Domain, and comes with no warranty.
 
-#include "modelmgr.hxx"
+#include <plib/ssg.h>
 
 #include <Main/fg_props.hxx>
+#include <Scenery/scenery.hxx>
+
+#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<SGPropertyNode *> model_nodes =
+  vector<SGPropertyNode_ptr> 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"));
 
@@ -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,11 +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;
+    FGModelPlacement * model = instance->model;
 
                                // Optionally set position from properties
     if (instance->lon_deg_node != 0)
@@ -117,15 +120,15 @@ FGModelMgr::update (int dt)
     if (instance->heading_deg_node != 0)
       model->setHeadingDeg(instance->heading_deg_node->getDoubleValue());
 
-    instance->model->update(dt);
+    instance->model->update();
   }
 }
 
 void
 FGModelMgr::draw ()
 {
-  ssgSetNearFar(_nearplane, _farplane);
-  ssgCullAndDraw(_scene);
+//   ssgSetNearFar(_nearplane, _farplane);
+//   ssgCullAndDraw(_scene);
 }