+
+ texMat->setUpdateCallback(updateCallback);
+ stateSet->setTextureAttribute(0, texMat);
+ parent.addChild(group);
+ return group;
+}
+
+void
+SGTexTransformAnimation::appendTexTranslate(const SGPropertyNode* config,
+ UpdateCallback* updateCallback)
+{
+ std::string propertyName = config->getStringValue("property", "");
+ SGSharedPtr<SGExpressiond> value;
+ if (propertyName.empty())
+ value = new SGConstExpression<double>(0);
+ else {
+ SGPropertyNode* inputProperty = getModelRoot()->getNode(propertyName, true);
+ value = new SGPropertyExpression<double>(inputProperty);
+ }
+
+ SGInterpTable* table = read_interpolation_table(config);
+ if (table) {
+ value = new SGInterpTableExpression<double>(value, table);
+ double biasValue = config->getDoubleValue("bias", 0);
+ if (biasValue != 0)
+ value = new SGBiasExpression<double>(value, biasValue);
+ value = new SGStepExpression<double>(value,
+ config->getDoubleValue("step", 0),
+ config->getDoubleValue("scroll", 0));
+ value = value->simplify();
+ } else {
+ double biasValue = config->getDoubleValue("bias", 0);
+ if (biasValue != 0)
+ value = new SGBiasExpression<double>(value, biasValue);
+ value = new SGStepExpression<double>(value,
+ config->getDoubleValue("step", 0),
+ config->getDoubleValue("scroll", 0));
+ value = read_offset_factor(config, value, "factor", "offset");
+
+ if (config->hasChild("min") || config->hasChild("max")) {
+ double minClip = config->getDoubleValue("min", -SGLimitsd::max());
+ double maxClip = config->getDoubleValue("max", SGLimitsd::max());
+ value = new SGClipExpression<double>(value, minClip, maxClip);
+ }
+ value = value->simplify();
+ }
+ SGVec3d axis(config->getDoubleValue("axis/x", 0),
+ config->getDoubleValue("axis/y", 0),
+ config->getDoubleValue("axis/z", 0));
+ Translation* translation;
+ translation = new Translation(normalize(axis));
+ translation->setValue(config->getDoubleValue("starting-position", 0));
+ updateCallback->appendTransform(translation, value);
+}
+
+void
+SGTexTransformAnimation::appendTexRotate(const SGPropertyNode* config,
+ UpdateCallback* updateCallback)
+{
+ std::string propertyName = config->getStringValue("property", "");
+ SGSharedPtr<SGExpressiond> value;
+ if (propertyName.empty())
+ value = new SGConstExpression<double>(0);
+ else {
+ SGPropertyNode* inputProperty = getModelRoot()->getNode(propertyName, true);
+ value = new SGPropertyExpression<double>(inputProperty);
+ }
+
+ SGInterpTable* table = read_interpolation_table(config);
+ if (table) {
+ value = new SGInterpTableExpression<double>(value, table);
+ double biasValue = config->getDoubleValue("bias", 0);
+ if (biasValue != 0)
+ value = new SGBiasExpression<double>(value, biasValue);
+ value = new SGStepExpression<double>(value,
+ config->getDoubleValue("step", 0),
+ config->getDoubleValue("scroll", 0));
+ value = value->simplify();
+ } else {
+ double biasValue = config->getDoubleValue("bias", 0);
+ if (biasValue != 0)
+ value = new SGBiasExpression<double>(value, biasValue);
+ value = new SGStepExpression<double>(value,
+ config->getDoubleValue("step", 0),
+ config->getDoubleValue("scroll", 0));
+ value = read_offset_factor(config, value, "factor", "offset-deg");
+
+ if (config->hasChild("min-deg") || config->hasChild("max-deg")) {
+ double minClip = config->getDoubleValue("min-deg", -SGLimitsd::max());
+ double maxClip = config->getDoubleValue("max-deg", SGLimitsd::max());
+ value = new SGClipExpression<double>(value, minClip, maxClip);
+ }
+ value = value->simplify();
+ }
+ SGVec3d axis(config->getDoubleValue("axis/x", 0),
+ config->getDoubleValue("axis/y", 0),
+ config->getDoubleValue("axis/z", 0));
+ SGVec3d center(config->getDoubleValue("center/x", 0),
+ config->getDoubleValue("center/y", 0),
+ config->getDoubleValue("center/z", 0));
+ Rotation* rotation;
+ rotation = new Rotation(normalize(axis), center);
+ rotation->setValue(config->getDoubleValue("starting-position-deg", 0));
+ updateCallback->appendTransform(rotation, value);