I/O Settings

Creating an I/O Settings Object

The FbxIOSettings class is responsible for specifying which elements of a scene are imported from a file, or exported to a file. Such elements include cameras, lights, meshes, textures, materials, animations, custom properties, etc. A FbxIOSettings object must be instantiated and configured before it is passed to a FbxImporter or FbxExporter object. Similarly to most objects in the FBX SDK, the FbxIOSettings object is created and managed using the FbxManager singleton (see FBX SDK Object Model).

#include <fbxsdk.h>
#include <fbxfilesdk/fbxio/fbxiosettings.h>

// ...

// Create the FBX SDK manager
FbxManager* lSdkManager = FbxManager::Create();

// Create an IOSettings object. IOSROOT is defined in Fbxiosettingspath.h.
FbxIOSettings * ios = FbxIOSettings::Create(lSdkManager, IOSROOT );
lSdkManager->SetIOSettings(ios);

Configuring the I/O Settings

The Fbxiosettingspath.h header file defines the FbxIOSettings configuration options. These configuration options are used as parameters in the member functions of the FbxIOSettings class. Observe that the IMP_ prefix pertains to import options, whereas the EXP_ prefix pertains to export options. A newly instantiated FbxIOSettings object is configured with the default import and export options.

Import Settings

The following code snippet illustrates the configuration of the import settings with FbxIOSettings::SetBoolProp().

// Import options determine what kind of data is to be imported.
// True is the default, but here we’ll set some to true explicitly, and others to false.
(*(lSdkManager->GetIOSettings())).SetBoolProp(IMP_FBX_MATERIAL,        true);
(*(lSdkManager->GetIOSettings())).SetBoolProp(IMP_FBX_TEXTURE,         true);
(*(lSdkManager->GetIOSettings())).SetBoolProp(IMP_FBX_LINK,            false);
(*(lSdkManager->GetIOSettings())).SetBoolProp(IMP_FBX_SHAPE,           false);
(*(lSdkManager->GetIOSettings())).SetBoolProp(IMP_FBX_GOBO,            false);
(*(lSdkManager->GetIOSettings())).SetBoolProp(IMP_FBX_ANIMATION,       true);
(*(lSdkManager->GetIOSettings())).SetBoolProp(IMP_FBX_GLOBAL_SETTINGS, true);

Export Settings

The following code snippet illustrates the configuration of the export settings with FbxIOSettings::SetBoolProp().

// Set the export states. By default, the export states are always set to 
// true except for the option eEXPORT_TEXTURE_AS_EMBEDDED. The code below 
// shows how to change these states.
bool lEmbedMedia = true;
(*(lSdkManager->GetIOSettings())).SetBoolProp(EXP_FBX_MATERIAL,        true);
(*(lSdkManager->GetIOSettings())).SetBoolProp(EXP_FBX_TEXTURE,         true);
(*(lSdkManager->GetIOSettings())).SetBoolProp(EXP_FBX_EMBEDDED,        lEmbedMedia);
(*(lSdkManager->GetIOSettings())).SetBoolProp(EXP_FBX_SHAPE,           true);
(*(lSdkManager->GetIOSettings())).SetBoolProp(EXP_FBX_GOBO,            true);
(*(lSdkManager->GetIOSettings())).SetBoolProp(EXP_FBX_ANIMATION,       true);
(*(lSdkManager->GetIOSettings())).SetBoolProp(EXP_FBX_GLOBAL_SETTINGS, true);

The current import and export configuration options of a FbxIOSettings object may be analogously obtained using the FbxIOSettings::GetBoolProp().

Embedding Media

The FbxIOSettings object's EXP_FBX_EMBEDDED property specifies how the FBX SDK should export any media (textures, sound, movies, etc) related to the scene:

bool lEmbedMedia = true;
(*(lSdkManager->GetIOSettings())).SetBoolProp(EXP_FBX_EMBEDDED,        lEmbedMedia);

If the EXP_FBX_EMBEDDED property is set to:

When the FBX SDK imports a binary FBX file which contains embedded media (for example: myExportFile.fbx), it will extract the embedded media files into the binary FBX file's myExportFile.fbm/ subdirectory. If this subdirectory does not exist, it is automatically created.

Password Protection

The content of an FBX file can be password protected. This is achieved by setting the appropriate string and boolean properties of the FbxIOSettings object before it is passed to a FbxImporter or FbxExporter object.

Password-Protected Import Settings

// The FbxString used to store the password.
FbxString lString;

// ... Assign the password to lString ...

// Set the FbxIOSettings import password properties.
(*(lSdkManager->GetIOSettings())).SetStringProp(IMP_FBX_PASSWORD, lString);
(*(lSdkManager->GetIOSettings())).SetBoolProp(IMP_FBX_PASSWORD_ENABLE, true);

Password-Protected Export Settings

// The FbxString used to store the password.
FbxString lString;

// ... Assign the password to lString ...

// Set the FbxIOSettings import password properties.
(*(lSdkManager->GetIOSettings())).SetStringProp(EXP_FBX_PASSWORD, lString);
(*(lSdkManager->GetIOSettings())).SetBoolProp(EXP_FBX_PASSWORD_ENABLE, true);

Custom I/O Settings

Custom I/O settings may be specified by adding FbxProperty objects to the FbxIOSettings object using methods such as FbxIOSettings::AddProperty() and FbxIOSettings::AddPropertyGroup(). The underlying FbxProperty tree structure of the FbxIOSettings class is a relevant concept in understanding how to define your own custom I/O settings. Consult the FbxIOSettings class documentation for more details.

NOTE:The FBX SDK does not directly support exporting and importing to/from a memory stream.

See Also