diff --git a/components/nif/nif_file.cpp b/components/nif/nif_file.cpp index 231349302..789bae5e3 100644 --- a/components/nif/nif_file.cpp +++ b/components/nif/nif_file.cpp @@ -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(); +} diff --git a/components/nif/node.hpp b/components/nif/node.hpp index 1f1b91a46..f7d3c6e96 100644 --- a/components/nif/node.hpp +++ b/components/nif/node.hpp @@ -24,6 +24,8 @@ #ifndef _NIF_NODE_H_ #define _NIF_NODE_H_ +#include + #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