* Read an interpolation table from properties.
*/
static SGInterpTable *
-read_interpolation_table (const SGPropertyNode * props)
+read_interpolation_table (SGPropertyNode_ptr props)
{
- const SGPropertyNode * table_node = props->getNode("interpolation");
+ SGPropertyNode_ptr table_node = props->getNode("interpolation");
if (table_node != 0) {
SGInterpTable * table = new SGInterpTable();
vector<SGPropertyNode_ptr> entries = table_node->getChildren("entry");
static void
make_animation (ssgBranch * model,
- const char * object_name,
- SGPropertyNode * node)
+ vector<SGPropertyNode_ptr> &name_nodes,
+ SGPropertyNode_ptr node)
{
Animation * animation = 0;
const char * type = node->getStringValue("type");
}
ssgEntity * object;
- if (object_name != 0) {
- object = find_named_node(model, object_name);
+ if (name_nodes.size() > 0) {
+ object = find_named_node(model, name_nodes[0]->getStringValue());
if (object == 0) {
- SG_LOG(SG_INPUT, SG_WARN, "Object " << object_name << " not found");
+ SG_LOG(SG_INPUT, SG_WARN, "Object " << name_nodes[0]->getStringValue()
+ << " not found");
delete animation;
animation = 0;
}
ssgBranch * branch = animation->getBranch();
splice_branch(branch, object);
+
+ for (int i = 1; i < name_nodes.size(); i++) {
+ const char * name = name_nodes[i]->getStringValue();
+ object = find_named_node(model, name);
+ if (object == 0) {
+ SG_LOG(SG_INPUT, SG_WARN, "Object " << name << " not found");
+ delete animation;
+ animation = 0;
+ }
+ ssgBranch * oldParent = object->getParent(0);
+ std::cerr << "Moving " << name << " to new parent\n";
+ branch->addKid(object);
+ oldParent->removeKid(object);
+ std::cerr << " leaf has " << object->getNumParents() << " parents\n";
+ std::cerr << " branch has " << branch->getNumKids() << " kids\n";
+ }
+
branch->setUserData(animation);
branch->setTravCallback(SSG_CALLBACK_PRETRAV, animation_callback);
}
for (i = 0; i < animation_nodes.size(); i++) {
vector<SGPropertyNode_ptr> name_nodes =
animation_nodes[i]->getChildren("object-name");
- if (name_nodes.size() < 1) {
- make_animation(model, 0, animation_nodes[i]);
- } else {
- for (unsigned int j = 0; j < name_nodes.size(); j++) {
- make_animation(model, name_nodes[j]->getStringValue(), animation_nodes[i]);
- }
- }
+ make_animation(model, name_nodes, animation_nodes[i]);
}
// Load panels
: Animation(props, new ssgSelector),
_condition(0)
{
- SGPropertyNode * node = props->getChild("condition");
+ SGPropertyNode_ptr node = props->getChild("condition");
if (node != 0)
_condition = fgReadCondition(node);
}
#include <plib/sg.h>
#include <plib/ssg.h>
+#include <simgear/misc/props.hxx>
+
// Don't pull in the headers, since we don't need them here.
class ssgBranch;
class ssgSelector;
class ssgTransform;
-class SGPropertyNode;
class SGInterpTable;
class FGCondition;
class FGLocation;
virtual ~SpinAnimation ();
virtual void update ();
private:
- SGPropertyNode * _prop;
+ SGPropertyNode_ptr _prop;
double _factor;
double _position_deg;
double _last_time_sec;
virtual ~RotateAnimation ();
virtual void update ();
private:
- SGPropertyNode * _prop;
+ SGPropertyNode_ptr _prop;
double _offset_deg;
double _factor;
SGInterpTable * _table;
virtual ~TranslateAnimation ();
virtual void update ();
private:
- SGPropertyNode * _prop;
+ SGPropertyNode_ptr _prop;
double _offset_m;
double _factor;
SGInterpTable * _table;