clean up main() processing a bit in preparation for metadata loading
This commit is contained in:
parent
fdcb7f459d
commit
8c7f07d797
33
src/main.cpp
33
src/main.cpp
|
@ -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;
|
std::string extension;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
extension = file.substr(file.find_last_of('.'), std::string::npos);
|
extension = file.substr(file.find_last_of('.'), std::string::npos);
|
||||||
|
@ -60,20 +62,39 @@ int main(int argc, char **argv)
|
||||||
extension = "";
|
extension = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string meshFile = "";
|
// make sure the ms3d file didn't have some other extension for some reason
|
||||||
if (extension.length() > 0)
|
// which might conflict with our automatic mesh and metadata filename
|
||||||
|
// creation ...
|
||||||
|
if (extension == ".mesh" || extension == ".xml")
|
||||||
{
|
{
|
||||||
meshFile = file;
|
printf("Bad input filename extension.\n\n");
|
||||||
meshFile.erase(meshFile.find_last_of('.'), std::string::npos);
|
return 1;
|
||||||
meshFile.append(".mesh");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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();
|
Ms3d *ms3d = new Ms3d();
|
||||||
if (!ms3d->Load(file))
|
if (!ms3d->Load(file))
|
||||||
{
|
{
|
||||||
printf("Error loading MS3D file.\n\n");
|
printf("Error loading MS3D file.\n\n");
|
||||||
return 1;
|
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))
|
if (!ConvertToMeshFile(meshFile, ms3d, scaleFactor))
|
||||||
{
|
{
|
||||||
printf("Error converting MS3D to MESH.\n\n");
|
printf("Error converting MS3D to MESH.\n\n");
|
||||||
|
|
Reference in a new issue