moved scale factor option to the metadata file under transformations

This commit is contained in:
Gered 2012-12-23 23:32:30 -05:00
parent c9e521c1e5
commit b1ffbb4298
3 changed files with 10 additions and 35 deletions

View file

@ -12,41 +12,11 @@ int main(int argc, char **argv)
if (argc == 1) if (argc == 1)
{ {
printf("No input file specified.\n"); printf("Usage: ms3dtomesh.exe inputFile\n\n");
printf("Usage: ms3dtomesh.exe [--scale=<scale factor>] [inputfile]\n\n");
return 1; return 1;
} }
// input file is always the last argument std::string file = argv[1];
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;
}
}
}
// find file extension part of the string in the input filename // find file extension part of the string in the input filename
// we will use this to make an appropriate output mesh filename *and* // 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 // convert to a mesh file
if (!ConvertToMeshFile(meshFile, &ms3d, &metadata, scaleFactor)) if (!ConvertToMeshFile(meshFile, &ms3d, &metadata))
{ {
printf("Error converting MS3D to MESH.\n\n"); printf("Error converting MS3D to MESH.\n\n");
return 1; return 1;

View file

@ -27,7 +27,7 @@
#include <vector> #include <vector>
#include <assert.h> #include <assert.h>
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; VerticesChunk *vertices = NULL;
NormalsChunk *normals = NULL; NormalsChunk *normals = NULL;
@ -39,6 +39,11 @@ BOOL ConvertToMeshFile(const std::string &meshFilename, const Ms3d *source, cons
KeyframesChunk *keyframes = NULL; KeyframesChunk *keyframes = NULL;
AnimationsChunk *animations = 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 // collect all unique vertices (position + normal + texcoord) and the
// original MS3D file data vertex index each one was originally from based // 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 // on the MS3D triangle data. In MS3D the triangle data can give the same

View file

@ -7,6 +7,6 @@
class MetadataFile; class MetadataFile;
class Ms3d; 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 #endif