Skeletal Animation
The importing of animations is done with Assimp, from fbx and dae files.
When creating meshes, it reads the bones that it is using and create the corresponding bone resource. It then reads all the animations of the scene and creates the animation resources, storing the corresponding transformations over time of the bones (linked by name).
When assigning a resource to a component animation, it looks for the used bones inside the gameObjects hierarchy and find them by the name.
On the Update, it loops through all the bones and apply the corresponding transformation to the gameObjects, calculating interpolations if activated, as well as animation blending when changing them.
To do the interpolation, it basically does a Lerp operation of the current frame and the next frame based on the percentage of time elapsed. For animation blending, it temporally keeps the new resource that will be assigned and do interpolation between the frame of the current animation and the first frame of the next animation before finally swaping the animations.
Before the render of the mesh, it calculates a morphed version of it, adapting to the linked bones and rendering it instead of the original one.
Controls
Animation
- Hold 2: animation run
- 1: attack