+
+ // Figure out the animation type
+ string type_name = node->getStringValue("type");
+ if (type_name == "spin") {
+ SG_LOG(SG_INPUT, SG_INFO, "Reading spin animation");
+ animation.type = Animation::Spin;
+ } else if (type_name == "rotate") {
+ SG_LOG(SG_INPUT, SG_INFO, "Reading rotate animation");
+ animation.type = Animation::Rotate;
+ } else if (type_name == "none") {
+ SG_LOG(SG_INPUT, SG_INFO, "Reading disabled animation");
+ animation.type = Animation::None;
+ return animation;
+ } else {
+ animation.type = Animation::None;
+ SG_LOG(SG_INPUT, SG_ALERT, "Unknown animation type " << type_name);
+ return animation;
+ }
+
+ // Splice a transform node into the tree
+ animation.transform = new ssgTransform;
+ int nParents = target->getNumParents();
+ animation.transform->addKid(target);
+ for (int i = 0; i < nParents; i++) {
+ ssgBranch * parent = target->getParent(i);
+ parent->replaceKid(target, animation.transform);
+ }
+
+ // Get the node
+ animation.prop =
+ fgGetNode(node->getStringValue("property", "/null"), true);
+
+ animation.position = node->getFloatValue("initial-position", 0);
+ animation.offset = node->getFloatValue("offset", 0);
+ if (node->hasValue("min")) {
+ animation.has_min = true;
+ animation.min = node->getFloatValue("min");
+ } else {
+ animation.has_min = false;
+ }
+ if (node->hasValue("max")) {
+ animation.has_max = true;
+ animation.max = node->getFloatValue("max");
+ } else {
+ animation.has_max = false;
+ }
+ animation.factor = node->getFloatValue("factor", 1);
+
+ // Get the center and axis
+ animation.center[0] = node->getFloatValue("center/x-m", 0);
+ animation.center[1] = node->getFloatValue("center/y-m", 0);
+ animation.center[2] = node->getFloatValue("center/z-m", 0);
+ animation.axis[0] = node->getFloatValue("axis/x", 0);
+ animation.axis[1] = node->getFloatValue("axis/y", 0);
+ animation.axis[2] = node->getFloatValue("axis/z", 0);
+
+ sgNormalizeVec3(animation.axis);
+
+ return animation;