mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-21 08:09:41 +00:00
Add methods to get a node's local and full transform as a 4x4 matrix
This commit is contained in:
parent
441a5c2da2
commit
61f32eca77
2 changed files with 19 additions and 0 deletions
|
@ -210,3 +210,17 @@ void NiSkinInstance::post(NIFFile *nif)
|
||||||
bones[i]->makeBone(i, data->bones[i]);
|
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_
|
#ifndef _NIF_NODE_H_
|
||||||
#define _NIF_NODE_H_
|
#define _NIF_NODE_H_
|
||||||
|
|
||||||
|
#include <OgreMatrix4.h>
|
||||||
|
|
||||||
#include "controlled.hpp"
|
#include "controlled.hpp"
|
||||||
#include "data.hpp"
|
#include "data.hpp"
|
||||||
#include "property.hpp"
|
#include "property.hpp"
|
||||||
|
@ -108,6 +110,9 @@ public:
|
||||||
boneTrafo = &bi.trafo;
|
boneTrafo = &bi.trafo;
|
||||||
boneIndex = ind;
|
boneIndex = ind;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ogre::Matrix4 getLocalTransform();
|
||||||
|
Ogre::Matrix4 getWorldTransform();
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NiNode : Node
|
struct NiNode : Node
|
||||||
|
|
Loading…
Reference in a new issue