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

Feature/add mirror animation option #89070

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Lunatix89
Copy link

@Lunatix89 Lunatix89 commented Mar 1, 2024

This PR adds two things to Godot:

  • Counterparts for all bones in SkeletonProfileHumanoid which can be mirror (like LeftHand <> RightHand)
  • get_bone_counterpart_name to BoneMap and Skeleton3D so we can retrieve a bones counterpart name
  • A module which adds the option and logic to mirror animations via post import plugin

However, during development I've discovered that animations whose rest pose is not in T-Pose will be heavily broken by this implementation.
I think the reason why this works in Unity is that they have an Avatar system which contains a models T-Pose.
Since this avatar is then by individual animations they can always figure out the correct rest pose.

Maybe there is a fix for this problem but I don't have one yet, maybe someone else knows more about this.

@fire
Copy link
Member

fire commented Mar 2, 2024

@SaracenOne Was interested in these workflows.

@Lunatix89 Can you check the new fbx importer?

Copy link
Member

@TokageItLab TokageItLab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SkeletonProfile is available only in the editor and is not available at runtime.

If you want to use SkeletonProfile, this feature must be dedicated to editor only. From looking at the PR code, it appears that this is a function for mirroring on import, but if so, all the code needs to be in the importer.

So, at least Skeleton3D and SkeletonProfile1 will never have bone_counterpart_name property. Even without such a property, as long as you are using SkeletonProfileHumanoid, it is definitely sufficient to use a simple regular expression to map the left and right bones. You can refer to BoneMapper::guess_bone_segregation() for the regular expression.

Footnotes

  1. SkeletonProfileHumanoid is just a template with some constants for SkeletonProfile, but SkeletonProfile needs to be generic. For this reason, it is not a good way that only SkeletonProfileHumanoid have additional property

@TokageItLab
Copy link
Member

TokageItLab commented Mar 2, 2024

BTW, considering the original proposal godotengine/godot-proposals#8478, this feature would seem to be better available on AnimationTrackEditor than on importer. Considering the possibility of creating animations in Godot, having this feature in the importer would not be applicable to it.

FYI, If you want to add SkeletonProfileHumanoid data, the best way would be to create a dedicated SkeletonProfileHumanoid editor. If the feature is only for SkeletonProfileHumanoid, then you can make the SkeletonProfileHumanoid editor to have a left-right mapping of bones that uses each SkeletonProfileHumanoid bone name as a definition. You can also include any other data.

However, this is non-generic and cannot be used for any SkeletonProfile other than Humanoid, so it may be more preferable to have it as an add-on. With this way, you can add a metadata to Skeleton to check if a Skeleton has been imported as a Humanoid.

As I said in godotengine/godot-proposals#8478 (comment), we can come up with many additional features for Humanoid animations, so it might be nice to have one package add-on that brings them all together in a single repository like GodotHumanoidEditor addon.

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

Successfully merging this pull request may close these issues.

Add AnimationPlayer.play_flipped() to play mirrored 3D animations
4 participants