--- ray/src/util/rad.c 1993/03/13 09:33:17 2.5 +++ ray/src/util/rad.c 1993/05/26 11:37:42 2.9 @@ -94,6 +94,13 @@ int (*setqopts[3])() = {lowqopts, medqopts, hiqopts}; #define renderopts (*setqopts[vscale(QUALITY)]) + /* overture calculation file */ +#ifdef NIX +char overfile[] = "overture.raw"; +#else +char overfile[] = "/dev/null"; +#endif + extern long fdate(), time(); long scenedate; /* date of latest scene or object file */ @@ -159,8 +166,11 @@ char *argv[]; /* print all values if requested */ if (explicate) printvals(); - /* run simulation */ + /* build octree */ oconv(); + /* check date on ambient file */ + checkambfile(); + /* run simulation */ renderopts(ropts); xferopts(ropts); if (rvdevice != NULL) @@ -547,6 +557,18 @@ register char *oo; } +checkambfile() /* check date on ambient file */ +{ + long afdate; + + if (vdef(AMBFILE)) { + afdate = fdate(vval(AMBFILE)); + if (afdate >= 0 & octreedate > afdate) + rmfile(vval(AMBFILE)); + } +} + + double ambval() /* compute ambient value */ { @@ -777,16 +799,7 @@ char *ro; } #ifdef MSDOS else if (n > 50) { - register char *evp = bmalloc(n+6); - if (evp == NULL) - syserr(progname); - strcpy(evp, "ROPT="); - strcat(evp, ro); - if (putenv(evp) != 0) { - fprintf(stderr, "%s: out of environment space\n", - progname); - exit(1); - } + setenv("ROPT", ro+1); strcpy(ro, " $ROPT"); } #endif @@ -926,8 +939,13 @@ register char *vs; cp += strlen(cp); } } - /* append any additional options */ - strcpy(cp, vs); + strcpy(cp, vs); /* append any additional options */ +#ifdef MSDOS + if (strlen(viewopts) > 40) { + setenv("VIEW", viewopts); + return("$VIEW"); + } +#endif return(viewopts); } @@ -935,11 +953,11 @@ register char *vs; char * getview(n, vn) /* get view n, or NULL if none */ int n; -char *vn; +char *vn; /* returned view name */ { - register char *mv; + register char *mv = NULL; - if (viewselect != NULL) { + if (viewselect != NULL) { /* command-line selected */ if (n) /* only do one */ return(NULL); if (viewselect[0] == '-') { /* already specified */ @@ -958,13 +976,14 @@ char *vn; return(specview(mv)); return(specview(viewselect)); /* standard view? */ } - if (vn != NULL && (mv = nvalue(vv+VIEW, n)) != NULL) { + mv = nvalue(vv+VIEW, n); /* use view n */ + if (vn != NULL & mv != NULL) { if (*mv != '-') while (*mv && !isspace(*mv)) *vn++ = *mv++; *vn = '\0'; } - return(specview(nvalue(vv+VIEW, n))); /* use view n */ + return(specview(mv)); } @@ -1022,12 +1041,6 @@ char *opts; else badvalue(REPORT); } - /* check date on ambient file */ - if (vdef(AMBFILE)) { - long afdate = fdate(vval(AMBFILE)); - if (afdate >= 0 & octreedate > afdate) - rmfile(vval(AMBFILE)); - } /* do each view */ vn = 0; while ((vw = getview(vn++, vs)) != NULL) { @@ -1047,14 +1060,16 @@ char *opts; sprintf(combuf, "rpict%s %s%s -x 64 -y 64 -ps 1 %s > %s", rep, vw, opts, - vval(OCTREE), rawfile); + vval(OCTREE), overfile); if (runcom(combuf)) { fprintf(stderr, - "%s: error in overture for view %s\n\t%s removed\n", - progname, vs, rawfile); - unlink(rawfile); + "%s: error in overture for view %s\n", + progname, vs); exit(1); } +#ifdef NIX + rmfile(overfile); +#endif } sprintf(combuf, "rpict%s %s %s%s %s > %s", rep, vw, res, opts, @@ -1110,6 +1125,26 @@ char *fn; return(0); return(unlink(fn)); } + + +#ifdef MSDOS +setenv(vname, value) /* set an environment variable */ +char *vname, *value; +{ + register char *evp; + + evp = bmalloc(strlen(vname)+strlen(value)+2); + if (evp == NULL) + syserr(progname); + sprintf(evp, "%s=%s", vname, value); + if (putenv(evp) != 0) { + fprintf(stderr, "%s: out of environment space\n", progname); + exit(1); + } + if (!silent) + printf("set %s\n", evp); +} +#endif badvalue(vc) /* report bad variable value and exit */