Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gather_animation_hook #2464

Open
evaera opened this issue Jan 22, 2025 · 4 comments
Open

gather_animation_hook #2464

evaera opened this issue Jan 22, 2025 · 4 comments
Labels

Comments

@evaera
Copy link

evaera commented Jan 22, 2025

It seems like there is no exporter hook that exists that can be used to modify the gltf2_io.Animation object. There are hooks for modifying its constituent objects, but none for the object itself.

I think it'd go somewhere around here?

animation = gltf2_io.Animation(
channels=all_channels,
name=blender_action.name,
extras=__gather_extras(blender_action, export_settings),
samplers=[], # This will be generated later, in link_samplers
extensions=None
)

I know that there is pre_gather_animation_hook, but that doesn't grant access to the final object (for obvious reasons..)

I'm trying to make a plugin that renames the glTF animations as they are exported, without changing the name of the associated Blender actions. I want this because our studio is making use of Blender's Collection Exporters feature, and so there is a one-to-many relationship between Blend files and models our game engine sees. (doors.blend may produce "door.glb", "double-door.glb", "sliding-door.glb", etc.)

The issue is that Blender forces name uniqueness across the entire blend file, even though each object might have its own animation. For cleanliness, we'd like to solve this issue in the exporter, so that our .glb files each contain an animation with a consistent name, like "Open", "Close", rather than "Open.001", "Close.004", etc. This is of course solvable on the engine side as well by making the code that finds the animations more complex, but we'd like to consider that as a last resort.

By the way, if this is solvable with the existing export hooks and I just missed something, please let me know!

@evaera
Copy link
Author

evaera commented Jan 23, 2025

After looking at the code some more, maybe an alternative solution that could work is to add a name field to the ActionData object, and copy the Blender Action name into that object when the ActionData is created. Then, when the gltf2_io.Animation object is created, copy the name from the ActionData.name field. This way, I can rename glTF animations as they are exported without the need to add a new hook for plugins, by using the existing gather_actions_hook.

Willing to make a PR for this pending feedback from project management!

@julienduroure
Copy link
Collaborator

Hello,
Thanks for your analysis.
Looks like a good idea at first look.
Let me know when/if you have a PR

@evaera
Copy link
Author

evaera commented Jan 24, 2025

Which of my two proposed approaches did you prefer?

@julienduroure
Copy link
Collaborator

I was think about the ActionData name field

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants