This topic presents how to customize or extend the features of the FBX SDK.
Instances of FbxObject
and FbxProperty
provide a (void*
) pointer so you can associate any custom data to that instance:
FbxObject
user data: FbxObject::SetUserDataPtr()
, FbxObject::GetUserDataPtr()
.FbxProperty
user data: FbxProperty::SetUserDataPtr()
, FbxProperty::GetUserDataPtr()
.You are responsible for creating, destroying, and otherwise managing your custom data.
Custom instances of FbxProperty
can be dynamically added to a FbxObject
. 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 FbxManager
by invoking FbxManager::RegisterFbxClass()
.
In the following sample taken from <span class="char_link">[ExportScene03]()
/main.cxx, the custom classes MyFbxMesh
and MyFbxObject
are defined in ExportScene03/MyFbxMesh.h
. These classes respectively inherit from FbxMesh
and FbxObject
.
#include <fbxsdk.h>
#include "../Common/Common.h"
#include "MyFbxMesh.h"
// ...
int main(int argc, char** argv)
{
FbxManager* lSdkManager = NULL;
FbxScene* lScene = NULL;
// ...
// Prepare the FBX SDK.
InitializeSdkObjects(lSdkManager, lScene);
//Add the new class we have created to the Sdk Manager
//Our class MyFbxMesh is derived from FbxMesh
lSdkManager->RegisterFbxClass("MyFbxMesh", FBX_TYPE(MyFbxMesh), FBX_TYPE(FbxMesh));
//Now, our class MyFbxMesh is ready to be used
lSdkManager->RegisterFbxClass("MyFbxObject", FBX_TYPE(MyFbxObject), FBX_TYPE(FbxObject), "MyFbxObjectType", "MyFbxObjectSubType");
// ...
}
To create a layer element with a custom type, use the FbxLayerElementUserData
class. Like any other layer element, it can be mapped by polygon vertex, by vertex, by polygon, etc.
Refer to the CreateCubeWithMaterialAndMyFbxMesh()
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 FbxWriter
) and reader class (derived from FbxReader
). To use your custom FbxWriter
and FbxReader
, 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.