diff --git a/src/FBX2glTF.cpp b/src/FBX2glTF.cpp index 19fc32f..a29b839 100644 --- a/src/FBX2glTF.cpp +++ b/src/FBX2glTF.cpp @@ -313,9 +313,7 @@ int main(int argc, char* argv[]) { fmt::printf("Note: Ignoring --embed; it's meaningless with --binary.\n"); } - if (gltfOptions.keepOriginals) { - outputPath = "./" + FileUtils::GetFileBase(inputPath); - } else if (outputPath.empty() && !gltfOptions.keepOriginals) { + if (outputPath.empty()) { // if -o is not given, default to the basename of the .fbx outputPath = "./" + FileUtils::GetFileBase(inputPath); } diff --git a/src/gltf/TextureBuilder.cpp b/src/gltf/TextureBuilder.cpp index 72bb78b..0b21af8 100644 --- a/src/gltf/TextureBuilder.cpp +++ b/src/gltf/TextureBuilder.cpp @@ -185,7 +185,17 @@ std::shared_ptr TextureBuilder::simple(int rawTexIndex, const std:: const std::string textureName = FileUtils::GetFileBase(rawTexture.name); const std::string relativeFilename = FileUtils::GetFileName(rawTexture.fileLocation); ImageData* image = nullptr; - if (options.outputBinary) { + if (options.keepOriginals && !relativeFilename.empty()) { + image = new ImageData(textureName, relativeFilename); + } else if (options.keepOriginals && relativeFilename.empty()) { + std::string outputPath = "textures/" + textureName; + image = new ImageData(textureName, outputPath); + if (FileUtils::CopyFile(rawTexture.fileLocation, outputPath, true)) { + if (verboseOutput) { + fmt::printf("Copied texture '%s' to output folder: %s\n", textureName, outputPath); + } + } + } else if (options.outputBinary) { auto bufferView = gltf.AddBufferViewForFile(*gltf.defaultBuffer, rawTexture.fileLocation); if (bufferView) { const auto& suffix = FileUtils::GetFileSuffix(rawTexture.fileLocation); @@ -201,7 +211,6 @@ std::shared_ptr TextureBuilder::simple(int rawTexIndex, const std:: } image = new ImageData(relativeFilename, *bufferView, mimeType); } - } else if (!relativeFilename.empty()) { image = new ImageData(relativeFilename, relativeFilename); std::string outputPath = outputFolder + "/" + relativeFilename;