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);
|
virtual void traverse(osg::NodeVisitor& nv);
|
||||||
|
|
||||||
|
|
||||||
void setMinHPR(const osg::Vec3& hpr) { _minHPR = hpr;}
|
void setMinHPR(const osg::Vec3& hpr) { _minHPR = hpr;}
|
||||||
const osg::Vec3& getMinHPR() const { return _minHPR;}
|
const osg::Vec3& getMinHPR() const { return _minHPR;}
|
||||||
|
|
||||||
@ -89,6 +90,18 @@ class OSGSIM_EXPORT DOFTransform : public osg::Transform
|
|||||||
void setLimitationFlags(unsigned long flags) { _limitationFlags = flags;}
|
void setLimitationFlags(unsigned long flags) { _limitationFlags = flags;}
|
||||||
inline unsigned long getLimitationFlags() const {return _limitationFlags;}
|
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 void setAnimationOn(bool do_animate) {_animationOn = do_animate;}
|
||||||
inline bool getAnimationOn() const {return _animationOn;}
|
inline bool getAnimationOn() const {return _animationOn;}
|
||||||
@ -153,6 +166,9 @@ class OSGSIM_EXPORT DOFTransform : public osg::Transform
|
|||||||
8 = z scale
|
8 = z scale
|
||||||
*/
|
*/
|
||||||
unsigned short _increasingFlags;
|
unsigned short _increasingFlags;
|
||||||
|
|
||||||
|
MultOrder _multOrder;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -92,6 +92,16 @@ bool DOFTransform_readLocalData(Object& obj, Input& fr)
|
|||||||
ReadVec3(setIncrementScale,"incrementScale")
|
ReadVec3(setIncrementScale,"incrementScale")
|
||||||
ReadVec3(setCurrentScale,"currentScale")
|
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"))
|
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()<<"incrementScale "<<transform.getIncrementScale()<<std::endl;
|
||||||
fw.indent()<<"currentScale "<<transform.getCurrentScale()<<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()<<"limitationFlags 0x"<<hex<<transform.getLimitationFlags()<<dec<<std::endl;
|
||||||
|
|
||||||
fw.indent()<<"animationOn ";
|
fw.indent()<<"animationOn ";
|
||||||
|
@ -31,7 +31,8 @@ DOFTransform::DOFTransform():
|
|||||||
_previousTime(0.0),
|
_previousTime(0.0),
|
||||||
_limitationFlags(0),
|
_limitationFlags(0),
|
||||||
_animationOn(true),
|
_animationOn(true),
|
||||||
_increasingFlags(0xffff)
|
_increasingFlags(0xffff),
|
||||||
|
_multOrder(PRH)
|
||||||
{
|
{
|
||||||
setNumChildrenRequiringUpdateTraversal(1);
|
setNumChildrenRequiringUpdateTraversal(1);
|
||||||
}
|
}
|
||||||
@ -56,7 +57,8 @@ DOFTransform::DOFTransform(const DOFTransform& dof, const osg::CopyOp& copyop):
|
|||||||
_inversePut(dof._inversePut),
|
_inversePut(dof._inversePut),
|
||||||
_limitationFlags(dof._limitationFlags),
|
_limitationFlags(dof._limitationFlags),
|
||||||
_animationOn(dof._animationOn),
|
_animationOn(dof._animationOn),
|
||||||
_increasingFlags(dof._increasingFlags)
|
_increasingFlags(dof._increasingFlags),
|
||||||
|
_multOrder(dof._multOrder)
|
||||||
{
|
{
|
||||||
setNumChildrenRequiringUpdateTraversal(getNumChildrenRequiringUpdateTraversal()+1);
|
setNumChildrenRequiringUpdateTraversal(getNumChildrenRequiringUpdateTraversal()+1);
|
||||||
}
|
}
|
||||||
@ -92,9 +94,43 @@ bool DOFTransform::computeLocalToWorldMatrix(osg::Matrix& matrix,osg::NodeVisito
|
|||||||
current.makeTranslate(getCurrentTranslate());
|
current.makeTranslate(getCurrentTranslate());
|
||||||
|
|
||||||
//now create the local rotation:
|
//now create the local rotation:
|
||||||
|
if(_multOrder == PRH)
|
||||||
|
{
|
||||||
current.preMult(osg::Matrix::rotate(getCurrentHPR()[1], 1.0, 0.0, 0.0));//pitch
|
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()[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()[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:
|
//and scale:
|
||||||
current.preMult(osg::Matrix::scale(getCurrentScale()));
|
current.preMult(osg::Matrix::scale(getCurrentScale()));
|
||||||
@ -128,11 +164,42 @@ bool DOFTransform::computeWorldToLocalMatrix(osg::Matrix& matrix,osg::NodeVisito
|
|||||||
current.makeTranslate(-getCurrentTranslate());
|
current.makeTranslate(-getCurrentTranslate());
|
||||||
|
|
||||||
//now create the local rotation:
|
//now create the local rotation:
|
||||||
|
if(_multOrder == PRH)
|
||||||
|
{
|
||||||
current.postMult(osg::Matrix::rotate(-getCurrentHPR()[0], 0.0, 0.0, 1.0));//heading
|
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()[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()[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:
|
//and scale:
|
||||||
current.postMult(osg::Matrix::scale(1./getCurrentScale()[0], 1./getCurrentScale()[1], 1./getCurrentScale()[2]));
|
current.postMult(osg::Matrix::scale(1./getCurrentScale()[0], 1./getCurrentScale()[1], 1./getCurrentScale()[2]));
|
||||||
|
Loading…
Reference in New Issue
Block a user