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 FbxObject and FbxProperty connection-management methods such as: FbxObject::ConnectSrcObject(), FbxObject::ConnectDstObject(), FbxProperty::ConnectDstObject(), FbxProperty::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 FbxProperty to be dynamically added to a FbxObject. This gives you the flexibility of defining your own datatype, wrapping it into an FBX property via the FbxProperty::SetUserDataPtr() member function , and binding that property to an FBX object via the FbxObject::ConnectSrcProperty() member function.

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

Before delving into the use of connections in relation to nodes (FbxNode) and node attributes (FbxNodeAttribute), 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 FbxNodes in a FbxScene is used to specify the geometric transformation stack. The classes which inherit from FbxNodeAttribute, for example, FbxMesh, FbxCamera, and FbxLight describe all the elements in the scene. A FbxNodeAttribute is connected to a FbxNode 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 FbxNode::AddChild() method, which adds a child node to the parent node on which the method is called:

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

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

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

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

The following connections will be made:

NOTE:lParentNode is a source object of lScene. Thus, lScene is the destination object of lParentNode.
NOTE:The 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 FbxNode's relationship to a FbxNodeAttribute is normally created by invoking FbxNode::SetNodeAttribute(). As such, an instance of FbxMesh (which inherits from FbxNodeAttribute) can be bound to a node in a scene. In this case:

NOTE:Materials (FbxSurfaceMaterial) are also connected as source objects to FbxNodes. One node can be connected to many materials, and one material can be connected to many nodes (to reduce memory usage). Observe, however, that FbxSurfaceMaterial is not a subclass of FbxNodeAttribute.

"Object-Property" Connection Example: Nodes and Transformations

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