-class SGTexScaleOffsetValue : public SGDoubleValue {
-public:
- SGTexScaleOffsetValue(const SGPropertyNode* propertyNode) :
- _propertyNode(propertyNode),
- _scale(1),
- _offset(0),
- _step(0),
- _scroll(0),
- _bias(0),
- _min(-SGLimitsd::max()),
- _max(SGLimitsd::max())
- { }
- void setScale(double scale)
- { _scale = scale; }
- void setOffset(double offset)
- { _offset = offset; }
- void setStep(double step)
- { _step = step; }
- void setScroll(double scroll)
- { _scroll = scroll; }
- void setBias(double bias)
- { _bias = bias; }
- void setMin(double min)
- { _min = min; }
- void setMax(double max)
- { _max = max; }
-
- virtual double getValue() const
- {
- double value = _propertyNode ? _propertyNode->getDoubleValue() : 0;
- value = apply_mods(value, _step, _scroll, _bias);
- return SGMiscd::clip(_scale*(_offset + value), _min, _max);
- }
-private:
- SGSharedPtr<const SGPropertyNode> _propertyNode;
- double _scale;
- double _offset;
- double _step;
- double _scroll;
- double _bias;
- double _min;
- double _max;
-};
-
-class SGTexTableValue : public SGDoubleValue {
-public:
- SGTexTableValue(const SGPropertyNode* propertyNode,
- const SGInterpTable* interpTable) :
- _propertyNode(propertyNode),
- _interpTable(interpTable)
- { }
- void setStep(double step)
- { _step = step; }
- void setScroll(double scroll)
- { _scroll = scroll; }
- void setBias(double bias)
- { _bias = bias; }
- virtual double getValue() const
- {
- double value = _propertyNode ? _propertyNode->getDoubleValue() : 0;
- value = apply_mods(value, _step, _scroll, _bias);
- return _interpTable->interpolate(value);
- }
-private:
- SGSharedPtr<SGPropertyNode const> _propertyNode;
- SGSharedPtr<SGInterpTable const> _interpTable;
- double _step;
- double _scroll;
- double _bias;
-};
+static SGExpressiond*
+read_factor_offset(const SGPropertyNode* configNode, SGExpressiond* expr,
+ const std::string& factor, const std::string& offset)
+{
+ double factorValue = configNode->getDoubleValue(factor, 1);
+ if (factorValue != 1)
+ expr = new SGScaleExpression<double>(expr, factorValue);
+ double offsetValue = configNode->getDoubleValue(offset, 0);
+ if (offsetValue != 0)
+ expr = new SGBiasExpression<double>(expr, offsetValue);
+ return expr;
+}