Original Post
Hi, I am currently working on a milkshape loader and have gotten everything to work except the rotations in the animation. Here is my code. the qCur->m_fParam are the rotation values (x(0), y(1), z(2)) for the current frame and pPrev are for the previous frame. The translation works fine but the rotation doesn't. It keeps jumping at odd moments.
R3D_Ms3dKeyFrame *pCur = &pJoint->m_RotKeyFrames[frame];
R3D_Ms3dKeyFrame *pPrev = &pJoint->m_RotKeyFrames[frame-1];
// Get the time between the two frames
float fDeltaT = pCur->m_fTime - pPrev->m_fTime;
float fInterp = (fTime - pPrev->m_fTime) / fDeltaT;
D3DXQUATERNION qCur, qPrev, qFinal;
D3DXQuaternionRotationYawPitchRoll(&qCur, pCur->m_fParam[1], pCur->m_fParam[0], pCur->m_fParam[2]);
D3DXQuaternionRotationYawPitchRoll(&qPrev, pPrev->m_fParam[1], pPrev->m_fParam[0], pPrev->m_fParam[2]);
D3DXQuaternionSlerp(&qFinal, &qCur, &qPrev, fInterp);
fRotation[0] = qFinal.x;
fRotation[1] = qFinal.y;
fRotation[2] = qFinal.z;
// Make the matrix 0
m_pJoints.m_matLocal.Zero();
// Rotate the matrix with the original rotation + new rotation
m_pJoints.m_matLocal.Rotate(m_pJoints.m_fRotation[0]+fRotation[0], m_pJoints.m_fRotation[1]+fRotation[1], m_pJoints.m_fRotation[2]+fRotation[2]);
// Translate the matrix with the original translation + new translation
m_pJoints.m_matLocal.SetTranslation(R3DVector(m_pJoints.m_fPosition[0]+fTranslation[0], m_pJoints.m_fPosition[1]+fTranslation[1], m_pJoints.m_fPosition[2]+fTranslation[2]));