diff --git a/src/main.cpp b/src/main.cpp index 86661c5..6d3af1c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,41 +12,11 @@ int main(int argc, char **argv) if (argc == 1) { - printf("No input file specified.\n"); - printf("Usage: ms3dtomesh.exe [--scale=] [inputfile]\n\n"); + printf("Usage: ms3dtomesh.exe inputFile\n\n"); return 1; } - // input file is always the last argument - std::string file = argv[argc - 1]; - - // default option values - float scaleFactor = 1.0f; - - // find any options and update their values - for (int i = 1; i < argc - 1; ++i) - { - std::string arg = argv[i]; - - if (arg.substr(0, 8) == "--scale=") - { - // scale factor - - if (arg.length() == 8) - { - printf("Missing scale factor.\n"); - return 1; - } - - scaleFactor = (float)atof(arg.substr(8).c_str()); - - if (scaleFactor == 0.0f) - { - printf("Invalid or 0.0 scale factor.\n"); - return 1; - } - } - } + std::string file = argv[1]; // find file extension part of the string in the input filename // we will use this to make an appropriate output mesh filename *and* @@ -100,7 +70,7 @@ int main(int argc, char **argv) } // convert to a mesh file - if (!ConvertToMeshFile(meshFile, &ms3d, &metadata, scaleFactor)) + if (!ConvertToMeshFile(meshFile, &ms3d, &metadata)) { printf("Error converting MS3D to MESH.\n\n"); return 1; diff --git a/src/meshfile.cpp b/src/meshfile.cpp index 7ccf83e..d4cbfd1 100644 --- a/src/meshfile.cpp +++ b/src/meshfile.cpp @@ -27,7 +27,7 @@ #include #include -BOOL ConvertToMeshFile(const std::string &meshFilename, const Ms3d *source, const MetadataFile *metadata, float scaleFactor) +BOOL ConvertToMeshFile(const std::string &meshFilename, const Ms3d *source, const MetadataFile *metadata) { VerticesChunk *vertices = NULL; NormalsChunk *normals = NULL; @@ -39,6 +39,11 @@ BOOL ConvertToMeshFile(const std::string &meshFilename, const Ms3d *source, cons KeyframesChunk *keyframes = NULL; AnimationsChunk *animations = NULL; + // global-ish metadata info + float scaleFactor = 1.0f; + if (metadata->IsLoaded()) + scaleFactor = metadata->GetScale(); + // collect all unique vertices (position + normal + texcoord) and the // original MS3D file data vertex index each one was originally from based // on the MS3D triangle data. In MS3D the triangle data can give the same diff --git a/src/meshfile.h b/src/meshfile.h index d5427c9..646ca9d 100644 --- a/src/meshfile.h +++ b/src/meshfile.h @@ -7,6 +7,6 @@ class MetadataFile; class Ms3d; -BOOL ConvertToMeshFile(const std::string &meshFilename, const Ms3d *source, const MetadataFile *metadata, float scaleFactor); +BOOL ConvertToMeshFile(const std::string &meshFilename, const Ms3d *source, const MetadataFile *metadata); #endif