--- ray/src/util/rad.c 1993/05/26 11:37:42 2.9 +++ ray/src/util/rad.c 1993/08/24 21:44:55 2.20 @@ -105,10 +105,12 @@ extern long fdate(), time(); long scenedate; /* date of latest scene or object file */ long octreedate; /* date of octree */ +long matdate; /* date of latest material file */ int explicate = 0; /* explicate variables */ int silent = 0; /* do work silently */ int noaction = 0; /* don't do anything */ +int vwonly = 0; /* print view only */ char *rvdevice = NULL; /* rview output device */ char *viewselect = NULL; /* specific view only */ @@ -142,6 +144,9 @@ char *argv[]; case 'o': rvdevice = argv[++i]; break; + case 'V': + vwonly++; + /* fall through */ case 'v': viewselect = argv[++i]; break; @@ -166,6 +171,9 @@ char *argv[]; /* print all values if requested */ if (explicate) printvals(); + /* print view and exit? */ + if (vwonly) + exit(printview()==0 ? 0 : 1); /* build octree */ oconv(); /* check date on ambient file */ @@ -309,7 +317,7 @@ register int n; { register char *cp; - if (vp == NULL || n < 0 || n >= vp->nass) + if (vp == NULL | n < 0 | n >= vp->nass) return(NULL); cp = vp->value; while (n--) @@ -423,6 +431,9 @@ checkfiles() /* check for existence and modified tim vnam(OCTREE), vnam(SCENE)); exit(1); } + matdate = -1; + if (vdef(MATERIAL)) + matdate = checklast(vval(MATERIAL)); } @@ -561,11 +572,12 @@ checkambfile() /* check date on ambient file */ { long afdate; - if (vdef(AMBFILE)) { - afdate = fdate(vval(AMBFILE)); - if (afdate >= 0 & octreedate > afdate) - rmfile(vval(AMBFILE)); - } + if (!vdef(AMBFILE)) + return; + if ((afdate = fdate(vval(AMBFILE))) < 0) + return; + if (octreedate > afdate | matdate > afdate) + rmfile(vval(AMBFILE)); } @@ -573,11 +585,11 @@ double ambval() /* compute ambient value */ { if (vdef(EXPOSURE)) { + if (!isflt(vval(EXPOSURE))) + badvalue(EXPOSURE); if (vval(EXPOSURE)[0] == '+' || vval(EXPOSURE)[0] == '-') return(.5/pow(2.,atof(vval(EXPOSURE)))); - if (isdigit(vval(EXPOSURE)[0]) || vval(EXPOSURE)[0] == '.') - return(.5/atof(vval(EXPOSURE))); - badvalue(EXPOSURE); + return(.5/atof(vval(EXPOSURE))); } if (vlet(ZONE) == 'E') return(10.); @@ -621,7 +633,7 @@ register char *op; op = addarg(op, "-ds .4"); else op = addarg(op, "-ds 0"); - op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .7"); + op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .5"); if (vdef(AMBFILE)) { sprintf(op, " -af %s", vval(AMBFILE)); op += strlen(op); @@ -629,13 +641,13 @@ register char *op; overture = 0; switch (vscale(VARIABILITY)) { case LOW: - op = addarg(op, "-aa .4 -ad 32"); + op = addarg(op, "-aa .4 -ad 64"); break; case MEDIUM: - op = addarg(op, "-aa .3 -ad 64"); + op = addarg(op, "-aa .3 -ad 128"); break; case HIGH: - op = addarg(op, "-aa .25 -ad 128"); + op = addarg(op, "-aa .25 -ad 256"); break; } op = addarg(op, "-as 0"); @@ -685,7 +697,7 @@ register char *op; op = addarg(op, "-ds .2 -dj .35"); else op = addarg(op, "-ds .3"); - op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .15"); + op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1"); if (overture = vint(INDIRECT)) { sprintf(op, " -ab %d", overture); op += strlen(op); @@ -697,13 +709,13 @@ register char *op; overture = 0; switch (vscale(VARIABILITY)) { case LOW: - op = addarg(op, "-aa .25 -ad 128 -as 0"); + op = addarg(op, "-aa .25 -ad 196 -as 0"); break; case MEDIUM: - op = addarg(op, "-aa .2 -ad 300 -as 64"); + op = addarg(op, "-aa .2 -ad 400 -as 64"); break; case HIGH: - op = addarg(op, "-aa .15 -ad 500 -as 128"); + op = addarg(op, "-aa .15 -ad 768 -as 196"); break; } d = ambval(); @@ -752,7 +764,7 @@ register char *op; op = addarg(op, "-ds .1 -dj .7"); else op = addarg(op, "-ds .2"); - op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .03"); + op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01"); sprintf(op, " -ab %d", overture=vint(INDIRECT)+1); op += strlen(op); if (vdef(AMBFILE)) { @@ -762,13 +774,13 @@ register char *op; overture = 0; switch (vscale(VARIABILITY)) { case LOW: - op = addarg(op, "-aa .15 -ad 200 -as 0"); + op = addarg(op, "-aa .15 -ad 256 -as 0"); break; case MEDIUM: - op = addarg(op, "-aa .125 -ad 512 -as 128"); + op = addarg(op, "-aa .125 -ad 512 -as 256"); break; case HIGH: - op = addarg(op, "-aa .08 -ad 850 -as 256"); + op = addarg(op, "-aa .08 -ad 1024 -as 512"); break; } d = ambval(); @@ -784,18 +796,22 @@ xferopts(ro) /* transfer options if indicated */ char *ro; { int fd, n; + register char *cp; n = strlen(ro); if (n < 2) return; if (vdef(OPTFILE)) { - if ((fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1) + for (cp = ro; cp[1]; cp++) + if (isspace(cp[1]) && cp[2] == '-' && isalpha(cp[3])) + *cp = '\n'; + else + *cp = cp[1]; + *cp = '\n'; + fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666); + if (fd < 0 || write(fd, ro, n) != n || close(fd) < 0) syserr(vval(OPTFILE)); - if (write(fd, ro+1, n-1) != n-1) - syserr(vval(OPTFILE)); - write(fd, "\n", 1); - close(fd); - sprintf(ro, " \"^%s\"", vval(OPTFILE)); + sprintf(ro, " @%s", vval(OPTFILE)); } #ifdef MSDOS else if (n > 50) { @@ -814,8 +830,14 @@ register char *po; po = addarg(po, "-1 -e"); po = addarg(po, vval(EXPOSURE)); } - if (vscale(QUALITY) == HIGH) - po = addarg(po, "-r .65"); + switch (vscale(QUALITY)) { + case MEDIUM: + po = addarg(po, "-r 1"); + break; + case HIGH: + po = addarg(po, "-m .25"); + break; + } if (vdef(PFILT)) po = addarg(po, vval(PFILT)); } @@ -955,7 +977,7 @@ getview(n, vn) /* get view n, or NULL if none */ int n; char *vn; /* returned view name */ { - register char *mv = NULL; + register char *mv; if (viewselect != NULL) { /* command-line selected */ if (n) /* only do one */ @@ -970,6 +992,9 @@ char *vn; /* returned view name */ ; *vn = '\0'; } + /* view number? */ + if (isint(viewselect)) + return(specview(nvalue(vv+VIEW, atoi(viewselect)-1))); /* check list */ while ((mv = nvalue(vv+VIEW, n++)) != NULL) if (matchword(viewselect, mv)) @@ -978,15 +1003,63 @@ char *vn; /* returned view name */ } mv = nvalue(vv+VIEW, n); /* use view n */ if (vn != NULL & mv != NULL) { - if (*mv != '-') - while (*mv && !isspace(*mv)) - *vn++ = *mv++; + register char *mv2 = mv; + if (*mv2 != '-') + while (*mv2 && !isspace(*mv2)) + *vn++ = *mv2++; *vn = '\0'; } return(specview(mv)); } +printview() /* print out selected view */ +{ + extern char *atos(); + char buf[256]; + FILE *fp; + register char *vopts, *cp; + + vopts = getview(0, NULL); + if (vopts == NULL) + return(-1); + fputs("VIEW=", stdout); + do { + if (matchword(vopts, "-vf")) { /* expand view file */ + vopts = sskip(vopts); + if (!*atos(buf, sizeof(buf), vopts)) + return(-1); + if ((fp = fopen(buf, "r")) == NULL) + return(-1); + for (buf[sizeof(buf)-2] = '\n'; + fgets(buf, sizeof(buf), fp) != NULL && + buf[0] != '\n'; + buf[sizeof(buf)-2] = '\n') { + if (buf[sizeof(buf)-2] != '\n') { + ungetc(buf[sizeof(buf)-2], fp); + buf[sizeof(buf)-2] = '\0'; + } + if (matchword(buf, "VIEW=") || + matchword(buf, "rview")) { + for (cp = sskip(buf); *cp && *cp != '\n'; cp++) + putchar(*cp); + } + } + fclose(fp); + vopts = sskip(vopts); + } else { + while (isspace(*vopts)) + vopts++; + putchar(' '); + while (*vopts && !isspace(*vopts)) + putchar(*vopts++); + } + } while (*vopts++); + putchar('\n'); + return(0); +} + + rview(opts) /* run rview with first view */ char *opts; { @@ -1011,6 +1084,7 @@ char *opts; char pfopts[128]; char vs[32], *vw; int vn, mult; + long lastdate; /* get pfilt options */ pfiltopts(pfopts); /* get resolution, reporting */ @@ -1041,6 +1115,8 @@ char *opts; else badvalue(REPORT); } + /* get update time */ + lastdate = octreedate > matdate ? octreedate : matdate; /* do each view */ vn = 0; while ((vw = getview(vn++, vs)) != NULL) { @@ -1048,11 +1124,11 @@ char *opts; sprintf(vs, "%d", vn); sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs); /* check date on picture */ - if (fdate(picfile) > octreedate) + if (fdate(picfile) >= lastdate) continue; /* build rpict command */ sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs); - if (fdate(rawfile) > octreedate) /* recover */ + if (fdate(rawfile) >= octreedate) /* recover */ sprintf(combuf, "rpict%s%s -ro %s %s", rep, opts, rawfile, vval(OCTREE)); else {