Sunday, November 3, 2019

c++ - File format for static and animated 3D models



I'm currently writing a 3D game in C++ with OpenGL and I'm coming to the part where to load 3D models in. Therefore I'm looking for popular file formats and techniques to



  • display static meshs and

  • render animated meshs.


I've already found quite a large number of possible formats and techniques, like keyframe animations, skeletal animation, MD2 up to MD5, 3DS, X, Collada etc. pp.


For simplicity I'd like to use a format (and technique) that allows both, namely static and animated meshs. So my question is if one format is suitable for that task and which one you'd suggest. And to clarify a bit: I don't need super-smooth animations or brandnew features.


Sidenote: Because I'm a blender fan (but not an expert ;-)) it'd be helpful if it can be used with that -- but of course that shouldn't be the show stopper, here.



Answer



Let me propose you to use Collada.



It's widely supported by DCC tools and well standardized. It supports skeletal animations and .. well, it does almost everything, including shaders and physics - those won't be relevant for you.


Vertex-based animations such as in the MDL or MD2 formats are more or less a relict of the past. Today, most animations are skeletal animations (i.e. think if smoothly-rigged characters) and the content creation tools are optimized for them.


Blender has a working Collada exporter, but as always, exporting stuff from Blender can be annoying. You may need to try alternative exporters or file formats or hack the scripts manually should you experience problems.


To load Collada, use libraries such as FCollada or ColladaDOM (Don't try to parse it on your own, Collada is a really fat XML monster ...). There's also Open Asset Import Library, which loads ~25 file formats, including Collada (and all the other formats you mention). It would be an excellent choice since it aims especially towards game developers and provides its output in a format suitable for real-time rendering. But to be honest: I'm one of its co-authors, so I'm probably a bit biased.


Last but not least: The file format you use to import your assets should not define the abilities of your engine and the techniques it uses - it should rather be the other way round. Whether your animations are super-smooth is not a question of the import format, it's about which technique you use to animate meshes and how good they are modeled in the first place. The import format should just help you bring your data from Blender into your game.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...