Animations
Working on implementing the animations was pretty fun. The hardest part of it were skeletons and how animations can use the same mesh, but with a different skeleton. I took the animations from Mixamo and testing was pretty hard, mainly because I would get error messages even though I was using the same skeleton for different animations. The issue was that Mixamo might change the skeleton based on the animation, so when importing a new animation the skeleton might not be compatible and the animation was not working.
Importing Animations
I'm using Assimp to import models, skeletons and animations. Importing models was pretty easy, but when I started to deal with animations I understood at what point FBX are weird. Because of how they separate the transforms Assimp has to create "helper" nodes and add them to the skeleton. I had to make a function to collapse those nodes into the actual bone like so:
while (src->mNumChildren == 1 && IsAssimpFbxHelperNode(src->mName.C_Str()))
{
aiMatrix4x4 combinedTransform = src->mTransformation * src->mChildren[0]->mTransformation;
src = src->mChildren[0];
src->mTransformation = combinedTransform;
}
I took the Unreal approach of importing animations. I either pick a skeleton that matches the animation (for now manually, but I'm planning in making it auto select it) and import the animation with it. Or I let the animation create the skeleton. That being said, my AssetManager system is not very efficient right now. It's using handles to track assets and I need to release these handles manually. And when it comes to animations, I can't track both the animation asset and the skeleton so I had to make an Animation System that would do that.
PS: I'm going to refactor the asset system and add actual assets instead of always importing things at runtime with Assimp.
Here is how the skeleton looks. I compared it to Unreal and it almost matches 1:1.
In the next chapter I'll start looking into compute shaders and particles. I already have a particle system with compute shaders in Open GL so moving it to Vulkan shouldn't be that hard.
There are some differences, but only because Unreal doesn't add some bone nodes (because they're never used) and because Assimp and Unreal use different naming conventions.
And now, here's a showcase of the system working.


Comments
Post a Comment