diff --git a/src/FBX2glTF.cpp b/src/FBX2glTF.cpp index a29b839..dc480b2 100644 --- a/src/FBX2glTF.cpp +++ b/src/FBX2glTF.cpp @@ -40,9 +40,8 @@ int main(int argc, char* argv[]) { exit(0); }); - std::string inputPath; - app.add_option("FBX Model", inputPath, "The FBX model to convert.")->check(CLI::ExistingFile); - app.add_option("-i,--input", inputPath, "The FBX model to convert.")->check(CLI::ExistingFile); + app.add_option("FBX Model", gltfOptions.inputPath, "The FBX model to convert.")->check(CLI::ExistingFile); + app.add_option("-i,--input", gltfOptions.inputPath, "The FBX model to convert.")->check(CLI::ExistingFile); std::string outputPath; app.add_option("-o,--output", outputPath, "Where to generate the output, without suffix."); @@ -297,7 +296,7 @@ int main(int argc, char* argv[]) { } } - if (inputPath.empty()) { + if (gltfOptions.inputPath.empty()) { fmt::printf("You must supply a FBX file to convert.\n"); exit(1); } @@ -315,7 +314,7 @@ int main(int argc, char* argv[]) { if (outputPath.empty()) { // if -o is not given, default to the basename of the .fbx - outputPath = "./" + FileUtils::GetFileBase(inputPath); + outputPath = "./" + FileUtils::GetFileBase(gltfOptions.inputPath); } // the output folder in .gltf mode, not used for .glb std::string outputFolder; @@ -355,10 +354,10 @@ int main(int argc, char* argv[]) { RawModel raw; if (verboseOutput) { - fmt::printf("Loading FBX File: %s\n", inputPath); + fmt::printf("Loading FBX File: %s\n", gltfOptions.inputPath); } - if (!LoadFBXFile(raw, inputPath, {"png", "jpg", "jpeg"}, gltfOptions)) { - fmt::fprintf(stderr, "ERROR:: Failed to parse FBX: %s\n", inputPath); + if (!LoadFBXFile(raw, gltfOptions.inputPath, {"png", "jpg", "jpeg"}, gltfOptions)) { + fmt::fprintf(stderr, "ERROR:: Failed to parse FBX: %s\n", gltfOptions.inputPath); return 1; } diff --git a/src/FBX2glTF.h b/src/FBX2glTF.h index 0ab1e00..10b4e2a 100644 --- a/src/FBX2glTF.h +++ b/src/FBX2glTF.h @@ -78,6 +78,7 @@ enum class AnimationFramerateOptions { * User-supplied options that dictate the nature of the glTF being generated. */ struct GltfOptions { + std::string inputPath; /** * If negative, disabled. Otherwise, a bitfield of RawVertexAttributes that * specify the largest set of attributes that'll ever be kept for a vertex. diff --git a/src/gltf/TextureBuilder.cpp b/src/gltf/TextureBuilder.cpp index 0b21af8..e7d225c 100644 --- a/src/gltf/TextureBuilder.cpp +++ b/src/gltf/TextureBuilder.cpp @@ -188,7 +188,8 @@ std::shared_ptr TextureBuilder::simple(int rawTexIndex, const std:: if (options.keepOriginals && !relativeFilename.empty()) { image = new ImageData(textureName, relativeFilename); } else if (options.keepOriginals && relativeFilename.empty()) { - std::string outputPath = "textures/" + textureName; + std::string inputPathBase = FileUtils::GetFileBase(gltfOptions.inputPath); + std::string outputPath = inputPathBase + "/textures/" + textureName; image = new ImageData(textureName, outputPath); if (FileUtils::CopyFile(rawTexture.fileLocation, outputPath, true)) { if (verboseOutput) {