Not a bug

Mirrored rotation curves after FBX Export

maciej.szczesnik 1 month ago updated 3 weeks ago 9

Hello,

Once again - it's a great tool :). But I think, I've found a bug. A lot of times when I have an animation with full 360 rotation on a given axis - say a pirouette, when I export the animation to FBX (update an existing FBX file), the quaternion curves of the rotation are flipped - returning to the same position at the end. Visually everything works fine until you want to edit the curves (smooth them for instance). Please inspect the attached images. The first one shows the Y rotation curve in the editor (this is OK). The second image shows the curve in the FBX file (flipped). It is possible to fix those curves in Blender for instance (you have to select all Quaternion rotation curves one by one, flip them in the Y-axis and move them to match the keys). But it is really time-consuming. 

Rotation in UMotion editor

The same curve in the FBX file (imported to Blender). 


(if you select the second "half" of it, flip it along the Y-axis and match the ends - it works perfectly fine - of course, you have to do it for every quaternion element).

UMotion Version:
1.18
Unity Version:
2019.1.8f1

Answer

Answer
Not a bug

Hi,

I just finished my investigations.


Please note that the *.FBX file format does not support quaternion rotation curves. It can only contain euler curves by definition. So when UMotion is generating the *.FBX file it stores euler curves in it. To check if UMotion is exporting the curves correctly, I exported your animation to *.FBX and then disabled "Resample Animation" in Unity's import settings. This ensures that the original animation curves from inside the *.FBX are used. Then I opened the animimation of the *.FBX file using Unity's native Animation Window and checked the hips curve:

As you can see, the animation curves look fine (and they also play correctly).

One thing I immediately noticed when looking at the blender file, is that the animation curve is a quaternion curve. That means that Blender must have converted the original euler curve to quaternion. Chances are that this conversion process introduces the wrong curve (i.e. it doesn't "ensure quaternion continuity"). So you need to tell Blender somehow to import the original euler curves (probably by importing the model first, then switch all transforms to euler and then import the animations in a second step).

Please let me know in case you have any follow-up questions.

Best regards,
Peter

Under review

Hi,
thank you very much for your bug report. I really appreciate it.

May I ask you to create a small *.unitypackage that includes just what I need to reproduce this behavior (e.g. a UMotion Project and the related character)? Please also add a short description that tells me which bone and which clip in the umotion project shows the problem. That would make it much easier for me to further investigate and fix this issue. You can send the package via the email support form (or send me a request for a link to my dropbox if filesize is too big). 

Thank you very much.

Best regards,
Peter

Hello, 

Sure thing. You can find the unity package attached. It contains of a scene, UMotion project, a character, an exported FBX character and a Blend file (compressed in ZIP) with the problematic section already shown in the Graph editor. Hope it helps!UmotionFBXExportProblem.unitypackage

Hi,
thank you so much for providing the requested files. I'm going to further investigate and keep this thread updated.

Best regards,
Peter

Hi,

Please let me know if I can help any further. A fix or a workaround for that would be great, as manually fixing it is quite tedious. I was looking for a workaround myself but was unable to find one. I've tried to disable the "try to convert to progressive" option during import and not using IK constraints, but it seems that if I have a 180 degrees rotation on any bone, the problem still appears. I can experiment further if you have any ideas on what to check. 

Answer
Not a bug

Hi,

I just finished my investigations.


Please note that the *.FBX file format does not support quaternion rotation curves. It can only contain euler curves by definition. So when UMotion is generating the *.FBX file it stores euler curves in it. To check if UMotion is exporting the curves correctly, I exported your animation to *.FBX and then disabled "Resample Animation" in Unity's import settings. This ensures that the original animation curves from inside the *.FBX are used. Then I opened the animimation of the *.FBX file using Unity's native Animation Window and checked the hips curve:

As you can see, the animation curves look fine (and they also play correctly).

One thing I immediately noticed when looking at the blender file, is that the animation curve is a quaternion curve. That means that Blender must have converted the original euler curve to quaternion. Chances are that this conversion process introduces the wrong curve (i.e. it doesn't "ensure quaternion continuity"). So you need to tell Blender somehow to import the original euler curves (probably by importing the model first, then switch all transforms to euler and then import the animations in a second step).

Please let me know in case you have any follow-up questions.

Best regards,
Peter

Thanks. I wasn't aware of that FBX files store only Euler rotations. I have a small request (or maybe it's a large one) - could you please add support for exporting to BVH files also? I think that Blender is quite important for indie devs. I will search more, but I cannot find a way to import FBX with Euler rotations to Blender - it looks like Blender is baking the animation on import and it converts it to the default Quaternion mode. But one can import BVH files with Euler rotations with ease. That would be super helpful. 

Sorry for double posting, but I've found a workaround that could be helpful for people like me. When the problem appears (it's mostly on the hips), you can:

1) Export the animation from UMotion as NEW FBX file. 

2) Import it in Blender - it will import as a hierarchy of empties (with Euler rotation). 

3) Import your final rig.

4) Change the problematic bones to EULER rotation mode in Blender. 

5) Retarget the animation from empties to your final rig using Bone Constraints (you can look it up here: https://connect.unity.com/p/retargeting-animations-with-blender-2-80

6) Bake the animation in Blender. Blender will bake the rotations taking their Rotation Mode into consideration. 

7) Import to Unity. It will import correctly with Quaternion rotations avoiding gimbal locks.

I've added BVH export to my "ideas for the future" list, but unfortunately I currently don't have immediate plans to include this in one of the next updates.

Thanks for posting your solution on this issue. Of course if you just want to use Blenders curve smoothing feature, you could short-cut your solution and just import and edit the "new FBX" directly (which is imported correctly as euler).

Best regards,
Peter

A "NEW FBX" file, imports to Blender as a hierarchy of empties, not an armature (rig). So it can't be exported to Unity properly. But, since I can retarget those empties to my rig, it's no big deal anymore. Once again, thanks for the tool - it's amazing.