]> git.mxchange.org Git - flightgear.git/blobdiff - src/Model/model_panel.cxx
Roy Vegard Ovesen:
[flightgear.git] / src / Model / model_panel.cxx
index 3c197f661018faed7e1e359600088ca9352002cc..692270138d4551622f7d3cd57624f1bf47b0fa9c 100644 (file)
@@ -17,7 +17,7 @@
 #include <plib/ssg.h>
 #include <plib/ul.h>
 
-#include <simgear/misc/exception.hxx>
+#include <simgear/structure/exception.hxx>
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/props/props.hxx>
 #include <simgear/props/props_io.hxx>
@@ -49,19 +49,16 @@ fgLoad3DModelPanel( const string &fg_root, const string &path,
   SGPropertyNode props;
 
                                 // Load the 3D aircraft object itself
-  SGPath xmlpath;
   SGPath modelpath = path;
-  if ( ulIsAbsolutePathName( path.c_str() ) ) {
-    xmlpath = modelpath;
-  }
-  else {
-    xmlpath = fg_root;
-    xmlpath.append(modelpath.str());
+  if ( !ulIsAbsolutePathName( path.c_str() ) ) {
+    SGPath tmp = fg_root;
+    tmp.append(modelpath.str());
+    modelpath = tmp;
   }
 
                                 // Check for an XML wrapper
-  if (xmlpath.str().substr(xmlpath.str().size() - 4, 4) == ".xml") {
-    readProperties(xmlpath.str(), &props);
+  if (modelpath.str().substr(modelpath.str().size() - 4, 4) == ".xml") {
+    readProperties(modelpath.str(), &props);
     if (props.hasValue("/path")) {
       modelpath = modelpath.dir();
       modelpath.append(props.getStringValue("/path"));
@@ -74,7 +71,7 @@ fgLoad3DModelPanel( const string &fg_root, const string &path,
                                 // Assume that textures are in
                                 // the same location as the XML file.
   if (model == 0) {
-    ssgTexturePath((char *)xmlpath.dir().c_str());
+    ssgTexturePath((char *)modelpath.dir().c_str());
     model = (ssgBranch *)ssgLoad((char *)modelpath.c_str());
     if (model == 0)
       throw sg_exception("Failed to load 3D model");
@@ -105,16 +102,6 @@ fgLoad3DModelPanel( const string &fg_root, const string &path,
     model->addKid(panel);
   }
 
-                                // Load animations
-  vector<SGPropertyNode_ptr> animation_nodes = props.getChildren("animation");
-  for (i = 0; i < animation_nodes.size(); i++) {
-    const char * name = animation_nodes[i]->getStringValue("name", 0);
-    vector<SGPropertyNode_ptr> name_nodes =
-      animation_nodes[i]->getChildren("object-name");
-    sgMakeAnimation( model, name, name_nodes, prop_root, animation_nodes[i],
-                     sim_time_sec);
-  }
-
                                 // Load sub-models
   vector<SGPropertyNode_ptr> model_nodes = props.getChildren("model");
   for (i = 0; i < model_nodes.size(); i++) {
@@ -133,9 +120,20 @@ fgLoad3DModelPanel( const string &fg_root, const string &path,
     ssgBranch * kid = sgLoad3DModel( fg_root, node->getStringValue("path"),
                                      prop_root, sim_time_sec );
     align->addKid(kid);
+    align->setName(node->getStringValue("name", ""));
     model->addKid(align);
   }
 
+                                // Load animations
+  vector<SGPropertyNode_ptr> animation_nodes = props.getChildren("animation");
+  for (i = 0; i < animation_nodes.size(); i++) {
+    const char * name = animation_nodes[i]->getStringValue("name", 0);
+    vector<SGPropertyNode_ptr> name_nodes =
+      animation_nodes[i]->getChildren("object-name");
+    sgMakeAnimation( model, name, name_nodes, prop_root, animation_nodes[i],
+                     sim_time_sec);
+  }
+
   return alignmainmodel;
 }