Sign in to follow this  
SteveDeFacto

FBX SDK only returning one object from GetChildCount

Recommended Posts

I placed a bunch of objects into the FBX file and doubled checked with the quicktime plugin to make sure they are there but when I run the code below GetChildCount only returns 1 no matter how many objects are in the scene.


KFbxSdkManager* FBXManager;
FBXManager = KFbxSdkManager::Create();
KFbxImporter* FBXImporter;
KFbxScene* FBXScene;
FBXImporter = KFbxImporter::Create( FBXManager, "" );
FBXScene = KFbxScene::Create( FBXManager, "" );
FBXImporter->Initialize( file.c_str(), -1, FBXManager->GetIOSettings() );
FBXImporter->Import( FBXScene );
KFbxNode* Node = FBXScene->GetRootNode();
if(Node)
{
for(DWORD i = 0; i < Node->GetChildCount(); i++)
{
KFbxNodeAttribute::EAttributeType AttributeType = Node->GetChild(i)->GetNodeAttribute()->GetAttributeType();
if ( AttributeType == KFbxNodeAttribute::eLIGHT )
{
KFbxLight* Light = (KFbxLight*) Node->GetChild(i)->GetNodeAttribute();
scene->CreateLight( &AxMatrixTranslation( 0.0f, 0.0f, 0.0f ), &AxVector4Set( 1.0f, Light->Color.Get()[0], Light->Color.Get()[1], Light->Color.Get()[2] ));
}
}
}



What am I doing wrong?!

Share this post


Link to post
Share on other sites
Are all of the nodes children of the root node or of another node, The usual way of doing this would be to use recursion.

Pseudo Code:

GetNodeLights(Scene* scene, KFbxNode* node)
{
KFbxNodeAttribute::EAttributeType AttributeType = Node->GetChild(i)->GetNodeAttribute()->GetAttributeType();
if(AttributeType == KFbxNodeAttribute::eLIGHT){
// Handle Creating the light here
scene->CreateLight(...)
}

for(DWORD i = 0; i < node->GetChildCount(); ++i){
GetNodeLights(scene, node->GetChild(i));
}
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this