Tutorial: CubeCreator
 
 
 

This tutorial program shows how to add textures, materials, and animation to meshes representing a model (in this case, a cube). Operations include:

High level operations Low level operations
Constructing the baseline scene
  • Defining the animation stack and animation layer that will contain the animation.
  • Creating a marker to be used as a reference point.
  • Creating a camera.
  • Creating one texture available to all cubes.
  • Embedding media files in an FBX file.
  • Processing FBX files that contain embedded media.
  • Processing scene files with references to media.
  • Creating an array of materials to be shared.
  • Pointing the camera at the marker.
  • Setting the position of the marker.
  • Setting the position of the camera.
Adding animation to the camera
  • Constructing the initial scene graph.
  • Setting a camera as the scene’s default camera.
  • Adding a cube to the scene.
  • Setting the cube’s name, position, and rotation.
  • Applying the user’s specifications to the cube.
  • Setting the cube’s position in the scene.
  • Creating a mesh for the cube.
  • Defining the cube’s vertices and the normals.
  • Defining the cube’s faces.
  • Using layer 0 to store a normal to each face.
  • Creating a layer element for the materials and textures.
  • Saving memory by sharing a mesh among multiple nodes.
  • Adding animation to a cube.
  • Adding a texture to a cube.
Adding a material to a cube No lower-level operations.
NoteBuilds and runs on Windows only.

Project Organization

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

CubeCreator has two source files:

Source file Description
SDK_Utility.cxx Contains all the code that calls FBX SDK to create the scene, add the cubes, 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 displays the tree view of the scene and that interacts with the user. The code uses FBX SDK to retrieve the scene data that the UI displays in its tree view.This tutorial does not explain any of the code in this file.

User Interface

The CubeCreator sample program shows you how to add textures, materials, and animation to models in a scene.

At startup, CubeCreator displays a tree view of a scene containing only a marker and a camera.

As a user, you can add cubes one at a time to the scene. For each cube, you can opt to:

You can save the scene as an FBX file (or in any file format exported by FBX SDK).

Here is what 8cubes.fbx (the scene shown as a tree, above) looks like when opened in FBX for QuickTime:

Location of a Texture File at Run Time

<yourFBXSDKpath>\examples\UI Examples\CubeCreator\ contains a file named crate.jpg, which CubeCreator uses as a texture file.

You must copy this texture file into the folder where the executable for CubeCreator will start. Unless you change the settings for the CubeCreator project:

If FBX for QuickTime cannot find a texture file for a surface, it renders the surface as a checkerboard pattern. Here is how that looks for the faces of our cubes:

Main Logic

CubeCreator does the following operations: