Community
FBX Forum
Welcome to Autodesk’s FBX Forums. Share your knowledge, ask questions, and explore popular FBX topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Node transformations

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
1438 Views, 3 Replies

Node transformations

Hello,

i've been trying to import a FBX file using the FBX SDK but it's not working for me and i cant find any info how to do what i want.
I am trying to:
import a FBX file containing multiple mesh nodes.
I want to convert all vertices (control points?) to to object space.
I'd like to have all vertices in object space (scene global space i gues?) so that i can render them using a single world matrix.
All vertices need to end up in a left-handed coordinate system.

The problem with this however is that some meshes are positioned incorrectly. I am converting the scene to a right handed system like so:
 KFbxAxisSystem axisSystem( KFbxAxisSystem::OpenGL );
if( fbxScene->GetGlobalSettings().GetAxisSystem() != axisSystem )
axisSystem.ConvertScene( fbxScene );

Then when importing a node i've tried converting it's vertices to object space like so:
 KFbxAnimEvaluator* sceneEvaluator = node.node->GetScene()->GetEvaluator();
KFbxXMatrix fbxMatrix = sceneEvaluator->GetNodeGlobalTransform( node.node );
//KFbxXMatrix axisChanger;
//axisChanger.mData = -1;
//fbxMatrix *= axisChanger;
mesh.SetPivot( fbxMatrix );
mesh.ApplyPivot();

The axis changer should convert the model to left handed but that makes the model look even more off from what it should be. Also instead of the Set/Apply-Pivot, i have tried manually transforming every vertex by calling the MultT function, same results.

The problems i'm having is that the x-axis seems to be swapped and nodes are not positioned correctly. I was hoping someone could tell me what i am missing. I could provide screenshots if that helps.
3 REPLIES 3
Message 2 of 4
jiayang.xu
in reply to: Anonymous

Hello Menno, it seems you misunderstood object space, it is not world space.
Please take a look at this:
http://download.autodesk.com/global/docs/maya2012/en_us/index.html?url=files/Transforming_objects_Wo...

In FBX, mesh's control points are stored as in mesh's object space.
So to convert them to as under world space, you need to do something like this:
int lVertexCount = pMesh->GetControlPointsCount();
for(int i = 0; i<lVertexCount; ++i)
{
KFbxVector4 lSrcVertex = pVertexArray;
KFbxVector4& lDstVertex = pVertexArray;

KFbxXMatrix lMeshGlobal =sceneEvaluator->GetNodeGlobalTransform(pMeshNode ) ;
KFbxXMatrix lMeshGeometry = GetGeometry(pMesh->GetNode());
lMeshGlobal *= lMeshGeometry;

lDstVertex = lMeshGlobal.MultT(lSrcVertex);
}

And you description about axis conversion confused me, you mentioned finally you want something under left-handed coordinate, but you are converting things to OpenGL, which is right-handed coordinate.
Please take a look at the following links about left-handed to right-handed, might be helpful:
http://area.autodesk.com/forum/autodesk-fbx/fbx-sdk/kfbxaxissystem-problem/
http://area.autodesk.com/forum/autodesk-fbx/fbx-sdk/axis-system-convertion-bug-/
Message 3 of 4
Anonymous
in reply to: Anonymous

ahh works like a charm. I just missed the geometric transformation, thanks for that 🙂

i'm doing the axis conversion with an identity matrix with the z-axis inverted. I have seen those posts about problems with converting to directX so i converted it to OpenGL and then apply the custom rhs -> lhs conversion.

You are right about about the matrix namings. I'm used to using names from directx/opengl where all vertices in a model are in object space, then transformed by a world matrix into world space. I gues fbx's global space is called world space aswell if you think of one scene being the entire world. However in my case the world is made up of multiple fbx'es so i need to convert all fbx nodes to their respective scene world space (which is called object space when looking at it from opengl point of view).

Just one question, is there a reason your example suggests MultT over Set/Apply-Pivot? I've got this now and it seems to work just fine:
 KFbxAnimEvaluator* sceneEvaluator = node.node->GetScene()->GetEvaluator();
KFbxXMatrix fbxMatrix = sceneEvaluator->GetNodeGlobalTransform( node.node );
fbxMatrix *= GetGeometry( node.node );
KFbxXMatrix axisChanger;
axisChanger.mData = -1;
fbxMatrix = axisChanger * fbxMatrix;
mesh.SetPivot( fbxMatrix );
mesh.ApplyPivot();


either way, thanks again 🙂
Message 4 of 4
jiayang.xu
in reply to: Anonymous

Hello Menno,
Set/Apply-Pivot will actually change the pivot information and the geometry in the FBX scene graph.
It might cause issue later if you want to use original pivot information. But if you are aware of that change, then that's fine.
In your case, what you want is to convert vertex values to world space, there seems no need to actually change the geometry. Use MultiT can just to do an calculation, it won't affect any information that is already in the scene graph in memory.
But it totally depends what you want, both can work.

And thanks for clarifying the coordinate terms. Object/local/global/world are all relative, it depends on from what level we are talking about these coordinates. 🙂

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report