simgear/scene/model: expose some animation info for use by Highlight system.
simgear/scene/model/animation.*: added TransformExpression() - returns SGExpressiond if given a SGRotAnimTransform or SGTranslateTransform. simgear/scene/model/SGTranslateTransform.hxx:SGTranslateTransform: added copy of SGExpressiond for use by TransformExpression().
This commit is contained in:
parent
e7cca0c407
commit
50170da13d
@ -24,6 +24,9 @@
|
||||
|
||||
#include <osg/Transform>
|
||||
#include <simgear/math/SGMath.hxx>
|
||||
#include <simgear/structure/SGSharedPtr.hxx>
|
||||
#include <simgear/structure/SGExpression.hxx>
|
||||
|
||||
|
||||
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<SGExpressiond const> _animationValue;
|
||||
|
||||
private:
|
||||
SGVec3d _axis;
|
||||
double _value;
|
||||
|
@ -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<SGExpressiond const> TransformExpression(osg::Transform* transform)
|
||||
{
|
||||
SGSharedPtr<SGExpressiond const> ret;
|
||||
if (auto rot_anim_transform = dynamic_cast<SGRotAnimTransform*>(transform)) {
|
||||
ret = rot_anim_transform->_animationValue;
|
||||
}
|
||||
else if (auto translate_transform = dynamic_cast<SGTranslateTransform*>(transform)) {
|
||||
ret = translate_transform->_animationValue;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -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<SGExpressiond const> TransformExpression(osg::Transform* transform);
|
||||
|
||||
/**
|
||||
* Base class for animation installers
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user