To reduce memory requirements, a single instance of KFbxMesh can be bound to multiple instances of KFbxNode. Imagine that you need a program where all cubes looked alike, but you needed many thousands of them. You could save memory by creating one KFbxMesh object when the program starts up. Then, every time you needed a new cube, you create a new KFbxNode object, then point that node to the one mesh. This is called instancing.
In general, you can save memory by having many node objects share one node attribute object (i.e., one object of any subclass of KFbxNodeAttribute). The following function illustrates how to bind a KFbxMesh to a newly created node.
// Create a cube instance with the given mesh as node attribute, and add it to the scene. KFbxNode* CreateCubeInstance(KFbxScene* pScene, const char* pName, KFbxMesh* pFirstCube) { // create a KFbxNode KFbxNode* lNode = KFbxNode::Create(pScene,pName); // set the node attribute lNode->SetNodeAttribute(pFirstCube); // rescale the cube lNode->LclScaling.Set(KFbxVector4(0.3, 0.3, 0.3)); // Add node to the scene pScene->GetRootNode()->AddChild(lNode); // return the KFbxNode return lNode; }
Each node is an instance of the mesh, NURBS, or other scene element. If you export your scene to an FBX file, instancing also reduces the file size. You can also save memory by having multiple nodes share textures, materials, animation curves, etc.