]> git.mxchange.org Git - flightgear.git/commitdiff
AIModels use PagedLOD
authorJames Turner <zakalawe@mac.com>
Sun, 23 Feb 2014 19:51:21 +0000 (11:51 -0800)
committerJames Turner <zakalawe@mac.com>
Mon, 24 Feb 2014 19:43:20 +0000 (19:43 +0000)
- allows AIModels to be unloaded by the Pager
- move AI models into the 'models' sub-branch of FGScenery

src/AIModel/AIBase.cxx
src/AIModel/AIBase.hxx

index a648a35c955d1a8f1ecb2406b57222449e9d4211..3e00f55424c1b7344bf2891c869ce10147294af0 100644 (file)
@@ -207,7 +207,7 @@ FGAIBase::removeModel()
     if (pSceneryManager)
     {
         osg::ref_ptr<osg::Object> temp = _model.get();
-        pSceneryManager->get_scene_graph()->removeChild(aip.getSceneGraph());
+        pSceneryManager->get_models_branch()->removeChild(aip.getSceneGraph());
         // withdraw from SGModelPlacement and drop own reference (unref)
         aip.clear();
         _modeldata = 0;
@@ -365,26 +365,25 @@ bool FGAIBase::init(bool search_in_AI_path)
         _installed = true;
 
     _modeldata = new FGAIModelData(props);
-    osg::Node * mdl = SGModelLib::loadDeferredModel(f, props, _modeldata);
+    _model= SGModelLib::loadPagedModel(f, props, _modeldata);
 
-    _model = new osg::LOD;
     _model->setName("AI-model range animation node");
 
-    _model->addChild( mdl, 0, FLT_MAX );
-    _model->setCenterMode(osg::LOD::USE_BOUNDING_SPHERE_CENTER);
-    _model->setRangeMode(osg::LOD::DISTANCE_FROM_EYE_POINT);
+  //  _model->setCenterMode(osg::LOD::USE_BOUNDING_SPHERE_CENTER);
+  //  _model->setRangeMode(osg::LOD::DISTANCE_FROM_EYE_POINT);
+  
 //    We really need low-resolution versions of AI/MP aircraft.
 //    Or at least dummy "stubs" with some default silhouette.
 //        _model->addChild( SGModelLib::loadPagedModel(fgGetString("/sim/multiplay/default-model", default_model),
 //                                                    props, new FGNasalModelData(props)), FLT_MAX, FLT_MAX);
     updateLOD();
-
-    initModel(mdl);
+    initModel();
+  
     if (_model.valid() && _initialized == false) {
         aip.init( _model.get() );
         aip.setVisible(true);
         invisible = false;
-        globals->get_scenery()->get_scene_graph()->addChild(aip.getSceneGraph());
+        globals->get_scenery()->get_models_branch()->addChild(aip.getSceneGraph());
         _initialized = true;
 
         SG_LOG(SG_AI, SG_DEBUG, "AIBase: Loaded model " << model_path);
@@ -399,7 +398,7 @@ bool FGAIBase::init(bool search_in_AI_path)
     return true;
 }
 
-void FGAIBase::initModel(osg::Node *node)
+void FGAIBase::initModel()
 {
     if (_model.valid()) { 
 
index 52be8e5a3d89b7b205f671f89ef150d26fc14da3..dd88987cde028e97bdb163440e0e48e680b1b6ad 100644 (file)
@@ -21,8 +21,7 @@
 #define _FG_AIBASE_HXX
 
 #include <string>
-
-#include <osg/LOD>
+#include <osg/ref_ptr>
 
 #include <simgear/constants.h>
 #include <simgear/scene/model/placement.hxx>
@@ -36,6 +35,8 @@
 
 #include <Main/fg_props.hxx>
 
+namespace osg { class PagedLOD; }
+
 namespace simgear {
 class BVHMaterial;
 }
@@ -59,7 +60,7 @@ public:
     virtual void readFromScenario(SGPropertyNode* scFileNode);
 
     virtual bool init(bool search_in_AI_path=false);
-    virtual void initModel(osg::Node *node);
+    virtual void initModel();
     virtual void update(double dt);
     virtual void bind();
     virtual void unbind();
@@ -233,7 +234,7 @@ private:
     int _refID;
     object_type _otype;
     bool _initialized;
-    osg::ref_ptr<osg::LOD> _model; //The 3D model LOD object
+    osg::ref_ptr<osg::PagedLOD> _model;
 
     osg::ref_ptr<FGAIModelData> _modeldata;