1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
#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; }
|