# Skeletal Animation : Rotation !

## Recommended Posts

I'm having a problem in rotation in keyframes, all keyframes and other stuff are read from x file. the bone structure has two matrices, localMat, and the worldMat, which is calculated recursively by multiplying localMat s. when I export Matrix keyframes, it works fine , the localMat, calculation part looks like this:
	hmrMatrix3 transformMat( nextKey.m - key.m );
float s = (time - key.t) / (nextKey.t - key.t);
_bone->_localMat = transformMat * s + key.m;

but when I export quaternions, the animation gets messed up :
	hmrMatrix3 mat;
float s = (time - key.t) / (nextKey.t - key.t);
hmrQuaternion q = hmrQuaternion::slerp(key.q, nextKey.q, s);
mat.setRotation( q );
_bone->_localMat *= mat;

I thought the problem is with slerp or setting up matrix rotation calculations, but I tested it with D3DX functions and matrices too, and nothing chenged. am I doing something wrong here ?

##### Share on other sites
anyone ?
I've read somewhere that if I use, D3DXMatrixRoatationQuaternion, I must also transpose the matrix, which I did, but I get messed up results as usual.

another thing, when i read X file, the keyframe is formated something like this:
  AnimationKey {   0;   61;   0;4;-0.707107,-0.000000,0.707107,0.000000;;, <----------- quaternion   ....

the quaternion key is stored in [time][numValues][w][x][y][z], am I right ?

could someone at least, help me with the transform matrix calculation part, and confirm if it is correct ?

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627689
• Total Posts
2978659

• 18
• 14
• 12
• 10
• 12