From: ehofman Date: Mon, 9 Jun 2003 09:11:20 +0000 (+0000) Subject: Add the ability to include stepped texture translations for things like digital displ... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e053941467a777732ff3b471b1d7bdeabdf6f754;p=simgear.git Add the ability to include stepped texture translations for things like digital displays in 3D model animation. --- diff --git a/simgear/scene/model/animation.cxx b/simgear/scene/model/animation.cxx index f9ebc188..1c9c5b02 100644 --- a/simgear/scene/model/animation.cxx +++ b/simgear/scene/model/animation.cxx @@ -5,6 +5,7 @@ #include // for strcmp() +#include #include #include @@ -478,6 +479,7 @@ SGTexTranslateAnimation::SGTexTranslateAnimation( SGPropertyNode *prop_root, _prop((SGPropertyNode *)prop_root->getNode(props->getStringValue("property", "/null"), true)), _offset_m(props->getDoubleValue("offset-m", 0.0)), _factor(props->getDoubleValue("factor", 1.0)), + _step(props->getDoubleValue("step",0.0)), _table(read_interpolation_table(props)), _has_min(props->hasValue("min-m")), _min_m(props->getDoubleValue("min-m")), @@ -500,7 +502,15 @@ void SGTexTranslateAnimation::update() { if (_table == 0) { - _position_m = (_prop->getDoubleValue() + _offset_m) * _factor; + if(_step > 0) { + // apply stepping of input value + if(_prop->getDoubleValue() > 0) + _position_m = ((floor(_prop->getDoubleValue()/_step) * _step) + _offset_m) * _factor; + else + _position_m = ((ceil(_prop->getDoubleValue()/_step) * _step) + _offset_m) * _factor; + } else { + _position_m = (_prop->getDoubleValue() + _offset_m) * _factor; + } if (_has_min && _position_m < _min_m) _position_m = _min_m; if (_has_max && _position_m > _max_m) diff --git a/simgear/scene/model/animation.hxx b/simgear/scene/model/animation.hxx index f365ec97..c80edc15 100644 --- a/simgear/scene/model/animation.hxx +++ b/simgear/scene/model/animation.hxx @@ -1,3 +1,4 @@ + // animation.hxx - classes to manage model animation. // Written by David Megginson, started 2002. // @@ -261,6 +262,7 @@ private: SGPropertyNode_ptr _prop; double _offset_m; double _factor; + double _step; SGInterpTable * _table; bool _has_min; double _min_m;