From a370cbbb6a42e2399bff8d2a5443142a62c5332b Mon Sep 17 00:00:00 2001 From: david Date: Wed, 27 Feb 2002 20:32:24 +0000 Subject: [PATCH] A single transformation can now be applied to more than one object by including multiple entries. --- src/Main/model.cxx | 37 +++++++++++++++++++++++-------------- src/Main/model.hxx | 3 ++- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/Main/model.cxx b/src/Main/model.cxx index 4359a2e31..3cf6c3031 100644 --- a/src/Main/model.cxx +++ b/src/Main/model.cxx @@ -95,7 +95,16 @@ FGAircraftModel::init () vector animation_nodes = props.getChildren("animation"); for (int i = 0; i < animation_nodes.size(); i++) { - _animations.push_back(read_animation(animation_nodes[i])); + vector 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(); diff --git a/src/Main/model.hxx b/src/Main/model.hxx index 60e2c398d..685c37d0e 100644 --- a/src/Main/model.hxx +++ b/src/Main/model.hxx @@ -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; -- 2.39.5