KhronosGroup / glTF-Blender-IO

Blender glTF 2.0 importer and exporter
https://docs.blender.org/manual/en/latest/addons/import_export/scene_gltf2.html
Apache License 2.0
1.49k stars 317 forks source link

Meshes bound to individual bones don't export correctly #1748

Closed blackears closed 2 years ago

blackears commented 2 years ago

Describe the bug

The glTF exporter incorrectly binds meshes that have been bound to a rig using Bone parenting and the rig is not in bind pose when the exporter is run. This is particularly a problem when exporting humanoid models with animations since eyes are often bound to single bones rather than using automatic weights.

To Reproduce

I've been using Blender's rigify plugin to rig some humanoid models. I have one mesh for the body and a mesh for each eyeball. While the body mesh is parented to the rig using Ctrl-P/Armature Deform/Using Automatic Weights, I bind the eyeballs to individual bones. To do this

The problem with this setup is that if I try to export the mesh when the head is tilted in any position other than the bind position, the eyes in the exported file are in the wrong spot. Because the glTF exporter plays the action animations during the export process, every time I want to re-export I need to select the rig, go into pose mode, select every posed bone and clear all the transforms before exporting again. I also need to make sure that no actions are selected in the action editor. If I don't go through the process every time, the eyes will not be positioned correctly in the exported glTF file.

Expected behavior Since meshes bound using Automatic Weights appear to export correctly even if the mesh is not in bind pose, I would expect meshes bound to individual bones to also export correctly.

Screenshots image image

testMonster.zip

Version

julienduroure commented 2 years ago

Hello, This bug is already fixed on 3.4 alpha.

Note that you have a workaround in 3.3 : use "Use current Frame" option.

If you want to export with 3.4 alpha : On your file, you have set (wrongly) some armature action on your eye.L mesh. Remove it before export. Having an animation (wrong or not) in object parented to bone is currently buggy, but will be fixed by #1749

blackears commented 2 years ago

How is eye.L bound incorrectly? It needs to be bound to the rig so it animates on export. I bound it using the steps I described above. How should it be bound?

I've checked out the latest version of the plugin and tried to use it with blender 3.3, but when I try to export it gives me many errors.

julienduroure commented 2 years ago

eye.L is bound correctly, no issue here.

But you assigned some armature action to this object. That is incorrect. No need to have some action on the mesh. Because of action on armature and parenting of the mesh to the bone, the eye.L will follow. Remove the action on the eye.L object will solve the issue on current 3.4 alpha (or with 3.3 and last version of the plugin)

Capture d’écran du 2022-10-04 19-21-11

1749 is not merge yet, so you can't use the last version of the plugin yet (at least if you not remove the wrong action)