Skip to content

Conversation

@SAM-tak
Copy link
Contributor

@SAM-tak SAM-tak commented Jun 10, 2023

Overview

This pull request supports exporting models and animations with the Unreal Mannequin bone structure from Blender.

Also, it supports exporting Blender's custom property animation in a format that Unreal Engine can recognize as curve data animation.

To achieve these, we decided to include a modified version of the Blender standard fbx I/O api, instead of using the original one.

The UE Mannequin's bone structure

Basically, the X-axis positive direction is the bone direction, but the right side of the body is inverted on all axes compared to the corresponding left side.

In addition, the pelvis bone and foot bone have the X-axis pointing straight up. (The right foot is further inverted, so the X-axis points straight down)

Also, for some reason, the thigh bone and calf bone have the opposite direction of the bone direction as the X-axis on the left side, and the right side is inverted, so the bone direction is the negative X-axis.

image
image
image

Thus, depending on the part, the correspondence between the bone direction and the transform coordinate axis is different, and it is difficult to handle in Blender, where you cannot set the bone direction and transform coordinate axis independently.

New export options

image

Revert direction of symmetry right side bones

As described above, in UE, the right side bones are inverted on all axes compared to the left side, so this is an option to invert the coordinate axes of the right side bones.

Even if compatibility with Mannequin is not important, this option is useful if you want to use the 'Mirror' function of the Physics Asset Editor, which assumes that the corresponding opposite side bones have all axes inverted.

Apply bone alignments similar to UE Mannequin

Furthermore, it applies the hierarchy-specific alignment process mentioned earlier. That is, it makes the thigh and calf bones face the opposite direction, and the pelvis and foot bones face straight up.

This can only be enabled if 'Revert direction of symmetry right side bones' is enabled.

Disable non-uniform scale animation

image

UE does not support bone animation with individual scale values for each XYZ axis ('non-uniform') by default.

You can enable it by checking the 'Preserve Local Transform' option in the import settings, but it is better not to use it as it may cause performance issues or other problems.

However, in some cases, such as animations generated by Visual Keying for animation retargeting, you may unintentionally end up with non-uniform scale animations. Stretch bone constraints can also cause these unintended non-uniform scale animations.

And it occurs taking a posture that is 180 degrees inverted from what you see in Blender, as shown below.

image

I thought this was a bug in the 'Apply bone alignments similar to UE Mannequin' feature, so I kept this pull request in Draft for a long time. In fact, it was a phenomenon related to the animation specification of UE, and it was not a bug.

By turning on this feature, you can force a uniform scale value when exporting, instead of correcting non-uniform scale values.

Export custom properties animation to Curves UE readable

In 'Preferences > Add-ons > Import-Export: Beldner for Unreal' Panel,

image

If check this 'Export custom properties' check box, add-on export custom properties animation to curve data that UE readable.

image

image

@SAM-tak SAM-tak force-pushed the pr/support-mannequin-bone-coordinate branch from 6ecbde3 to 7ae0d43 Compare June 11, 2023 03:51
@xavier150
Copy link
Owner

xavier150 commented Jun 21, 2023

I'm very busy currently with the game and I only see now your Pull request. Thanks you very much for you work on the addon.
Edit: If you want speak about here my discord: BleuRaven

@SAM-tak
Copy link
Contributor Author

SAM-tak commented Jun 23, 2023

I thought it was complete, so I was planning to submit a Pull Request. However, I discovered an issue with the animation export, so I'm currently working on fixing it. As there is currently no immediate prospect of resolving the issue, this Pull Request may need to be withdrawn.
Once the animation problem is resolved, I will provide a detailed explanation of the changes made.

@xavier150
Copy link
Owner

You want speak about ? You can contact me on Discord @Bleuraven

@xavier150
Copy link
Owner

Hello, I made several changes in the dev branch. I committed some fixes to resolve conflicts.
My plan is to rename classes, functions, and variables in the dev branch to adhere to Blender's best practices.
Additionally, I will separate UI script files and parameters to avoid excessively long files and gain better control over them.

@SAM-tak SAM-tak changed the base branch from Dev to release August 9, 2023 19:07
@SAM-tak SAM-tak force-pushed the pr/support-mannequin-bone-coordinate branch from 6921e9a to 8a01778 Compare August 9, 2023 19:43
@SAM-tak SAM-tak changed the base branch from release to Dev August 10, 2023 05:21
@SAM-tak SAM-tak changed the base branch from Dev to release August 10, 2023 05:43
Fix shape animation exporting bug
Fix script reload failure
Fix typo
@SAM-tak SAM-tak force-pushed the pr/support-mannequin-bone-coordinate branch from 8a01778 to 37a23bf Compare August 10, 2023 06:05
@SAM-tak SAM-tak changed the base branch from release to Dev August 10, 2023 06:05
Copy link
Contributor Author

@SAM-tak SAM-tak left a comment

Choose a reason for hiding this comment

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

  • fbxio\data_types.py
  • fbxio\encode_bin.py
  • fbxio\export_fbx_bin.py
  • fbxio\fbx_utils.py
    these are modified version of Blender's fbx importer/exporter addon located at 'Blender 3.6/3.6/scripts/addons/io_scene_fbx'

**.blend30
**.blend31
**.blend32
**.blend[1-9]*
Copy link
Contributor Author

Choose a reason for hiding this comment

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

By doing this, you can ignore not only .blender1~.blender32, but also blender999 or any other backup files. It will also ignore patterns that are not just numbers, such as .blend1foo, but that should not be a problem in practice.

BFU_AP_UI_UTILS,
BFU_AP_UI_UTILS.BFU_OT_OpenDocumentationTargetPage,
BFU_AP_UI_UTILS.BFU_OT_OpenDocumentationTargetExportPage
BFU_OT_OpenDocumentationTargetPage,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This 'BFU_AP_UI_UTILS' class blocks script reloading.
I remove it simply because BFU_AP_UI_UTILS has no effect.

Comment on lines +29 to +41
if "bpy" in locals():
import importlib
if "bfu_export_utils" in locals():
importlib.reload(bfu_export_utils)
if "bbpl" in locals():
importlib.reload(bbpl)
if "bfu_basics" in locals():
importlib.reload(bfu_basics)
if "bfu_utils" in locals():
importlib.reload(bfu_utils)
if "export_fbx_bin" in locals():
importlib.reload(export_fbx_bin)

Copy link
Contributor Author

@SAM-tak SAM-tak Aug 10, 2023

Choose a reason for hiding this comment

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

this is still needed for script reloading
may be

Comment on lines -120 to +141
my_action_curve_scale = bfu_utils.ActionCurveScale(rrf*active.scale.z)
my_action_curve_scale.ResacleForUnrealEngine()
if not action_curve_scale:
action_curve_scale = bfu_utils.ActionCurveScale(rrf*active.scale.z)
action_curve_scale.ResacleForUnrealEngine()
Copy link
Contributor Author

@SAM-tak SAM-tak Aug 10, 2023

Choose a reason for hiding this comment

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

When there are many Actions, the process of scaling all Actions for each Action export and then returning them to their original scale was very slow, so I made it so that it only do once.

@SAM-tak SAM-tak marked this pull request as ready for review August 10, 2023 07:26
@SAM-tak
Copy link
Contributor Author

SAM-tak commented Aug 10, 2023

@xavier150
I'm sorry for being late. How about this?

@xavier150 xavier150 merged commit 872e604 into xavier150:Dev Aug 28, 2023
@xavier150
Copy link
Owner

Wow that a crazy work! Thank you very much @SAM-tak for your work <3 and sorry for the delay.
I merge it in the Dev Branch. I will do some tests and update the wiki before merge in the Master.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants