mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-28 19:15:32 +00:00
58 lines
1.6 KiB
C++
58 lines
1.6 KiB
C++
#include "matrixtransform.hpp"
|
|
|
|
namespace NifOsg
|
|
{
|
|
MatrixTransform::MatrixTransform()
|
|
: osg::MatrixTransform()
|
|
{
|
|
}
|
|
|
|
MatrixTransform::MatrixTransform(int recordIndex, const Nif::Transformation &trafo)
|
|
: osg::MatrixTransform(trafo.toMatrix())
|
|
, mIndex(recordIndex)
|
|
, mScale(trafo.scale)
|
|
, mRotationScale(trafo.rotation)
|
|
{
|
|
}
|
|
|
|
MatrixTransform::MatrixTransform(const MatrixTransform ©, const osg::CopyOp ©op)
|
|
: osg::MatrixTransform(copy, copyop)
|
|
, mIndex(copy.mIndex)
|
|
, mScale(copy.mScale)
|
|
, mRotationScale(copy.mRotationScale)
|
|
{
|
|
}
|
|
|
|
void MatrixTransform::applyCurrentRotation()
|
|
{
|
|
for (int i = 0; i < 3; ++i)
|
|
for (int j = 0; j < 3; ++j)
|
|
_matrix(j,i) = mRotationScale.mValues[i][j]; // NB column/row major difference
|
|
}
|
|
|
|
void MatrixTransform::applyCurrentScale()
|
|
{
|
|
for (int i = 0; i < 3; ++i)
|
|
for (int j = 0; j < 3; ++j)
|
|
_matrix(i,j) *= mScale;
|
|
}
|
|
|
|
void MatrixTransform::updateRotation(const osg::Quat& rotation)
|
|
{
|
|
_matrix.setRotate(rotation);
|
|
for (int i = 0; i < 3; ++i)
|
|
for (int j = 0; j < 3; ++j)
|
|
mRotationScale.mValues[i][j] = _matrix(j,i); // NB column/row major difference
|
|
}
|
|
|
|
void MatrixTransform::updateScale(const float scale)
|
|
{
|
|
mScale = scale;
|
|
applyCurrentScale();
|
|
}
|
|
|
|
void MatrixTransform::setTranslation(const osg::Vec3f& translation)
|
|
{
|
|
_matrix.setTrans(translation);
|
|
}
|
|
}
|