I am making my skinning engine and got it to work for 1 matrix/frame/bone. However that is a huge number of data, so I want to go further and do 1 matrix/keyframe/bone, so I can intepolate the rotation and translation of a bone (scaling is always 1 on each axis, so I am ignoring that). For that I want to decompose a matrix (XMMATRIX structure) for (scaling vector), rotation quaternion and translation vector, interpolate them and reassemble a matrix from them. My code is roughly:
XMMATRIX temp;
{..} //Fill it from a file
temp = XMMatrixTranspose( temp ); //Transposing temp because it was in a shader-readable format
XMVECTOR scal; //for scaling
XMVECTOR quat; //for rotation
XMVECTOR tran; //for translation
XMMatrixDecompose(&scal,&quat,&tran,temp);
XMMATRIX final=XMMatrixIdentity()*XMMatrixScalingFromVector(scal)*XMMatrixRotationQuaternion(quat)*XMMatrixTranslationFromVector(tran);
final = XMMatrixTranspose( final ); //Transposing to get back the shader format
In this short code I try to decompose the correct matrix (temp) and then reassemble in the final matrix, but I do not get the original matrix back. (using the temp matrix gives correct results, but using the final matrix does not)
It seems I am missing something very trivial here, could someone point it out please?
It seems that the correct code was posted, but in my program it was faulty, as I missed one of the transposes.