View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# FBX - 4x4 Matrix affine decomposition gone worng?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

2 replies to this topic

### #1Samurai Jack  Members

Posted 08 January 2013 - 03:39 AM

Hello!

I am working on a FBX converter. So, the target is FBX, and the input is a format that has LOCAL MATRICES.

So the rotation, translation and scaling is stored into 4x4 Matrix. Usualy everything goes right except there

are some situations, where objects are turned for 90 or 180 degrees in the wrong direction.

The easisest thing for me would be if I could say: FbxNode->SetLocalMatrix() .

But there is no souch function. I can only say: SetTranslation, SetRotation, SetScaling

and they all require vectors for input. What to do?

I create a FbxAMatrix (affine matrix) and then get the Translation and Rotation vector

out of it. Of course, the rotation is not allways right.

My Idea was, to create a vector with [1,1,1] and then transform it by the original matrix,

get "OriginalOutputVector" and then take the same vector [1,1,1] and transform it

by the Affine Matrix to "AffineOutputVector" and compare them. So I would get

when the affine decomposition went wrong. But how to solve that?

Feel free to post.

### #2L. Spiro  Members

Posted 08 January 2013 - 06:22 PM

You say the rotation vector is not always right, and I am assuming it is those 90- and 180- degree cases.
If so then I will forego the long explanation as to why decomposing matrices can’t give you the exact original data that was entered into it, since this might be a different problem.

Firstly, are you setting the order of transforms correctly on the node? FbxNode::SetRotationOrder().

Secondly I am not sure how you are getting any of the data from the FbxAMatrix because none of those functions exist.
Are you calling FbxAMatrix::GetROnly()? FbxAMatrix::GetR()? FbxAMatrix::GetUnnormalizedQ()?
How are you verifying this data? Are you sure things are wrong coming out of the FbxAMatrix or are they wrong after going into the FbxNode?

Why not post code?

You can also post at their official forums: http://area.autodesk.com/forum/autodesk-fbx/fbx-sdk/

L. Spiro

Edited by L. Spiro, 08 January 2013 - 06:23 PM.

### #3Samurai Jack  Members

Posted 09 January 2013 - 07:33 AM

Hello!

I set the FbxAMatrix with float[16] from my source file:

float f[16];

FbxAMatrix m;
m[0] = FbxVector4(f[0],f[1],f[2],f[3]);
m[1] = FbxVector4(f[4],f[5],f[6],f[7]);
m[2] = FbxVector4(f[8],f[9],f[10],f[11]);
m[3] = FbxVector4(f[12],f[13],f[14],f[15]);

Sofar so good. The FbxAMatrix is set correct, no problems there.

The problems appear when I try to set that roatation and translation data into the FbxNode.

Let us take a test vector[1, 2, 3]

The source matrix is like this:

-0.2016   -0.5842   -0.7862    0.0000
-0.2564   -0.7432    0.6180    0.0000
-0.9453    0.3261   -0.0000    0.0000
0.3173   -0.0200   -0.3904    1.0000

If I put it against the source matrix i get: [  -3.2331,   -1.1121,    0.0593] which is correct.

Now I take the source matrix and say:

FbxVector4 r = src->GetROnly();
FbxVector4 t = src->GetT();

node->LclTranslation.Set(t);
node->LclRotation.Set(r);


What I get is a FbxNode matrix like this:

-0.2016   -0.5842   -0.7862    0.0000
-0.0496   -0.1438    0.1196    0.0000
-1.7902    0.6176   -0.0000    0.0000
0.3173   -0.0200   -0.3904    1.0000

If I now take the vector [1,2,3] and transform it over the matrix I get: [  -5.3543,    0.9612,   -0.9375] which is not the same.

Vector comparison:

A [  -3.2331,   -1.1121,    0.0593]
B [  -5.3543,    0.9612,   -0.9375]

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.