Model Converter with animation support

XL2

Established Member
Hi!

Here is a tool I wrote but never shared here.
It's a model converter that also allows to export animations to a binary format.
Animations are using compressed keyframes with linear interpolation (similar to Quake 2).
It's per-vertex animation, so you can store your whole model in a single mesh.
The normals are compressed like in Quake 2 (you can see the "anorm.obj" model to see it).

It's what I use in Sonic Z-Treme, so you can swap Sonic's model if you'd like, just make sure the keyframes are matching as the frames are hardcoded in the game.
I've also included the converter's source code, just give me some credits if you use it or modify it.

While I am using SGL directly in my game, I haven't made a standalone SGL version of the model player demo, so I've included the Jo Engine version, just ask me if you want/need a standalone SGL version and I could send you the sprite loading functions, cd loading functions and everything else you'd need to get this working.
This demo also doesn't include the functions to select a proper animation, but it's quite easy, just ask if you need help with it.

Here is the short tutorial (only Blender was tested, it will probably not work with other software) :
1) You need to export one "base" model without animations, which is what you will load at first. Say the name is "Sonic.obj", make sure you also export the materials (which won't be read by the converter, only the "usemtl" name will be read). The textures (TGA files, 32 bpp, no RLE compression) must match that usemtl name. Again, look at the Sonic example.
2) Export your animations, you don't need to export the materials, so you can save some space. It will output something like "Sonic00001.obj" to, say, Sonic00040.obj".
3) Make sure your files, with the TGA textures (again, no compression, 32 bpp) are all in the same folder. Open the converter.
4) It will first ask how many keyframes you have. I think it's 38 for Sonic in Z-Treme. Interpolation factor is 1, scale is 4, then enter the path "IN/SONIC/" and then "Sonic.obj".
That's it!

The converter was very quickly coded, so don't mind too much the actual code, which is a mess that I never cleaned up. It's also using older versions of my map converter, so it's still using fixed points instead of floating points, but I haven't changed that yet.

If you want a dual plane quad, use the "DUAL_" flag in your TGA file (see Tails for an example).
 

Attachments

  • ZTP CONVERTER 0.15.zip
    1.6 MB · Views: 217
  • MODEL_CONVERTER_0.15.zip
    5.3 MB · Views: 221
  • ZT - Model loading (1).zip
    2.7 MB · Views: 212
great tools, thanks for sharing ! just curious, do you tweak the sgl work area ? i don't see anything in the model loading sample.
 
great tools, thanks for sharing ! just curious, do you tweak the sgl work area ? i don't see anything in the model loading sample.
I do in my own game, but for the demo I just used Jo Engine and added some functions since I'm not ready yet to share my own stuff.
So the way it works is that each project can have its own SGL work area to increase vertices count and polygon count. I think in Sonic Z-Treme I set it to 3000 vertices and 2000 polygons, but in the fps game I set it even higher to allow Quake maps. The SGL default is something like 2500 vertices and 1800 polygons.
 
  • Like
Reactions: vbt
Back
Top