Exporting with the FBX Extensions SDK
 
 
 

Host Application Flow

The following pseudocode shows the order of execution of an FBX Extension while a scene is being exported by the host application.

Before translating any scene objects to FBX:
    ExportBegin();
 
For each object in the scene:
    If ( ExportHandled() returns TRUE ):
        The host application will let your extension translate the object.
    Else:
        The host application will translate the object, if it knows how to.
 
For each object translated by the host application:
    ExportTranslated(), passing the object and its translation;
 
The translation of the scene is now complete:
    ExportEnd()

ExportBegin()

EXPORT_DLL void MayaExt_ExportBegin(KFbxScene* pFbxScene);
EXPORT_DLL void MaxExt_ExportBegin(KFbxScene* pFbxScene, INode* pMaxRootNode);
EXPORT_DLL void MBExt_ExportBegin( KFbxScene* pFbxScene );

This function is called before the host application translates any data from the scene into the corresponding FBX scene. The host application passes a pointer to the empty FBX scene that it has created. Your FBX Extension can access the 3ds Max/Maya/MotionBuilder scene by calling functions in the 3ds Max/Maya/MotionBuilder SDKs.

Your FBX Extension can create your custom data now, or wait at the end of the export depending if that custom data replaces objects in the FBX scene hierarchy.

ExportHandled()

EXPORT_DLL bool MayaExt_ExportHandled(MObject& pMayaObject);
EXPORT_DLL bool MaxExt_ExportHandled(INode* pMaxObject);
EXPORT_DLL bool MBExt_ExportHandled( HFBComponent pFBComponent );

Called for each object in the scene. Called before that object is translated into an FBX object. May be called more than once for the same object.

Your extension must return:

ExportTranslated()

EXPORT_DLL void MayaExt_ExportTranslated(KFbxObject* pFbxObject, MObject& pMayaObject);
EXPORT_DLL void MaxExt_ExportTranslated(KFbxObject* pFbxObject, INode* pMaxObject);
EXPORT_DLL void MBExt_ExportTranslated( KFbxObject* pFbxObject, HFBComponent pFBComponent );

After all objects in the scene have been translated into FBX objects, the host application calls this function once for each object that has been translated.

The purpose of this function is to tell the extension: for this 3ds Max/Maya/MotionBuilder object, this is the corresponding FBX object.

ExportEnd()

EXPORT_DLL void MayaExt_ExportEnd(KFbxScene* pFbxScene);
EXPORT_DLL void MaxExt_ExportEnd(KFbxScene* pFbxScene, INode* pMaxRootNode);
EXPORT_DLL void MBExt_ExportEnd( KFbxScene* pFbxScene );

The host application calls this function after it has completely translated the scene into FBX (and before the file I/O begins). This is the last chance for your extension to modify the FBX scene.