Hello,
I am 5 days old in FBX SDK so please excuse my lack of knowledge.
I am trying to create a converter which will take the "mesh" data (Vertices, Normals and UV co-ordinates) and transfer them in my customized format.
What I have been trying is as follows:
FbxNode* rootNode = lScene->GetRootNode();
int childCount = rootNode->GetChildCount(false);
for (int i=0; i < childCount; i++)
{
FbxNode* child = rootNode->GetChild(i);
FbxMesh* nodeMesh = child->GetMesh();
}
But I am not getting Mesh in any of the child Nodes and also not in the rootNode. What am I doing wrong?
I have setup the Visual Studio as explained in "Downloading and installing" @ Autodesk FBX.
Any help would be deeply appreciated.
Solved! Go to Solution.
Solved by kevinvandecar. Go to Solution.
Hi,
The rootNode->GetChild(i) function only returns the children immediately underneath the root node. My guess is that you do not actually have any Mesh nodes as immediate children beneath the root node.
Maybe that's it?
Thank you for your reply.
If I want to have these datas i.e, vertices, normals and texture UV co-ordinate then where should I look for them?
I know that the FBX file does have them. Because in FBX viewer I see the texture and the geometry. Also if I convert the same file to Collada format, using FBX Convertor, I get all the three data.
Regards,
Sandeep Patil
You're not walking the entire tree of nodes in the FBX file. You are only checking the root node (which is always empty) and the level of children below that node. You are not checking for children of those nodes below the root node's children - that's your problem.
I would suggest looking at the ViewScene sample program that comes with the SDK.
Walk the code through the SceneContext::LoadFile() function. This function goes through each node of an FBX file, and if the node is a Mesh, it pulls the data into a VBOMesh class.
So look at LoadFile() to learn how to walk through the nodes of a file to figure out which ones are Meshes. Then, when you find a Mesh, the VBOMesh::Initialize() function shows how to pull the data out of it.
I agree… it seems you are not iterating the file correctly. Typically you would do a recursive call on the node tree to get everything. The basic idea is like this:
int main(...)
{
...
FbxNode *rootNode = scene->GetRootNode();
traverseScene( rootNode );
...
}
void traverseScene( FbxNode *currentNode, int level = 0 )
{
// ... process each node ...
// ...
// Recurse on the node children
int numKids = currentNode->GetChildCount();
for (int k = 0; k < numKids; k++)
{
FbxNode *child = currentNode->GetChild(k);
traverseScene(child, level+1);
}
}
I have attached a complete working example which I modified from some sample code we use for training. It iterates the input scene (I included a sample export from 3ds Max) and finds the nodes with FbxMesh attached. When FbxMesh is encountered, it will output some basic data (# of control points and polygons). This is a console app and also exports the scene as an ASCII file (this is handy when trying to determine file structure to look at in ASCII viewer). For complete Mesh handing details, the .\samples\ImportScene\DisplayMesh.cxx code is a great example of getting all the mesh data.
The sample takes one input that is the file name. Also note to build the code, the project is using two environment variables:
ADN_FBXSDK_PATH=<Full path the SDK directory>
ADN_FBXSDK_VER=<SDK version; for example I used 2013.3>
Hope it helps,
Kevin
Can't find what you're looking for? Ask the community or share your knowledge.