Update FBXBaker::exportScene with FBXWriter

This commit is contained in:
Ryan Huffman 2017-09-07 14:12:15 -07:00
parent b60d68c714
commit 7214f57376

View file

@ -212,7 +212,7 @@ void FBXBaker::importScene() {
QFile fbxFile(_originalFBXFilePath); QFile fbxFile(_originalFBXFilePath);
if (!fbxFile.open(QIODevice::ReadOnly)) { if (!fbxFile.open(QIODevice::ReadOnly)) {
handleError("Error opening " + _originalFBXFilePath); handleError("Error opening " + _originalFBXFilePath + " for reading");
return; return;
} }
@ -502,29 +502,25 @@ void FBXBaker::handleBakedTexture() {
} }
void FBXBaker::exportScene() { void FBXBaker::exportScene() {
// setup the exporter
FbxExporter* exporter = FbxExporter::Create(_sdkManager.get(), "");
// save the relative path to this FBX inside our passed output folder // save the relative path to this FBX inside our passed output folder
auto fileName = _fbxURL.fileName(); auto fileName = _fbxURL.fileName();
auto baseName = fileName.left(fileName.lastIndexOf('.')); auto baseName = fileName.left(fileName.lastIndexOf('.'));
auto bakedFilename = baseName + BAKED_FBX_EXTENSION; auto bakedFilename = baseName + BAKED_FBX_EXTENSION;
_bakedFBXFilePath = _bakedOutputDir + "/" + bakedFilename; _bakedFBXFilePath = _bakedOutputDir + "/" + bakedFilename;
bool exportStatus = exporter->Initialize(_bakedFBXFilePath.toLocal8Bit().data()); auto fbxData = FBXWriter::encodeFBX(_rootNode);
if (!exportStatus) { QFile bakedFile(_bakedFBXFilePath);
// failed to initialize exporter, print an error and return
handleError("Failed to export FBX file at " + _fbxURL.toString() + " to " + _bakedFBXFilePath if (!bakedFile.open(QIODevice::WriteOnly)) {
+ "- error: " + exporter->GetStatus().GetErrorString()); handleError("Error opening " + _bakedFBXFilePath + " for writing");
return;
} }
_outputFiles.push_back(_bakedFBXFilePath); bakedFile.write(fbxData);
// export the scene _outputFiles.push_back(_bakedFBXFilePath);
exporter->Export(_scene);
qCDebug(model_baking) << "Exported" << _fbxURL << "with re-written paths to" << _bakedFBXFilePath; qCDebug(model_baking) << "Exported" << _fbxURL << "with re-written paths to" << _bakedFBXFilePath;
} }