Here is the code though I doubt it will help:
void Ovgl::Actor::UpdateAnimation( int bone, Ovgl::Matrix44* matrix, DWORD time )
{
// Initialize animation rotation matrix.
Ovgl::Matrix44 animRot;
Ovgl::Matrix44 animRot2;
animRot = Ovgl::MatrixIdentity();
animRot2 = Ovgl::MatrixIdentity();
// Get animation rotation.
float currentRot[3] = {0};
for( unsigned int a = 0; a < 3; a++)
{
Ovgl::Curve uCurve;
Ovgl::Curve lCurve;
uCurve.time = ULONG_MAX;
uCurve.value = 0;
lCurve.time = 0;
lCurve.value = 0;
// Find two frames that are directly before and after the current time.
for( unsigned int i = 0; i < mesh->bones[bone]->Rot_Keys[a].size(); i++)
{
Ovgl::Curve nCurve = mesh->bones[bone]->Rot_Keys[a];
if(nCurve.time > lCurve.time && nCurve.time < time )
{
lCurve = nCurve;
}
if(nCurve.time < uCurve.time && nCurve.time > time )
{
uCurve = nCurve;
}
}
// If we can't find an upper curve then just set it to the lower curve.
if(uCurve.time == ULONG_MAX)
{
uCurve = lCurve;
}
// Check if we found any frames then interpolate between the two curves.
if(uCurve.time > 0)
{
currentRot[a] = Ovgl::DegToRad(Ovgl::Lerp(lCurve.value, uCurve.value, (float)time / (float)uCurve.time));
}
}
animRot = Ovgl::MatrixRotationEuler(currentRot[0], currentRot[2], currentRot[3]);
// Offset the center of rotation.
animRot2 = Ovgl::MatrixInverse( &Ovgl::Vector4(), &mesh->bones[bone]->matrix.Translation()) * animRot * mesh->bones[bone]->matrix.Translation();
// Get difference from original pose to the animated pose.
matrices[bone] = animRot2 * (*matrix) * Ovgl::MatrixInverse( &Ovgl::Vector4(), &mesh->bones[bone]->matrix);
// Loop through all child bones and update their animations.
for( unsigned int i = 0; i < mesh->bones[bone]->childen.size(); i++)
{
Ovgl::Matrix44 accumulate;
Ovgl::Matrix44 Bone2Parent;
Ovgl::Matrix44 animRot3 = Ovgl::MatrixInverse( &Ovgl::Vector4(), &mesh->bones[mesh->bones[bone]->childen]->matrix.Translation()) * Ovgl::MatrixInverse( &Ovgl::Vector4(),&animRot) * mesh->bones[mesh->bones[bone]->childen]->matrix.Translation();
Bone2Parent = Ovgl::MatrixInverse( &Ovgl::Vector4(), &mesh->bones[bone]->matrix ) * mesh->bones[mesh->bones[bone]->childen]->matrix;
accumulate = animRot3 * animRot2 * (*matrix) * Bone2Parent;
Ovgl::Actor::UpdateAnimation( mesh->bones[bone]->childen, &accumulate, time );
}
}