A single transformation can now be applied to more than one object by
including multiple <object-name> entries.
This commit is contained in:
parent
249fbedcae
commit
a370cbbb6a
2 changed files with 25 additions and 15 deletions
|
@ -95,7 +95,16 @@ FGAircraftModel::init ()
|
||||||
vector<SGPropertyNode *> animation_nodes =
|
vector<SGPropertyNode *> animation_nodes =
|
||||||
props.getChildren("animation");
|
props.getChildren("animation");
|
||||||
for (int i = 0; i < animation_nodes.size(); i++) {
|
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
|
// Set up the alignment node
|
||||||
|
@ -173,10 +182,22 @@ FGAircraftModel::update (int dt)
|
||||||
}
|
}
|
||||||
|
|
||||||
FGAircraftModel::Animation
|
FGAircraftModel::Animation
|
||||||
FGAircraftModel::read_animation (const SGPropertyNode * node)
|
FGAircraftModel::read_animation (const string &object_name,
|
||||||
|
const SGPropertyNode * node)
|
||||||
{
|
{
|
||||||
Animation animation;
|
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
|
// Figure out the animation type
|
||||||
string type_name = node->getStringValue("type");
|
string type_name = node->getStringValue("type");
|
||||||
if (type_name == "spin") {
|
if (type_name == "spin") {
|
||||||
|
@ -195,18 +216,6 @@ FGAircraftModel::read_animation (const SGPropertyNode * node)
|
||||||
return animation;
|
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
|
// Splice a transform node into the tree
|
||||||
animation.transform = new ssgTransform;
|
animation.transform = new ssgTransform;
|
||||||
int nParents = target->getNumParents();
|
int nParents = target->getNumParents();
|
||||||
|
|
|
@ -54,7 +54,8 @@ private:
|
||||||
void setRotation ();
|
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);
|
void do_animation (Animation &animation, long elapsed_ms);
|
||||||
|
|
||||||
ssgEntity * _model;
|
ssgEntity * _model;
|
||||||
|
|
Loading…
Reference in a new issue