ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/rad.c
(Generate patch)

Comparing ray/src/util/rad.c (file contents):
Revision 2.5 by greg, Sat Mar 13 09:33:17 1993 UTC vs.
Revision 2.40 by greg, Thu Apr 21 12:22:44 1994 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1993 Regents of the University of California */
1 > /* Copyright (c) 1994 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 11 | Line 11 | static char SCCSid[] = "$SunId$ LBL";
11   #include "standard.h"
12   #include "paths.h"
13   #include <ctype.h>
14 + #include <sys/types.h>
15  
16  
17   typedef struct {
# Line 21 | Line 22 | typedef struct {
22          int     (*fixval)();    /* assignment checking function */
23   } VARIABLE;
24  
25 < int     onevalue(), catvalues();
25 > int     onevalue(), catvalues(), boolvalue(),
26 >        qualvalue(), fltvalue(), intvalue();
27  
28                                  /* variables */
29   #define OBJECT          0               /* object files */
30   #define SCENE           1               /* scene files */
31   #define MATERIAL        2               /* material files */
32 < #define RENDER          3               /* rendering options */
33 < #define OCONV           4               /* oconv options */
34 < #define PFILT           5               /* pfilt options */
35 < #define VIEW            6               /* view(s) for picture(s) */
36 < #define ZONE            7               /* simulation zone */
37 < #define QUALITY         8               /* desired rendering quality */
38 < #define OCTREE          9               /* octree file name */
39 < #define PICTURE         10              /* picture file name */
40 < #define AMBFILE         11              /* ambient file name */
41 < #define OPTFILE         12              /* rendering options file */
42 < #define EXPOSURE        13              /* picture exposure setting */
43 < #define RESOLUTION      14              /* maximum picture resolution */
44 < #define UP              15              /* view up (X, Y or Z) */
45 < #define INDIRECT        16              /* indirection in lighting */
46 < #define DETAIL          17              /* level of scene detail */
47 < #define PENUMBRAS       18              /* shadow penumbras are desired */
48 < #define VARIABILITY     19              /* level of light variability */
49 < #define REPORT          20              /* report frequency and errfile */
32 > #define ILLUM           3               /* mkillum input files */
33 > #define MKILLUM         4               /* mkillum options */
34 > #define RENDER          5               /* rendering options */
35 > #define OCONV           6               /* oconv options */
36 > #define PFILT           7               /* pfilt options */
37 > #define VIEW            8               /* view(s) for picture(s) */
38 > #define ZONE            9               /* simulation zone */
39 > #define QUALITY         10              /* desired rendering quality */
40 > #define OCTREE          11              /* octree file name */
41 > #define PICTURE         12              /* picture file name */
42 > #define AMBFILE         13              /* ambient file name */
43 > #define OPTFILE         14              /* rendering options file */
44 > #define EXPOSURE        15              /* picture exposure setting */
45 > #define RESOLUTION      16              /* maximum picture resolution */
46 > #define UP              17              /* view up (X, Y or Z) */
47 > #define INDIRECT        18              /* indirection in lighting */
48 > #define DETAIL          19              /* level of scene detail */
49 > #define PENUMBRAS       20              /* shadow penumbras are desired */
50 > #define VARIABILITY     21              /* level of light variability */
51 > #define REPORT          22              /* report frequency and errfile */
52                                  /* total number of variables */
53 < #define NVARS           21
53 > #define NVARS           23
54  
55   VARIABLE        vv[NVARS] = {           /* variable-value pairs */
56          {"objects",     3,      0,      NULL,   catvalues},
57          {"scene",       3,      0,      NULL,   catvalues},
58          {"materials",   3,      0,      NULL,   catvalues},
59 +        {"illum",       3,      0,      NULL,   catvalues},
60 +        {"mkillum",     3,      0,      NULL,   catvalues},
61          {"render",      3,      0,      NULL,   catvalues},
62          {"oconv",       3,      0,      NULL,   catvalues},
63          {"pfilt",       2,      0,      NULL,   catvalues},
64          {"view",        2,      0,      NULL,   NULL},
65          {"ZONE",        2,      0,      NULL,   onevalue},
66 <        {"QUALITY",     3,      0,      NULL,   onevalue},
66 >        {"QUALITY",     3,      0,      NULL,   qualvalue},
67          {"OCTREE",      3,      0,      NULL,   onevalue},
68          {"PICTURE",     3,      0,      NULL,   onevalue},
69          {"AMBFILE",     3,      0,      NULL,   onevalue},
70          {"OPTFILE",     3,      0,      NULL,   onevalue},
71 <        {"EXPOSURE",    3,      0,      NULL,   onevalue},
71 >        {"EXPOSURE",    3,      0,      NULL,   fltvalue},
72          {"RESOLUTION",  3,      0,      NULL,   onevalue},
73          {"UP",          2,      0,      NULL,   onevalue},
74 <        {"INDIRECT",    3,      0,      NULL,   onevalue},
75 <        {"DETAIL",      3,      0,      NULL,   onevalue},
76 <        {"PENUMBRAS",   3,      0,      NULL,   onevalue},
77 <        {"VARIABILITY", 3,      0,      NULL,   onevalue},
74 >        {"INDIRECT",    3,      0,      NULL,   intvalue},
75 >        {"DETAIL",      3,      0,      NULL,   qualvalue},
76 >        {"PENUMBRAS",   3,      0,      NULL,   boolvalue},
77 >        {"VARIABILITY", 3,      0,      NULL,   qualvalue},
78          {"REPORT",      3,      0,      NULL,   onevalue},
79   };
80  
81   VARIABLE        *matchvar();
82   char    *nvalue();
77 int     vscale();
83  
84   #define UPPER(c)        ((c)&~0x20)     /* ASCII trick */
85  
# Line 83 | Line 88 | int    vscale();
88   #define vval(vc)        (vv[vc].value)
89   #define vint(vc)        atoi(vval(vc))
90   #define vlet(vc)        UPPER(vval(vc)[0])
91 + #define vscale          vlet
92   #define vbool(vc)       (vlet(vc)=='T')
93  
94 < #define HIGH            2
95 < #define MEDIUM          1
96 < #define LOW             0
94 > #define HIGH            'H'
95 > #define MEDIUM          'M'
96 > #define LOW             'L'
97  
98 < int     lowqopts(), medqopts(), hiqopts();
99 < int     (*setqopts[3])() = {lowqopts, medqopts, hiqopts};
98 >                                /* overture calculation file */
99 > #ifdef NIX
100 > char    overfile[] = "overture.raw";
101 > #else
102 > char    overfile[] = "/dev/null";
103 > #endif
104  
105 < #define renderopts      (*setqopts[vscale(QUALITY)])
105 > extern time_t   fdate(), time();
106  
107 < extern long     fdate(), time();
107 > time_t  scenedate;              /* date of latest scene or object file */
108 > time_t  octreedate;             /* date of octree */
109 > time_t  matdate;                /* date of latest material file */
110 > time_t  illumdate;              /* date of last illum file */
111  
112 < long    scenedate;              /* date of latest scene or object file */
113 < long    octreedate;             /* date of octree */
112 > char    *oct0name;              /* name of pre-mkillum octree */
113 > time_t  oct0date;               /* date of pre-mkillum octree */
114 > char    *oct1name;              /* name of post-mkillum octree */
115 > time_t  oct1date;               /* date of post-mkillum octree (>= matdate) */
116  
117 + int     nowarn = 0;             /* no warnings */
118   int     explicate = 0;          /* explicate variables */
119   int     silent = 0;             /* do work silently */
120   int     noaction = 0;           /* don't do anything */
121 + int     sayview = 0;            /* print view out */
122   char    *rvdevice = NULL;       /* rview output device */
123   char    *viewselect = NULL;     /* specific view only */
124  
125   int     overture = 0;           /* overture calculation needed */
126  
127   char    *progname;              /* global argv[0] */
128 + char    *rifname;               /* global rad input file name */
129  
130   char    radname[MAXPATH];       /* root Radiance file name */
131  
# Line 117 | Line 135 | int    argc;
135   char    *argv[];
136   {
137          char    ropts[512];
138 +        char    popts[64];
139          int     i;
140  
141          progname = argv[0];
# Line 135 | Line 154 | char   *argv[];
154                  case 'o':
155                          rvdevice = argv[++i];
156                          break;
157 +                case 'V':
158 +                        sayview++;
159 +                        break;
160                  case 'v':
161                          viewselect = argv[++i];
162                          break;
163 +                case 'w':
164 +                        nowarn++;
165 +                        break;
166                  default:
167                          goto userr;
168                  }
169          if (i >= argc)
170                  goto userr;
171 +        rifname = argv[i];
172                                  /* assign Radiance root file name */
173 <        rootname(radname, argv[i]);
173 >        rootname(radname, rifname);
174                                  /* load variable values */
175 <        load(argv[i]);
175 >        load(rifname);
176                                  /* get any additional assignments */
177          for (i++; i < argc; i++)
178                  setvariable(argv[i]);
# Line 159 | Line 185 | char   *argv[];
185                                  /* print all values if requested */
186          if (explicate)
187                  printvals();
188 <                                /* run simulation */
188 >                                /* build octree (and run mkillum) */
189          oconv();
190 <        renderopts(ropts);
190 >                                /* check date on ambient file */
191 >        checkambfile();
192 >                                /* run simulation */
193 >        renderopts(ropts, popts);
194          xferopts(ropts);
195          if (rvdevice != NULL)
196 <                rview(ropts);
196 >                rview(ropts, popts);
197          else
198 <                rpict(ropts);
198 >                rpict(ropts, popts);
199          exit(0);
200   userr:
201          fprintf(stderr,
202 <        "Usage: %s [-s][-n][-e][-v view][-o dev] rfile [VAR=value ..]\n",
202 >        "Usage: %s [-s][-n][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n",
203                          progname);
204          exit(1);
205   }
# Line 191 | Line 220 | register char  *rn, *fn;
220   }
221  
222  
223 + #define NOCHAR  127             /* constant for character to delete */
224 +
225 +
226   load(rfname)                    /* load Radiance simulation file */
227   char    *rfname;
228   {
# Line 206 | Line 238 | char   *rfname;
238                  for (cp = buf; *cp; cp++) {
239                          switch (*cp) {
240                          case '\\':
241 <                        case '\n':
210 <                                *cp = ' ';
241 >                                *cp++ = NOCHAR;
242                                  continue;
243                          case '#':
244                                  *cp = '\0';
# Line 227 | Line 258 | setvariable(ass)               /* assign variable according to stri
258   register char   *ass;
259   {
260          char    varname[32];
261 +        int     n;
262          register char   *cp;
263          register VARIABLE       *vp;
264          register int    i;
233        int     n;
265  
266          while (isspace(*ass))           /* skip leading space */
267                  ass++;
# Line 244 | Line 275 | register char  *ass;
275                                          /* trim value */
276          while (isspace(*ass) || *ass == '=')
277                  ass++;
278 <        cp = ass + strlen(ass);
279 <        do
280 <                *cp-- = '\0';
281 <        while (cp >= ass && isspace(*cp));
251 <        n = cp - ass + 1;
252 <        if (!n) {
278 >        for (n = strlen(ass); n > 0; n--)
279 >                if (!isspace(ass[n-1]))
280 >                        break;
281 >        if (!n && !nowarn) {
282                  fprintf(stderr, "%s: warning - missing value for variable '%s'\n",
283                                  progname, varname);
284                  return;
# Line 273 | Line 302 | register char  *ass;
302                  vp->value = malloc(n+1);
303          if (vp->value == NULL)
304                  syserr(progname);
305 <        strcpy(vp->value+i, ass);
305 >        cp = vp->value+i;               /* copy value, squeezing spaces */
306 >        *cp = *ass;
307 >        for (i = 1; i <= n; i++) {
308 >                if (ass[i] == NOCHAR)
309 >                        continue;
310 >                if (isspace(*cp))
311 >                        while (isspace(ass[i]))
312 >                                i++;
313 >                *++cp = ass[i];
314 >        }
315 >        if (isspace(*cp))               /* remove trailing space */
316 >                *cp = '\0';
317          vp->nass++;
318   }
319  
# Line 299 | Line 339 | register int   n;
339   {
340          register char   *cp;
341  
342 <        if (vp == NULL || n < 0 || n >= vp->nass)
342 >        if (vp == NULL | n < 0 | n >= vp->nass)
343                  return(NULL);
344          cp = vp->value;
345          while (n--)
# Line 309 | Line 349 | register int   n;
349   }
350  
351  
312 int
313 vscale(vc)                      /* return scale for variable vc */
314 int     vc;
315 {
316        switch(vlet(vc)) {
317        case 'H':
318                return(HIGH);
319        case 'M':
320                return(MEDIUM);
321        case 'L':
322                return(LOW);
323        }
324        badvalue(vc);
325 }
326
327
352   checkvalues()                   /* check assignments */
353   {
354          register int    i;
# Line 340 | Line 364 | register VARIABLE      *vp;
364   {
365          if (vp->nass < 2)
366                  return;
367 <        fprintf(stderr, "%s: warning - multiple assignment of variable '%s'\n",
367 >        if (!nowarn)
368 >                fprintf(stderr,
369 >                "%s: warning - multiple assignment of variable '%s'\n",
370                          progname, vp->name);
371          do
372                  vp->value += strlen(vp->value)+1;
# Line 363 | Line 389 | register VARIABLE      *vp;
389   }
390  
391  
392 < long
392 > int
393 > badmatch(tv, cv)                /* case insensitive truncated comparison */
394 > register char   *tv, *cv;
395 > {
396 >        if (!*tv) return(1);            /* null string cannot match */
397 >        do
398 >                if (UPPER(*tv) != *cv++)
399 >                        return(1);
400 >        while (*++tv);
401 >        return(0);              /* OK */
402 > }
403 >
404 >
405 > boolvalue(vp)                   /* check boolean for legal values */
406 > register VARIABLE       *vp;
407 > {
408 >        if (!vp->nass) return;
409 >        onevalue(vp);
410 >        switch (UPPER(vp->value[0])) {
411 >        case 'T':
412 >                if (badmatch(vp->value, "TRUE")) break;
413 >                return;
414 >        case 'F':
415 >                if (badmatch(vp->value, "FALSE")) break;
416 >                return;
417 >        }
418 >        fprintf(stderr, "%s: illegal value for boolean variable '%s'\n",
419 >                        progname, vp->name);
420 >        exit(1);
421 > }
422 >
423 >
424 > qualvalue(vp)                   /* check qualitative var. for legal values */
425 > register VARIABLE       *vp;
426 > {
427 >        if (!vp->nass) return;
428 >        onevalue(vp);
429 >        switch (UPPER(vp->value[0])) {
430 >        case 'L':
431 >                if (badmatch(vp->value, "LOW")) break;
432 >                return;
433 >        case 'M':
434 >                if (badmatch(vp->value, "MEDIUM")) break;
435 >                return;
436 >        case 'H':
437 >                if (badmatch(vp->value, "HIGH")) break;
438 >                return;
439 >        }
440 >        fprintf(stderr, "%s: illegal value for qualitative variable '%s'\n",
441 >                        progname, vp->name);
442 >        exit(1);
443 > }
444 >
445 >
446 > intvalue(vp)                    /* check integer variable for legal values */
447 > register VARIABLE       *vp;
448 > {
449 >        if (!vp->nass) return;
450 >        onevalue(vp);
451 >        if (isint(vp->value)) return;
452 >        fprintf(stderr, "%s: illegal value for integer variable '%s'\n",
453 >                        progname, vp->name);
454 >        exit(1);
455 > }
456 >
457 >
458 > fltvalue(vp)                    /* check float variable for legal values */
459 > register VARIABLE       *vp;
460 > {
461 >        if (!vp->nass) return;
462 >        onevalue(vp);
463 >        if (isflt(vp->value)) return;
464 >        fprintf(stderr, "%s: illegal value for real variable '%s'\n",
465 >                        progname, vp->name);
466 >        exit(1);
467 > }
468 >
469 >
470 > time_t
471   checklast(fnames)                       /* check files and find most recent */
472   register char   *fnames;
473   {
474          char    thisfile[MAXPATH];
475 <        long    thisdate, lastdate = -1;
475 >        time_t  thisdate, lastdate = 0;
476          register char   *cp;
477  
478 +        if (fnames == NULL)
479 +                return(0);
480          while (*fnames) {
481                  while (isspace(*fnames)) fnames++;
482                  cp = thisfile;
483                  while (*fnames && !isspace(*fnames))
484                          *cp++ = *fnames++;
485                  *cp = '\0';
486 <                if ((thisdate = fdate(thisfile)) < 0)
486 >                if (!(thisdate = fdate(thisfile)))
487                          syserr(thisfile);
488                  if (thisdate > lastdate)
489                          lastdate = thisdate;
# Line 386 | Line 492 | register char  *fnames;
492   }
493  
494  
495 + char *
496 + newfname(orig, pred)            /* create modified file name */
497 + char    *orig;
498 + int     pred;
499 + {
500 +        extern char     *rindex();
501 +        register char   *cp;
502 +        register int    n;
503 +        int     suffix;
504 +
505 +        n = 0; cp = orig; suffix = -1;          /* suffix position, length */
506 +        while (*cp) {
507 +                if (*cp == '.') suffix = n;
508 +                else if (ISDIRSEP(*cp)) suffix = -1;
509 +                cp++; n++;
510 +        }
511 +        if (suffix == -1) suffix = n;
512 +        if ((cp = bmalloc(n+2)) == NULL)
513 +                syserr(progname);
514 +        strncpy(cp, orig, suffix);
515 +        cp[suffix] = pred;                      /* root name + pred + suffix */
516 +        strcpy(cp+suffix+1, orig+suffix);
517 +        return(cp);
518 + }
519 +
520 +
521   checkfiles()                    /* check for existence and modified times */
522   {
523 <        char    *cp;
392 <        long    objdate;
523 >        time_t  objdate;
524  
525          if (!vdef(OCTREE)) {
526 <                if ((cp = bmalloc(strlen(radname)+5)) == NULL)
526 >                if ((vval(OCTREE) = bmalloc(strlen(radname)+5)) == NULL)
527                          syserr(progname);
528 <                sprintf(cp, "%s.oct", radname);
398 <                vval(OCTREE) = cp;
528 >                sprintf(vval(OCTREE), "%s.oct", radname);
529                  vdef(OCTREE)++;
530          }
531          octreedate = fdate(vval(OCTREE));
532 <        scenedate = -1;
533 <        if (vdef(SCENE)) {
534 <                scenedate = checklast(vval(SCENE));
535 <                if (vdef(OBJECT)) {
536 <                        objdate = checklast(vval(OBJECT));
537 <                        if (objdate > scenedate)
538 <                                scenedate = objdate;
539 <                }
540 <        }
541 <        if (octreedate < 0 & scenedate < 0) {
542 <                fprintf(stderr, "%s: need '%s' or '%s'\n", progname,
543 <                                vnam(OCTREE), vnam(SCENE));
532 >        if (vdef(ILLUM)) {              /* illum requires secondary octrees */
533 >                oct0name = newfname(vval(OCTREE), '0');
534 >                oct1name = newfname(vval(OCTREE), '1');
535 >                oct0date = fdate(oct0name);
536 >                oct1date = fdate(oct1name);
537 >        } else
538 >                oct0name = oct1name = vval(OCTREE);
539 >        if ((scenedate = checklast(vval(SCENE))) &&
540 >                        (objdate = checklast(vval(OBJECT))) > scenedate)
541 >                scenedate = objdate;
542 >        illumdate = checklast(vval(ILLUM));
543 >        if (!octreedate & !scenedate & !illumdate) {
544 >                fprintf(stderr, "%s: need '%s' or '%s' or '%s'\n", progname,
545 >                                vnam(OCTREE), vnam(SCENE), vnam(ILLUM));
546                  exit(1);
547          }
548 +        matdate = checklast(vval(MATERIAL));
549   }      
550  
551  
# Line 421 | Line 554 | double org[3], *sizp;
554   {
555          extern FILE     *popen();
556          static double   oorg[3], osiz = 0.;
557 <        char    buf[MAXPATH+16];
557 >        double  min[3], max[3];
558 >        char    buf[512];
559          FILE    *fp;
560 +        register int    i;
561  
562 <        if (osiz <= FTINY) {
563 <                oconv();                /* does nothing if done already */
564 <                sprintf(buf, "getinfo -d < %s", vval(OCTREE));
565 <                if ((fp = popen(buf, "r")) == NULL)
566 <                        syserr("getinfo");
567 <                if (fscanf(fp, "%lf %lf %lf %lf", &oorg[0], &oorg[1],
568 <                                &oorg[2], &osiz) != 4) {
569 <                        fprintf(stderr,
562 >        if (osiz <= FTINY)
563 >                if (noaction && fdate(oct1name) <
564 >                                (scenedate>illumdate?scenedate:illumdate)) {
565 >                                                        /* run getbbox */
566 >                        sprintf(buf, "getbbox -w -h %s",
567 >                                vdef(SCENE) ? vval(SCENE) : vval(ILLUM));
568 >                        if ((fp = popen(buf, "r")) == NULL)
569 >                                syserr("getbbox");
570 >                        if (fscanf(fp, "%lf %lf %lf %lf %lf %lf",
571 >                                        &min[0], &max[0], &min[1], &max[1],
572 >                                        &min[2], &max[2]) != 6) {
573 >                                fprintf(stderr,
574 >                        "%s: error reading bounding box from getbbox\n",
575 >                                                progname);
576 >                                exit(1);
577 >                        }
578 >                        for (i = 0; i < 3; i++)
579 >                                if (max[i] - min[i] > osiz)
580 >                                        osiz = max[i] - min[i];
581 >                        for (i = 0; i < 3; i++)
582 >                                oorg[i] = (max[i]+min[i]-osiz)*.5;
583 >                        pclose(fp);
584 >                } else {                                /* from octree */
585 >                        oconv();        /* does nothing if done already */
586 >                        sprintf(buf, "getinfo -d < %s", oct1name);
587 >                        if ((fp = popen(buf, "r")) == NULL)
588 >                                syserr("getinfo");
589 >                        if (fscanf(fp, "%lf %lf %lf %lf", &oorg[0], &oorg[1],
590 >                                        &oorg[2], &osiz) != 4) {
591 >                                fprintf(stderr,
592                          "%s: error reading bounding cube from getinfo\n",
593 <                                        progname);
594 <                        exit(1);
593 >                                                progname);
594 >                                exit(1);
595 >                        }
596 >                        pclose(fp);
597                  }
439                pclose(fp);
440        }
598          org[0] = oorg[0]; org[1] = oorg[1]; org[2] = oorg[2]; *sizp = osiz;
599   }
600  
# Line 491 | Line 648 | setdefaults()                  /* set default values for unassigned v
648  
649   printvals()                     /* print variable values */
650   {
651 <        register int    i, j;
651 >        int     i, j, clipline;
652 >        register char   *cp;
653 >        register int    k;
654  
655 <        for (i = 0; i < NVARS; i++)
656 <                for (j = 0; j < vdef(i); j++)
657 <                        printf("%s= %s\n", vnam(i), nvalue(vv+i, j));
655 >        for (i = 0; i < NVARS; i++)             /* print each variable */
656 >            for (j = 0; j < vdef(i); j++) {     /* print each assignment */
657 >                fputs(vnam(i), stdout);
658 >                fputs("= ", stdout);
659 >                k = clipline = ( vv[i].fixval == catvalues ? 64 : 320 )
660 >                                - strlen(vnam(i)) ;
661 >                cp = nvalue(vv+i, j);
662 >                while (*cp) {
663 >                    putchar(*cp++);
664 >                    if (--k <= 0) {             /* line too long */
665 >                        while (*cp && !isspace(*cp))
666 >                            putchar(*cp++);     /* finish this word */
667 >                        if (*cp) {              /* start new line */
668 >                            putchar('\n');
669 >                            fputs(vnam(i), stdout);
670 >                            putchar('=');
671 >                            k = clipline;
672 >                        }
673 >                    }
674 >                }
675 >                putchar('\n');
676 >            }
677          fflush(stdout);
678   }
679  
680  
681 < oconv()                         /* run oconv if necessary */
681 > oconv()                         /* run oconv and mkillum if necessary */
682   {
683 <        char    combuf[512], ocopts[64];
683 >        static char     illumtmp[] = "ilXXXXXX";
684 >        char    combuf[512], ocopts[64], mkopts[64];
685  
686 <        if (octreedate >= scenedate)    /* check dates */
687 <                return;
688 <                                        /* build command */
689 <        oconvopts(ocopts);
690 <        if (vdef(MATERIAL))
512 <                sprintf(combuf, "oconv%s %s %s > %s", ocopts,
686 >        oconvopts(ocopts);              /* get options */
687 >        if (octreedate < scenedate) {   /* check date on original octree */
688 >                                                /* build command */
689 >                if (vdef(MATERIAL))
690 >                        sprintf(combuf, "oconv%s %s %s > %s", ocopts,
691                                  vval(MATERIAL), vval(SCENE), vval(OCTREE));
692 +                else
693 +                        sprintf(combuf, "oconv%s %s > %s", ocopts,
694 +                                        vval(SCENE), vval(OCTREE));
695 +                
696 +                if (runcom(combuf)) {           /* run it */
697 +                        fprintf(stderr,
698 +                                "%s: error generating octree\n\t%s removed\n",
699 +                                        progname, vval(OCTREE));
700 +                        unlink(vval(OCTREE));
701 +                        exit(1);
702 +                }
703 +                octreedate = time((time_t *)NULL);
704 +                if (octreedate < scenedate)     /* in case clock is off */
705 +                        octreedate = scenedate;
706 +        }
707 +        if (oct1name == vval(OCTREE))           /* no mkillum? */
708 +                oct1date = octreedate > matdate ? octreedate : matdate;
709 +        if (oct1date >= octreedate & oct1date >= matdate
710 +                        & oct1date >= illumdate)        /* all done */
711 +                return;
712 +                                                /* make octree0 */
713 +        if (oct0date < scenedate | oct0date < illumdate) {
714 +                                                /* build command */
715 +                if (octreedate)
716 +                        sprintf(combuf, "oconv%s -i %s %s > %s", ocopts,
717 +                                vval(OCTREE), vval(ILLUM), oct0name);
718 +                else if (vdef(MATERIAL))
719 +                        sprintf(combuf, "oconv%s %s %s > %s", ocopts,
720 +                                vval(MATERIAL), vval(ILLUM), oct0name);
721 +                else
722 +                        sprintf(combuf, "oconv%s %s > %s", ocopts,
723 +                                vval(ILLUM), oct0name);
724 +                if (runcom(combuf)) {           /* run it */
725 +                        fprintf(stderr,
726 +                                "%s: error generating octree\n\t%s removed\n",
727 +                                        progname, oct0name);
728 +                        unlink(oct0name);
729 +                        exit(1);
730 +                }
731 +                oct0date = time((time_t *)NULL);
732 +                if (oct0date < octreedate)      /* in case clock is off */
733 +                        oct0date = octreedate;
734 +                if (oct0date < illumdate)       /* ditto */
735 +                        oct0date = illumdate;
736 +        }
737 +        mkillumopts(mkopts);                    /* build mkillum command */
738 +        mktemp(illumtmp);
739 +        sprintf(combuf, "mkillum%s %s \"<\" %s > %s", mkopts,
740 +                        oct0name, vval(ILLUM), illumtmp);
741 +        if (runcom(combuf)) {                   /* run it */
742 +                fprintf(stderr, "%s: error running mkillum\n", progname);
743 +                unlink(illumtmp);
744 +                exit(1);
745 +        }
746 +                                                /* make octree1 (frozen) */
747 +        if (octreedate)
748 +                sprintf(combuf, "oconv%s -f -i %s %s > %s", ocopts,
749 +                        vval(OCTREE), illumtmp, oct1name);
750 +        else if (vdef(MATERIAL))
751 +                sprintf(combuf, "oconv%s -f %s %s > %s", ocopts,
752 +                        vval(MATERIAL), illumtmp, oct1name);
753          else
754 <                sprintf(combuf, "oconv%s %s > %s", ocopts,
755 <                                vval(SCENE), vval(OCTREE));
517 <        
754 >                sprintf(combuf, "oconv%s -f %s > %s", ocopts,
755 >                        illumtmp, oct1name);
756          if (runcom(combuf)) {           /* run it */
757 <                fprintf(stderr, "%s: error generating octree\n\t%s removed\n",
758 <                                progname, vval(OCTREE));
759 <                unlink(vval(OCTREE));
757 >                fprintf(stderr,
758 >                        "%s: error generating octree\n\t%s removed\n",
759 >                                progname, oct1name);
760 >                unlink(oct1name);
761                  exit(1);
762          }
763 <        octreedate = time(0);
763 >        oct1date = time((time_t *)NULL);
764 >        if (oct1date < oct0date)        /* in case clock is off */
765 >                oct1date = oct0date;
766 >        rmfile(illumtmp);
767   }
768  
769  
# Line 547 | Line 789 | register char  *oo;
789   }
790  
791  
792 + mkillumopts(mo)                         /* get mkillum options */
793 + register char   *mo;
794 + {
795 +        /* BEWARE:  This may be called via setdefaults(), so no assumptions */
796 +
797 +        *mo = '\0';
798 +        if (vdef(MKILLUM))
799 +                addarg(mo, vval(MKILLUM));
800 + }
801 +
802 +
803 + checkambfile()                  /* check date on ambient file */
804 + {
805 +        time_t  afdate;
806 +
807 +        if (!vdef(AMBFILE))
808 +                return;
809 +        if (!(afdate = fdate(vval(AMBFILE))))
810 +                return;
811 +        if (oct1date > afdate)
812 +                rmfile(vval(AMBFILE));
813 + }
814 +
815 +
816   double
817   ambval()                                /* compute ambient value */
818   {
819          if (vdef(EXPOSURE)) {
820                  if (vval(EXPOSURE)[0] == '+' || vval(EXPOSURE)[0] == '-')
821                          return(.5/pow(2.,atof(vval(EXPOSURE))));
822 <                if (isdigit(vval(EXPOSURE)[0]) || vval(EXPOSURE)[0] == '.')
557 <                        return(.5/atof(vval(EXPOSURE)));
558 <                badvalue(EXPOSURE);
822 >                return(.5/atof(vval(EXPOSURE)));
823          }
824          if (vlet(ZONE) == 'E')
825                  return(10.);
# Line 565 | Line 829 | ambval()                               /* compute ambient value */
829   }
830  
831  
832 < lowqopts(op)                            /* low quality rendering options */
832 > renderopts(op, po)                      /* set rendering options */
833 > char    *op, *po;
834 > {
835 >        switch(vscale(QUALITY)) {
836 >        case LOW:
837 >                lowqopts(op, po);
838 >                break;
839 >        case MEDIUM:
840 >                medqopts(op, po);
841 >                break;
842 >        case HIGH:
843 >                hiqopts(op, po);
844 >                break;
845 >        }
846 > }
847 >
848 >
849 > lowqopts(op, po)                        /* low quality rendering options */
850   register char   *op;
851 + char    *po;
852   {
853          double  d, org[3], siz[3];
854  
855          *op = '\0';
856 +        *po = '\0';
857          if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf", &org[0],
858                          &siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6)
859                  badvalue(ZONE);
860          siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2];
861 +        if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY)
862 +                badvalue(ZONE);
863          getoctcube(org, &d);
864          d *= 3./(siz[0]+siz[1]+siz[2]);
865          switch (vscale(DETAIL)) {
866          case LOW:
867 <                op = addarg(op, "-ps 16 -dp 16");
867 >                po = addarg(po, "-ps 16");
868 >                op = addarg(op, "-dp 64");
869                  sprintf(op, " -ar %d", (int)(4*d));
870                  op += strlen(op);
871                  break;
872          case MEDIUM:
873 <                op = addarg(op, "-ps 8 -dp 32");
873 >                po = addarg(po, "-ps 8");
874 >                op = addarg(op, "-dp 128");
875                  sprintf(op, " -ar %d", (int)(8*d));
876                  op += strlen(op);
877                  break;
878          case HIGH:
879 <                op = addarg(op, "-ps 4 -dp 64");
879 >                po = addarg(po, "-ps 4");
880 >                op = addarg(op, "-dp 256");
881                  sprintf(op, " -ar %d", (int)(16*d));
882                  op += strlen(op);
883                  break;
884          }
885 <        op = addarg(op, "-pt .16");
885 >        po = addarg(po, "-pt .16");
886          if (vbool(PENUMBRAS))
887                  op = addarg(op, "-ds .4");
888          else
889                  op = addarg(op, "-ds 0");
890 <        op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .7");
890 >        op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .5");
891          if (vdef(AMBFILE)) {
892                  sprintf(op, " -af %s", vval(AMBFILE));
893                  op += strlen(op);
# Line 607 | Line 895 | register char  *op;
895                  overture = 0;
896          switch (vscale(VARIABILITY)) {
897          case LOW:
898 <                op = addarg(op, "-aa .4 -ad 32");
898 >                op = addarg(op, "-aa .4 -ad 64");
899                  break;
900          case MEDIUM:
901 <                op = addarg(op, "-aa .3 -ad 64");
901 >                op = addarg(op, "-aa .3 -ad 128");
902                  break;
903          case HIGH:
904 <                op = addarg(op, "-aa .25 -ad 128");
904 >                op = addarg(op, "-aa .25 -ad 256");
905                  break;
906          }
907          op = addarg(op, "-as 0");
# Line 626 | Line 914 | register char  *op;
914   }
915  
916  
917 < medqopts(op)                            /* medium quality rendering options */
917 > medqopts(op, po)                        /* medium quality rendering options */
918   register char   *op;
919 + char    *po;
920   {
921          double  d, org[3], siz[3];
922  
923          *op = '\0';
924 +        *po = '\0';
925          if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf", &org[0],
926                          &siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6)
927                  badvalue(ZONE);
928          siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2];
929 +        if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY)
930 +                badvalue(ZONE);
931          getoctcube(org, &d);
932          d *= 3./(siz[0]+siz[1]+siz[2]);
933          switch (vscale(DETAIL)) {
934          case LOW:
935 <                op = addarg(op, vbool(PENUMBRAS) ? "-ps 4" : "-ps 8");
936 <                op = addarg(op, "-dp 64");
935 >                po = addarg(po, vbool(PENUMBRAS) ? "-ps 4" : "-ps 8");
936 >                op = addarg(op, "-dp 256");
937                  sprintf(op, " -ar %d", (int)(8*d));
938                  op += strlen(op);
939                  break;
940          case MEDIUM:
941 <                op = addarg(op, vbool(PENUMBRAS) ? "-ps 3" : "-ps 6");
942 <                op = addarg(op, "-dp 128");
941 >                po = addarg(po, vbool(PENUMBRAS) ? "-ps 3" : "-ps 6");
942 >                op = addarg(op, "-dp 512");
943                  sprintf(op, " -ar %d", (int)(16*d));
944                  op += strlen(op);
945                  break;
946          case HIGH:
947 <                op = addarg(op, vbool(PENUMBRAS) ? "-ps 2" : "-ps 4");
948 <                op = addarg(op, "-dp 256");
947 >                po = addarg(po, vbool(PENUMBRAS) ? "-ps 2" : "-ps 4");
948 >                op = addarg(op, "-dp 1024");
949                  sprintf(op, " -ar %d", (int)(32*d));
950                  op += strlen(op);
951                  break;
952          }
953 <        op = addarg(op, "-pt .08");
953 >        po = addarg(po, "-pt .08");
954          if (vbool(PENUMBRAS))
955 <                op = addarg(op, "-ds .2 -dj .35");
955 >                op = addarg(op, "-ds .2 -dj .5");
956          else
957                  op = addarg(op, "-ds .3");
958 <        op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .15");
958 >        op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1");
959          if (overture = vint(INDIRECT)) {
960                  sprintf(op, " -ab %d", overture);
961                  op += strlen(op);
# Line 675 | Line 967 | register char  *op;
967                  overture = 0;
968          switch (vscale(VARIABILITY)) {
969          case LOW:
970 <                op = addarg(op, "-aa .25 -ad 128 -as 0");
970 >                op = addarg(op, "-aa .25 -ad 196 -as 0");
971                  break;
972          case MEDIUM:
973 <                op = addarg(op, "-aa .2 -ad 300 -as 64");
973 >                op = addarg(op, "-aa .2 -ad 400 -as 64");
974                  break;
975          case HIGH:
976 <                op = addarg(op, "-aa .15 -ad 500 -as 128");
976 >                op = addarg(op, "-aa .15 -ad 768 -as 196");
977                  break;
978          }
979          d = ambval();
# Line 693 | Line 985 | register char  *op;
985   }
986  
987  
988 < hiqopts(op)                             /* high quality rendering options */
988 > hiqopts(op, po)                         /* high quality rendering options */
989   register char   *op;
990 + char    *po;
991   {
992          double  d, org[3], siz[3];
993  
994          *op = '\0';
995 +        *po = '\0';
996          if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf", &org[0],
997                          &siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6)
998                  badvalue(ZONE);
999          siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2];
1000 +        if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY)
1001 +                badvalue(ZONE);
1002          getoctcube(org, &d);
1003          d *= 3./(siz[0]+siz[1]+siz[2]);
1004          switch (vscale(DETAIL)) {
1005          case LOW:
1006 <                op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 8");
1007 <                op = addarg(op, "-dp 256");
1006 >                po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 8");
1007 >                op = addarg(op, "-dp 1024");
1008                  sprintf(op, " -ar %d", (int)(16*d));
1009                  op += strlen(op);
1010                  break;
1011          case MEDIUM:
1012 <                op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 5");
1013 <                op = addarg(op, "-dp 512");
1012 >                po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 5");
1013 >                op = addarg(op, "-dp 2048");
1014                  sprintf(op, " -ar %d", (int)(32*d));
1015                  op += strlen(op);
1016                  break;
1017          case HIGH:
1018 <                op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 3");
1019 <                op = addarg(op, "-dp 1024");
1018 >                po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 3");
1019 >                op = addarg(op, "-dp 4096");
1020                  sprintf(op, " -ar %d", (int)(64*d));
1021                  op += strlen(op);
1022                  break;
1023          }
1024 <        op = addarg(op, "-pt .04");
1024 >        po = addarg(po, "-pt .04");
1025          if (vbool(PENUMBRAS))
1026                  op = addarg(op, "-ds .1 -dj .7");
1027          else
1028                  op = addarg(op, "-ds .2");
1029 <        op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .03");
1029 >        op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01");
1030          sprintf(op, " -ab %d", overture=vint(INDIRECT)+1);
1031          op += strlen(op);
1032          if (vdef(AMBFILE)) {
# Line 740 | Line 1036 | register char  *op;
1036                  overture = 0;
1037          switch (vscale(VARIABILITY)) {
1038          case LOW:
1039 <                op = addarg(op, "-aa .15 -ad 200 -as 0");
1039 >                op = addarg(op, "-aa .15 -ad 256 -as 0");
1040                  break;
1041          case MEDIUM:
1042 <                op = addarg(op, "-aa .125 -ad 512 -as 128");
1042 >                op = addarg(op, "-aa .125 -ad 512 -as 256");
1043                  break;
1044          case HIGH:
1045 <                op = addarg(op, "-aa .08 -ad 850 -as 256");
1045 >                op = addarg(op, "-aa .08 -ad 1024 -as 512");
1046                  break;
1047          }
1048          d = ambval();
# Line 762 | Line 1058 | xferopts(ro)                           /* transfer options if indicated */
1058   char    *ro;
1059   {
1060          int     fd, n;
1061 +        register char   *cp;
1062          
1063          n = strlen(ro);
1064          if (n < 2)
1065                  return;
1066          if (vdef(OPTFILE)) {
1067 <                if ((fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1)
1067 >                for (cp = ro; cp[1]; cp++)
1068 >                        if (isspace(cp[1]) && cp[2] == '-' && isalpha(cp[3]))
1069 >                                *cp = '\n';
1070 >                        else
1071 >                                *cp = cp[1];
1072 >                *cp = '\n';
1073 >                fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666);
1074 >                if (fd < 0 || write(fd, ro, n) != n || close(fd) < 0)
1075                          syserr(vval(OPTFILE));
1076 <                if (write(fd, ro+1, n-1) != n-1)
773 <                        syserr(vval(OPTFILE));
774 <                write(fd, "\n", 1);
775 <                close(fd);
776 <                sprintf(ro, " \"^%s\"", vval(OPTFILE));
1076 >                sprintf(ro, " @%s", vval(OPTFILE));
1077          }
1078   #ifdef MSDOS
1079          else if (n > 50) {
1080 <                register char   *evp = bmalloc(n+6);
781 <                if (evp == NULL)
782 <                        syserr(progname);
783 <                strcpy(evp, "ROPT=");
784 <                strcat(evp, ro);
785 <                if (putenv(evp) != 0) {
786 <                        fprintf(stderr, "%s: out of environment space\n",
787 <                                        progname);
788 <                        exit(1);
789 <                }
1080 >                setenv("ROPT", ro+1);
1081                  strcpy(ro, " $ROPT");
1082          }
1083   #endif
# Line 801 | Line 1092 | register char  *po;
1092                  po = addarg(po, "-1 -e");
1093                  po = addarg(po, vval(EXPOSURE));
1094          }
1095 <        if (vscale(QUALITY) == HIGH)
1096 <                po = addarg(po, "-r .65");
1095 >        switch (vscale(QUALITY)) {
1096 >        case MEDIUM:
1097 >                po = addarg(po, "-r 1");
1098 >                break;
1099 >        case HIGH:
1100 >                po = addarg(po, "-m .25");
1101 >                break;
1102 >        }
1103          if (vdef(PFILT))
1104                  po = addarg(po, vval(PFILT));
1105   }
# Line 874 | Line 1171 | register char  *vs;
1171                          badvalue(ZONE);
1172                  for (i = 0; i < 3; i++) {
1173                          dim[i] -= cent[i];
1174 +                        if (dim[i] <= FTINY)
1175 +                                badvalue(ZONE);
1176                          cent[i] += .5*dim[i];
1177                  }
1178                  mult = vlet(ZONE)=='E' ? 2. : .45 ;
# Line 926 | Line 1225 | register char  *vs;
1225                          cp += strlen(cp);
1226                  }
1227          }
1228 <                                        /* append any additional options */
1228 >        if (cp == viewopts)             /* append any additional options */
1229 >                vs++;           /* skip prefixed space if unneeded */
1230          strcpy(cp, vs);
1231 + #ifdef MSDOS
1232 +        if (strlen(viewopts) > 40) {
1233 +                setenv("VIEW", viewopts);
1234 +                return("$VIEW");
1235 +        }
1236 + #endif
1237          return(viewopts);
1238   }
1239  
# Line 935 | Line 1241 | register char  *vs;
1241   char *
1242   getview(n, vn)                          /* get view n, or NULL if none */
1243   int     n;
1244 < char    *vn;
1244 > char    *vn;            /* returned view name */
1245   {
1246          register char   *mv;
1247  
1248 <        if (viewselect != NULL) {
1248 >        if (viewselect != NULL) {               /* command-line selected */
1249                  if (n)                          /* only do one */
1250                          return(NULL);
1251                  if (viewselect[0] == '-') {     /* already specified */
# Line 952 | Line 1258 | char   *vn;
1258                                  ;
1259                          *vn = '\0';
1260                  }
1261 +                                                /* view number? */
1262 +                if (isint(viewselect))
1263 +                        return(specview(nvalue(vv+VIEW, atoi(viewselect)-1)));
1264                                                  /* check list */
1265                  while ((mv = nvalue(vv+VIEW, n++)) != NULL)
1266                          if (matchword(viewselect, mv))
1267                                  return(specview(mv));
1268                  return(specview(viewselect));   /* standard view? */
1269          }
1270 <        if (vn != NULL && (mv = nvalue(vv+VIEW, n)) != NULL) {
1271 <                if (*mv != '-')
1272 <                        while (*mv && !isspace(*mv))
1273 <                                *vn++ = *mv++;
1270 >        mv = nvalue(vv+VIEW, n);                /* use view n */
1271 >        if (vn != NULL & mv != NULL) {
1272 >                register char   *mv2 = mv;
1273 >                if (*mv2 != '-')
1274 >                        while (*mv2 && !isspace(*mv2))
1275 >                                *vn++ = *mv2++;
1276                  *vn = '\0';
1277          }
1278 <        return(specview(nvalue(vv+VIEW, n)));   /* use view n */
1278 >        return(specview(mv));
1279   }
1280  
1281  
1282 < rview(opts)                             /* run rview with first view */
1283 < char    *opts;
1282 > printview(vopts)                        /* print out selected view */
1283 > register char   *vopts;
1284   {
1285 +        extern char     *atos(), *getenv();
1286 +        char    buf[256];
1287 +        FILE    *fp;
1288 +        register char   *cp;
1289 +
1290 +        if (vopts == NULL)
1291 +                return(-1);
1292 +        fputs("VIEW=", stdout);
1293 +        do {
1294 +                if (matchword(vopts, "-vf")) {          /* expand view file */
1295 +                        vopts = sskip(vopts);
1296 +                        if (!*atos(buf, sizeof(buf), vopts))
1297 +                                return(-1);
1298 +                        if ((fp = fopen(buf, "r")) == NULL)
1299 +                                return(-1);
1300 +                        for (buf[sizeof(buf)-2] = '\n';
1301 +                                        fgets(buf, sizeof(buf), fp) != NULL &&
1302 +                                                buf[0] != '\n';
1303 +                                        buf[sizeof(buf)-2] = '\n') {
1304 +                                if (buf[sizeof(buf)-2] != '\n') {
1305 +                                        ungetc(buf[sizeof(buf)-2], fp);
1306 +                                        buf[sizeof(buf)-2] = '\0';
1307 +                                }
1308 +                                if (matchword(buf, "VIEW=") ||
1309 +                                                matchword(buf, "rview")) {
1310 +                                        for (cp = sskip(buf); *cp && *cp != '\n'; cp++)
1311 +                                                putchar(*cp);
1312 +                                }
1313 +                        }
1314 +                        fclose(fp);
1315 +                        vopts = sskip(vopts);
1316 +                } else {
1317 +                        while (isspace(*vopts))
1318 +                                vopts++;
1319 +                        putchar(' ');
1320 + #ifdef MSDOS
1321 +                        if (*vopts == '$') {            /* expand env. var. */
1322 +                                if (!*atos(buf, sizeof(buf), vopts+1))
1323 +                                        return(-1);
1324 +                                if ((cp = getenv(buf)) == NULL)
1325 +                                        return(-1);
1326 +                                fputs(cp, stdout);
1327 +                                vopts = sskip(vopts);
1328 +                        } else
1329 + #endif
1330 +                                while (*vopts && !isspace(*vopts))
1331 +                                        putchar(*vopts++);
1332 +                }
1333 +        } while (*vopts++);
1334 +        putchar('\n');
1335 +        return(0);
1336 + }
1337 +
1338 +
1339 + rview(opts, po)                         /* run rview with first view */
1340 + char    *opts, *po;
1341 + {
1342 +        char    *vw;
1343          char    combuf[512];
1344                                          /* build command */
1345 <        sprintf(combuf, "rview %s%s ", getview(0, NULL), opts);
1345 >        if ((vw = getview(0, NULL)) == NULL)
1346 >                return;
1347 >        if (sayview)
1348 >                printview(vw);
1349 >        sprintf(combuf, "rview %s%s%s -R %s ", vw, po, opts, rifname);
1350          if (rvdevice != NULL)
1351                  sprintf(combuf+strlen(combuf), "-o %s ", rvdevice);
1352 <        strcat(combuf, vval(OCTREE));
1352 >        if (vdef(EXPOSURE))
1353 >                sprintf(combuf+strlen(combuf), "-pe %s ", vval(EXPOSURE));
1354 >        strcat(combuf, oct1name);
1355          if (runcom(combuf)) {           /* run it */
1356                  fprintf(stderr, "%s: error running rview\n", progname);
1357                  exit(1);
# Line 984 | Line 1359 | char   *opts;
1359   }
1360  
1361  
1362 < rpict(opts)                             /* run rpict and pfilt for each view */
1363 < char    *opts;
1362 > rpict(opts, po)                         /* run rpict and pfilt for each view */
1363 > char    *opts, *po;
1364   {
1365          char    combuf[1024];
1366          char    rawfile[MAXPATH], picfile[MAXPATH], rep[MAXPATH+16], res[32];
# Line 995 | Line 1370 | char   *opts;
1370                                          /* get pfilt options */
1371          pfiltopts(pfopts);
1372                                          /* get resolution, reporting */
1373 <        mult = vscale(QUALITY)+1;
1373 >        switch (vscale(QUALITY)) {
1374 >        case LOW:
1375 >                mult = 1;
1376 >                break;
1377 >        case MEDIUM:
1378 >                mult = 2;
1379 >                break;
1380 >        case HIGH:
1381 >                mult = 3;
1382 >                break;
1383 >        }
1384          {
1385                  int     xres, yres;
1386                  double  aspect;
# Line 1022 | Line 1407 | char   *opts;
1407                  else
1408                          badvalue(REPORT);
1409          }
1025                                        /* check date on ambient file */
1026        if (vdef(AMBFILE)) {
1027                long    afdate = fdate(vval(AMBFILE));
1028                if (afdate >= 0 & octreedate > afdate)
1029                        rmfile(vval(AMBFILE));
1030        }
1410                                          /* do each view */
1411          vn = 0;
1412          while ((vw = getview(vn++, vs)) != NULL) {
1413 +                if (sayview)
1414 +                        printview(vw);
1415                  if (!vs[0])
1416                          sprintf(vs, "%d", vn);
1417                  sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs);
1418                                                  /* check date on picture */
1419 <                if (fdate(picfile) > octreedate)
1419 >                if (fdate(picfile) >= oct1date)
1420                          continue;
1421                                                  /* build rpict command */
1422                  sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs);
1423 <                if (fdate(rawfile) > octreedate)        /* recover */
1424 <                        sprintf(combuf, "rpict%s%s -ro %s %s",
1425 <                                        rep, opts, rawfile, vval(OCTREE));
1423 >                if (fdate(rawfile) >= oct1date)         /* recover */
1424 >                        sprintf(combuf, "rpict%s%s%s -ro %s %s",
1425 >                                        rep, po, opts, rawfile, oct1name);
1426                  else {
1427                          if (overture) {         /* run overture calculation */
1428                                  sprintf(combuf,
1429                                  "rpict%s %s%s -x 64 -y 64 -ps 1 %s > %s",
1430                                                  rep, vw, opts,
1431 <                                                vval(OCTREE), rawfile);
1431 >                                                oct1name, overfile);
1432                                  if (runcom(combuf)) {
1433                                          fprintf(stderr,
1434 <                        "%s: error in overture for view %s\n\t%s removed\n",
1435 <                                                progname, vs, rawfile);
1055 <                                        unlink(rawfile);
1434 >                                        "%s: error in overture for view %s\n",
1435 >                                                progname, vs);
1436                                          exit(1);
1437                                  }
1438 + #ifdef NIX
1439 +                                rmfile(overfile);
1440 + #endif
1441                          }
1442 <                        sprintf(combuf, "rpict%s %s %s%s %s > %s",
1443 <                                        rep, vw, res, opts,
1444 <                                        vval(OCTREE), rawfile);
1442 >                        sprintf(combuf, "rpict%s %s %s%s%s %s > %s",
1443 >                                        rep, vw, res, po, opts,
1444 >                                oct1name, rawfile);
1445                  }
1446                  if (runcom(combuf)) {           /* run rpict */
1447                          fprintf(stderr, "%s: error rendering view %s\n",
# Line 1110 | Line 1493 | char   *fn;
1493                  return(0);
1494          return(unlink(fn));
1495   }
1496 +
1497 +
1498 + #ifdef MSDOS
1499 + setenv(vname, value)            /* set an environment variable */
1500 + char    *vname, *value;
1501 + {
1502 +        register char   *evp;
1503 +
1504 +        evp = bmalloc(strlen(vname)+strlen(value)+2);
1505 +        if (evp == NULL)
1506 +                syserr(progname);
1507 +        sprintf(evp, "%s=%s", vname, value);
1508 +        if (putenv(evp) != 0) {
1509 +                fprintf(stderr, "%s: out of environment space\n", progname);
1510 +                exit(1);
1511 +        }
1512 +        if (!silent)
1513 +                printf("set %s\n", evp);
1514 + }
1515 + #endif
1516  
1517  
1518   badvalue(vc)                    /* report bad variable value and exit */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines