Added supported for setting animation path on MatrixTransform's.

This commit is contained in:
Robert Osfield
2002-12-16 09:55:30 +00:00
parent 22ada7ee6b
commit c6b6e200a4
7 changed files with 291 additions and 3 deletions

View File

@@ -16,12 +16,19 @@ namespace osg {
* Subclassed from Transform::ComputeTransformCallback allows AnimationPath to
* be attached directly to Transform nodes to move subgraphs around the scene.
*/
class SG_EXPORT AnimationPath : public osg::Referenced
class SG_EXPORT AnimationPath : public virtual osg::Object
{
public:
AnimationPath():_loopMode(LOOP) {}
AnimationPath(const AnimationPath& ap, const CopyOp& copyop=CopyOp::SHALLOW_COPY):
Object(ap,copyop),
_timeControlPointMap(ap._timeControlPointMap),
_loopMode(ap._loopMode) {}
META_Object(osg,AnimationPath)
struct ControlPoint
{
ControlPoint():

View File

@@ -28,6 +28,8 @@ class SG_EXPORT MatrixTransform : public Transform
META_Node(osg, MatrixTransform);
virtual void traverse(NodeVisitor& nv);
/** Set the transform's matrix.*/
void setMatrix(const Matrix& mat) { (*_matrix) = mat; _inverseDirty=true; dirtyBound(); }
@@ -79,8 +81,22 @@ class SG_EXPORT MatrixTransform : public Transform
return true;
}
/** Set an optional animation path. */
void setAnimationPath(AnimationPath* ap) { _animationPath = ap; }
/** Get a read only version of the AnimationPath object*/
AnimationPath* getAnimationPath() { return _animationPath.get(); }
/** Get a read only version of the AnimationPath object*/
const AnimationPath* getAnimationPath() const { return _animationPath.get(); }
/** Callback which can be attached to a MatrixTransform as an app
* callback to allow it to follow the path defined by a AnimationPath.*/
* callback to allow it to follow the path defined by a AnimationPath.
* note, now deprecated by attaching an AnimationPath directly to MatrixTransform.*/
class SG_EXPORT AnimationPathCallback : public NodeCallback
{
public:
@@ -107,6 +123,9 @@ class SG_EXPORT MatrixTransform : public Transform
ref_ptr<Matrix> _matrix;
mutable ref_ptr<Matrix> _inverse;
mutable bool _inverseDirty;
osg::ref_ptr<AnimationPath> _animationPath;
};