I'm trying to get Havok Animation running underneath Ogre's graphics, and while I seem to be really close, I've hit an obstacle. My problem is that the animation is definitely recognizable, but extremely distorted. The skinning appears to be intact, and the transformations appear to correspond with the correct bone, but the animation is represented chaotically. For one animation, the character stayed in its figure pose and I turned its head to look to the left. This resulted in the character's head coming out forward and to the left; The rest of the character's body was still a total mess. The mesh, when no Havok animation is attempted, will appear as it should.
Here is the code that I'm using to translate the pose. Any help that can be offered would be greatly appreciated, and if I'm not giving enough info, please let me know.
void OgreHavok::ApplyHavokPoseToOgreSkeleton(Ogre::Skeleton* ogreskeleton, hkaAnimatedSkeleton* havokskeleton, std::vector<hkaBone*> havokbones){ hkaPose pose(havokskeleton->getSkeleton()); havokskeleton->sampleAndCombineAnimations(pose.accessUnsyncedPoseLocalSpace().begin(), pose.getFloatSlotValues().begin()); int i = 0; for(i; i < havokbones.size(); i++) { if(havokbones.at(i) != HK_NULL) { hkQsTransform transform = pose.getBoneLocalSpace(i); ogreskeleton->getBone(i)->setOrientation(ConvertToOQuaternion(transform.getRotation())); ogreskeleton->getBone(i)->setPosition(ConvertToOVector3(transform.getTranslation())); } }}
And my Quaternion conversion, just in case:
Ogre::Quaternion OgreHavok::ConvertToOQuaternion(const hkQuaternion &quaternion){ hkQuaternion newRotation = quaternion; hkVector4 vec = newRotation.m_vec; Ogre::Quaternion newOgRot( vec(3), vec(0), vec(1), vec(2) ); return newOgRot;}