Well met!
I have a question regarding the transitioning between two (bone-based) animations.
As an example, image a character running. Right in the middle of the stepping-cycle, with one foot in the air, the player decides to cast a spell.
If I now just start the casting-animation, a very noticeable jump is happening. Therefore, I have to transition from one the current skeleton to the first frame of the new one.
I expected that to be done like this:
Animation n;
for(int i=0; i<currentSkeleton.numBones; i++){
KeyFrame start, end;
AnimationTrack t;
start.value = currentAnimation.Frames[currentFrame].matrices[i];
start.time = 0.0f;
end.value = nextAnimation.Frames[0].matrices[i];
end.time = animationTransitionDuration;
t.add(start);
t.add(end);
n.add(t);
}
//The Animation is interpolating like this:
float interpolation = (currentTime - lastKey.time) / (1000.0f/FPS);
*valueToModify = lastKey.value * (1.0f - interpolation) + nextKey.value * interpolation; The final result is kind of right, but not really. Image a foot and a leg, with the foot bend upwards. Trying to transition that to a standing leg results in the foot becoming small and wierd, and then getting bigger again to stretch to the final pose.
I think this is what I am supposed to see with this method of animation-blending, so my question is:
What better method is there to blend from one animation into the other?
Or I am doing the correct thing and just messed something up?
Thank you for your time!