Creating an I/O Settings Object
The KFbxIOSettings 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 KFbxIOSettings object must be instantiated and configured before it is passed to a KFbxImporter or KFbxExporter object. Similarly to most objects in the FBX SDK, the KFbxIOSettings object is created and managed using the KFbxSdkManager singleton (see FBX SDK Object Model).
#include <fbxsdk.h> #include <fbxfilesdk/kfbxio/kfbxiosettings.h> // ... // Create the FBX SDK manager KFbxSdkManager* lSdkManager = KFbxSdkManager::Create(); // Create an IOSettings object. IOSROOT is defined in kfbxiosettingspath.h. KFbxIOSettings * ios = KFbxIOSettings::Create(lSdkManager, IOSROOT ); lSdkManager->SetIOSettings(ios);
The kfbxiosettingspath.h header file defines the KFbxIOSettings configuration options. These configuration options are used as parameters in the member functions of the KFbxIOSettings class. Observe that the IMP_ prefix pertains to import options, whereas the EXP_ prefix pertains to export options. A newly instantiated KFbxIOSettings object is configured with the default import and export options.
The following code snippet illustrates the configuration of the import settings with KFbxIOSettings::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 KFbxIOSettings::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 KFbxIOSettings object may be analogously obtained using the KFbxIOSettings::GetBoolProp().
The KFbxIOSettings 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.
The content of an FBX file can be password protected. This is achieved by setting the appropriate string and boolean properties of the KFbxIOSettings object before it is passed to a KFbxImporter or KFbxExporter object.
Password-Protected Import Settings
// The KString used to store the password. KString lString; // ... Assign the password to lString ... // Set the KFbxIOSettings import password properties. (*(lSdkManager->GetIOSettings())).SetStringProp(IMP_FBX_PASSWORD, lString); (*(lSdkManager->GetIOSettings())).SetBoolProp(IMP_FBX_PASSWORD_ENABLE, true);
Password-Protected Export Settings
// The KString used to store the password. KString lString; // ... Assign the password to lString ... // Set the KFbxIOSettings 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 KFbxProperty objects to the KFbxIOSettings object using methods such as KFbxIOSettings::AddProperty() and KFbxIOSettings::AddPropertyGroup(). The underlying KFbxProperty tree structure of the KFbxIOSettings class is a relevant concept in understanding how to define your own custom I/O settings. Consult the KFbxIOSettings class documentation for more details.