FBX SDK Programmer's Guide > Sample Programs > Tutorial Programs >

# Tutorial: SceneTreeView

Shows how to traverse all the nodes in an FBX scene, and how to determine the content of each node, i.e., whether a node contains a camera, a light, a mesh, etc. For more information, see Nodes and the Scene Graph.

Operations include:

- Getting a reference to the root node of a scene.
- Getting references to each of the child nodes.
- Getting references in both directions of a two-way relationship.
- Getting a node’s properties as a point in space.
- Getting a node’s attribute type and contents.

NoteBuilds and runs on Windows only.

Project Organization

The SceneTreeView project is located at <yourFBXSDKpath>\examples\UI Examples\SceneTreeView\.

SceneTreeView has two source files:

Source file | Description
--- | ---
SDK_Utility.cxx | Contains platform-independent code that calls FBX SDK to create the scene, import the file, retrieve data from each node in the scene graph, and add materials, textures, and animation to the cubes. This tutorial explains much of the code in this file.
UI.cxx | Contains the code that interacts with the user and with Windows, and traverses the scene graph to display the tree view of the scene. The code contains some calls to FBX SDK.

User Interface

The SceneTreeView sample program imports an FBX file into an empty scene, then displays the scene graph. The scene graph is more precisely a tree, also called a node hierarchy.

The nodes of the tree refer to the scene elements—the cameras, lights, meshes, skeletons, NURBS, and so forth—that were imported from the FBX file. To display this tree, SceneTreeView must traverse the entire tree, that is, it must visit each node.

Main Logic

SceneTreeView logic:

- Accepts from the user interface the name and path of the file to be imported.
- Loads the import file into the scene.
- Gets a reference to the root node of the scene.

Starting with the root node, SceneTreeView traverses the tree recursively. At each node, SceneTreeView:

- Displays the name and attribute type of the node.
- Displays selected properties of the node, including properties that are stored in the node attribute.
- Gets a reference to each of the children of that node.