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

Add option to import actions as additive animations relative to a base pose #27

Open
Noterstone opened this issue Nov 2, 2022 · 11 comments
Assignees
Labels
enhancement New feature or request

Comments

@Noterstone
Copy link

Hello! Is it possible to add a function to add the first frame of the animation (BasePose) to the frames of the additive animation? There are two blending modes for additive animations: LocalSpace and MeshSpace. This could be a very useful feature for many. Blend mode difference: https://docs.unrealengine.com/4.27/en-US/AnimatingObjects/SkeletalMeshAnimation/AimOffset/

@cmbasnett
Copy link
Member

@Noterstone I'm not sure I understand what the feature request is since I'm not familiar with this feature.

Would it be to insert one frame of animation from the "base" pose on other animations?

image

So for example, the Base Idle Pose would be frame 0 and Upward Anim would be frame 1?

@Noterstone
Copy link
Author

To restore an additive animation, you just need to take the first frame of the base animation, and the frame of the additive animation. Everything is simple.

For the case of additive animation in LocalSpace mode blending:

additiveAnimationBone.localPosition += baseFrameBone.localPosition
additiveAnimationBone.localEulerRotation += baseFrameBone.localEulerRotation
//(OR) additiveAnimationBone.localQuaternionRotation*= baseFrameBone.localQuaternionRotation
additiveAnimationBone.localScale *= baseFrameBone.localScale

For the case of additive animation in MeshSpace mode blending:

baseFrameBone.localPosition += baseFrameBone.localPosition
additiveAnimationBone.localEulerRotation = baseFrameBone.localEulerRotation - baseFrameBone.GetParentBone().localEulerRotation
//(OR) additiveAnimationBone.localQuaternionRotation = baseFrameBone.localQuaternionRotation * (baseFrameBone.localQuaternionRotation * InverseQuaternion(baseFrameBone.GetParentBone().localQuaternionRotation))
3)additiveAnimationBone.localScale *= baseFrameBone.localScale

I tried to restore the additive animation that was exposed in LocalSpace. But I couldn't translate position, rotation and scale from POSE space to local space.

psa_additive_anim_restore.py

@Noterstone
Copy link
Author

comment - 91 line

psa_additive_anim_restore.py.txt

@Noterstone
Copy link
Author

Someone managed to do this for 3dsMax (see AdditiveAnimsAlter.ms). I think the functionality can be done for the import plugin for Blender https://github.com/PeterZhenhh/PSA_ImportHelper

@cmbasnett
Copy link
Member

I think I understand now. So you want a new function on the PSA import, where each selected action is imported as though it is an additive animation on top of a specified base pose? If that's the case, that should be simple enough to do. Please confirm if that sounds correct. I just want to make sure I fully understand before I actually write anything! :)

@Noterstone
Copy link
Author

Cool) yes)

@cmbasnett cmbasnett self-assigned this Nov 7, 2022
@cmbasnett cmbasnett added enhancement New feature or request and removed needs more information labels Nov 7, 2022
@cmbasnett
Copy link
Member

@Noterstone Would you be able to provide a PSK and PSA for testing? I prefer to work with real data for testing purposes.

@cmbasnett cmbasnett changed the title Restore additive animations Add option to import actions as additive animations relative to a base pose Nov 7, 2022
@Noterstone
Copy link
Author

Sure, no problem! In the archive, the character, and animations in psa and also in fbx (and the results so that you can check the correctness of the restoration)
ForTest.zip

@Noterstone
Copy link
Author

Noterstone commented Nov 10, 2022

You can also see how it is implemented in UnrealEngine in terms of calculations. The method in which the logic is written begins on the line 1593. The essence of the calculations that takes place there, I described above in the messages.
https://github.com/EpicGames/UnrealEngine/blob/46544fa5e0aa9e6740c19b44b0628b72e7bbd5ce/Engine/Source/Runtime/Engine/Private/Animation/AnimationRuntime.cpp

@cmbasnett
Copy link
Member

Thanks, I'm fairly busy at the moment but I will get around to this eventually. It might also be something that could just be added to Blender's native functionality (e.g., taking one action and transforming it so that is it an additive animation of another action).

@AleksKavil
Copy link

Thanks, I'm fairly busy at the moment but I will get around to this eventually. It might also be something that could just be added to Blender's native functionality (e.g., taking one action and transforming it so that is it an additive animation of another action).

I'm looking forward to you adding this feature

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

No branches or pull requests

3 participants