1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
14#ifndef OSGSIM_DOFTRANSFORM
15#define OSGSIM_DOFTRANSFORM 1
18#include <osg/Transform>
20#include <osgSim/Export>
24/** DOFTransform - encapsulates Multigen DOF behavior*/
25class OSGSIM_EXPORT DOFTransform : public osg::Transform
32 DOFTransform(const DOFTransform& dof, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
34 META_Node(osgSim, DOFTransform);
36 virtual void traverse(osg::NodeVisitor& nv);
39 void setMinHPR(const osg::Vec3& hpr) { _minHPR = hpr;}
40 const osg::Vec3& getMinHPR() const { return _minHPR;}
42 void setMaxHPR(const osg::Vec3& hpr) {_maxHPR = hpr;}
43 const osg::Vec3& getMaxHPR() const { return _maxHPR;}
45 void setIncrementHPR(const osg::Vec3& hpr) {_incrementHPR = hpr;}
46 const osg::Vec3& getIncrementHPR() const { return _incrementHPR;}
48 void setCurrentHPR(const osg::Vec3& hpr) {_currentHPR = hpr; dirtyBound(); }
49 const osg::Vec3& getCurrentHPR() const {return _currentHPR;}
51 void updateCurrentHPR(const osg::Vec3& hpr);
54 void setMinTranslate(const osg::Vec3& translate) {_minTranslate = translate; }
55 const osg::Vec3& getMinTranslate() const { return _minTranslate;}
57 void setMaxTranslate(const osg::Vec3& translate) {_maxTranslate = translate; }
58 const osg::Vec3& getMaxTranslate() const { return _maxTranslate;}
60 void setIncrementTranslate(const osg::Vec3& translate) { _incrementTranslate = translate; }
61 const osg::Vec3& getIncrementTranslate() const { return _incrementTranslate;}
63 void setCurrentTranslate(const osg::Vec3& translate){ _currentTranslate = translate; dirtyBound(); }
64 inline const osg::Vec3& getCurrentTranslate() const { return _currentTranslate;}
66 void updateCurrentTranslate(const osg::Vec3& translate);
69 void setMinScale(const osg::Vec3& scale) { _minScale = scale;}
70 const osg::Vec3& getMinScale() const { return _minScale;}
72 void setMaxScale(const osg::Vec3& scale) { _maxScale = scale;}
73 const osg::Vec3& getMaxScale() const { return _maxScale;}
75 void setIncrementScale(const osg::Vec3& scale) { _incrementScale = scale;}
76 const osg::Vec3& getIncrementScale() const { return _incrementScale;}
78 void setCurrentScale(const osg::Vec3& scale) { _currentScale = scale; dirtyBound(); }
79 inline const osg::Vec3& getCurrentScale() const { return _currentScale;}
81 void updateCurrentScale(const osg::Vec3& scale);
84 void setPutMatrix(const osg::Matrix& put) { _Put = put; dirtyBound(); }
85 inline const osg::Matrix& getPutMatrix() const {return _Put;}
87 void setInversePutMatrix(const osg::Matrix& inversePut) { _inversePut = inversePut; dirtyBound(); }
88 inline const osg::Matrix& getInversePutMatrix() const {return _inversePut;}
90 void setLimitationFlags(unsigned long flags) { _limitationFlags = flags;}
91 inline unsigned long getLimitationFlags() const {return _limitationFlags;}
103 void setHPRMultOrder(MultOrder order) { _multOrder = order; }
104 inline MultOrder getHPRMultOrder() const { return _multOrder;}
106 void setAnimationOn(bool do_animate);
107 inline bool getAnimationOn() const { return _animationOn; }
109 void animate(float deltaTime);
111 virtual bool computeLocalToWorldMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) const;
113 virtual bool computeWorldToLocalMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) const;
117 virtual ~DOFTransform() {}
119 unsigned int _previousTraversalNumber;
120 double _previousTime;
124 osg::Vec3 _currentHPR;
125 osg::Vec3 _incrementHPR;
127 osg::Vec3 _minTranslate;
128 osg::Vec3 _maxTranslate;
129 osg::Vec3 _currentTranslate;
130 osg::Vec3 _incrementTranslate;
134 osg::Vec3 _currentScale;
135 osg::Vec3 _incrementScale;
138 osg::Matrix _inversePut;
140 unsigned long _limitationFlags;
141 /* bits from left to right
142 0 = x translation limited (2^31)
143 1 = y translation limited (2^30)
144 2 = z translation limited (2^29)
145 3 = pitch limited (2^28)
146 4 = roll limited (2^27)
147 5 = yaw limited (2^26)
148 6 = x scale limited (2^25)
149 7 = y scale limited (2^24)
150 8 = z scale limited (2^23)
156 /** flags indicating whether value is incerasing or decreasing in animation
157 bits form right to left, 1 means increasing while 0 is decreasing
168 unsigned short _increasingFlags;
170 MultOrder _multOrder;