clean up main() processing a bit in preparation for metadata loading

This commit is contained in:
Gered 2012-12-22 16:04:01 -05:00
parent fdcb7f459d
commit 8c7f07d797

View file

@ -47,8 +47,10 @@ int main(int argc, char **argv)
}
}
// find file extension part of the string in the input filename
// we will use this to make an appropriate output mesh filename *and*
// to make an XML metadata filename
std::string extension;
try
{
extension = file.substr(file.find_last_of('.'), std::string::npos);
@ -59,21 +61,40 @@ int main(int argc, char **argv)
{
extension = "";
}
std::string meshFile = "";
if (extension.length() > 0)
// make sure the ms3d file didn't have some other extension for some reason
// which might conflict with our automatic mesh and metadata filename
// creation ...
if (extension == ".mesh" || extension == ".xml")
{
meshFile = file;
meshFile.erase(meshFile.find_last_of('.'), std::string::npos);
meshFile.append(".mesh");
printf("Bad input filename extension.\n\n");
return 1;
}
// create mesh filename based on ms3d filename
std::string meshFile = file;
if (extension.length() > 0)
meshFile.erase(meshFile.find_last_of('.'), std::string::npos);
meshFile.append(".mesh");
std::string metadataFile = file;
if (extension.length() > 0)
metadataFile.erase(metadataFile.find_last_of('.'), std::string::npos);
metadataFile.append((".xml"));
// load the MS3D ...
Ms3d *ms3d = new Ms3d();
if (!ms3d->Load(file))
{
printf("Error loading MS3D file.\n\n");
return 1;
}
// attempt to load a metadata file
// TODO: write this
// convert to a mesh file
// TODO: pass in loaded metadata object
if (!ConvertToMeshFile(meshFile, ms3d, scaleFactor))
{
printf("Error converting MS3D to MESH.\n\n");