]> git.mxchange.org Git - flightgear.git/blobdiff - src/Model/acmodel.cxx
- rename fgcommand "set-mouse" to "set-cursor"
[flightgear.git] / src / Model / acmodel.cxx
index 4b0a87841251bbec8e29d8e438708b77c74acc84..1f9b15a7e692c8b87607603adccaa71f1bb51f89 100644 (file)
@@ -35,7 +35,6 @@
 FGAircraftModel::FGAircraftModel ()
   : _aircraft(0),
     _selector(new osg::Switch),
-    _scene(new osg::Group),
     _nearplane(0.10f),
     _farplane(1000.0f)
 {
@@ -43,10 +42,6 @@ FGAircraftModel::FGAircraftModel ()
 
 FGAircraftModel::~FGAircraftModel ()
 {
-  // Unregister that one at the scenery manager
-  if (_aircraft)
-    globals->get_scenery()->unregister_placement_transform(_aircraft->getTransform());
-
   delete _aircraft;
                                // SSG will delete it
   globals->get_scenery()->get_aircraft_branch()->removeChild(_selector.get());
@@ -55,45 +50,23 @@ FGAircraftModel::~FGAircraftModel ()
 void 
 FGAircraftModel::init ()
 {
-  SGPath liveryPath;
   _aircraft = new SGModelPlacement;
   string path = fgGetString("/sim/model/path", "Models/Geometry/glider.ac");
-  string texture_path = fgGetString("/sim/model/texture-path");
-  if( texture_path.size() ) {
-      SGPath temp_path;
-      if ( !ulIsAbsolutePathName( texture_path.c_str() ) ) {
-          temp_path = globals->get_fg_root();
-          temp_path.append( SGPath( path ).dir() );
-          temp_path.append( texture_path );
-          liveryPath = temp_path;
-      } else
-          liveryPath = texture_path;
-  }
   try {
-    osg::Node *model = fgLoad3DModelPanel( globals->get_fg_root(),
-                                           path,
-                                           globals->get_props(),
-                                           globals->get_sim_time_sec(),
-                                           liveryPath);
+    osg::Node *model = fgLoad3DModelPanel( path, globals->get_props());
     _aircraft->init( model );
   } catch (const sg_exception &ex) {
-    SG_LOG(SG_GENERAL, SG_ALERT, "Failed to load aircraft from " << path);
+    SG_LOG(SG_GENERAL, SG_ALERT, "Failed to load aircraft from " << path << ':');
+    SG_LOG(SG_GENERAL, SG_ALERT, "  " << ex.getFormattedMessage());
     SG_LOG(SG_GENERAL, SG_ALERT, "(Falling back to glider.ac.)");
-    osg::Node *model = fgLoad3DModelPanel( globals->get_fg_root(),
-                                           "Models/Geometry/glider.ac",
-                                           globals->get_props(),
-                                           globals->get_sim_time_sec(),
-                                           liveryPath);
+    osg::Node *model = fgLoad3DModelPanel( "Models/Geometry/glider.ac",
+                                           globals->get_props());
     _aircraft->init( model );
   }
-  _scene->addChild(_aircraft->getSceneGraph());
-  _selector->addChild(_aircraft->getSceneGraph());
+  _selector->addChild(_aircraft->getSceneGraph(), true);
   // Do not do altitude computations with that model
   _selector->setNodeMask(~SG_NODEMASK_TERRAIN_BIT);
   globals->get_scenery()->get_aircraft_branch()->addChild(_selector.get());
-
-  // Register that one at the scenery manager
-  globals->get_scenery()->register_placement_transform(_aircraft->getTransform());
 }
 
 void