//----------------------------------------------------------------------------- // main() //----------------------------------------------------------------------------- int main(int argc, char ** argv) { // Get file names and options Options opt; string inFile; string outFile; try { if(argc < 3) throw runtime_error("Too few arguments."); inFile = string(argv[1]); outFile = string(argv[2]); opt.GetFromArgs(argc, argv, 3); } catch(exception &e) { cout << "Error: " << e.what() << endl << endl; cout << "Usage: " << argv[0] << " infile outfile [options]" << endl << endl; cout << "Options:" << endl; cout << endl << " Data manipulation (all formats)" << endl; cout << " --scale arg Scale the mesh by a scalar factor." << endl; cout << " --upaxis arg Set up axis (X, Y, Z, -X, -Y, -Z). If != Z, the mesh will" << endl; cout << " be flipped." << endl; cout << " --flip Flip triangle orientation." << endl; cout << " --calc-normals If the source file does not contain any normals, calculate" << endl; cout << " them." << endl; cout << " --no-normals Do not export normals." << endl; cout << " --no-texcoords Do not export texture coordinates." << endl; cout << " --no-colors Do not export vertex colors." << endl; cout << endl << " OpenCTM output" << endl; cout << " --method arg Select compression method (RAW, MG1, MG2)" << endl; cout << " --level arg Set the compression level (0 - 9)" << endl; cout << endl << " OpenCTM MG2 method" << endl; cout << " --vprec arg Set vertex precision" << endl; cout << " --vprecrel arg Set vertex precision, relative method" << endl; cout << " --nprec arg Set normal precision" << endl; cout << " --tprec arg Set texture map precision" << endl; cout << " --cprec arg Set color precision" << endl; cout << endl << " Miscellaneous" << endl; cout << " --comment arg Set the file comment (default is to use the comment" << endl; cout << " from the input file, if any)." << endl; cout << " --texfile arg Set the texture file name reference for the texture" << endl; cout << " (default is to use the texture file name reference" << endl; cout << " from the input file, if any)." << endl; // Show supported formats cout << endl << "Supported file formats:" << endl << endl; list<string> formatList; SupportedFormats(formatList); for(list<string>::iterator i = formatList.begin(); i != formatList.end(); ++ i) cout << " " << (*i) << endl; cout << endl; return 0; } try { // Define mesh Mesh mesh; // Create a timer instance SysTimer timer; double dt; // Load input file cout << "Loading " << inFile << "... " << flush; timer.Push(); ImportMesh(inFile.c_str(), &mesh); dt = timer.PopDelta(); cout << 1000.0 * dt << " ms" << endl; // Manipulate the mesh PreProcessMesh(mesh, opt); // Override comment? if(opt.mComment.size() > 0) mesh.mComment = opt.mComment; // Override texture file name? if(opt.mTexFileName.size() > 0) mesh.mTexFileName = opt.mTexFileName; // Save output file cout << "Saving " << outFile << "... " << flush; timer.Push(); ExportMesh(outFile.c_str(), &mesh, opt); dt = timer.PopDelta(); cout << 1000.0 * dt << " ms" << endl; } catch(exception &e) { cout << "Error: " << e.what() << endl; } return 0; }