added command line option to override the output filename/path

This commit is contained in:
gered 2011-04-27 17:24:25 -04:00
parent fb15ed80cb
commit 624c09ab82

View file

@ -17,19 +17,33 @@ int main(int argc, char *argv[])
if (argc == 1) if (argc == 1)
{ {
printf("Usage: assimptomesh.exe [--showinfo] inputfile\n\n"); printf("Usage: assimptomesh.exe [--showinfo] [--out=outputfile] inputfile\n\n");
return 0; return 0;
} }
// input file is always the last argument // input file is always the last argument
std::string file = argv[argc - 1]; std::string file = argv[argc - 1];
std::string outputFile;
bool showInfo = false; bool showInfo = false;
// find any options // find any options
for (int i = 1; i < argc - 1; ++i) for (int i = 1; i < argc - 1; ++i)
{ {
if (strcmp(argv[i], "--showinfo") == 0) std::string arg = argv[i];
if (arg == "--showinfo")
showInfo = true; showInfo = true;
else if (arg.substr(0, 6) == "--out=")
{
if (arg.length() == 6)
{
printf("Missing output filename.\n");
return 1;
}
outputFile = arg.substr(6);
}
} }
// attempt to load the input file // attempt to load the input file
@ -52,13 +66,16 @@ int main(int argc, char *argv[])
} }
printf("Scene loaded.\n"); printf("Scene loaded.\n");
// input file loaded, now get the output filename // input file loaded, now get the output filename (if not provided via command line)
std::string outputFile = GetMeshFilenameFromInput(file); if (outputFile.length() == 0)
{
outputFile = GetMeshFilenameFromInput(file);
if (outputFile.length() == 0) if (outputFile.length() == 0)
{ {
printf("Unable to determine output mesh filename from the input file name.\n\n"); printf("Unable to determine output mesh filename from the input file name.\n\n");
return 1; return 1;
} }
}
printf("Output file: %s\n", outputFile.c_str()); printf("Output file: %s\n", outputFile.c_str());
// optionally show info about the entire scene before doing the conversion // optionally show info about the entire scene before doing the conversion