2002-08-05 23:07:18 +08:00
|
|
|
//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield
|
|
|
|
//created by Sasa Bistrovic
|
|
|
|
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
|
|
|
//as published by the Free Software Foundation.
|
|
|
|
|
2002-10-04 21:53:41 +08:00
|
|
|
#ifndef OSG_DOFTRANSFORM
|
|
|
|
#define OSG_DOFTRANSFORM 1
|
2002-08-05 23:07:18 +08:00
|
|
|
|
|
|
|
//base class:
|
2002-10-04 21:53:41 +08:00
|
|
|
#include <osg/Transform>
|
2002-08-05 23:07:18 +08:00
|
|
|
|
|
|
|
namespace osg{
|
|
|
|
/** DOFTransform - encapsulates Multigen DOF behavior*/
|
2002-08-07 01:07:05 +08:00
|
|
|
class SG_EXPORT DOFTransform : public Transform
|
2002-08-05 23:07:18 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** constructor*/
|
|
|
|
DOFTransform();
|
|
|
|
|
|
|
|
/**copy constructor*/
|
|
|
|
DOFTransform(const DOFTransform& dof, const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
2002-08-07 01:07:05 +08:00
|
|
|
Transform(dof, copyop),
|
2002-08-05 23:07:18 +08:00
|
|
|
_minHPR(dof._minHPR),
|
|
|
|
_maxHPR(dof._maxHPR),
|
|
|
|
_currentHPR(dof._currentHPR),
|
|
|
|
_incrementHPR(dof._incrementHPR),
|
|
|
|
_minTranslate(dof._minTranslate),
|
|
|
|
_maxTranslate(dof._maxTranslate),
|
|
|
|
_currentTranslate(dof._currentTranslate),
|
|
|
|
_incrementTranslate(dof._incrementTranslate),
|
|
|
|
_minScale(dof._minScale),
|
|
|
|
_maxScale(dof._maxScale),
|
|
|
|
_currentScale(dof._currentScale),
|
|
|
|
_incrementScale(dof._incrementScale),
|
|
|
|
_Put(dof._Put),
|
|
|
|
_inversePut(dof._inversePut),
|
|
|
|
_limitationFlags(dof._limitationFlags),
|
|
|
|
_animationOn(dof._animationOn),
|
|
|
|
_increasingFlags(dof._increasingFlags) {}
|
|
|
|
|
|
|
|
META_Node(osg, DOFTransform);
|
|
|
|
|
2002-08-12 21:42:43 +08:00
|
|
|
virtual void traverse(NodeVisitor& nv);
|
2002-08-05 23:07:18 +08:00
|
|
|
|
2002-08-28 04:18:43 +08:00
|
|
|
void setMinHPR(const Vec3& hpr) { _minHPR = hpr;}
|
|
|
|
const Vec3& getMinHPR() const { return _minHPR;}
|
|
|
|
|
2002-08-12 21:42:43 +08:00
|
|
|
void setMaxHPR(const Vec3& hpr) {_maxHPR = hpr;}
|
2002-08-28 04:18:43 +08:00
|
|
|
const Vec3& getMaxHPR() const { return _maxHPR;}
|
|
|
|
|
2002-08-12 21:42:43 +08:00
|
|
|
void setIncrementHPR(const Vec3& hpr) {_incrementHPR = hpr;}
|
2002-08-28 04:18:43 +08:00
|
|
|
const Vec3& getIncrementHPR() const { return _incrementHPR;}
|
|
|
|
|
|
|
|
void setCurrentHPR(const Vec3& hpr) {_currentHPR = hpr;}
|
|
|
|
const Vec3& getCurrentHPR() const {return _currentHPR;}
|
2002-08-05 23:07:18 +08:00
|
|
|
|
2002-08-12 21:42:43 +08:00
|
|
|
void updateCurrentHPR(const Vec3& hpr);
|
2002-08-28 04:18:43 +08:00
|
|
|
|
2002-08-05 23:07:18 +08:00
|
|
|
|
2002-08-12 21:42:43 +08:00
|
|
|
void setMinTranslate(const Vec3& translate) {_minTranslate = translate;}
|
2002-08-28 04:18:43 +08:00
|
|
|
const Vec3& getMinTranslate() const { return _minTranslate;}
|
|
|
|
|
2002-08-12 21:42:43 +08:00
|
|
|
void setMaxTranslate(const Vec3& translate) {_maxTranslate = translate;}
|
2002-08-28 04:18:43 +08:00
|
|
|
const Vec3& getMaxTranslate() const { return _maxTranslate;}
|
|
|
|
|
|
|
|
void setIncrementTranslate(const Vec3& translate) { _incrementTranslate = translate;}
|
|
|
|
const Vec3& getIncrementTranslate() const { return _incrementTranslate;}
|
|
|
|
|
|
|
|
void setCurrentTranslate(const Vec3& translate){ _currentTranslate = translate;}
|
|
|
|
inline const Vec3& getCurrentTranslate() const { return _currentTranslate;}
|
2002-08-05 23:07:18 +08:00
|
|
|
|
2002-08-12 21:42:43 +08:00
|
|
|
void updateCurrentTranslate(const Vec3& translate);
|
2002-08-05 23:07:18 +08:00
|
|
|
|
2002-08-12 21:42:43 +08:00
|
|
|
|
2002-08-28 04:18:43 +08:00
|
|
|
void setMinScale(const Vec3& scale) { _minScale = scale;}
|
|
|
|
const Vec3& getMinScale() const { return _minScale;}
|
|
|
|
|
|
|
|
void setMaxScale(const Vec3& scale) { _maxScale = scale;}
|
|
|
|
const Vec3& getMaxScale() const { return _maxScale;}
|
|
|
|
|
|
|
|
void setIncrementScale(const Vec3& scale) { _incrementScale = scale;}
|
|
|
|
const Vec3& getIncrementScale() const { return _incrementScale;}
|
2002-08-05 23:07:18 +08:00
|
|
|
|
2002-08-28 04:18:43 +08:00
|
|
|
void setCurrentScale(const Vec3& scale) { _currentScale = scale;}
|
|
|
|
inline const Vec3& getCurrentScale() const { return _currentScale;}
|
2002-08-05 23:07:18 +08:00
|
|
|
|
2002-08-28 04:18:43 +08:00
|
|
|
void updateCurrentScale(const Vec3& scale);
|
2002-08-05 23:07:18 +08:00
|
|
|
|
|
|
|
|
2002-08-28 04:18:43 +08:00
|
|
|
void setPutMatrix(const Matrix& put) { _Put = put;}
|
2002-08-05 23:07:18 +08:00
|
|
|
inline const Matrix& getPutMatrix() const {return _Put;}
|
2002-08-28 04:18:43 +08:00
|
|
|
|
|
|
|
void setInversePutMatrix(const Matrix& inversePut) { _inversePut = inversePut;}
|
2002-08-05 23:07:18 +08:00
|
|
|
inline const Matrix& getInversePutMatrix() const {return _inversePut;}
|
|
|
|
|
2002-08-28 04:18:43 +08:00
|
|
|
void setLimitationFlags(unsigned long flags) { _limitationFlags = flags;}
|
|
|
|
inline unsigned long getLimitationFlags() const {return _limitationFlags;}
|
|
|
|
|
2002-08-05 23:07:18 +08:00
|
|
|
|
|
|
|
inline void setAnimationOn(bool do_animate) {_animationOn = do_animate;}
|
2002-08-28 04:18:43 +08:00
|
|
|
inline bool getAnimationOn() const {return _animationOn;}
|
2002-08-05 23:07:18 +08:00
|
|
|
|
|
|
|
void animate();
|
|
|
|
|
2002-09-02 20:31:35 +08:00
|
|
|
virtual bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor* nv) const;
|
2002-08-12 21:42:43 +08:00
|
|
|
|
2002-09-02 20:31:35 +08:00
|
|
|
virtual bool computeWorldToLocalMatrix(Matrix& matrix,NodeVisitor* nv) const;
|
2002-08-12 21:42:43 +08:00
|
|
|
|
2002-08-05 23:07:18 +08:00
|
|
|
protected:
|
2003-01-10 17:25:42 +08:00
|
|
|
|
2002-08-05 23:07:18 +08:00
|
|
|
virtual ~DOFTransform() {}
|
|
|
|
|
|
|
|
Vec3 _minHPR;
|
|
|
|
Vec3 _maxHPR;
|
|
|
|
Vec3 _currentHPR;
|
|
|
|
Vec3 _incrementHPR;
|
|
|
|
|
|
|
|
Vec3 _minTranslate;
|
|
|
|
Vec3 _maxTranslate;
|
|
|
|
Vec3 _currentTranslate;
|
|
|
|
Vec3 _incrementTranslate;
|
|
|
|
|
|
|
|
Vec3 _minScale;
|
|
|
|
Vec3 _maxScale;
|
|
|
|
Vec3 _currentScale;
|
|
|
|
Vec3 _incrementScale;
|
|
|
|
|
|
|
|
Matrix _Put;
|
|
|
|
Matrix _inversePut;
|
|
|
|
|
|
|
|
unsigned long _limitationFlags;
|
|
|
|
/* bits from left to right
|
|
|
|
0 = x translation limited (2^31)
|
|
|
|
1 = y translation limited (2^30)
|
|
|
|
2 = z translation limited (2^29)
|
|
|
|
3 = pitch limited (2^28)
|
|
|
|
4 = roll limited (2^27)
|
|
|
|
5 = yaw limited (2^26)
|
|
|
|
6 = x scale limited (2^25)
|
|
|
|
7 = y scale limited (2^24)
|
|
|
|
8 = z scale limited (2^23)
|
|
|
|
|
|
|
|
else reserved
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool _animationOn;
|
|
|
|
/** flags indicating whether value is incerasing or decreasing in animation
|
|
|
|
bits form right to left, 1 means increasing while 0 is decreasing
|
|
|
|
0 = x translation
|
|
|
|
1 = y translation
|
|
|
|
2 = z translation
|
|
|
|
3 = pitch
|
|
|
|
4 = roll
|
|
|
|
5 = yaw
|
|
|
|
6 = x scale
|
|
|
|
7 = y scale
|
|
|
|
8 = z scale
|
|
|
|
*/
|
|
|
|
unsigned short _increasingFlags;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|