diff --git a/simgear/scene/model/SGTranslateTransform.hxx b/simgear/scene/model/SGTranslateTransform.hxx index be6ac0a7..d7de92c0 100644 --- a/simgear/scene/model/SGTranslateTransform.hxx +++ b/simgear/scene/model/SGTranslateTransform.hxx @@ -24,6 +24,9 @@ #include #include +#include +#include + class SGTranslateTransform : public osg::Transform { public: @@ -49,6 +52,9 @@ public: osg::NodeVisitor* nv) const; virtual osg::BoundingSphere computeBound() const; + // Only used for highlighting. + SGSharedPtr _animationValue; + private: SGVec3d _axis; double _value; diff --git a/simgear/scene/model/animation.cxx b/simgear/scene/model/animation.cxx index 95e0d003..a9ecaece 100644 --- a/simgear/scene/model/animation.cxx +++ b/simgear/scene/model/animation.cxx @@ -982,6 +982,7 @@ SGTranslateAnimation::createAnimationGroup(osg::Group& parent) if (_animationValue && !_animationValue->isConst()) { UpdateCallback* uc = new UpdateCallback(_condition, _animationValue); transform->setUpdateCallback(uc); + transform->_animationValue = _animationValue; } transform->setAxis(_axis); transform->setValue(_initialValue); @@ -2494,3 +2495,16 @@ SGTexTransformAnimation::appendTexTrapezoid( const SGPropertyNode& cfg, trapezoid->setValue(cfg.getDoubleValue("starting-position", 0)); updateCallback->appendTransform(trapezoid, readValue(cfg)); } + +SGSharedPtr TransformExpression(osg::Transform* transform) +{ + SGSharedPtr ret; + if (auto rot_anim_transform = dynamic_cast(transform)) { + ret = rot_anim_transform->_animationValue; + } + else if (auto translate_transform = dynamic_cast(transform)) { + ret = translate_transform->_animationValue; + } + return ret; +} + diff --git a/simgear/scene/model/animation.hxx b/simgear/scene/model/animation.hxx index 51174cb1..5826b9ba 100644 --- a/simgear/scene/model/animation.hxx +++ b/simgear/scene/model/animation.hxx @@ -38,6 +38,11 @@ read_value(const SGPropertyNode* configNode, SGPropertyNode* modelRoot, SGVec3d readTranslateAxis(const SGPropertyNode* configNode); +/** + * Returns transform's expression if it has one. + */ +SGSharedPtr TransformExpression(osg::Transform* transform); + /** * Base class for animation installers */