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.24 by greg, Thu Sep 9 13:07:13 1993 UTC vs.
Revision 2.37 by greg, Sat Jan 1 09:16:50 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  
92 int     lowqopts(), medqopts(), hiqopts();
93 int     (*setqopts[3])() = {lowqopts, medqopts, hiqopts};
94
95 #define renderopts      (*setqopts[vscale(QUALITY)])
96
98                                  /* overture calculation file */
99   #ifdef NIX
100   char    overfile[] = "overture.raw";
# Line 101 | Line 102 | char   overfile[] = "overture.raw";
102   char    overfile[] = "/dev/null";
103   #endif
104  
105 < extern long     fdate(), time();
105 > extern time_t   fdate(), time();
106  
107 < long    scenedate;              /* date of latest scene or object file */
108 < long    octreedate;             /* date of octree */
109 < long    matdate;                /* date of latest material file */
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 + 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 */
# Line 151 | Line 159 | char   *argv[];
159                  case 'v':
160                          viewselect = argv[++i];
161                          break;
162 +                case 'w':
163 +                        nowarn++;
164 +                        break;
165                  default:
166                          goto userr;
167                  }
# Line 173 | Line 184 | char   *argv[];
184                                  /* print all values if requested */
185          if (explicate)
186                  printvals();
187 <                                /* build octree */
187 >                                /* build octree (and run mkillum) */
188          oconv();
189                                  /* check date on ambient file */
190          checkambfile();
# Line 187 | Line 198 | char   *argv[];
198          exit(0);
199   userr:
200          fprintf(stderr,
201 <        "Usage: %s [-s][-n][-e][-v view][-o dev] rfile [VAR=value ..]\n",
201 >        "Usage: %s [-s][-n][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n",
202                          progname);
203          exit(1);
204   }
# Line 208 | Line 219 | register char  *rn, *fn;
219   }
220  
221  
222 + #define NOCHAR  127             /* constant for character to delete */
223 +
224 +
225   load(rfname)                    /* load Radiance simulation file */
226   char    *rfname;
227   {
# Line 223 | Line 237 | char   *rfname;
237                  for (cp = buf; *cp; cp++) {
238                          switch (*cp) {
239                          case '\\':
240 <                        case '\n':
227 <                                *cp = ' ';
240 >                                *cp++ = NOCHAR;
241                                  continue;
242                          case '#':
243                                  *cp = '\0';
# Line 244 | Line 257 | setvariable(ass)               /* assign variable according to stri
257   register char   *ass;
258   {
259          char    varname[32];
260 +        int     n;
261          register char   *cp;
262          register VARIABLE       *vp;
263          register int    i;
250        int     n;
264  
265          while (isspace(*ass))           /* skip leading space */
266                  ass++;
# Line 261 | Line 274 | register char  *ass;
274                                          /* trim value */
275          while (isspace(*ass) || *ass == '=')
276                  ass++;
277 <        cp = ass + strlen(ass);
278 <        do
279 <                *cp-- = '\0';
280 <        while (cp >= ass && isspace(*cp));
268 <        n = cp - ass + 1;
269 <        if (!n) {
277 >        for (n = strlen(ass); n > 0; n--)
278 >                if (!isspace(ass[n-1]))
279 >                        break;
280 >        if (!n && !nowarn) {
281                  fprintf(stderr, "%s: warning - missing value for variable '%s'\n",
282                                  progname, varname);
283                  return;
# Line 290 | Line 301 | register char  *ass;
301                  vp->value = malloc(n+1);
302          if (vp->value == NULL)
303                  syserr(progname);
304 <        strcpy(vp->value+i, ass);
304 >        cp = vp->value+i;               /* copy value, squeezing spaces */
305 >        *cp = *ass;
306 >        for (i = 1; i <= n; i++) {
307 >                if (ass[i] == NOCHAR)
308 >                        continue;
309 >                if (isspace(*cp))
310 >                        while (isspace(ass[i]))
311 >                                i++;
312 >                *++cp = ass[i];
313 >        }
314 >        if (isspace(*cp))               /* remove trailing space */
315 >                *cp = '\0';
316          vp->nass++;
317   }
318  
# Line 326 | Line 348 | register int   n;
348   }
349  
350  
329 int
330 vscale(vc)                      /* return scale for variable vc */
331 int     vc;
332 {
333        switch(vlet(vc)) {
334        case 'H':
335                return(HIGH);
336        case 'M':
337                return(MEDIUM);
338        case 'L':
339                return(LOW);
340        }
341        badvalue(vc);
342 }
343
344
351   checkvalues()                   /* check assignments */
352   {
353          register int    i;
# Line 357 | Line 363 | register VARIABLE      *vp;
363   {
364          if (vp->nass < 2)
365                  return;
366 <        fprintf(stderr, "%s: warning - multiple assignment of variable '%s'\n",
366 >        if (!nowarn)
367 >                fprintf(stderr,
368 >                "%s: warning - multiple assignment of variable '%s'\n",
369                          progname, vp->name);
370          do
371                  vp->value += strlen(vp->value)+1;
# Line 380 | Line 388 | register VARIABLE      *vp;
388   }
389  
390  
391 < long
391 > int
392 > badmatch(tv, cv)                /* case insensitive truncated comparison */
393 > register char   *tv, *cv;
394 > {
395 >        if (!*tv) return(1);            /* null string cannot match */
396 >        do
397 >                if (UPPER(*tv) != *cv++)
398 >                        return(1);
399 >        while (*++tv);
400 >        return(0);              /* OK */
401 > }
402 >
403 >
404 > boolvalue(vp)                   /* check boolean for legal values */
405 > register VARIABLE       *vp;
406 > {
407 >        if (!vp->nass) return;
408 >        onevalue(vp);
409 >        switch (UPPER(vp->value[0])) {
410 >        case 'T':
411 >                if (badmatch(vp->value, "TRUE")) break;
412 >                return;
413 >        case 'F':
414 >                if (badmatch(vp->value, "FALSE")) break;
415 >                return;
416 >        }
417 >        fprintf(stderr, "%s: illegal value for boolean variable '%s'\n",
418 >                        progname, vp->name);
419 >        exit(1);
420 > }
421 >
422 >
423 > qualvalue(vp)                   /* check qualitative var. for legal values */
424 > register VARIABLE       *vp;
425 > {
426 >        if (!vp->nass) return;
427 >        onevalue(vp);
428 >        switch (UPPER(vp->value[0])) {
429 >        case 'L':
430 >                if (badmatch(vp->value, "LOW")) break;
431 >                return;
432 >        case 'M':
433 >                if (badmatch(vp->value, "MEDIUM")) break;
434 >                return;
435 >        case 'H':
436 >                if (badmatch(vp->value, "HIGH")) break;
437 >                return;
438 >        }
439 >        fprintf(stderr, "%s: illegal value for qualitative variable '%s'\n",
440 >                        progname, vp->name);
441 >        exit(1);
442 > }
443 >
444 >
445 > intvalue(vp)                    /* check integer variable for legal values */
446 > register VARIABLE       *vp;
447 > {
448 >        if (!vp->nass) return;
449 >        onevalue(vp);
450 >        if (isint(vp->value)) return;
451 >        fprintf(stderr, "%s: illegal value for integer variable '%s'\n",
452 >                        progname, vp->name);
453 >        exit(1);
454 > }
455 >
456 >
457 > fltvalue(vp)                    /* check float variable for legal values */
458 > register VARIABLE       *vp;
459 > {
460 >        if (!vp->nass) return;
461 >        onevalue(vp);
462 >        if (isflt(vp->value)) return;
463 >        fprintf(stderr, "%s: illegal value for real variable '%s'\n",
464 >                        progname, vp->name);
465 >        exit(1);
466 > }
467 >
468 >
469 > time_t
470   checklast(fnames)                       /* check files and find most recent */
471   register char   *fnames;
472   {
473          char    thisfile[MAXPATH];
474 <        long    thisdate, lastdate = -1;
474 >        time_t  thisdate, lastdate = 0;
475          register char   *cp;
476  
477 +        if (fnames == NULL)
478 +                return(0);
479          while (*fnames) {
480                  while (isspace(*fnames)) fnames++;
481                  cp = thisfile;
482                  while (*fnames && !isspace(*fnames))
483                          *cp++ = *fnames++;
484                  *cp = '\0';
485 <                if ((thisdate = fdate(thisfile)) < 0)
485 >                if (!(thisdate = fdate(thisfile)))
486                          syserr(thisfile);
487                  if (thisdate > lastdate)
488                          lastdate = thisdate;
# Line 403 | Line 491 | register char  *fnames;
491   }
492  
493  
494 + char *
495 + newfname(orig, pred)            /* create modified file name */
496 + char    *orig;
497 + int     pred;
498 + {
499 +        extern char     *rindex();
500 +        register char   *cp;
501 +        register int    n;
502 +        int     suffix;
503 +
504 +        n = 0; cp = orig; suffix = -1;          /* suffix position, length */
505 +        while (*cp) {
506 +                if (*cp == '.') suffix = n;
507 +                else if (ISDIRSEP(*cp)) suffix = -1;
508 +                cp++; n++;
509 +        }
510 +        if (suffix == -1) suffix = n;
511 +        if ((cp = bmalloc(n+2)) == NULL)
512 +                syserr(progname);
513 +        strncpy(cp, orig, suffix);
514 +        cp[suffix] = pred;                      /* root name + pred + suffix */
515 +        strcpy(cp+suffix+1, orig+suffix);
516 +        return(cp);
517 + }
518 +
519 +
520   checkfiles()                    /* check for existence and modified times */
521   {
522 <        char    *cp;
409 <        long    objdate;
522 >        time_t  objdate;
523  
524          if (!vdef(OCTREE)) {
525 <                if ((cp = bmalloc(strlen(radname)+5)) == NULL)
525 >                if ((vval(OCTREE) = bmalloc(strlen(radname)+5)) == NULL)
526                          syserr(progname);
527 <                sprintf(cp, "%s.oct", radname);
415 <                vval(OCTREE) = cp;
527 >                sprintf(vval(OCTREE), "%s.oct", radname);
528                  vdef(OCTREE)++;
529          }
530          octreedate = fdate(vval(OCTREE));
531 <        scenedate = -1;
532 <        if (vdef(SCENE)) {
533 <                scenedate = checklast(vval(SCENE));
534 <                if (vdef(OBJECT)) {
535 <                        objdate = checklast(vval(OBJECT));
536 <                        if (objdate > scenedate)
537 <                                scenedate = objdate;
538 <                }
539 <        }
540 <        if (octreedate < 0 & scenedate < 0) {
541 <                fprintf(stderr, "%s: need '%s' or '%s'\n", progname,
542 <                                vnam(OCTREE), vnam(SCENE));
531 >        if (vdef(ILLUM)) {              /* illum requires secondary octrees */
532 >                oct0name = newfname(vval(OCTREE), '0');
533 >                oct1name = newfname(vval(OCTREE), '1');
534 >                oct0date = fdate(oct0name);
535 >                oct1date = fdate(oct1name);
536 >        } else
537 >                oct0name = oct1name = vval(OCTREE);
538 >        if ((scenedate = checklast(vval(SCENE))) &&
539 >                        (objdate = checklast(vval(OBJECT))) > scenedate)
540 >                scenedate = objdate;
541 >        illumdate = checklast(vval(ILLUM));
542 >        if (!octreedate & !scenedate & !illumdate) {
543 >                fprintf(stderr, "%s: need '%s' or '%s' or '%s'\n", progname,
544 >                                vnam(OCTREE), vnam(SCENE), vnam(ILLUM));
545                  exit(1);
546          }
547 <        matdate = -1;
434 <        if (vdef(MATERIAL))
435 <                matdate = checklast(vval(MATERIAL));
547 >        matdate = checklast(vval(MATERIAL));
548   }      
549  
550  
# Line 441 | Line 553 | double org[3], *sizp;
553   {
554          extern FILE     *popen();
555          static double   oorg[3], osiz = 0.;
556 <        char    buf[MAXPATH+16];
556 >        double  min[3], max[3];
557 >        char    buf[512];
558          FILE    *fp;
559 +        register int    i;
560  
561 <        if (osiz <= FTINY) {
562 <                oconv();                /* does nothing if done already */
563 <                sprintf(buf, "getinfo -d < %s", vval(OCTREE));
564 <                if ((fp = popen(buf, "r")) == NULL)
565 <                        syserr("getinfo");
566 <                if (fscanf(fp, "%lf %lf %lf %lf", &oorg[0], &oorg[1],
567 <                                &oorg[2], &osiz) != 4) {
568 <                        fprintf(stderr,
561 >        if (osiz <= FTINY)
562 >                if (noaction && fdate(oct1name) <
563 >                                (scenedate>illumdate?scenedate:illumdate)) {
564 >                                                        /* run getbbox */
565 >                        sprintf(buf, "getbbox -w -h %s",
566 >                                vdef(SCENE) ? vval(SCENE) : vval(ILLUM));
567 >                        if ((fp = popen(buf, "r")) == NULL)
568 >                                syserr("getbbox");
569 >                        if (fscanf(fp, "%lf %lf %lf %lf %lf %lf",
570 >                                        &min[0], &max[0], &min[1], &max[1],
571 >                                        &min[2], &max[2]) != 6) {
572 >                                fprintf(stderr,
573 >                        "%s: error reading bounding box from getbbox\n",
574 >                                                progname);
575 >                                exit(1);
576 >                        }
577 >                        for (i = 0; i < 3; i++)
578 >                                if (max[i] - min[i] > osiz)
579 >                                        osiz = max[i] - min[i];
580 >                        for (i = 0; i < 3; i++)
581 >                                oorg[i] = (max[i]+min[i]-osiz)*.5;
582 >                        pclose(fp);
583 >                } else {                                /* from octree */
584 >                        oconv();        /* does nothing if done already */
585 >                        sprintf(buf, "getinfo -d < %s", oct1name);
586 >                        if ((fp = popen(buf, "r")) == NULL)
587 >                                syserr("getinfo");
588 >                        if (fscanf(fp, "%lf %lf %lf %lf", &oorg[0], &oorg[1],
589 >                                        &oorg[2], &osiz) != 4) {
590 >                                fprintf(stderr,
591                          "%s: error reading bounding cube from getinfo\n",
592 <                                        progname);
593 <                        exit(1);
592 >                                                progname);
593 >                                exit(1);
594 >                        }
595 >                        pclose(fp);
596                  }
459                pclose(fp);
460        }
597          org[0] = oorg[0]; org[1] = oorg[1]; org[2] = oorg[2]; *sizp = osiz;
598   }
599  
# Line 511 | Line 647 | setdefaults()                  /* set default values for unassigned v
647  
648   printvals()                     /* print variable values */
649   {
650 <        register int    i, j;
650 >        int     i, j, clipline;
651 >        register char   *cp;
652 >        register int    k;
653  
654 <        for (i = 0; i < NVARS; i++)
655 <                for (j = 0; j < vdef(i); j++)
656 <                        printf("%s= %s\n", vnam(i), nvalue(vv+i, j));
654 >        for (i = 0; i < NVARS; i++)             /* print each variable */
655 >            for (j = 0; j < vdef(i); j++) {     /* print each assignment */
656 >                fputs(vnam(i), stdout);
657 >                fputs("= ", stdout);
658 >                k = clipline = ( vv[i].fixval == catvalues ? 64 : 320 )
659 >                                - strlen(vnam(i)) ;
660 >                cp = nvalue(vv+i, j);
661 >                while (*cp) {
662 >                    putchar(*cp++);
663 >                    if (--k <= 0) {             /* line too long */
664 >                        while (*cp && !isspace(*cp))
665 >                            putchar(*cp++);     /* finish this word */
666 >                        if (*cp) {              /* start new line */
667 >                            putchar('\n');
668 >                            fputs(vnam(i), stdout);
669 >                            putchar('=');
670 >                            k = clipline;
671 >                        }
672 >                    }
673 >                }
674 >                putchar('\n');
675 >            }
676          fflush(stdout);
677   }
678  
679  
680 < oconv()                         /* run oconv if necessary */
680 > oconv()                         /* run oconv and mkillum if necessary */
681   {
682 <        char    combuf[512], ocopts[64];
682 >        static char     illumtmp[] = "ilXXXXXX";
683 >        char    combuf[512], ocopts[64], mkopts[64];
684  
685 <        if (octreedate >= scenedate)    /* check dates */
686 <                return;
687 <                                        /* build command */
688 <        oconvopts(ocopts);
689 <        if (vdef(MATERIAL))
532 <                sprintf(combuf, "oconv%s %s %s > %s", ocopts,
685 >        oconvopts(ocopts);              /* get options */
686 >        if (octreedate < scenedate) {   /* check date on original octree */
687 >                                                /* build command */
688 >                if (vdef(MATERIAL))
689 >                        sprintf(combuf, "oconv%s %s %s > %s", ocopts,
690                                  vval(MATERIAL), vval(SCENE), vval(OCTREE));
691 +                else
692 +                        sprintf(combuf, "oconv%s %s > %s", ocopts,
693 +                                        vval(SCENE), vval(OCTREE));
694 +                
695 +                if (runcom(combuf)) {           /* run it */
696 +                        fprintf(stderr,
697 +                                "%s: error generating octree\n\t%s removed\n",
698 +                                        progname, vval(OCTREE));
699 +                        unlink(vval(OCTREE));
700 +                        exit(1);
701 +                }
702 +                octreedate = time((time_t *)NULL);
703 +        }
704 +        if (oct1name == vval(OCTREE))           /* no mkillum? */
705 +                oct1date = octreedate > matdate ? octreedate : matdate;
706 +        if (oct1date >= octreedate & oct1date >= matdate
707 +                        & oct1date >= illumdate)        /* all done */
708 +                return;
709 +                                                /* make octree0 */
710 +        if (oct0date < scenedate | oct0date < illumdate) {
711 +                                                /* build command */
712 +                if (octreedate)
713 +                        sprintf(combuf, "oconv%s -i %s %s > %s", ocopts,
714 +                                vval(OCTREE), vval(ILLUM), oct0name);
715 +                else if (vdef(MATERIAL))
716 +                        sprintf(combuf, "oconv%s %s %s > %s", ocopts,
717 +                                vval(MATERIAL), vval(ILLUM), oct0name);
718 +                else
719 +                        sprintf(combuf, "oconv%s %s > %s", ocopts,
720 +                                vval(ILLUM), oct0name);
721 +                if (runcom(combuf)) {           /* run it */
722 +                        fprintf(stderr,
723 +                                "%s: error generating octree\n\t%s removed\n",
724 +                                        progname, oct0name);
725 +                        unlink(oct0name);
726 +                        exit(1);
727 +                }
728 +                oct0date = time((time_t *)NULL);
729 +        }
730 +        mkillumopts(mkopts);                    /* build mkillum command */
731 +        mktemp(illumtmp);
732 +        sprintf(combuf, "mkillum%s %s \"<\" %s > %s", mkopts,
733 +                        oct0name, vval(ILLUM), illumtmp);
734 +        if (runcom(combuf)) {                   /* run it */
735 +                fprintf(stderr, "%s: error running mkillum\n", progname);
736 +                unlink(illumtmp);
737 +                exit(1);
738 +        }
739 +                                                /* make octree1 (frozen) */
740 +        if (octreedate)
741 +                sprintf(combuf, "oconv%s -f -i %s %s > %s", ocopts,
742 +                        vval(OCTREE), illumtmp, oct1name);
743 +        else if (vdef(MATERIAL))
744 +                sprintf(combuf, "oconv%s -f %s %s > %s", ocopts,
745 +                        vval(MATERIAL), illumtmp, oct1name);
746          else
747 <                sprintf(combuf, "oconv%s %s > %s", ocopts,
748 <                                vval(SCENE), vval(OCTREE));
537 <        
747 >                sprintf(combuf, "oconv%s -f %s > %s", ocopts,
748 >                        illumtmp, oct1name);
749          if (runcom(combuf)) {           /* run it */
750 <                fprintf(stderr, "%s: error generating octree\n\t%s removed\n",
751 <                                progname, vval(OCTREE));
752 <                unlink(vval(OCTREE));
750 >                fprintf(stderr,
751 >                        "%s: error generating octree\n\t%s removed\n",
752 >                                progname, oct1name);
753 >                unlink(oct1name);
754                  exit(1);
755          }
756 <        octreedate = time(0);
756 >        oct1date = time((time_t *)NULL);
757 >        rmfile(illumtmp);
758   }
759  
760  
# Line 567 | Line 780 | register char  *oo;
780   }
781  
782  
783 + mkillumopts(mo)                         /* get mkillum options */
784 + register char   *mo;
785 + {
786 +        /* BEWARE:  This may be called via setdefaults(), so no assumptions */
787 +
788 +        *mo = '\0';
789 +        if (vdef(MKILLUM))
790 +                addarg(mo, vval(MKILLUM));
791 + }
792 +
793 +
794   checkambfile()                  /* check date on ambient file */
795   {
796 <        long    afdate;
796 >        time_t  afdate;
797  
798          if (!vdef(AMBFILE))
799                  return;
800 <        if ((afdate = fdate(vval(AMBFILE))) < 0)
800 >        if (!(afdate = fdate(vval(AMBFILE))))
801                  return;
802 <        if (octreedate > afdate | matdate > afdate)
802 >        if (oct1date > afdate)
803                  rmfile(vval(AMBFILE));
804   }
805  
# Line 584 | Line 808 | double
808   ambval()                                /* compute ambient value */
809   {
810          if (vdef(EXPOSURE)) {
587                if (!isflt(vval(EXPOSURE)))
588                        badvalue(EXPOSURE);
811                  if (vval(EXPOSURE)[0] == '+' || vval(EXPOSURE)[0] == '-')
812                          return(.5/pow(2.,atof(vval(EXPOSURE))));
813                  return(.5/atof(vval(EXPOSURE)));
# Line 598 | Line 820 | ambval()                               /* compute ambient value */
820   }
821  
822  
823 + renderopts(op)                          /* set rendering options */
824 + char    *op;
825 + {
826 +        switch(vscale(QUALITY)) {
827 +        case LOW:
828 +                lowqopts(op);
829 +                break;
830 +        case MEDIUM:
831 +                medqopts(op);
832 +                break;
833 +        case HIGH:
834 +                hiqopts(op);
835 +                break;
836 +        }
837 + }
838 +
839 +
840   lowqopts(op)                            /* low quality rendering options */
841   register char   *op;
842   {
# Line 693 | Line 932 | register char  *op;
932          }
933          op = addarg(op, "-pt .08");
934          if (vbool(PENUMBRAS))
935 <                op = addarg(op, "-ds .2 -dj .35");
935 >                op = addarg(op, "-ds .2 -dj .5");
936          else
937                  op = addarg(op, "-ds .3");
938          op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1");
# Line 960 | Line 1199 | register char  *vs;
1199                          cp += strlen(cp);
1200                  }
1201          }
1202 <        strcpy(cp, vs);                 /* append any additional options */
1202 >        if (cp == viewopts)             /* append any additional options */
1203 >                vs++;           /* skip prefixed space if unneeded */
1204 >        strcpy(cp, vs);
1205   #ifdef MSDOS
1206          if (strlen(viewopts) > 40) {
1207                  setenv("VIEW", viewopts);
# Line 1082 | Line 1323 | char   *opts;
1323          sprintf(combuf, "rview %s%s -R %s ", vw, opts, rifname);
1324          if (rvdevice != NULL)
1325                  sprintf(combuf+strlen(combuf), "-o %s ", rvdevice);
1326 <        strcat(combuf, vval(OCTREE));
1326 >        if (vdef(EXPOSURE))
1327 >                sprintf(combuf+strlen(combuf), "-pe %s ", vval(EXPOSURE));
1328 >        strcat(combuf, oct1name);
1329          if (runcom(combuf)) {           /* run it */
1330                  fprintf(stderr, "%s: error running rview\n", progname);
1331                  exit(1);
# Line 1098 | Line 1341 | char   *opts;
1341          char    pfopts[128];
1342          char    vs[32], *vw;
1343          int     vn, mult;
1101        long    lastdate;
1344                                          /* get pfilt options */
1345          pfiltopts(pfopts);
1346                                          /* get resolution, reporting */
1347 <        mult = vscale(QUALITY)+1;
1347 >        switch (vscale(QUALITY)) {
1348 >        case LOW:
1349 >                mult = 1;
1350 >                break;
1351 >        case MEDIUM:
1352 >                mult = 2;
1353 >                break;
1354 >        case HIGH:
1355 >                mult = 3;
1356 >                break;
1357 >        }
1358          {
1359                  int     xres, yres;
1360                  double  aspect;
# Line 1129 | Line 1381 | char   *opts;
1381                  else
1382                          badvalue(REPORT);
1383          }
1132                                        /* get update time */
1133        lastdate = octreedate > matdate ? octreedate : matdate;
1384                                          /* do each view */
1385          vn = 0;
1386          while ((vw = getview(vn++, vs)) != NULL) {
# Line 1140 | Line 1390 | char   *opts;
1390                          sprintf(vs, "%d", vn);
1391                  sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs);
1392                                                  /* check date on picture */
1393 <                if (fdate(picfile) >= lastdate)
1393 >                if (fdate(picfile) >= oct1date)
1394                          continue;
1395                                                  /* build rpict command */
1396                  sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs);
1397 <                if (fdate(rawfile) >= octreedate)       /* recover */
1397 >                if (fdate(rawfile) >= oct1date)         /* recover */
1398                          sprintf(combuf, "rpict%s%s -ro %s %s",
1399 <                                        rep, opts, rawfile, vval(OCTREE));
1399 >                                        rep, opts, rawfile, oct1name);
1400                  else {
1401                          if (overture) {         /* run overture calculation */
1402                                  sprintf(combuf,
1403                                  "rpict%s %s%s -x 64 -y 64 -ps 1 %s > %s",
1404                                                  rep, vw, opts,
1405 <                                                vval(OCTREE), overfile);
1405 >                                                oct1name, overfile);
1406                                  if (runcom(combuf)) {
1407                                          fprintf(stderr,
1408                                          "%s: error in overture for view %s\n",
# Line 1165 | Line 1415 | char   *opts;
1415                          }
1416                          sprintf(combuf, "rpict%s %s %s%s %s > %s",
1417                                          rep, vw, res, opts,
1418 <                                        vval(OCTREE), rawfile);
1418 >                                oct1name, rawfile);
1419                  }
1420                  if (runcom(combuf)) {           /* run rpict */
1421                          fprintf(stderr, "%s: error rendering view %s\n",

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines