]> git.mxchange.org Git - flightgear.git/commitdiff
A single transformation can now be applied to more than one object by
authordavid <david>
Wed, 27 Feb 2002 20:32:24 +0000 (20:32 +0000)
committerdavid <david>
Wed, 27 Feb 2002 20:32:24 +0000 (20:32 +0000)
including multiple <object-name> entries.

src/Main/model.cxx
src/Main/model.hxx

index 4359a2e317ad33638ccf76c369ddcaa759ffd934..3cf6c3031f66be2e4cff90caf1c00bb3cf9264f1 100644 (file)
@@ -95,7 +95,16 @@ FGAircraftModel::init ()
   vector<SGPropertyNode *> animation_nodes =
     props.getChildren("animation");
   for (int i = 0; i < animation_nodes.size(); i++) {
-    _animations.push_back(read_animation(animation_nodes[i]));
+    vector<SGPropertyNode *> name_nodes =
+      animation_nodes[i]->getChildren("object-name");
+    if (name_nodes.size() < 1) {
+      SG_LOG(SG_INPUT, SG_ALERT, "No object-name given for transformation");
+    } else {
+      for (int j = 0; j < name_nodes.size(); j++) {
+       _animations.push_back(read_animation(name_nodes[j]->getStringValue(),
+                                            animation_nodes[i]));
+      }
+    }
   }
 
                                // Set up the alignment node
@@ -173,10 +182,22 @@ FGAircraftModel::update (int dt)
 }
 
 FGAircraftModel::Animation
-FGAircraftModel::read_animation (const SGPropertyNode * node)
+FGAircraftModel::read_animation (const string &object_name,
+                                const SGPropertyNode * node)
 {
   Animation animation;
 
+                               // Find the object to be animated
+  ssgEntity * target = find_named_node(_model, object_name);
+  if (target != 0) {
+    SG_LOG(SG_INPUT, SG_INFO, "  Target object is " << object_name);
+  } else {
+    animation.type = Animation::None;
+    SG_LOG(SG_INPUT, SG_ALERT, "Object " << object_name
+          << " not found in model");
+    return animation;
+  }
+
                                // Figure out the animation type
   string type_name = node->getStringValue("type");
   if (type_name == "spin") {
@@ -195,18 +216,6 @@ FGAircraftModel::read_animation (const SGPropertyNode * node)
     return animation;
   }
 
-                               // Find the object to be animated
-  string object_name = node->getStringValue("object-name");
-  ssgEntity * target = find_named_node(_model, object_name);
-  if (target != 0) {
-    SG_LOG(SG_INPUT, SG_INFO, "  Target object is " << object_name);
-  } else {
-    animation.type = Animation::None;
-    SG_LOG(SG_INPUT, SG_ALERT, "Object " << object_name
-          << " not found in model");
-    return animation;
-  }
-
                                // Splice a transform node into the tree
   animation.transform = new ssgTransform;
   int nParents = target->getNumParents();
index 60e2c398dd0948dda83cf776bc4fc9481a5f847b..685c37d0e6d75aae1b3cc5ec83f401546c3f2c2d 100644 (file)
@@ -54,7 +54,8 @@ private:
     void setRotation ();
   };
 
-  Animation read_animation (const SGPropertyNode * node);
+  Animation read_animation (const string &object_name,
+                           const SGPropertyNode * node);
   void do_animation (Animation &animation, long elapsed_ms);
 
   ssgEntity * _model;