FBX SDK Programmer's Guide > Sample Programs >

# Feature-Oriented Programs

The FBX SDK ships with the following sample programs that run on all platforms supported by FBX SDK.

Brief sample program | Description
--- | ---
Common | Functions used by other sample programs to initialize objects, destroy objects, load scenes, and save scenes.
MyOwnWriterReader | Functions used by other sample programs to write and read files in a custom file format.
Animation | Shows how to create animation and how to evaluate a scene containing animation. Illustrates the use of animation stacks, animation layers, animation curves and animation curve nodes.
ExportScene01 | Creates and exports an animated scene containing a cylinder deformed by a skeleton made of two segments.
ExportScene02 | Creates and exports an animated scene containing a sphere morphed by two shapes.
ExportScene03 | Creates and exports an animated scene containing a textured cube, and a pyramid with materials mapped on its faces.
ExportScene04 | Creates and exports a scene containing a group of lights, a marker, and a camera. The animation rotates the lights and moves the camera.
ExportScene05 | In FBX, the position of a node is expressed in coordinates relative to the node’s parent. This example shows how to convert between FBX coordinates and a global coordinate system.
ImportScene | Displays the content of any FBX file.
Instances | Creates several instances of the same cube mesh and animates them using animation curves.
Layers | Creates a scene containing a cube with layered textures and materials mapped on each of the cube’s faces. Illustrates how to use layers.
UserProperties | Illustrates how to create user properties, attach the properties to a cube, and then animate the properties; how to create a constraint between a pyramid and a cube.
ViewScene | Shows how to evaluate the animation data and compute deformations. This is necessary for displaying the content of any FBX SDK-supported file in a graphical window. Uses the OpenGL Utility Toolkit (GLUT). A menu lets you select the view, the current camera, the current animation stack, etc.

Folders for each of these programs are located in <yourFBXSDKpath>\examples\. Each folder contains Visual Studio project files (Windows only) or makefiles (Mac OS or Linux) to help you build and run the program.

Common

The Common folder does not contain a standalone example.

It contains a common.cxx file, which shows how to use FBX SDK to perform basic operations such as creating and initializing scenes, destroying scenes, loading scenes, and saving scenes. The other sample programs call the functions defined in this file.

Animation

This sample program creates a scene containing only one property, a few animation curves, and the data structures that animate the property by connecting the curves to the property. The program then shows how to evaluate the scene using FbxAnimEvaluator.

This sample program illustrates how to:

- Create an animation stack (the highest level container for animation).
- Create animation layers.
- Set blending modes for each animation layer.
- Bypass blending for specified data types.
- Create a curve node to connect animation curves to animatable properties in a scene.
- Animate a property of an animation curve.
- Add and remove channels.
- Create animation curves by creating keyframes (animation keys) at the beginning and end of the curve.
- Animate channels.
- Add curve nodes to an animation layer.
- Connect curves to channels.
- Get a scene’s evaluator.
- Specify the animation stack to be evaluated.
- Step the evaluator through an animation curve one key at a time.
- Return evaluated values (to be used for rendering a scene).

MyOwnWriterReader

This sample code shows how to use the FBX SDK to write and read files in a custom file format, i.e., a file format not directly supported by the FBX SDK. The sample code reads and writes “CustomWriter” files.

The MyOwnWriterReader folder does not contain a standalone sample program. Instead, it contains sample functions that support CustomWriter files. The sample functions are in turn used by other sample programs (ExportScene05, ImportScene, and ViewScene) to write and read CustomWriter files.

For more information, see Customizing the FBX SDK.

ExportScene01

The scene created in this example is a cylinder linked to a skeleton made of two segments. Two animation stacks show the influence of the skeleton segments over the cylinder.

This sample program illustrates how to:

- Create a patch.
- Create a skeleton segment.
- Create a link.
- Store the bind pose.
- Store one arbitrary rest pose.
- Create multiple animation stacks.
- Create meta-data for a scene.
- Export a scene in an .fbx file (in ASCII mode).

ExportScene02

The scene created in this example is a sphere morphed by two shapes. An animation stack shows the influence of the shapes over the sphere.

This sample program illustrates how to:

- Create a NURBS.
- Map a shape over a NURBS.
- Map a texture over a NURBS on the Diffuse and Ambient material channels.
- Map a material over a NURBS.
- Create an animation.
- Export a scene in an .fbx file.

ExportScene03

The scene created in this example is a textured cube and a pyramid with materials mapped on its faces. The animation displays six different angles of both models.

This sample program illustrates how to:

- Create a mesh.
- Extend the SDK by creating your own version of the FbxMesh class.
- Map a texture over a mesh or your own mesh type.
- Map a material over a mesh or your own mesh type.
- Extend the SDK by applying your own user-defined Layer Element on a mesh.
- Use your own mesh type with your own User Data Layer Element.
- Create a vertex cache deformer to deform a simple model.
- Create animation.
- Animate the vertex cache.
- Export a scene in an .fbx file.

ExportScene04

The scene created in this example contains a group of lights, a marker, and a camera. The animation rotates the lights and moves the camera.

This sample program illustrates how to:

- Create a light and assign a gobo.
- Set global light settings.
- Create a marker.
- Create a camera and link it to a point of interest.
- Create an animation.
- Export a scene in an .fbx file.

ExportScene05

The scene created in this example contains a skeleton made of three segments. The position of a node in an .fbx file is expressed in coordinates relative to its parent. This example shows how to convert to and from a global position.

This sample program illustrates how to:

- Use a custom memory allocator.
- Create a skeleton segment.
- Get the global default position of a node.
- Set the global default position of a node.
- Set limits, rotation order, and pre/post pivots.
- Export a scene in an .fbx file.

ImportScene

This example illustrates how to detect if a scene is password protected, and how to import and browse the scene to access node and animation information. This example displays the contents of an .fbx file that is passed as program argument. It shows how to traverse an FBX scene graph and retrieve its contents. You can try this example using any of the .fbx files outputted by the export examples above.

Instances

This example illustrates how to instantiate meshes and curves. The example creates a scene with several instances of the same cube and animates them using an animation curve.

Layers

In this example, a scene is created containing a cube with layered textures and materials mapped on each of the cube’s faces. This example illustrates how to use texture layers.

NoteTexture layers are not the same as animation layers.

UserProperties

In this example, a scene is created containing a cube, a pyramid, and user properties.

This sample program illustrates how to:

- Create user properties
- Attach user properties to a cube.
- Animate attached user properties.
- Create a constraint that constrains a pyramid to a cube.

NoteUser properties are also called custom properties.

ViewScene

This example illustrates how to display the contents of a .fbx or a .obj file in a graphical window. This program is based on the OpenGL® Utility Toolkit (GLUT). Start the program on the command line by providing the name of any FBX SDK-supported file. A menu will open letting you select the current camera and the current animation stack.

This sample program illustrates how to:

- Import a scene from a .fbx or a .obj file.
- Convert the NURBS and patch attribute types of a scene into mesh node attributes.
- Get the list of all the cameras in the scene.
- Find the current camera.
- Get the relevant settings of a camera depending on its projection type and aperture mode.
- Compute the local and global positions of each node.
- Compute the shape deformation of mesh vertices.
- Compute the cluster deformation of mesh vertices.
- Display the point cache simulation of a mesh.
- Get a list of all poses in the scene.
- Display the scene with a specific pose.