From Joakim Simonsson, add s/getHPROrder method
This commit is contained in:
parent
add06bab8d
commit
4571238459
@ -35,6 +35,7 @@ class OSGSIM_EXPORT DOFTransform : public osg::Transform
|
||||
|
||||
virtual void traverse(osg::NodeVisitor& nv);
|
||||
|
||||
|
||||
void setMinHPR(const osg::Vec3& hpr) { _minHPR = hpr;}
|
||||
const osg::Vec3& getMinHPR() const { return _minHPR;}
|
||||
|
||||
@ -48,14 +49,14 @@ class OSGSIM_EXPORT DOFTransform : public osg::Transform
|
||||
const osg::Vec3& getCurrentHPR() const {return _currentHPR;}
|
||||
|
||||
void updateCurrentHPR(const osg::Vec3& hpr);
|
||||
|
||||
|
||||
|
||||
void setMinTranslate(const osg::Vec3& translate) {_minTranslate = translate;}
|
||||
const osg::Vec3& getMinTranslate() const { return _minTranslate;}
|
||||
|
||||
|
||||
void setMaxTranslate(const osg::Vec3& translate) {_maxTranslate = translate;}
|
||||
const osg::Vec3& getMaxTranslate() const { return _maxTranslate;}
|
||||
|
||||
|
||||
void setIncrementTranslate(const osg::Vec3& translate) { _incrementTranslate = translate;}
|
||||
const osg::Vec3& getIncrementTranslate() const { return _incrementTranslate;}
|
||||
|
||||
@ -89,6 +90,18 @@ class OSGSIM_EXPORT DOFTransform : public osg::Transform
|
||||
void setLimitationFlags(unsigned long flags) { _limitationFlags = flags;}
|
||||
inline unsigned long getLimitationFlags() const {return _limitationFlags;}
|
||||
|
||||
enum MultOrder
|
||||
{
|
||||
PRH,
|
||||
PHR,
|
||||
HPR,
|
||||
HRP,
|
||||
RPH,
|
||||
RHP
|
||||
};
|
||||
|
||||
void setHPRMultOrder(const MultOrder order) {_multOrder = order;}
|
||||
inline const MultOrder getHPRMultOrder() const { return _multOrder;}
|
||||
|
||||
inline void setAnimationOn(bool do_animate) {_animationOn = do_animate;}
|
||||
inline bool getAnimationOn() const {return _animationOn;}
|
||||
@ -153,7 +166,10 @@ class OSGSIM_EXPORT DOFTransform : public osg::Transform
|
||||
8 = z scale
|
||||
*/
|
||||
unsigned short _increasingFlags;
|
||||
};
|
||||
|
||||
MultOrder _multOrder;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -91,6 +91,16 @@ bool DOFTransform_readLocalData(Object& obj, Input& fr)
|
||||
ReadVec3(setMaxScale,"maxScale")
|
||||
ReadVec3(setIncrementScale,"incrementScale")
|
||||
ReadVec3(setCurrentScale,"currentScale")
|
||||
|
||||
if (fr[0].matchWord("multOrder"))
|
||||
{
|
||||
if (fr[1].matchWord("PRH")) dof.setHPRMultOrder(DOFTransform::PRH);
|
||||
else if(fr[1].matchWord("PHR")) dof.setHPRMultOrder(DOFTransform::PHR);
|
||||
else if(fr[1].matchWord("HPR")) dof.setHPRMultOrder(DOFTransform::HPR);
|
||||
else if(fr[1].matchWord("HRP")) dof.setHPRMultOrder(DOFTransform::HRP);
|
||||
else if(fr[1].matchWord("RHP")) dof.setHPRMultOrder(DOFTransform::RHP);
|
||||
else if(fr[1].matchWord("RPH")) dof.setHPRMultOrder(DOFTransform::RPH);
|
||||
}
|
||||
|
||||
|
||||
if (fr.matchSequence("limitationFlags %i"))
|
||||
@ -151,6 +161,10 @@ bool DOFTransform_writeLocalData(const Object& obj, Output& fw)
|
||||
fw.indent()<<"incrementScale "<<transform.getIncrementScale()<<std::endl;
|
||||
fw.indent()<<"currentScale "<<transform.getCurrentScale()<<std::endl;
|
||||
|
||||
|
||||
const char* mOrderStr[] = {"PRH", "PHR", "HPR", "HRP", "RPH", "RHP"};
|
||||
fw.indent()<<"multOrder "<<mOrderStr[transform.getHPRMultOrder()]<<std::endl;
|
||||
|
||||
fw.indent()<<"limitationFlags 0x"<<hex<<transform.getLimitationFlags()<<dec<<std::endl;
|
||||
|
||||
fw.indent()<<"animationOn ";
|
||||
|
@ -31,7 +31,8 @@ DOFTransform::DOFTransform():
|
||||
_previousTime(0.0),
|
||||
_limitationFlags(0),
|
||||
_animationOn(true),
|
||||
_increasingFlags(0xffff)
|
||||
_increasingFlags(0xffff),
|
||||
_multOrder(PRH)
|
||||
{
|
||||
setNumChildrenRequiringUpdateTraversal(1);
|
||||
}
|
||||
@ -56,7 +57,8 @@ DOFTransform::DOFTransform(const DOFTransform& dof, const osg::CopyOp& copyop):
|
||||
_inversePut(dof._inversePut),
|
||||
_limitationFlags(dof._limitationFlags),
|
||||
_animationOn(dof._animationOn),
|
||||
_increasingFlags(dof._increasingFlags)
|
||||
_increasingFlags(dof._increasingFlags),
|
||||
_multOrder(dof._multOrder)
|
||||
{
|
||||
setNumChildrenRequiringUpdateTraversal(getNumChildrenRequiringUpdateTraversal()+1);
|
||||
}
|
||||
@ -92,9 +94,43 @@ bool DOFTransform::computeLocalToWorldMatrix(osg::Matrix& matrix,osg::NodeVisito
|
||||
current.makeTranslate(getCurrentTranslate());
|
||||
|
||||
//now create the local rotation:
|
||||
current.preMult(osg::Matrix::rotate(getCurrentHPR()[1], 1.0, 0.0, 0.0));//pitch
|
||||
current.preMult(osg::Matrix::rotate(getCurrentHPR()[2], 0.0, 1.0, 0.0));//roll
|
||||
current.preMult(osg::Matrix::rotate(getCurrentHPR()[0], 0.0, 0.0, 1.0));//heading
|
||||
if(_multOrder == PRH)
|
||||
{
|
||||
current.preMult(osg::Matrix::rotate(getCurrentHPR()[1], 1.0, 0.0, 0.0));//pitch
|
||||
current.preMult(osg::Matrix::rotate(getCurrentHPR()[2], 0.0, 1.0, 0.0));//roll
|
||||
current.preMult(osg::Matrix::rotate(getCurrentHPR()[0], 0.0, 0.0, 1.0));//heading
|
||||
}
|
||||
else if(_multOrder == PHR)
|
||||
{
|
||||
current.preMult(osg::Matrix::rotate(getCurrentHPR()[1], 1.0, 0.0, 0.0));//pitch
|
||||
current.preMult(osg::Matrix::rotate(getCurrentHPR()[0], 0.0, 0.0, 1.0));//heading
|
||||
current.preMult(osg::Matrix::rotate(getCurrentHPR()[2], 0.0, 1.0, 0.0));//roll
|
||||
}
|
||||
else if(_multOrder == HPR)
|
||||
{
|
||||
current.preMult(osg::Matrix::rotate(getCurrentHPR()[0], 0.0, 0.0, 1.0));//heading
|
||||
current.preMult(osg::Matrix::rotate(getCurrentHPR()[1], 1.0, 0.0, 0.0));//pitch
|
||||
current.preMult(osg::Matrix::rotate(getCurrentHPR()[2], 0.0, 1.0, 0.0));//roll
|
||||
}
|
||||
else if(_multOrder == HRP)
|
||||
{
|
||||
current.preMult(osg::Matrix::rotate(getCurrentHPR()[0], 0.0, 0.0, 1.0));//heading
|
||||
current.preMult(osg::Matrix::rotate(getCurrentHPR()[2], 0.0, 1.0, 0.0));//roll
|
||||
current.preMult(osg::Matrix::rotate(getCurrentHPR()[1], 1.0, 0.0, 0.0));//pitch
|
||||
}
|
||||
else if(_multOrder == RHP)
|
||||
{
|
||||
current.preMult(osg::Matrix::rotate(getCurrentHPR()[2], 0.0, 1.0, 0.0));//roll
|
||||
current.preMult(osg::Matrix::rotate(getCurrentHPR()[0], 0.0, 0.0, 1.0));//heading
|
||||
current.preMult(osg::Matrix::rotate(getCurrentHPR()[1], 1.0, 0.0, 0.0));//pitch
|
||||
}
|
||||
else // _multOrder == RPH
|
||||
{
|
||||
current.preMult(osg::Matrix::rotate(getCurrentHPR()[2], 0.0, 1.0, 0.0));//roll
|
||||
current.preMult(osg::Matrix::rotate(getCurrentHPR()[1], 1.0, 0.0, 0.0));//pitch
|
||||
current.preMult(osg::Matrix::rotate(getCurrentHPR()[0], 0.0, 0.0, 1.0));//heading
|
||||
}
|
||||
|
||||
|
||||
//and scale:
|
||||
current.preMult(osg::Matrix::scale(getCurrentScale()));
|
||||
@ -128,11 +164,42 @@ bool DOFTransform::computeWorldToLocalMatrix(osg::Matrix& matrix,osg::NodeVisito
|
||||
current.makeTranslate(-getCurrentTranslate());
|
||||
|
||||
//now create the local rotation:
|
||||
|
||||
|
||||
current.postMult(osg::Matrix::rotate(-getCurrentHPR()[0], 0.0, 0.0, 1.0));//heading
|
||||
current.postMult(osg::Matrix::rotate(-getCurrentHPR()[2], 0.0, 1.0, 0.0));//roll
|
||||
current.postMult(osg::Matrix::rotate(-getCurrentHPR()[1], 1.0, 0.0, 0.0));//pitch
|
||||
if(_multOrder == PRH)
|
||||
{
|
||||
current.postMult(osg::Matrix::rotate(-getCurrentHPR()[0], 0.0, 0.0, 1.0));//heading
|
||||
current.postMult(osg::Matrix::rotate(-getCurrentHPR()[2], 0.0, 1.0, 0.0));//roll
|
||||
current.postMult(osg::Matrix::rotate(-getCurrentHPR()[1], 1.0, 0.0, 0.0));//pitch
|
||||
}
|
||||
else if(_multOrder == PHR)
|
||||
{
|
||||
current.postMult(osg::Matrix::rotate(-getCurrentHPR()[2], 0.0, 1.0, 0.0));//roll
|
||||
current.postMult(osg::Matrix::rotate(-getCurrentHPR()[0], 0.0, 0.0, 1.0));//heading
|
||||
current.postMult(osg::Matrix::rotate(-getCurrentHPR()[1], 1.0, 0.0, 0.0));//pitch
|
||||
}
|
||||
else if(_multOrder == HPR)
|
||||
{
|
||||
current.postMult(osg::Matrix::rotate(-getCurrentHPR()[2], 0.0, 1.0, 0.0));//roll
|
||||
current.postMult(osg::Matrix::rotate(-getCurrentHPR()[1], 1.0, 0.0, 0.0));//pitch
|
||||
current.postMult(osg::Matrix::rotate(-getCurrentHPR()[0], 0.0, 0.0, 1.0));//heading
|
||||
}
|
||||
else if(_multOrder == HRP)
|
||||
{
|
||||
current.postMult(osg::Matrix::rotate(-getCurrentHPR()[1], 1.0, 0.0, 0.0));//pitch
|
||||
current.postMult(osg::Matrix::rotate(-getCurrentHPR()[2], 0.0, 1.0, 0.0));//roll
|
||||
current.postMult(osg::Matrix::rotate(-getCurrentHPR()[0], 0.0, 0.0, 1.0));//heading
|
||||
}
|
||||
else if(_multOrder == RHP)
|
||||
{
|
||||
current.postMult(osg::Matrix::rotate(-getCurrentHPR()[1], 1.0, 0.0, 0.0));//pitch
|
||||
current.postMult(osg::Matrix::rotate(-getCurrentHPR()[0], 0.0, 0.0, 1.0));//heading
|
||||
current.postMult(osg::Matrix::rotate(-getCurrentHPR()[2], 0.0, 1.0, 0.0));//roll
|
||||
}
|
||||
else // _multOrder == MultOrder::RPH
|
||||
{
|
||||
current.postMult(osg::Matrix::rotate(-getCurrentHPR()[0], 0.0, 0.0, 1.0));//heading
|
||||
current.postMult(osg::Matrix::rotate(-getCurrentHPR()[1], 1.0, 0.0, 0.0));//pitch
|
||||
current.postMult(osg::Matrix::rotate(-getCurrentHPR()[2], 0.0, 1.0, 0.0));//roll
|
||||
}
|
||||
|
||||
//and scale:
|
||||
current.postMult(osg::Matrix::scale(1./getCurrentScale()[0], 1./getCurrentScale()[1], 1./getCurrentScale()[2]));
|
||||
|
Loading…
Reference in New Issue
Block a user