oneMillionWorlds / Tamarin

A VR utilities library for JMonkeyEngine
Other
12 stars 2 forks source link

Bone orientations cannot be preserved via the GLTF import #4

Closed goatchurchprime closed 1 year ago

goatchurchprime commented 2 years ago

At least we got the necessary communication through before the stackexchange editors shut us down!
https://blender.stackexchange.com/questions/250363/armature-becomes-deformed-when-exported-from-blender-into-gltf-format/276862?noredirect=1#comment475360_276862 The problem is that new users cannot post comments, only answers, or I would have done so.

As you have shown, if you design the bones in blender (and save as blend files) you have some control over the bone axis vectors by drawing them in a non-aligned direction. (These blend files give +X vectors. For OpenXR hand tracking we need -Z vectors.)

Now, if you take your blend file, save as GLTF and then reimport the GLTF, (and then save as GLTF again), you get the bones back to their usual +Y alignment:

So it appears that the information loss is happening at the GLTF import function. Blender could have a mode where it preserved the bone orientations on input, but I think their whole UI assumes the bones are always Y-aligned, so they rewrite them.

If everyone operated with blend files, we would have a work-around. However, since most avatars with hands are distributed as GLTF, we have a problem if people try to tweak them in Blender.

Do you think we now have enough evidence to write up a correct answer to your question? (ie 1. You can control the GLTF bone axis by making non-aligned bones, 2. GLTF import is not your friend.)

richardTingle commented 2 years ago

Yes, I never quite got to the bottom of it but I agree the problem seems to be on import. This is why I generated the starter blend files to try to bypass the issue for anyone else. It was a while ago I did this but I think I might have looked at the way that the fbx files from the steam openVR examples looked for inspiration on where the bones should be. Why the bones are supposed to be sticking out of the fingers is beyond me, I would have expected them to be... well... along the fingers, like bones, but that didn't work out.

If everyone operated with blend files, we would have a work-around. However, since most avatars with hands are distributed as GLTF, we have a problem if people try to tweak them in Blender.

I can understand the appeal of that, but JMonkeyEngine tried that (supported .blend files for model upload) but the .blend format isn't stable (it changes with each version of blender) so it was perpetually needing to be updated. Which is kind of fair enough as .blend files are not intended really as an exchange format but for blender itself to save its state.

These blend files give +X vectors. For OpenXR hand tracking we need -Z vectors.

That's interesting, these are for OpenVR, I was hoping that it would be the same though as OpenXR is I think an improved, inspired by OpenVR, standard. Apparently not as similar as I had been hoping. [One day I intend to move JMonkeyEngine and Tamarin over to OpenXR, but never enough time and always too many other interesting things to do]

richardTingle commented 1 year ago

I hope I was able to be helpful, I'm going to close this issue now but feel free to reopen it if anything else comes up