bool SaveScene(FbxManager* pManager, FbxDocument* pScene, const char* pFilename, int pFileFormat = -1, bool pEmbedMedia = false) { int lMajor, lMinor, lRevision; bool lStatus = true; // Create an exporter. FbxExporter* lExporter = FbxExporter::Create(pManager, ""); if (pFileFormat < 0 || pFileFormat >= pManager->GetIOPluginRegistry()->GetWriterFormatCount()) { // Write in fall back format in less no ASCII format found pFileFormat = pManager->GetIOPluginRegistry()->GetNativeWriterFormat(); //Try to export in ASCII if possible int lFormatIndex, lFormatCount = pManager->GetIOPluginRegistry()->GetWriterFormatCount(); for (lFormatIndex = 0; lFormatIndex < lFormatCount; lFormatIndex++) { if (pManager->GetIOPluginRegistry()->WriterIsFBX(lFormatIndex)) { FbxString lDesc = pManager->GetIOPluginRegistry()->GetWriterFormatDescription(lFormatIndex); const char *lASCII = "ascii"; if (lDesc.Find(lASCII) >= 0) { pFileFormat = lFormatIndex; break; } } } } // Set the export states. By default, the export states are always set to // true except for the option eEXPORT_TEXTURE_AS_EMBEDDED. The code below // shows how to change these states. IOSETTING_REF.SetBoolProp(EXP_FBX_MATERIAL, true); IOSETTING_REF.SetBoolProp(EXP_FBX_TEXTURE, true); IOSETTING_REF.SetBoolProp(EXP_FBX_EMBEDDED, pEmbedMedia); IOSETTING_REF.SetBoolProp(EXP_FBX_SHAPE, true); IOSETTING_REF.SetBoolProp(EXP_FBX_GOBO, true); IOSETTING_REF.SetBoolProp(EXP_FBX_ANIMATION, true); IOSETTING_REF.SetBoolProp(EXP_FBX_GLOBAL_SETTINGS, true); // Initialize the exporter by providing a filename. if (lExporter->Initialize(pFilename, pFileFormat, pManager->GetIOSettings()) == false) { printf("Call to FbxExporter::Initialize() failed.\n"); printf("Error returned: %s\n\n", lExporter->GetStatus().GetErrorString()); return false; } FbxManager::GetFileFormatVersion(lMajor, lMinor, lRevision); printf("FBX file format version %d.%d.%d\n\n", lMajor, lMinor, lRevision); // Export the scene. lStatus = lExporter->Export(pScene); // Destroy the exporter. lExporter->Destroy(); return lStatus; }
int ILDLMesh::SaveScene(FbxManager* pManager, FbxDocument* pScene, const char* pFilename, int pFileFormat, bool pEmbedMedia) { int lMajor, lMinor, lRevision; int lStatus = -1; // Create an exporter. FbxExporter* lExporter = FbxExporter::Create(pManager, ""); if( pFileFormat < 0 || pFileFormat >= pManager->GetIOPluginRegistry()->GetWriterFormatCount() ) { // Write in fall back format in less no ASCII format found pFileFormat = pManager->GetIOPluginRegistry()->GetNativeWriterFormat(); //Try to export in ASCII if possible int lFormatIndex, lFormatCount = pManager->GetIOPluginRegistry()->GetWriterFormatCount(); for (lFormatIndex=0; lFormatIndex<lFormatCount; lFormatIndex++) { if (pManager->GetIOPluginRegistry()->WriterIsFBX(lFormatIndex)) { FbxString lDesc =pManager->GetIOPluginRegistry()->GetWriterFormatDescription(lFormatIndex); const char *lASCII = "ascii"; if (lDesc.Find(lASCII)>=0) { pFileFormat = lFormatIndex; break; } } } } // Initialize the exporter by providing a filename. if(lExporter->Initialize(pFilename, pFileFormat, pManager->GetIOSettings()) == false) { //FBXSDK_printf("Call to FbxExporter::Initialize() failed.\n"); //FBXSDK_printf("Error returned: %s\n\n", lExporter->GetStatus().GetErrorString()); return 431; } FbxManager::GetFileFormatVersion(lMajor, lMinor, lRevision); //FBXSDK_printf("FBX file format version %d.%d.%d\n\n", lMajor, lMinor, lRevision); // Export the scene. if ( !lExporter->Export(pScene) ) lStatus = 432; // Destroy the exporter. lExporter->Destroy(); return lStatus; }