This week I’ve been working on importing Collada animation and skinning into my engine.
I’ve messed with bone animation before. Facewound had bone animation – although the animations were stored in plain text files, and you had to manually type in angles and times for each of the bones.. the internals are still the same.
I hadn’t messed with skinning before. So I wasn’t sure how it was done. But it turned out to be pretty simple. Each Vertex is given a number of bones id’s and weights. Then the bone position is translated along that bone relative to the weight. Simple.
My first attempt was a total car crash. My Collada importer was just a load of experimental code.. and my approach was all wrong. I’ve found that with fCollada it’s best to get all the input data, then go through the scenegraph using that input data. Sounds like common sense, but my first attempt was getting the mesh data, then getting the instances of that mesh, blah blah. Nightmare. My new code is clean as a bean, and only took a couple of hours to throw together.
I did find fCollada so incredibly hard to figure out at first. I was constantly wondering why no-one had made a nice high level wrapper on top of it, which only deals with importing. I’m considering making one now I know a bit more about it all. But at the same time I feel like I probably don’t know enough to do it properly.
Here’s a little tip for anyone that is going to be doing this though:
FCDSceneNodeTools::GenerateSampledAnimation( pSceneNode );
const FloatList& frameList = FCDSceneNodeTools::GetSampledAnimationKeys();
const FMMatrix44List& matList = FCDSceneNodeTools::GetSampledAnimationMatrices();
Assert( matList.size() == frameList.size() );
for ( int i=0; i
FCDSceneNodeTools saved me SO much work (Sadly, it was work I'd already previously done in my messy implementation). They basically compound all the animation into frames, rather than dealing directly with the translations/rotations. It's hard to explain how much work this saves unless you're in the middle of doing it.
Oh yeah, and during all of this I learned to model! When I say model, I mean programmer 'hole filling' modelling. But I learned to rig and skin and animate! Here's the mildly underwhelming result of all this hard work.
The animation represents my joy at getting it all to work. You can download my latest benchtest here to see the animation yourself. (It runs quite slow at the moment, since there's still a lot of boilerplate). Run bin/benchtest.exe to see it. I left the sources to the animations and my converter exe in there if anyone wants to tinker (the converter converts every .dae file in the models folder).
If you get render.dll error you need to install this.