Jump to content
  • Advertisement
Sign in to follow this  
SteveDeFacto

FBX SDK only returning one object from GetChildCount

This topic is 2846 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!