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 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);
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.
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);
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()
.
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);
EXP_FBX_EMBEDDED
property is set to:true
: the media is embedded within the exported file. This option is available only when exporting to binary FBX files.false
: the media is not embedded within the exported file. Instead, the FBX file contains relative references to the media files.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.
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.
// 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);
// 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 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.
The FBX SDK does not directly support exporting and importing to/from a memory stream.