pingpoli.de



GameDev 2019 Week 33: Animated Models Improvements

New Models, New Code

10.09.2019 - 20:45
This blogpost spans two weeks, however, in the first week I didn't do a lot, because I had other stuff to do. I only created a few more item images and tried a few things with the new Blender version.

Orc Model

On of the most lacking things in the game at the moment is the diversity of enemies. There are only 3 variants of a slime, a bird and a squirrel, and I'm not even sure whether I want to use the bird or the squirrel in the final version of the game. And I am always a bit hesitant to start an animated model in Blender, because I struggle a lot more with animated models than with normal ones. But I started an Orc model anyway. Just modeling the mesh is more difficult, because organic/alive creatures are harder to model than a symmetric building for example. However, I finished most of the mesh on the first day. On the second day I added a few more details to the mesh, like boots, pants and a bone necklace. At that point a non animated model would have been complete, but animated models need a few more steps. Creating the skeleton is quick and easy. But then comes the next and by far the hardest step, which is weight painting. The automatic weight painting never really gets everything right, and then it is time to painstakingly decide for every vertex near the joints which bones affects it how much. Even though in low poly there are less vertices, every vertex matters more in the overall look. Finally, it's time to create the actual animation, which is quite fun, at least when you are not fixing weight painting related issues you only notice now. I need to do more animated models to get more proficient at it.



New Animated Model Code

As mentioned in previous blogposts, my animated model code could use some improvements. It was okay, it did work after all, but two points made it very confusing and complicated. Firstly, the old Blender Collada exporter had no option to change the coordinate axes from Blender to OpenGL, so I had a bunch of special cases in my code to change the coordinate system when loading a Collada model. And secondly, I made my own animation editor, where I could add new keyframes, change existing ones and even add additional animations to a model, which bloated a lot of the code to support these features. The editor worked, but it wasn't really nice to use. So I decided to take the opportunity presented by the new Blender version and its new Collada exporter, which does support a coordinate system change, to redo most of my animated model code. In fact I created a new version and left the old one in the engine, because there are some older models that use that code and I didn't want to break the editor completely, because I may want to fix it in the future(tm). So I started with a new Collada importer ( I could copy a lot from the old importer, but of course there were a few small differences between a Blender 2.79 Collada file and a Blender 2.8 Collada file ). I also added more error checks so when a new Blender version changes something it hopefully catches it ( I very much doubt it could parse a Collada file from any program other than Blender, but I don't have/use any other programs, so I am not going to try it, as long as I don't try there is a small chance it could work, right? ). Unlike the old version, which could support multiple animations in the same file, the new version is only for ONE model with ONE animation, because that's what I need at the moment and it makes the code a lot cleaner. So I created a new skeleton class, which handles the bone animation. I added debug renderers for the bones and realized at that point that the correct coordinate system when exorting really helped, because I could just use the data from the Collada file and didn't need to change anything. The animation played correctly with just the bones. Then I added a new animated model class, which takes all the mesh data and the weights to display the model and it also worked without any coordinate system changes. With the working model animation it was time to make it more convenient to use and add save and load functions to it. I wrote the code more in line with my non animated model code, so animated model templates can be loaded at program start and later new animated models can be created from the templates very easily.

Finally I made a new animated model viewer program which can load Collada files and my own animated model file format and convert from the Collada files to my own format.



Pterodactyl Model

Inspired by the new animated model code I also made a Pterodactyl model in Blender, which was a lot easier to model than the orc.






by Christian - 10.09.2019 - 20:45


Comments


Comments are disabled
Social Media:  © pingpoli.de 2020 All rights reservedCookiesImpressum generated in 7 ms