#include <fbxsdk.h>
#include "../Common/Common.h"
#define SAMPLE_FILENAME "box.fbx"
const char* lFileTypes[] =
{
"_dae.dae", "Collada DAE (*.dae)",
"_fbx7binary.fbx", "FBX binary (*.fbx)",
"_fbx7ascii.fbx", "FBX ascii (*.fbx)",
"_fbx6binary.fbx", "FBX 6.0 binary (*.fbx)",
"_fbx6ascii.fbx", "FBX 6.0 ascii (*.fbx)",
"_obj.obj", "Alias OBJ (*.obj)",
"_dxf.dxf", "AutoCAD DXF (*.dxf)"
};
int main(int argc, char** argv)
{
FbxString lFilePath("");
for( int i = 1, c = argc; i < c; ++i )
{
if( FbxString(argv[i]) == "-test" ) continue;
else if( lFilePath.IsEmpty() ) lFilePath = argv[i];
}
if( lFilePath.IsEmpty() ) lFilePath = SAMPLE_FILENAME;
FbxManager* lSdkManager = NULL;
FbxScene* lScene = NULL;
InitializeSdkObjects(lSdkManager, lScene);
bool lResult = LoadScene(lSdkManager, lScene, lFilePath.Buffer());
if( lResult )
{
const size_t lFileNameLength = strlen((argc>=3)?argv[2]:lFilePath.Buffer());
char* lNewFileName = new char[lFileNameLength+64];
FBXSDK_strcpy(lNewFileName,lFileNameLength+64,(argc>=3)?argv[2]:lFilePath.Buffer());
const size_t lFileTypeCount = sizeof(lFileTypes)/sizeof(lFileTypes[0])/2;
for(size_t i=0; i<lFileTypeCount; ++i)
{
int lFormat = lSdkManager->GetIOPluginRegistry()->FindWriterIDByDescription(lFileTypes[i*2+1]);
FBXSDK_strcpy(lNewFileName+lFileNameLength-4,60, lFileTypes[i*2]);
FbxExporter* lExporter = FbxExporter::Create(lSdkManager, "");
lResult = lExporter->Initialize(lNewFileName, lFormat, lSdkManager->GetIOSettings());
if( !lResult )
{
FBXSDK_printf("%s:\tCall to FbxExporter::Initialize() failed.\n", lFileTypes[i*2+1]);
FBXSDK_printf("Error returned: %s\n\n", lExporter->GetStatus().GetErrorString());
}
else
{
lResult = lExporter->Export(lScene);
if( !lResult )
{
FBXSDK_printf("Call to FbxExporter::Export() failed.\n");
}
}
lExporter->Destroy();
}
delete[] lNewFileName;
}
else
{
FBXSDK_printf("Call to LoadScene() failed.\n");
}
DestroySdkObjects(lSdkManager, lResult);
return 0;
}