All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Importing and Exporting Data using FBX

An Import Example

Importing a scene using the FBX importer is extremely simple. The example below illustrates this:

// Temporarily disable undos.
// Tell the importer to import the file into a new scene
bool do_merge = false;
// Use default settings to import the file.
FBX_ImportOptions import_options;
// Use default types filter for the import.
// Create and run the importer
FBX_Translator fbx_translator;
bool did_succeed = fbx_translator.importScene("test.fbx", do_merge, &import_options, &type_filter);
// Re-enable undos.

See FBX_ImportOptions and FBX_ObjectTypeFilter for documentation on setting various import options and importing only specific types of primitives such as lights or animation from FBX files.

Any errors or warnings produced by the importer can be retrieved as following:

// See if we have any errors
if (fbx_translator.getErrorManager()->getNumItems() > 0)
UI_ErrorType severity;
// See whether we have any critical errors or whether
// all we've got are warnings:
severity = UI_ERROR;
severity = UI_WARNING;
// Open a dialog with warnings/errors
SIopenMessageDialog(msg, severity);

An Export Example

An example below illustrates the export of the current scene to an FBX file. Note that FBX is capable of containing entire scenes, including cameras, animation, lights, and skinning, instead of supporting only the geometry.

// Temporarily disable undos.
// Create the wrapper and the options objects
ROP_FBXExporterWrapper fbx_exporter;
ROP_FBXExportOptions export_options;
// Initialize the exporter first
did_succeed = fbx_exporter.initializeExport("test_out.fbx", start_time, end_time, &export_options);
fbx_exporter.getErrorManager()->addError("Could not initialize FBX exporter", true);
// If everything is all right, perform the actual export.
// Cleanup and check for errors
did_succeed = fbx_exporter.finishExport();
fbx_exporter.getErrorManager()->addError("Could not finalize FBX export", true);
// Re-enable undos.

See ROP_FBXExportOptions for more information on possible export options.