]> git.mxchange.org Git - flightgear.git/blobdiff - src/Model/model.cxx
Change FGSteam into a proper subsystem rather than a collection of
[flightgear.git] / src / Model / model.cxx
index 430c48cc01d41f4ec1f57a14d6ba549811de2b6f..64621ea0c67429af8df04b4b0b33b99a99a261db 100644 (file)
@@ -26,6 +26,7 @@
 #include <Scenery/scenery.hxx>
 
 #include "model.hxx"
+#include "panelnode.hxx"
 
 
 \f
@@ -197,16 +198,19 @@ FG3DModel::init (const string &path)
       modelpath = modelpath.dir();
       modelpath.append(props.getStringValue("/path"));
     } else {
-      throw sg_exception("No path for model");
+      if (_model == 0)
+       _model = new ssgBranch;
     }
   }
 
                                 // Assume that textures are in
                                 // the same location as the XML file.
-  ssgTexturePath((char *)xmlpath.dir().c_str());
-  _model = (ssgBranch *)ssgLoad((char *)modelpath.c_str());
-  if (_model == 0)
-    throw sg_exception("Failed to load 3D model");
+  if (_model == 0) {
+    ssgTexturePath((char *)xmlpath.dir().c_str());
+    _model = (ssgBranch *)ssgLoad((char *)modelpath.c_str());
+    if (_model == 0)
+      throw sg_exception("Failed to load 3D model");
+  }
 
                                 // Set up the alignment node
   ssgTransform * align = new ssgTransform;
@@ -229,6 +233,8 @@ FG3DModel::init (const string &path)
       animation_nodes[i]->getChildren("object-name");
     if (name_nodes.size() < 1) {
       Animation * animation = make_animation(0, animation_nodes[i]);
+      if (animation != 0)
+       _animations.push_back(animation);
     } else {
       for (unsigned int j = 0; j < name_nodes.size(); j++) {
         Animation * animation =
@@ -239,6 +245,14 @@ FG3DModel::init (const string &path)
     }
   }
 
+                                // Load panels
+  vector<SGPropertyNode_ptr> panel_nodes = props.getChildren("panel");
+  for (i = 0; i < panel_nodes.size(); i++) {
+    printf("Reading a panel in model.cxx\n");
+    FGPanelNode * panel = new FGPanelNode(panel_nodes[i]);
+    _model->addKid(panel);
+  }
+
                                // Load sub-models
   vector<SGPropertyNode_ptr> model_nodes = props.getChildren("model");
   for (i = 0; i < model_nodes.size(); i++) {
@@ -309,7 +323,8 @@ FG3DModel::make_animation (const char * object_name,
     object = _model;
   }
 
-  animation->init(object, node);
+  if (animation != 0)
+    animation->init(object, node);
   return animation;
 }