Add to the keep original functionality.

This commit is contained in:
K. S. Ernest (iFire) Lee 2021-11-28 14:27:20 -08:00
parent 8be4ef3931
commit c9396fd2db
2 changed files with 12 additions and 5 deletions

View File

@ -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);
}

View File

@ -185,7 +185,17 @@ std::shared_ptr<TextureData> 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<TextureData> 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;