Add methods to get a node's local and full transform as a 4x4 matrix

actorid
Chris Robinson 13 years ago
parent 441a5c2da2
commit 61f32eca77

@ -210,3 +210,17 @@ void NiSkinInstance::post(NIFFile *nif)
bones[i]->makeBone(i, data->bones[i]);
}
}
Ogre::Matrix4 Node::getLocalTransform()
{
Ogre::Matrix4 mat4;
mat4.makeTransform(trafo.pos, Ogre::Vector3(trafo.scale), Ogre::Quaternion(trafo.rotation));
return mat4;
}
Ogre::Matrix4 Node::getWorldTransform()
{
if(parent != NULL)
return getLocalTransform() * parent->getWorldTransform();
return getLocalTransform();
}

@ -24,6 +24,8 @@
#ifndef _NIF_NODE_H_
#define _NIF_NODE_H_
#include <OgreMatrix4.h>
#include "controlled.hpp"
#include "data.hpp"
#include "property.hpp"
@ -108,6 +110,9 @@ public:
boneTrafo = &bi.trafo;
boneIndex = ind;
}
Ogre::Matrix4 getLocalTransform();
Ogre::Matrix4 getWorldTransform();
};
struct NiNode : Node

Loading…
Cancel
Save