OpenSceneGraph/include/osg/PositionAttitudeTransform
Robert Osfield f6934e25ab Made the callback class uses virtual inheritance of osg::Referenced to ensure
that a single class can be used for two different types of callbacks whithout
incurring issues of multiple ref counts and ref()/unref() methods existing.
2002-12-03 17:20:31 +00:00

87 lines
2.6 KiB
Plaintext

//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield
//Distributed under the terms of the GNU Library General Public License (LGPL)
//as published by the Free Software Foundation.
#ifndef OSG_POSITIONATTITIDETRANSFORM
#define OSG_POSITIONATTITIDETRANSFORM 1
#include <osg/Group>
#include <osg/Transform>
#include <osg/AnimationPath>
#include <osg/Quat>
namespace osg {
/** PositionAttitideTransform - is Transform the set the coordinates transform
up via a Vec3 position and Quat attitude.
*/
class SG_EXPORT PositionAttitudeTransform : public Transform
{
public :
PositionAttitudeTransform();
PositionAttitudeTransform(const PositionAttitudeTransform& pat,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
Transform(pat,copyop),
_position(pat._position),
_attitude(pat._attitude),
_pivotPoint(pat._pivotPoint) {}
META_Node(osg, PositionAttitudeTransform);
void setPosition(const Vec3& pos) { _position = pos; dirtyBound(); }
const Vec3& getPosition() const { return _position; }
void setAttitude(const Quat& quat) { _attitude = quat; dirtyBound(); }
const Quat& getAttitude() const { return _attitude; }
void setPivotPoint(const Vec3& pivot) { _pivotPoint = pivot; dirtyBound(); }
const Vec3& getPivotPoint() const { return _pivotPoint; }
virtual bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor* nv) const;
virtual bool computeWorldToLocalMatrix(Matrix& matrix,NodeVisitor* nv) const;
/** Callback which can be attached to a PositionAttitudeTransform
* as an app callback to allow it to follow the path defined by a
* AnimationPath.*/
class SG_EXPORT AnimationPathCallback : public virtual NodeCallback
{
public:
AnimationPathCallback(AnimationPath* ap,double timeOffset=0.0f,double timeMultiplier=1.0f):
_animationPath(ap),
_timeOffset(timeOffset),
_timeMultiplier(timeMultiplier),
_firstTime(0.0) {}
/** implements the callback*/
virtual void operator()(Node* node, NodeVisitor* nv);
ref_ptr<AnimationPath> _animationPath;
double _timeOffset;
double _timeMultiplier;
double _firstTime;
};
protected :
Vec3 _position;
Quat _attitude;
Vec3 _pivotPoint;
};
}
#endif