Write `.gltf` to parent directory & infer binary from `.glb` (#193)

If the output extension is gltf then set the output directory to the parent. The binary and any associated textures will be written to this directory.
This commit is contained in:
Jesse Vander Does 2019-08-07 09:35:17 -07:00 committed by Pär Winzell
parent 24092a80bb
commit 44d2d5bf97
1 changed files with 11 additions and 1 deletions

View File

@ -292,14 +292,24 @@ int main(int argc, char* argv[]) {
// the path of the actual .glb or .gltf file
std::string modelPath;
const auto& suffix = FileUtils::GetFileSuffix(outputPath);
// Assume binary output if extension is glb
if (suffix.has_value() && suffix.value() == "glb") {
gltfOptions.outputBinary = true;
}
if (gltfOptions.outputBinary) {
const auto& suffix = FileUtils::GetFileSuffix(outputPath);
// add .glb to output path, unless it already ends in exactly that
if (suffix.has_value() && suffix.value() == "glb") {
modelPath = outputPath;
} else {
modelPath = outputPath + ".glb";
}
// if the extension is gltf set the output folder to the parent directory
} else if (suffix.has_value() && suffix.value() == "gltf") {
outputFolder = FileUtils::getFolder(outputPath) + "/";
modelPath = outputPath;
} else {
// in gltf mode, we create a folder and write into that
outputFolder = fmt::format("{}_out/", outputPath.c_str());