Creating objects that are destroyed with their scenes
 
 
 

This code snippet creates an SDK manager object, and uses it to create a scene object, and then a node object:

// Create SDK manager
KFbxSdkManager* mySdkManager = KFbxSdkManager::Create();
 
// Create a scene object
KFbxScene* myScene = KFbxScene::Create(mySdkManager, "");
 
// Create a node object
KFbxNode* myNode = KFbxNode::Create(mySdkManager, "");

Although passing the application’s SDK manager object as a parameter is an acceptable way to create objects, we recommend that objects belonging to a given scene be created by passing the scene object as a parameter instead of the SDK manager. This way, these objects will be automatically destroyed when the scene object is destroyed (since they belong to the scene object).

If they were created with the SDK manager object as parameter, they would not be destroyed until the manager is destroyed (and searching for them from the scene would fail).

The example would then become:

// Create SDK manager
KFbxSdkManager* mySdkManager = KFbxSdkManager::Create();
 
// Create a scene object
KFbxScene* myScene = KFbxScene::Create(mySdkManager, "");
 
// Create a node object
KFbxNode* myNode = KFbxNode::Create(myScene, "");