From 7214f5737625d777ebdecb7bd6046e71f7d6f0bb Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 7 Sep 2017 14:12:15 -0700 Subject: [PATCH] Update FBXBaker::exportScene with FBXWriter --- libraries/baking/src/FBXBaker.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/libraries/baking/src/FBXBaker.cpp b/libraries/baking/src/FBXBaker.cpp index 9a28e6a788..35d981f337 100644 --- a/libraries/baking/src/FBXBaker.cpp +++ b/libraries/baking/src/FBXBaker.cpp @@ -212,7 +212,7 @@ void FBXBaker::importScene() { QFile fbxFile(_originalFBXFilePath); if (!fbxFile.open(QIODevice::ReadOnly)) { - handleError("Error opening " + _originalFBXFilePath); + handleError("Error opening " + _originalFBXFilePath + " for reading"); return; } @@ -502,29 +502,25 @@ void FBXBaker::handleBakedTexture() { } void FBXBaker::exportScene() { - // setup the exporter - FbxExporter* exporter = FbxExporter::Create(_sdkManager.get(), ""); - // save the relative path to this FBX inside our passed output folder - auto fileName = _fbxURL.fileName(); auto baseName = fileName.left(fileName.lastIndexOf('.')); auto bakedFilename = baseName + BAKED_FBX_EXTENSION; _bakedFBXFilePath = _bakedOutputDir + "/" + bakedFilename; - bool exportStatus = exporter->Initialize(_bakedFBXFilePath.toLocal8Bit().data()); + auto fbxData = FBXWriter::encodeFBX(_rootNode); - if (!exportStatus) { - // failed to initialize exporter, print an error and return - handleError("Failed to export FBX file at " + _fbxURL.toString() + " to " + _bakedFBXFilePath - + "- error: " + exporter->GetStatus().GetErrorString()); + QFile bakedFile(_bakedFBXFilePath); + + if (!bakedFile.open(QIODevice::WriteOnly)) { + handleError("Error opening " + _bakedFBXFilePath + " for writing"); + return; } - _outputFiles.push_back(_bakedFBXFilePath); + bakedFile.write(fbxData); - // export the scene - exporter->Export(_scene); + _outputFiles.push_back(_bakedFBXFilePath); qCDebug(model_baking) << "Exported" << _fbxURL << "with re-written paths to" << _bakedFBXFilePath; }