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

Exporting Special Animation Properties #1889

Open Shinmera opened 1 year ago

Shinmera commented 1 year ago

Maybe this is already possible and I'm not understanding how to do it, so please bear with me:

I'm defining IK chains in Blender and animating the influence strength over the animation to ensure foot/hand snapping is only done when appropriate. Now I'd like to also export those chains and the animation of their influence strength to glTF so I can properly import them into my game engine.

I do see that glTF allows custom animation channel target paths, and I've found some references to things that seem similar in the issues like #1007, but I'm not sure if they actually do what I want.

Any pointers would be appreciated!

julienduroure commented 1 year ago

Hello, Exporting "custom" animation is not something possible for now. Only TRS & shapekeys weigths animations are exportable.

In a future (not planned for now), KHR_animation_pointer will let you export some other animations. This will be a good first step to allow exporting custom animations (not included in KHR_animation_pointer specification, but that user want to include in extras fields for example).

For you particular case, right now, all chains will be exported (except if you export only deformation bones) , but not the influence strength.

Let's set it as enhancement, and will be included when working on KHR_animation_pointer

Shinmera commented 1 year ago

I see, good that there's at least a path forward for this. In the interim, is there a way I could write a plugin of my own that hooks into the glTF exporter to pack these animations into the exported gltf?

jhm-ciberman commented 1 year ago

Hello. I have the same problem. I want to export to my game engine a "face index" to make a texture swap for a character face like in old games that uses 2d textures for the character expressions and swap them to animate the face.

I also want to use it for "hand swaps". Have multiple low poly hand models and animate the active one.

Any update with this?

Shinmera commented 7 months ago

I'm working on my own plugin to handle the custom animated properties that I need for my game engine's combat data. I see you have a KHR_animation_pointer branch where the hard part of exporting the animation data seems to have been tackled already. Many thanks for that!

I've been trying to figure out how to hook into that system to make it export the animations for my properties (which are stored in a PropertyGroup and exported as an extension block on the rig node in the glTF). Is there any advice you can give on how to go about that? The code base of this addon is quite vast and not that easy to grok, so any pointers would be much appreciated!

Shinmera commented 6 months ago

@julienduroure I see that KHR_animation_pointer has been merged, thanks a lot for your work! I tried to have a look at the patchset, but it seems like there's quite a bit of wrangling all over to get these pointer properties exported. I'm guessing making this extensible to plugin-defined properties is still up in the air?