I wrote a basic routine to rotate bones based on a predefined frames. It works but not exactly as I expect, as things are now the time to reach the next frame depends on the difference of rotation magnitude between the frames. i.e reaching from frame with rotation 0.2 to frame with rotation 0.8 will take twice as long as reaching from 0.2 to 0.4. I`m looking for a transition between keys that always takes the same amount of time. Bellow is my code
VOID Animate( float time, BoneKeys* Bone, int Base, AnimSetup * Setup, int BoneIndex)
{
/* StringCchPrintfA(message, 1024, " Rot1 %f BoneCh 0 keys base +1 %f ", Bone[0].Rot1, Bone[0].Keys[Base +1].x);
MessageBoxA(NULL, message, "Textures.exe", MB_OK);*/
if (Setup[BoneIndex].firstrun)
{
Bone[BoneIndex].Rot1 = Bone[BoneIndex].Keys[0].x;
Setup[BoneIndex].firstrun = false;
}
if ((Bone[BoneIndex].Rot1*10 > Bone[BoneIndex].Keys[Setup[BoneIndex].Base +1].x *10 - 1) &amp;amp;&amp;amp; (Bone[BoneIndex].Rot1*10 < Bone[BoneIndex].Keys[Setup[BoneIndex].Base +1].x*10 + 1))
{
if(Setup[BoneIndex].Base +1 < 10)
Setup[BoneIndex].Base = Setup[BoneIndex].Base + 1;
}
else
{
if(Bone[BoneIndex].Keys[Setup[BoneIndex].Base].x < Bone[BoneIndex].Keys[Setup[BoneIndex].Base +1].x)
{
Bone[BoneIndex].Rot1 = Bone[BoneIndex].Rot1 + time;
}
if (Bone[BoneIndex].Keys[Setup[BoneIndex].Base].x > Bone[BoneIndex].Keys[Setup[BoneIndex].Base + 1].x)
{
Bone[BoneIndex].Rot1 = Bone[BoneIndex].Rot1 - time;
}
}
}
if (firstrun)
{
BKeys[0].Keys[0].x = -1.4; //right arm
BKeys[0].Keys[1].x = -0.8;
BKeys[0].Keys[2].x = -0.4;
BKeys[0].Keys[3].x = 0.0;
BKeys[0].Rot1 = 0;
BKeys[1].Keys[0].x = 0.8; //right shoulder
BKeys[1].Keys[1].x = 0.8;
BKeys[1].Keys[2].x = -0.2;
BKeys[1].Keys[3].x = -0.5;
BKeys[1].Keys[4].x = -0.7;
BKeys[1].Rot1 = 0;
firstrun = false;
for (int i = 0; i < 8; i++)
{
InitSetup(&amp;ASetup[0], i);
}
}
Animate(nms,&amp;BKeys[0],2,&amp;ASetup[0],0);
Animate(nms, &amp;BKeys[0], 2, &amp;ASetup[0], 1);