Example #1
0
Ogre::Vector3 GetBoneWorldPosition(Ogre::Entity* ent, Ogre::Bone* bone)
{
	Vector3 world_position = bone->_getDerivedPosition();

	//multiply with the parent derived transformation
	Ogre::Node *pParentNode = ent->getParentNode();
	Ogre::SceneNode *pSceneNode = ent->getParentSceneNode();
	while (pParentNode != NULL)
	{
		//process the current i_Node
		if (pParentNode != pSceneNode)
		{
			//this is a tag point (a connection point between 2 entities). which means it has a parent i_Node to be processed
			world_position = pParentNode->_getFullTransform() * world_position;
			pParentNode = pParentNode->getParent();
		}
		else
		{
			//this is the scene i_Node meaning this is the last i_Node to process
			world_position = pParentNode->_getFullTransform() * world_position;
			break;
		}
	}
	return world_position;
}