blender-to-gmstudio / blender-to-smf

Import-Export of Blender model from/to SMF model format
MIT License
11 stars 2 forks source link

Mismatched armature and mesh scales cause problems #22

Open angelwire opened 2 years ago

angelwire commented 2 years ago

When the armature and mesh have different scale values, animations cause the mesh to "explode". You can see that the skeleton lines up perfectly with the mesh in Blender, but after exporting it to SMF and viewing it with the model viewer, the skeleton and mesh aren't aligned.

Here's a link to the blender file: Dropbox link

bartteunis commented 2 years ago

This looks like it is fixed in a1e1a49 in master, though I still need to look into the details of how Blender combines all the transforms (world, armature local, bone, ...) for all kinds of object types. In this case it looks like the scale factor of the armature got applied twice.

When the data of a Blender 'MESH' object that is deformed by an armature object (i.e. the mesh is parented to it and has an armature modifier) is exported, the exporter uses the scene depsgraph to apply all modifiers, so also the armature's 'REST' pose to the mesh's data. The mesh's own transform is not applied because transforms are not a part of what gets applied by getting an evaluated mesh using the depsgraph.