FBX Axis to DirectX Axis Conversion Problem

Started by
4 comments, last by Endemoniada 4 years, 9 months ago

Hi guys, I am exporting my skeletal animation via FBX (from 3ds Max) and it's coming out wrong (see image). The image shows a mesh with a single bone. On the left is how it's supposed to look, I got that by simply setting the bone's transform to the identity, so the mesh part is good. The right side shows what's rendered when I transform by the bone. As you can see, it's rotated 90 degrees CCW around the X-axis. Also, when I do a simple animation of the bone rotating around the X-axis (it's local Z-axis) it goes the wrong way, it should go CCW but it goes CW.

I thought it would be simple to fix, by maybe swapping Y and Z but I've tried so many things. FBX says it uses a Y-up right-handed system, mine is standard DirextX Y-up, positive Z into the screen. Please help, this is making me crazy. Thank you.

 

fbx.jpg

Advertisement

I had similar issues with FBX build-in axis conversion (also unit conversion). Here is what I do for axis conversion now:

1) Compute a transform M which transform from FBX to your system. E.g. some rotation

2) Multiply all vertices by this transform. E.g. v' = M * v

3) For every bone transform B in the skeleton and bind pose you apply a basis change such that B' =  M * B * M^T

4) You do the same for every track in the animation clips

 

Here is how this works. When you apply the bone transform the overall transform looks like this:

v = ( M * B * M^T ) * ( M * v )

You take the transformed vertices and undo the axis transformation. Then you apply the *original* bone transform. Finally you apply the axis transformation again.

 

Let me know how this works.

 

 

2 hours ago, Dirk Gregorius said:

1) Compute a transform M which transform from FBX to your system. E.g. some rotation

I would say that unluckily he has affinely incompatible spaces I believe, where rotation is not sufficient to align them togehther. He will likely need inverse -1 scale around one of the axises.

To OP, you should apply inversing scale at the end of all transformations, as last, also it will mess up your winding order but you can account for that by inverting vertex normals at export time.

Yes, if the det = -1 you would need to fix the winding order as well. But I am not too deep into this right now. If the OP makes the example model available I can have a quick look though...

Hi guys, thanks for helping. I think I got it to work right, I need to double-check though.

I went though a bunch of threads at the official FBX SDK site, many of them old, and just kept trying things. I ended up getting the rotation angle correct by negating some of the rotation angles. At that point all I had to do was swap Y and Z of my transformed skin vertices. Changing the skin vertices after the transform isn't very satisfying but it's good enough for now.

Thanks again.

This topic is closed to new replies.

Advertisement