2002-07-17 04:07:32 +08:00
|
|
|
//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield
|
2002-01-24 06:15:39 +08:00
|
|
|
//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>
|
2002-08-13 23:31:10 +08:00
|
|
|
#include <osg/AnimationPath>
|
2002-01-24 06:15:39 +08:00
|
|
|
#include <osg/Quat>
|
|
|
|
|
|
|
|
namespace osg {
|
|
|
|
|
2002-08-13 23:31:10 +08:00
|
|
|
/** PositionAttitideTransform - is Transform the set the coordinates transform
|
2002-01-24 06:15:39 +08:00
|
|
|
up via a Vec3 position and Quat attitude.
|
|
|
|
*/
|
|
|
|
class SG_EXPORT PositionAttitudeTransform : public Transform
|
|
|
|
{
|
|
|
|
public :
|
|
|
|
PositionAttitudeTransform();
|
|
|
|
|
2002-01-29 22:04:06 +08:00
|
|
|
PositionAttitudeTransform(const PositionAttitudeTransform& pat,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
|
|
|
Transform(pat,copyop),
|
Added support for shallow and deep copy of nodes, drawables and state, via a
copy constructor which takes an optional Cloner object, and the old
osg::Object::clone() has changed so that it now requires a Cloner as paramter.
This is passed on to the copy constructor to help control the shallow vs
deep copying. The old functionality of clone() which was clone of type has
been renamed to cloneType().
Updated all of the OSG to work with these new conventions, implemention all
the required copy constructors etc. A couple of areas will do shallow
copies by design, a couple of other still need to be updated to do either
shallow or deep.
Neither of the shallow or deep copy operations have been tested yet, only
the old functionality of the OSG has been checked so far, such running the
viewer on various demo datasets.
Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which
was not checking that Group didn't have have any attached StateSet's, Callbacks
or UserData. These checks have now been added, which fixes a bug which was
revealled by the new osgscribe demo, this related to removal of group acting
as state decorator.
method
2002-01-29 05:17:01 +08:00
|
|
|
_position(pat._position),
|
2002-08-13 01:40:36 +08:00
|
|
|
_attitude(pat._attitude),
|
|
|
|
_pivotPoint(pat._pivotPoint) {}
|
Added support for shallow and deep copy of nodes, drawables and state, via a
copy constructor which takes an optional Cloner object, and the old
osg::Object::clone() has changed so that it now requires a Cloner as paramter.
This is passed on to the copy constructor to help control the shallow vs
deep copying. The old functionality of clone() which was clone of type has
been renamed to cloneType().
Updated all of the OSG to work with these new conventions, implemention all
the required copy constructors etc. A couple of areas will do shallow
copies by design, a couple of other still need to be updated to do either
shallow or deep.
Neither of the shallow or deep copy operations have been tested yet, only
the old functionality of the OSG has been checked so far, such running the
viewer on various demo datasets.
Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which
was not checking that Group didn't have have any attached StateSet's, Callbacks
or UserData. These checks have now been added, which fixes a bug which was
revealled by the new osgscribe demo, this related to removal of group acting
as state decorator.
method
2002-01-29 05:17:01 +08:00
|
|
|
|
|
|
|
|
2002-06-06 21:25:36 +08:00
|
|
|
META_Node(osg, PositionAttitudeTransform);
|
2002-01-24 06:15:39 +08:00
|
|
|
|
|
|
|
|
2002-08-13 01:40:36 +08:00
|
|
|
void setPosition(const Vec3& pos) { _position = pos; dirtyBound(); }
|
2002-01-24 06:15:39 +08:00
|
|
|
|
|
|
|
const Vec3& getPosition() const { return _position; }
|
|
|
|
|
2002-08-13 01:40:36 +08:00
|
|
|
|
|
|
|
void setAttitude(const Quat& quat) { _attitude = quat; dirtyBound(); }
|
2002-01-24 06:15:39 +08:00
|
|
|
|
|
|
|
const Quat& getAttitude() const { return _attitude; }
|
2002-08-13 01:40:36 +08:00
|
|
|
|
|
|
|
|
|
|
|
void setPivotPoint(const Vec3& pivot) { _pivotPoint = pivot; dirtyBound(); }
|
2002-01-24 06:15:39 +08:00
|
|
|
|
2002-08-13 01:40:36 +08:00
|
|
|
const Vec3& setPivotPoint() const { return _pivotPoint; }
|
|
|
|
|
|
|
|
|
2002-02-06 05:54:46 +08:00
|
|
|
virtual const bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor* nv) const;
|
2002-01-24 06:15:39 +08:00
|
|
|
|
2002-02-06 05:54:46 +08:00
|
|
|
virtual const bool computeWorldToLocalMatrix(Matrix& matrix,NodeVisitor* nv) const;
|
2002-01-24 06:15:39 +08:00
|
|
|
|
2002-08-13 23:31:10 +08:00
|
|
|
|
|
|
|
/** Callback which can be attached to a PositionAttitudeTransform
|
|
|
|
* as an app callback to allow it to follow the path defined by a
|
|
|
|
* AnimationPath.*/
|
2002-08-15 04:56:04 +08:00
|
|
|
class SG_EXPORT AnimationPathCallback : public NodeCallback
|
2002-08-13 23:31:10 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
AnimationPathCallback(AnimationPath* ap):
|
|
|
|
_animationPath(ap),
|
|
|
|
_firstTime(0.0) {}
|
|
|
|
|
|
|
|
/** implements the callback*/
|
|
|
|
virtual void operator()(Node* node, NodeVisitor* nv);
|
|
|
|
|
|
|
|
ref_ptr<AnimationPath> _animationPath;
|
|
|
|
double _firstTime;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-05-29 07:43:22 +08:00
|
|
|
protected :
|
|
|
|
|
|
|
|
|
2002-01-24 06:15:39 +08:00
|
|
|
Vec3 _position;
|
|
|
|
Quat _attitude;
|
2002-08-13 01:40:36 +08:00
|
|
|
Vec3 _pivotPoint;
|
2002-01-24 06:15:39 +08:00
|
|
|
};
|
|
|
|
|
2002-02-03 20:33:41 +08:00
|
|
|
}
|
2002-01-24 06:15:39 +08:00
|
|
|
|
|
|
|
#endif
|