2002-01-24 06:15:39 +08:00
|
|
|
#include <osg/PositionAttitudeTransform>
|
|
|
|
|
|
|
|
using namespace osg;
|
|
|
|
|
|
|
|
PositionAttitudeTransform::PositionAttitudeTransform()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-02-06 05:54:46 +08:00
|
|
|
const bool PositionAttitudeTransform::computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor*) const
|
2002-01-24 06:15:39 +08:00
|
|
|
{
|
2002-02-06 05:54:46 +08:00
|
|
|
if (_mode==MODEL || _mode==MODELVIEW)
|
2002-01-24 06:15:39 +08:00
|
|
|
{
|
2002-02-06 05:54:46 +08:00
|
|
|
matrix.makeRotate(_attitude);
|
|
|
|
matrix.setTrans(_position);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else // _mode==VIEW
|
|
|
|
{
|
|
|
|
matrix.makeTranslate(-_position);
|
|
|
|
matrix.postMult(osg::Matrix::rotate(_attitude.inverse()));
|
|
|
|
return true;
|
2002-01-24 06:15:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-02-06 05:54:46 +08:00
|
|
|
|
|
|
|
const bool PositionAttitudeTransform::computeWorldToLocalMatrix(Matrix& matrix,NodeVisitor*) const
|
2002-01-24 06:15:39 +08:00
|
|
|
{
|
2002-02-06 05:54:46 +08:00
|
|
|
if (_mode==MODEL || _mode==MODELVIEW)
|
|
|
|
{
|
|
|
|
matrix.makeTranslate(-_position);
|
|
|
|
matrix.postMult(osg::Matrix::rotate(_attitude.inverse()));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else // _mode==VIEW
|
2002-01-24 06:15:39 +08:00
|
|
|
{
|
2002-02-06 05:54:46 +08:00
|
|
|
matrix.makeRotate(_attitude);
|
|
|
|
matrix.setTrans(_position);
|
|
|
|
return true;
|
2002-01-24 06:15:39 +08:00
|
|
|
}
|
|
|
|
}
|