Nodes are primarily used to specify the position, rotation and scale of scene elements within a scene. Nodes are abstracted by the KFbxNode class. A KFbxScene contains a parent-child hierarchy of nodes. The root node of this tree is accessed via KFbxScene::GetRootNode(). As detailed in FBX Scenes, additional nodes can be created and added to this root node.
// Get the root node of the scene. KFbxNode* lRootNode = lScene->GetRootNode(); // Create a child node. KFbxNode* lNode = KFbxNode::Create(lScene, "child"); // Add the child to the root node. lRootNode->AddChild(lNode);
The node hierarchy is traversed using methods such as KFbxNode::GetChild() and KFbxNode::GetParent(). KFbxNode::GetChildCount() returns the number of children of that node.
Nodes are organized in a hierarchy such that the position, rotation and scale of a node is described in relation to its parent's coordinate system. For example, in the diagram below, if the cubeNode is translated by 4 units along the rootNode's x-axis, the lightNode will also be affected by this translation. However, cameraNode will not be affected by this translation because cameraNode is not a child of cubeNode.
The order in which the rotation and scaling transforms are applied to a parent and its children is specified by the node's inherit type (ETransformInheritType). This transformation inheritance can be set using KFbxNode::SetTransformationInheritType(). Consult the KFbxNode class documentation for more details.
As mentioned in Exporting a Scene and FBX Scenes, the root node of the scene is not saved when the scene is exported. Only the recursively descendant children of the root node are exported with the scene. In the diagram above, assume rootNode is the root node of a scene. When the scene is exported, rootNode will not be saved. However, cubeNode, lightNode, and cameraNode will be saved to the file, along with their node attributes.
A mesh, a light, a camera, or any other object present in a scene is typically abstracted by a subclass of KFbxNodeAttribute, for example KFbxMesh, KFbxLight or KFbxCamera. A KFbxNodeAttribute is bound to a KFbxNode to describe its position in the scene. This binding is performed using KFbxNode::SetNodeAttribute().
In the diagram above, the node attribute of KFbxNode* lightNode is a KFbxLight. The position of KFbxLight* light in the scene will therefore depend on the cumulative transformations applied to each node from KFbxNode* rootNode to KFbxNode* lightNode.
More than one node attribute can be bound to a single node. This notion is useful when dealing with meshes of varying levels of detail (LOD). Similarly, one node attribute can be bound to multiple nodes. This technique is known as "instancing", and reduces memory consumption. For more information, see Instancing.
The transformation data of a node includes its translation, rotation and scaling vectors with respect to its parent. This data is represented as a set of KFbxTypedProperty objects, accessible via KFbxNode::LclTranslation, KFbxNode::LclRotation, KFbxNode::LclScaling. Note that the "Lcl" prefix stands for "local".
fbxDouble3 translation = lNode->LclTranslation.Get(); fbxDouble3 rotation = lNode->LclRotation.Get(); fbxDouble3 scaling = lNode->LclScaling.Get();
The transformation data of a node can be limited by a KFbxNodeLimits object, accessible via KFbxNode::GetLimits(). Nodes can also be constrained using KFbxConstraint objects. Consult the class documentation of KFbxNodeLimits, KFbxLimits and KFbxConstraint for more details.
The translation, rotation and scaling properties of a node with respect to the scene's global coordinate system can be expressed as a transformation matrix. This transformation matrix is obtained via KFbxNode::EvaluateGlobalTransform().
Instances of KFbxNode can exist without a bound KFbxNodeAttribute. In this case, such a KFbxNode can be used to group or position its children nodes in the scene.