Connections
 
 
 

Visualizing Connections

A connection is an FBX SDK data structure which manages the two-way relationship between FBX objects and/or FBX properties. To guarantee the consistency of connections within the FBX SDK, the actual datastructure is not publically exposed. Instead, connections can be manipulated using the KFbxObject and KFbxProperty connection-management methods such as: KFbxObject::ConnectSrcObject(), KFbxObject::ConnectDstObject(), KFbxProperty::ConnectDstObject(), KFbxProperty::ConnectSrcProperty(), etc.

Connections can be visualized as a destination and source hierarchy of FBX objects and properties.

The destination and source connections in the diagram above are illustrated in the following code samples.

Connecting Objects and Properties

The concept of connections in the FBX SDK allows for instances of KFbxProperty to be dynamically added to a KFbxObject. This gives you the flexibility of defining your own datatype, wrapping it into an FBX property via the KFbxProperty::SetUserDataPtr() member function , and binding that property to an FBX object via the KFbxObject::ConnectSrcProperty() member function.

The KFbxCollection class also relies on connections to organize groups of objects into a hierarchy. For example, the KFbxScene class contains a hierarchy of KFbxNode objects, accessible via KFbxScene::GetRootNode().

Before delving into the use of connections in relation to nodes (KFbxNode) and node attributes (KFbxNodeAttribute), it is recommended that you familiarize yourself with the scene graph organization of the FBX SDK. Consult the Nodes and the Scene Graph section for more information. However, if you are feeling adventurous, the concepts laid out below will give you an intuition of how the scene graph is structured using nodes and their attributes.

As a brief introduction, the hierarchy of KFbxNodes in a KFbxScene is used to specify the geometric transformation stack. The classes which inherit from KFbxNodeAttribute, for example, KFbxMesh, KFbxCamera, and KFbxLight describe all the elements in the scene. A KFbxNodeAttribute is connected to a KFbxNode to specify where the mesh, camera, or light exists in the 3D space.

"Object-Object" Connection Example: Parent-Child Relationships Between Nodes in a Scene

The parent-child relationships between nodes in a scene make use of object connections. Consider the KFbxNode::AddChild() method, which adds a child node to the parent node on which the method is called:

// ... Assume lScene has been initialized as a KFbxScene*,

// Obtain the root node of a scene.
KFbxNode* lParentNode = lScene->GetRootNode();

// Create a child node.
KFbxNode* lChildNode = KFbxNode::Create(lScene, "child");

// Add the child node to the root node.
lParentNode->AddChild(lChildNode);

The following connections will be made:

NotelParentNode is a source object of lScene. Thus, lScene is the destination object of lParentNode.
NoteThe Merging Two Scenes topic explicitly manipulates the connections between nodes to merge the contents of two scenes.

"Object-Object" Connection Example: Nodes and Node Attributes

A KFbxNode's relationship to a KFbxNodeAttribute is normally created by invoking KFbxNode::SetNodeAttribute(). As such, an instance of KFbxMesh (which inherits from KFbxNodeAttribute) can be bound to a node in a scene. In this case:

NoteMaterials (KFbxSurfaceMaterial) are also connected as source objects to KFbxNodes. One node can be connected to many materials, and one material can be connected to many nodes (to reduce memory usage). Observe, however, that KFbxSurfaceMaterial is not a subclass of KFbxNodeAttribute.

"Object-Property" Connection Example: Nodes and Transformations

As mentioned in the Property Data subsection, the local transformation data of a KFbxNode is defined as a KFbxTypedProperty, parametrized with the fbxDouble3 datatype. In this case: