This topic presents how to customize or extend the features of the FBX SDK.
Instances of KFbxObject and KFbxProperty provide a (void*) pointer so you can associate any custom data to that instance:
Custom instances of KFbxProperty can be dynamically added to a KFbxObject. The sample code provided in FBX Properties illustrates how to create and add such custom properties.
The ExportScene05, UserProperties and Tutorial: ImportExport sample programs also provide insight on how to get and set data of custom properties.
Custom classes must be registered with the KFbxSdkManager by invoking KFbxSdkManager::RegisterFbxClass().
In the following sample taken from ExportScene03/main.cxx, the custom classes MyKFbxMesh and MyKFbxObject are defined in ExportScene03/MyKFbxMesh.h. These classes respectively inherit from KFbxMesh and KFbxObject.
#include <fbxsdk.h> #include "../Common/Common.h" #include "MyKFbxMesh.h" // ... int main(int argc, char** argv) { KFbxSdkManager* lSdkManager = NULL; KFbxScene* lScene = NULL; // ... // Prepare the FBX SDK. InitializeSdkObjects(lSdkManager, lScene); //Add the new class we have created to the Sdk Manager //Our class MyKFbxMesh is derived from KFbxMesh lSdkManager->RegisterFbxClass("MyKFbxMesh", FBX_TYPE(MyKFbxMesh), FBX_TYPE(KFbxMesh)); //Now, our class MyKFbxMesh is ready to be used lSdkManager->RegisterFbxClass("MyFbxObject", FBX_TYPE(MyFbxObject), FBX_TYPE(KFbxObject), "MyFbxObjectType", "MyFbxObjectSubType"); // ... }
Custom User Data for Layer Elements
To create a layer element with a custom type, use the KFbxLayerElementUserData class. Like any other layer element, it can be mapped by polygon vertex, by vertex, by polygon, etc.
Refer to the CreateCubeWithMaterialAndMyKFbxMesh() function in ExportScene03. This function creates a custom compound based on float and boolean data types, and adds data for each vertex.
The FBX SDK imports and exports scene data using several file formats. Each of these file formats has its own writer class (derived from KFbxWriter) and reader class (derived from KFbxReader). To use your custom KFbxWriter and KFbxReader, they must be loaded by means of an FBX SDK I/O plug-in. For more information, see Customizing File Formats with FBX SDK I/O Plug-ins.
The FBX Extensions SDK is a set of callback functions which you can implement in a .dll file. These functions customize the importing and exporting functionality of 3ds Max, Maya and MotionBuilder. For more information, see FBX Extensions SDK.