--- ray/src/util/rad.c 1994/10/24 13:49:16 2.41 +++ ray/src/util/rad.c 1995/12/08 19:55:50 2.47 @@ -1,4 +1,4 @@ -/* Copyright (c) 1994 Regents of the University of California */ +/* Copyright (c) 1995 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -38,7 +38,7 @@ int onevalue(), catvalues(), boolvalue(), #define ZONE 9 /* simulation zone */ #define QUALITY 10 /* desired rendering quality */ #define OCTREE 11 /* octree file name */ -#define PICTURE 12 /* picture file name */ +#define PICTURE 12 /* picture file root name */ #define AMBFILE 13 /* ambient file name */ #define OPTFILE 14 /* rendering options file */ #define EXPOSURE 15 /* picture exposure setting */ @@ -49,8 +49,10 @@ int onevalue(), catvalues(), boolvalue(), #define PENUMBRAS 20 /* shadow penumbras are desired */ #define VARIABILITY 21 /* level of light variability */ #define REPORT 22 /* report frequency and errfile */ +#define RAWFILE 23 /* raw picture file root name */ +#define ZFILE 24 /* distance file root name */ /* total number of variables */ -#define NVARS 23 +#define NVARS 25 VARIABLE vv[NVARS] = { /* variable-value pairs */ {"objects", 3, 0, NULL, catvalues}, @@ -76,6 +78,8 @@ VARIABLE vv[NVARS] = { /* variable-value pairs */ {"PENUMBRAS", 3, 0, NULL, boolvalue}, {"VARIABILITY", 3, 0, NULL, qualvalue}, {"REPORT", 3, 0, NULL, onevalue}, + {"RAWFILE", 3, 0, NULL, onevalue}, + {"ZFILE", 2, 0, NULL, onevalue}, }; VARIABLE *matchvar(); @@ -97,7 +101,7 @@ char *nvalue(); /* overture calculation file */ #ifdef NIX -char overfile[] = "overture.raw"; +char overfile[] = "overture.unf"; #else char overfile[] = "/dev/null"; #endif @@ -559,7 +563,7 @@ double org[3], *sizp; extern FILE *popen(); static double oorg[3], osiz = 0.; double min[3], max[3]; - char buf[512]; + char buf[1024]; FILE *fp; register int i; @@ -685,7 +689,7 @@ printvals() /* print variable values */ oconv() /* run oconv and mkillum if necessary */ { static char illumtmp[] = "ilXXXXXX"; - char combuf[512], ocopts[64], mkopts[64]; + char combuf[1024], ocopts[64], mkopts[64]; oconvopts(ocopts); /* get options */ if (octreedate < scenedate) { /* check date on original octree */ @@ -773,6 +777,7 @@ oconv() /* run oconv and mkillum if necessary */ "%s: error generating octree\n\t%s removed\n", progname, oct1name); unlink(oct1name); + unlink(illumtmp); exit(1); } rmfile(illumtmp); @@ -937,7 +942,7 @@ medqopts(op, po) /* medium quality rendering options register char *op; char *po; { - double d, org[3], siz[3]; + double d, org[3], siz[3], asz; *op = '\0'; *po = '\0'; @@ -948,25 +953,32 @@ char *po; if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY) badvalue(ZONE); getoctcube(org, &d); - d *= 3./(siz[0]+siz[1]+siz[2]); + asz = (siz[0]+siz[1]+siz[2])/3.; + d /= asz; switch (vscale(DETAIL)) { case LOW: po = addarg(po, vbool(PENUMBRAS) ? "-ps 4" : "-ps 8"); op = addarg(op, "-dp 256"); sprintf(op, " -ar %d", (int)(8*d)); op += strlen(op); + sprintf(op, " -ms %.2g", asz/20.); + op += strlen(op); break; case MEDIUM: po = addarg(po, vbool(PENUMBRAS) ? "-ps 3" : "-ps 6"); op = addarg(op, "-dp 512"); sprintf(op, " -ar %d", (int)(16*d)); op += strlen(op); + sprintf(op, " -ms %.2g", asz/40.); + op += strlen(op); break; case HIGH: po = addarg(po, vbool(PENUMBRAS) ? "-ps 2" : "-ps 4"); op = addarg(op, "-dp 1024"); sprintf(op, " -ar %d", (int)(32*d)); op += strlen(op); + sprintf(op, " -ms %.2g", asz/80.); + op += strlen(op); break; } po = addarg(po, "-pt .08"); @@ -1008,7 +1020,7 @@ hiqopts(op, po) /* high quality rendering options * register char *op; char *po; { - double d, org[3], siz[3]; + double d, org[3], siz[3], asz; *op = '\0'; *po = '\0'; @@ -1019,30 +1031,37 @@ char *po; if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY) badvalue(ZONE); getoctcube(org, &d); - d *= 3./(siz[0]+siz[1]+siz[2]); + asz = (siz[0]+siz[1]+siz[2])/3.; + d /= asz; switch (vscale(DETAIL)) { case LOW: po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 8"); op = addarg(op, "-dp 1024"); sprintf(op, " -ar %d", (int)(16*d)); op += strlen(op); + sprintf(op, " -ms %.2g", asz/40.); + op += strlen(op); break; case MEDIUM: po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 5"); op = addarg(op, "-dp 2048"); sprintf(op, " -ar %d", (int)(32*d)); op += strlen(op); + sprintf(op, " -ms %.2g", asz/80.); + op += strlen(op); break; case HIGH: po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 3"); op = addarg(op, "-dp 4096"); sprintf(op, " -ar %d", (int)(64*d)); op += strlen(op); + sprintf(op, " -ms %.2g", asz/160.); + op += strlen(op); break; } po = addarg(po, "-pt .04"); if (vbool(PENUMBRAS)) - op = addarg(op, "-ds .1 -dj .7"); + op = addarg(op, "-ds .1 -dj .65"); else op = addarg(op, "-ds .2"); op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01"); @@ -1179,7 +1198,7 @@ register char *vs; zpos = -1; vs++; } viewtype = 'v'; - if (*vs == 'v' | *vs == 'l' | *vs == 'a' | *vs == 'h') + if (*vs == 'v' | *vs == 'l' | *vs == 'a' | *vs == 'h' | *vs == 'c') viewtype = *vs++; cp = viewopts; if ((!*vs || isspace(*vs)) && (xpos|ypos|zpos)) { /* got one! */ @@ -1234,6 +1253,9 @@ register char *vs; case 'h': cp = addarg(cp, "-vh 180 -vv 180"); break; + case 'c': + cp = addarg(cp, "-vh 180 -vv 90"); + break; } } else { while (!isspace(*vs)) /* else skip id */ @@ -1382,7 +1404,8 @@ rpict(opts, po) /* run rpict and pfilt for each vie char *opts, *po; { char combuf[1024]; - char rawfile[MAXPATH], picfile[MAXPATH], rep[MAXPATH+16], res[32]; + char rawfile[MAXPATH], picfile[MAXPATH]; + char zopt[MAXPATH+4], rep[MAXPATH+16], res[32]; char pfopts[128]; char vs[32], *vw; int vn, mult; @@ -1435,12 +1458,17 @@ char *opts, *po; if (!vs[0]) sprintf(vs, "%d", vn); sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs); + if (vdef(ZFILE)) + sprintf(zopt, " -z %s_%s.zbf", vval(ZFILE), vs); + else + zopt[0] = '\0'; /* check date on picture */ pfdt = fdate(picfile); if (pfdt >= oct1date) continue; /* get raw file name */ - sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs); + sprintf(rawfile, "%s_%s.unf", + vdef(RAWFILE) ? vval(RAWFILE) : vval(PICTURE), vs); rfdt = fdate(rawfile); if (touchonly) { /* update times only */ if (rfdt) { @@ -1452,8 +1480,8 @@ char *opts, *po; } /* build rpict command */ if (rfdt >= oct1date) /* recover */ - sprintf(combuf, "rpict%s%s%s -ro %s %s", - rep, po, opts, rawfile, oct1name); + sprintf(combuf, "rpict%s%s%s%s -ro %s %s", + rep, po, opts, zopt, rawfile, oct1name); else { if (overture) { /* run overture calculation */ sprintf(combuf, @@ -1470,31 +1498,37 @@ char *opts, *po; rmfile(overfile); #endif } - sprintf(combuf, "rpict%s %s %s%s%s %s > %s", - rep, vw, res, po, opts, - oct1name, rawfile); + sprintf(combuf, "rpict%s %s %s%s%s%s %s > %s", + rep, vw, res, po, opts, zopt, + oct1name, rawfile); } if (runcom(combuf)) { /* run rpict */ fprintf(stderr, "%s: error rendering view %s\n", progname, vs); exit(1); } + if (!vdef(RAWFILE) || strcmp(vval(RAWFILE),vval(PICTURE))) { /* build pfilt command */ - if (mult > 1) - sprintf(combuf, "pfilt%s -x /%d -y /%d %s > %s", + if (mult > 1) + sprintf(combuf, "pfilt%s -x /%d -y /%d %s > %s", pfopts, mult, mult, rawfile, picfile); - else - sprintf(combuf, "pfilt%s %s > %s", pfopts, - rawfile, picfile); - if (runcom(combuf)) { /* run pfilt */ - fprintf(stderr, - "%s: error filtering view %s\n\t%s removed\n", - progname, vs, picfile); - unlink(picfile); - exit(1); + else + sprintf(combuf, "pfilt%s %s > %s", pfopts, + rawfile, picfile); + if (runcom(combuf)) { /* run pfilt */ + fprintf(stderr, + "%s: error filtering view %s\n\t%s removed\n", + progname, vs, picfile); + unlink(picfile); + exit(1); + } } - /* remove raw file */ - rmfile(rawfile); + /* remove/rename raw file */ + if (vdef(RAWFILE)) { + sprintf(combuf, "%s_%s.pic", vval(RAWFILE), vs); + mvfile(rawfile, combuf); + } else + rmfile(rawfile); } } @@ -1539,6 +1573,21 @@ char *fn; if (noaction) return(0); return(unlink(fn)); +} + + +mvfile(fold, fnew) /* move a file */ +char *fold, *fnew; +{ + if (!silent) +#ifdef MSDOS + printf("\trename %s %s\n", fold, fnew); +#else + printf("\tmv %s %s\n", fold, fnew); +#endif + if (noaction) + return(0); + return(rename(fold, fnew)); }