--- ray/src/ot/obj2mesh.c 2004/04/22 17:35:54 2.10 +++ ray/src/ot/obj2mesh.c 2021/07/28 22:16:43 2.16 @@ -1,11 +1,12 @@ #ifndef lint -static const char RCSid[] = "$Id: obj2mesh.c,v 2.10 2004/04/22 17:35:54 greg Exp $"; +static const char RCSid[] = "$Id: obj2mesh.c,v 2.16 2021/07/28 22:16:43 greg Exp $"; #endif /* * Main program to compile a Wavefront .OBJ file into a Radiance mesh */ #include "copyright.h" +#include "paths.h" #include "platform.h" #include "standard.h" #include "resolu.h" @@ -22,7 +23,7 @@ char *progname; /* argv[0] */ int nowarn = 0; /* supress warnings? */ -int objlim = 15; /* # of objects before split */ +int objlim = 9; /* # of objects before split */ int resolu = 16384; /* octree resolution limit */ @@ -38,8 +39,8 @@ main( /* compile a .OBJ file into a mesh */ char *argv[] ) { - int nmatf = 0; - char *matinp[32]; + int verbose = 0; + char *cp; int i, j; progname = argv[0]; @@ -54,11 +55,24 @@ main( /* compile a .OBJ file into a mesh */ resolu = atoi(argv[++i]); break; case 'a': /* material file */ - matinp[nmatf++] = argv[++i]; + readobj(argv[++i]); break; + case 'l': /* library material */ + cp = getpath(argv[++i], getrlibpath(), R_OK); + if (cp == NULL) { + sprintf(errmsg, + "cannot find library material: '%s'", + argv[i]); + error(SYSTEM, errmsg); + } + readobj(cp); + break; case 'w': /* supress warnings */ nowarn = 1; break; + case 'v': /* print mesh stats */ + verbose = 1; + break; default: sprintf(errmsg, "unknown option: '%s'", argv[i]); error(USER, errmsg); @@ -69,9 +83,6 @@ main( /* compile a .OBJ file into a mesh */ error(USER, "too many file arguments"); /* initialize mesh */ cvinit(i==argc-2 ? argv[i+1] : ""); - /* load material input */ - for (j = 0; j < nmatf; j++) - readobj(matinp[j]); /* read .OBJ file into triangles */ if (i == argc) wfreadobj(NULL); @@ -105,7 +116,8 @@ main( /* compile a .OBJ file into a mesh */ writemesh(ourmesh, stdout); /* write mesh to output */ - /* printmeshstats(ourmesh, stderr); */ + if (verbose) + printmeshstats(ourmesh, stderr); quit(0); return 0; /* pro forma return */