moved scale factor option to the metadata file under transformations
This commit is contained in:
parent
c9e521c1e5
commit
b1ffbb4298
36
src/main.cpp
36
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=<scale factor>] [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;
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <vector>
|
||||
#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;
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
Reference in a new issue