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.23 by greg, Tue Sep 7 11:57:04 1993 UTC vs.
Revision 2.34 by greg, Thu Nov 18 13:28:30 1993 UTC

# Line 21 | Line 21 | typedef struct {
21          int     (*fixval)();    /* assignment checking function */
22   } VARIABLE;
23  
24 < int     onevalue(), catvalues();
24 > int     onevalue(), catvalues(), boolvalue(),
25 >        qualvalue(), fltvalue(), intvalue();
26  
27                                  /* variables */
28   #define OBJECT          0               /* object files */
29   #define SCENE           1               /* scene files */
30   #define MATERIAL        2               /* material files */
31 < #define RENDER          3               /* rendering options */
32 < #define OCONV           4               /* oconv options */
33 < #define PFILT           5               /* pfilt options */
34 < #define VIEW            6               /* view(s) for picture(s) */
35 < #define ZONE            7               /* simulation zone */
36 < #define QUALITY         8               /* desired rendering quality */
37 < #define OCTREE          9               /* octree file name */
38 < #define PICTURE         10              /* picture file name */
39 < #define AMBFILE         11              /* ambient file name */
40 < #define OPTFILE         12              /* rendering options file */
41 < #define EXPOSURE        13              /* picture exposure setting */
42 < #define RESOLUTION      14              /* maximum picture resolution */
43 < #define UP              15              /* view up (X, Y or Z) */
44 < #define INDIRECT        16              /* indirection in lighting */
45 < #define DETAIL          17              /* level of scene detail */
46 < #define PENUMBRAS       18              /* shadow penumbras are desired */
47 < #define VARIABILITY     19              /* level of light variability */
48 < #define REPORT          20              /* report frequency and errfile */
31 > #define ILLUM           3               /* mkillum input files */
32 > #define MKILLUM         4               /* mkillum options */
33 > #define RENDER          5               /* rendering options */
34 > #define OCONV           6               /* oconv options */
35 > #define PFILT           7               /* pfilt options */
36 > #define VIEW            8               /* view(s) for picture(s) */
37 > #define ZONE            9               /* simulation zone */
38 > #define QUALITY         10              /* desired rendering quality */
39 > #define OCTREE          11              /* octree file name */
40 > #define PICTURE         12              /* picture file name */
41 > #define AMBFILE         13              /* ambient file name */
42 > #define OPTFILE         14              /* rendering options file */
43 > #define EXPOSURE        15              /* picture exposure setting */
44 > #define RESOLUTION      16              /* maximum picture resolution */
45 > #define UP              17              /* view up (X, Y or Z) */
46 > #define INDIRECT        18              /* indirection in lighting */
47 > #define DETAIL          19              /* level of scene detail */
48 > #define PENUMBRAS       20              /* shadow penumbras are desired */
49 > #define VARIABILITY     21              /* level of light variability */
50 > #define REPORT          22              /* report frequency and errfile */
51                                  /* total number of variables */
52 < #define NVARS           21
52 > #define NVARS           23
53  
54   VARIABLE        vv[NVARS] = {           /* variable-value pairs */
55          {"objects",     3,      0,      NULL,   catvalues},
56          {"scene",       3,      0,      NULL,   catvalues},
57          {"materials",   3,      0,      NULL,   catvalues},
58 +        {"illum",       3,      0,      NULL,   catvalues},
59 +        {"mkillum",     3,      0,      NULL,   catvalues},
60          {"render",      3,      0,      NULL,   catvalues},
61          {"oconv",       3,      0,      NULL,   catvalues},
62          {"pfilt",       2,      0,      NULL,   catvalues},
63          {"view",        2,      0,      NULL,   NULL},
64          {"ZONE",        2,      0,      NULL,   onevalue},
65 <        {"QUALITY",     3,      0,      NULL,   onevalue},
65 >        {"QUALITY",     3,      0,      NULL,   qualvalue},
66          {"OCTREE",      3,      0,      NULL,   onevalue},
67          {"PICTURE",     3,      0,      NULL,   onevalue},
68          {"AMBFILE",     3,      0,      NULL,   onevalue},
69          {"OPTFILE",     3,      0,      NULL,   onevalue},
70 <        {"EXPOSURE",    3,      0,      NULL,   onevalue},
70 >        {"EXPOSURE",    3,      0,      NULL,   fltvalue},
71          {"RESOLUTION",  3,      0,      NULL,   onevalue},
72          {"UP",          2,      0,      NULL,   onevalue},
73 <        {"INDIRECT",    3,      0,      NULL,   onevalue},
74 <        {"DETAIL",      3,      0,      NULL,   onevalue},
75 <        {"PENUMBRAS",   3,      0,      NULL,   onevalue},
76 <        {"VARIABILITY", 3,      0,      NULL,   onevalue},
73 >        {"INDIRECT",    3,      0,      NULL,   intvalue},
74 >        {"DETAIL",      3,      0,      NULL,   qualvalue},
75 >        {"PENUMBRAS",   3,      0,      NULL,   boolvalue},
76 >        {"VARIABILITY", 3,      0,      NULL,   qualvalue},
77          {"REPORT",      3,      0,      NULL,   onevalue},
78   };
79  
80   VARIABLE        *matchvar();
81   char    *nvalue();
77 int     vscale();
82  
83   #define UPPER(c)        ((c)&~0x20)     /* ASCII trick */
84  
# Line 83 | Line 87 | int    vscale();
87   #define vval(vc)        (vv[vc].value)
88   #define vint(vc)        atoi(vval(vc))
89   #define vlet(vc)        UPPER(vval(vc)[0])
90 + #define vscale          vlet
91   #define vbool(vc)       (vlet(vc)=='T')
92  
93 < #define HIGH            2
94 < #define MEDIUM          1
95 < #define LOW             0
93 > #define HIGH            'H'
94 > #define MEDIUM          'M'
95 > #define LOW             'L'
96  
92 int     lowqopts(), medqopts(), hiqopts();
93 int     (*setqopts[3])() = {lowqopts, medqopts, hiqopts};
94
95 #define renderopts      (*setqopts[vscale(QUALITY)])
96
97                                  /* overture calculation file */
98   #ifdef NIX
99   char    overfile[] = "overture.raw";
# Line 101 | Line 101 | char   overfile[] = "overture.raw";
101   char    overfile[] = "/dev/null";
102   #endif
103  
104 < extern long     fdate(), time();
104 > extern unsigned long    fdate(), time();
105  
106 < long    scenedate;              /* date of latest scene or object file */
107 < long    octreedate;             /* date of octree */
108 < long    matdate;                /* date of latest material file */
106 > unsigned long   scenedate;      /* date of latest scene or object file */
107 > unsigned long   octreedate;     /* date of octree */
108 > unsigned long   matdate;        /* date of latest material file */
109 > unsigned long   illumdate;      /* date of last illum file */
110  
111 + char    *oct0name;              /* name of pre-mkillum octree */
112 + unsigned long   oct0date;       /* date of pre-mkillum octree */
113 + char    *oct1name;              /* name of post-mkillum octree */
114 + unsigned long   oct1date;       /* date of post-mkillum octree (>= matdate) */
115 +
116   int     explicate = 0;          /* explicate variables */
117   int     silent = 0;             /* do work silently */
118   int     noaction = 0;           /* don't do anything */
# Line 173 | Line 179 | char   *argv[];
179                                  /* print all values if requested */
180          if (explicate)
181                  printvals();
182 <                                /* build octree */
182 >                                /* build octree (and run mkillum) */
183          oconv();
184                                  /* check date on ambient file */
185          checkambfile();
# Line 187 | Line 193 | char   *argv[];
193          exit(0);
194   userr:
195          fprintf(stderr,
196 <        "Usage: %s [-s][-n][-e][-v view][-o dev] rfile [VAR=value ..]\n",
196 >        "Usage: %s [-s][-n][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n",
197                          progname);
198          exit(1);
199   }
# Line 208 | Line 214 | register char  *rn, *fn;
214   }
215  
216  
217 + #define NOCHAR  127             /* constant for character to delete */
218 +
219 +
220   load(rfname)                    /* load Radiance simulation file */
221   char    *rfname;
222   {
# Line 223 | Line 232 | char   *rfname;
232                  for (cp = buf; *cp; cp++) {
233                          switch (*cp) {
234                          case '\\':
235 <                        case '\n':
227 <                                *cp = ' ';
235 >                                *cp++ = NOCHAR;
236                                  continue;
237                          case '#':
238                                  *cp = '\0';
# Line 244 | Line 252 | setvariable(ass)               /* assign variable according to stri
252   register char   *ass;
253   {
254          char    varname[32];
255 +        int     n;
256          register char   *cp;
257          register VARIABLE       *vp;
258          register int    i;
250        int     n;
259  
260          while (isspace(*ass))           /* skip leading space */
261                  ass++;
# Line 261 | Line 269 | register char  *ass;
269                                          /* trim value */
270          while (isspace(*ass) || *ass == '=')
271                  ass++;
272 <        cp = ass + strlen(ass);
273 <        do
274 <                *cp-- = '\0';
267 <        while (cp >= ass && isspace(*cp));
268 <        n = cp - ass + 1;
272 >        for (n = strlen(ass); n > 0; n--)
273 >                if (!isspace(ass[n-1]))
274 >                        break;
275          if (!n) {
276                  fprintf(stderr, "%s: warning - missing value for variable '%s'\n",
277                                  progname, varname);
# Line 290 | Line 296 | register char  *ass;
296                  vp->value = malloc(n+1);
297          if (vp->value == NULL)
298                  syserr(progname);
299 <        strcpy(vp->value+i, ass);
299 >        cp = vp->value+i;               /* copy value, squeezing spaces */
300 >        *cp = *ass;
301 >        for (i = 1; i <= n; i++) {
302 >                if (ass[i] == NOCHAR)
303 >                        continue;
304 >                if (isspace(*cp))
305 >                        while (isspace(ass[i]))
306 >                                i++;
307 >                *++cp = ass[i];
308 >        }
309 >        if (isspace(*cp))               /* remove trailing space */
310 >                *cp = '\0';
311          vp->nass++;
312   }
313  
# Line 326 | Line 343 | register int   n;
343   }
344  
345  
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
346   checkvalues()                   /* check assignments */
347   {
348          register int    i;
# Line 380 | Line 381 | register VARIABLE      *vp;
381   }
382  
383  
384 < long
384 > int
385 > badmatch(tv, cv)                /* case insensitive truncated comparison */
386 > register char   *tv, *cv;
387 > {
388 >        if (!*tv) return(1);            /* null string cannot match */
389 >        do
390 >                if (UPPER(*tv) != *cv++)
391 >                        return(1);
392 >        while (*++tv);
393 >        return(0);              /* OK */
394 > }
395 >
396 >
397 > boolvalue(vp)                   /* check boolean for legal values */
398 > register VARIABLE       *vp;
399 > {
400 >        if (!vp->nass) return;
401 >        onevalue(vp);
402 >        switch (UPPER(vp->value[0])) {
403 >        case 'T':
404 >                if (badmatch(vp->value, "TRUE")) break;
405 >                return;
406 >        case 'F':
407 >                if (badmatch(vp->value, "FALSE")) break;
408 >                return;
409 >        }
410 >        fprintf(stderr, "%s: illegal value for boolean variable '%s'\n",
411 >                        progname, vp->name);
412 >        exit(1);
413 > }
414 >
415 >
416 > qualvalue(vp)                   /* check qualitative var. for legal values */
417 > register VARIABLE       *vp;
418 > {
419 >        if (!vp->nass) return;
420 >        onevalue(vp);
421 >        switch (UPPER(vp->value[0])) {
422 >        case 'L':
423 >                if (badmatch(vp->value, "LOW")) break;
424 >                return;
425 >        case 'M':
426 >                if (badmatch(vp->value, "MEDIUM")) break;
427 >                return;
428 >        case 'H':
429 >                if (badmatch(vp->value, "HIGH")) break;
430 >                return;
431 >        }
432 >        fprintf(stderr, "%s: illegal value for qualitative variable '%s'\n",
433 >                        progname, vp->name);
434 >        exit(1);
435 > }
436 >
437 >
438 > intvalue(vp)                    /* check integer variable for legal values */
439 > register VARIABLE       *vp;
440 > {
441 >        if (!vp->nass) return;
442 >        onevalue(vp);
443 >        if (isint(vp->value)) return;
444 >        fprintf(stderr, "%s: illegal value for integer variable '%s'\n",
445 >                        progname, vp->name);
446 >        exit(1);
447 > }
448 >
449 >
450 > fltvalue(vp)                    /* check float variable for legal values */
451 > register VARIABLE       *vp;
452 > {
453 >        if (!vp->nass) return;
454 >        onevalue(vp);
455 >        if (isflt(vp->value)) return;
456 >        fprintf(stderr, "%s: illegal value for real variable '%s'\n",
457 >                        progname, vp->name);
458 >        exit(1);
459 > }
460 >
461 >
462 > unsigned long
463   checklast(fnames)                       /* check files and find most recent */
464   register char   *fnames;
465   {
466          char    thisfile[MAXPATH];
467 <        long    thisdate, lastdate = -1;
467 >        unsigned long   thisdate, lastdate = 0;
468          register char   *cp;
469  
470 +        if (fnames == NULL)
471 +                return(0);
472          while (*fnames) {
473                  while (isspace(*fnames)) fnames++;
474                  cp = thisfile;
475                  while (*fnames && !isspace(*fnames))
476                          *cp++ = *fnames++;
477                  *cp = '\0';
478 <                if ((thisdate = fdate(thisfile)) < 0)
478 >                if (!(thisdate = fdate(thisfile)))
479                          syserr(thisfile);
480                  if (thisdate > lastdate)
481                          lastdate = thisdate;
# Line 403 | Line 484 | register char  *fnames;
484   }
485  
486  
487 + char *
488 + newfname(orig, pred)            /* create modified file name */
489 + char    *orig;
490 + int     pred;
491 + {
492 +        extern char     *rindex();
493 +        register char   *cp;
494 +        register int    n;
495 +        int     suffix;
496 +
497 +        n = 0; cp = orig; suffix = -1;          /* suffix position, length */
498 +        while (*cp) {
499 +                if (*cp == '.') suffix = n;
500 +                else if (ISDIRSEP(*cp)) suffix = -1;
501 +                cp++; n++;
502 +        }
503 +        if (suffix == -1) suffix = n;
504 +        if ((cp = bmalloc(n+2)) == NULL)
505 +                syserr(progname);
506 +        strncpy(cp, orig, suffix);
507 +        cp[suffix] = pred;                      /* root name + pred + suffix */
508 +        strcpy(cp+suffix+1, orig+suffix);
509 +        return(cp);
510 + }
511 +
512 +
513   checkfiles()                    /* check for existence and modified times */
514   {
515 <        char    *cp;
409 <        long    objdate;
515 >        unsigned long   objdate;
516  
517          if (!vdef(OCTREE)) {
518 <                if ((cp = bmalloc(strlen(radname)+5)) == NULL)
518 >                if ((vval(OCTREE) = bmalloc(strlen(radname)+5)) == NULL)
519                          syserr(progname);
520 <                sprintf(cp, "%s.oct", radname);
415 <                vval(OCTREE) = cp;
520 >                sprintf(vval(OCTREE), "%s.oct", radname);
521                  vdef(OCTREE)++;
522          }
523          octreedate = fdate(vval(OCTREE));
524 <        scenedate = -1;
525 <        if (vdef(SCENE)) {
526 <                scenedate = checklast(vval(SCENE));
527 <                if (vdef(OBJECT)) {
528 <                        objdate = checklast(vval(OBJECT));
529 <                        if (objdate > scenedate)
530 <                                scenedate = objdate;
531 <                }
532 <        }
533 <        if (octreedate < 0 & scenedate < 0) {
534 <                fprintf(stderr, "%s: need '%s' or '%s'\n", progname,
535 <                                vnam(OCTREE), vnam(SCENE));
524 >        if (vdef(ILLUM)) {              /* illum requires secondary octrees */
525 >                oct0name = newfname(vval(OCTREE), '0');
526 >                oct1name = newfname(vval(OCTREE), '1');
527 >                oct0date = fdate(oct0name);
528 >                oct1date = fdate(oct1name);
529 >        } else
530 >                oct0name = oct1name = vval(OCTREE);
531 >        if ((scenedate = checklast(vval(SCENE))) &&
532 >                        (objdate = checklast(vval(OBJECT))) > scenedate)
533 >                scenedate = objdate;
534 >        illumdate = checklast(vval(ILLUM));
535 >        if (!octreedate & !scenedate & !illumdate) {
536 >                fprintf(stderr, "%s: need '%s' or '%s' or '%s'\n", progname,
537 >                                vnam(OCTREE), vnam(SCENE), vnam(ILLUM));
538                  exit(1);
539          }
540 <        matdate = -1;
434 <        if (vdef(MATERIAL))
435 <                matdate = checklast(vval(MATERIAL));
540 >        matdate = checklast(vval(MATERIAL));
541   }      
542  
543  
# Line 441 | Line 546 | double org[3], *sizp;
546   {
547          extern FILE     *popen();
548          static double   oorg[3], osiz = 0.;
549 <        char    buf[MAXPATH+16];
549 >        double  min[3], max[3];
550 >        char    buf[512];
551          FILE    *fp;
552 +        register int    i;
553  
554 <        if (osiz <= FTINY) {
555 <                oconv();                /* does nothing if done already */
556 <                sprintf(buf, "getinfo -d < %s", vval(OCTREE));
557 <                if ((fp = popen(buf, "r")) == NULL)
558 <                        syserr("getinfo");
559 <                if (fscanf(fp, "%lf %lf %lf %lf", &oorg[0], &oorg[1],
560 <                                &oorg[2], &osiz) != 4) {
561 <                        fprintf(stderr,
554 >        if (osiz <= FTINY)
555 >                if (noaction && fdate(oct1name) <
556 >                                (scenedate>illumdate?scenedate:illumdate)) {
557 >                                                        /* run getbbox */
558 >                        sprintf(buf, "getbbox -w -h %s",
559 >                                vdef(SCENE) ? vval(SCENE) : vval(ILLUM));
560 >                        if ((fp = popen(buf, "r")) == NULL)
561 >                                syserr("getbbox");
562 >                        if (fscanf(fp, "%lf %lf %lf %lf %lf %lf",
563 >                                        &min[0], &max[0], &min[1], &max[1],
564 >                                        &min[2], &max[2]) != 6) {
565 >                                fprintf(stderr,
566 >                        "%s: error reading bounding box from getbbox\n",
567 >                                                progname);
568 >                                exit(1);
569 >                        }
570 >                        for (i = 0; i < 3; i++)
571 >                                if (max[i] - min[i] > osiz)
572 >                                        osiz = max[i] - min[i];
573 >                        for (i = 0; i < 3; i++)
574 >                                oorg[i] = (max[i]+min[i]-osiz)*.5;
575 >                        pclose(fp);
576 >                } else {                                /* from octree */
577 >                        oconv();        /* does nothing if done already */
578 >                        sprintf(buf, "getinfo -d < %s", oct1name);
579 >                        if ((fp = popen(buf, "r")) == NULL)
580 >                                syserr("getinfo");
581 >                        if (fscanf(fp, "%lf %lf %lf %lf", &oorg[0], &oorg[1],
582 >                                        &oorg[2], &osiz) != 4) {
583 >                                fprintf(stderr,
584                          "%s: error reading bounding cube from getinfo\n",
585 <                                        progname);
586 <                        exit(1);
585 >                                                progname);
586 >                                exit(1);
587 >                        }
588 >                        pclose(fp);
589                  }
459                pclose(fp);
460        }
590          org[0] = oorg[0]; org[1] = oorg[1]; org[2] = oorg[2]; *sizp = osiz;
591   }
592  
# Line 520 | Line 649 | printvals()                    /* print variable values */
649   }
650  
651  
652 < oconv()                         /* run oconv if necessary */
652 > oconv()                         /* run oconv and mkillum if necessary */
653   {
654 <        char    combuf[512], ocopts[64];
654 >        static char     illumtmp[] = "ilXXXXXX";
655 >        char    combuf[512], ocopts[64], mkopts[64];
656  
657 <        if (octreedate >= scenedate)    /* check dates */
658 <                return;
659 <                                        /* build command */
660 <        oconvopts(ocopts);
661 <        if (vdef(MATERIAL))
532 <                sprintf(combuf, "oconv%s %s %s > %s", ocopts,
657 >        oconvopts(ocopts);              /* get options */
658 >        if (octreedate < scenedate) {   /* check date on original octree */
659 >                                                /* build command */
660 >                if (vdef(MATERIAL))
661 >                        sprintf(combuf, "oconv%s %s %s > %s", ocopts,
662                                  vval(MATERIAL), vval(SCENE), vval(OCTREE));
663 +                else
664 +                        sprintf(combuf, "oconv%s %s > %s", ocopts,
665 +                                        vval(SCENE), vval(OCTREE));
666 +                
667 +                if (runcom(combuf)) {           /* run it */
668 +                        fprintf(stderr,
669 +                                "%s: error generating octree\n\t%s removed\n",
670 +                                        progname, vval(OCTREE));
671 +                        unlink(vval(OCTREE));
672 +                        exit(1);
673 +                }
674 +                octreedate = time((unsigned long *)NULL);
675 +        }
676 +        if (oct1name == vval(OCTREE))           /* no mkillum? */
677 +                oct1date = octreedate > matdate ? octreedate : matdate;
678 +        if (oct1date >= octreedate & oct1date >= matdate
679 +                        & oct1date >= illumdate)        /* all done */
680 +                return;
681 +                                                /* make octree0 */
682 +        if (oct0date < scenedate | oct0date < illumdate) {
683 +                                                /* build command */
684 +                if (octreedate)
685 +                        sprintf(combuf, "oconv%s -i %s %s > %s", ocopts,
686 +                                vval(OCTREE), vval(ILLUM), oct0name);
687 +                else if (vdef(MATERIAL))
688 +                        sprintf(combuf, "oconv%s %s %s > %s", ocopts,
689 +                                vval(MATERIAL), vval(ILLUM), oct0name);
690 +                else
691 +                        sprintf(combuf, "oconv%s %s > %s", ocopts,
692 +                                vval(ILLUM), oct0name);
693 +                if (runcom(combuf)) {           /* run it */
694 +                        fprintf(stderr,
695 +                                "%s: error generating octree\n\t%s removed\n",
696 +                                        progname, oct0name);
697 +                        unlink(oct0name);
698 +                        exit(1);
699 +                }
700 +                oct0date = time((unsigned long *)NULL);
701 +        }
702 +        mkillumopts(mkopts);                    /* build mkillum command */
703 +        mktemp(illumtmp);
704 +        sprintf(combuf, "mkillum%s %s \"<\" %s > %s", mkopts,
705 +                        oct0name, vval(ILLUM), illumtmp);
706 +        if (runcom(combuf)) {                   /* run it */
707 +                fprintf(stderr, "%s: error running mkillum\n", progname);
708 +                unlink(illumtmp);
709 +                exit(1);
710 +        }
711 +                                                /* make octree1 (frozen) */
712 +        if (octreedate)
713 +                sprintf(combuf, "oconv%s -f -i %s %s > %s", ocopts,
714 +                        vval(OCTREE), illumtmp, oct1name);
715 +        else if (vdef(MATERIAL))
716 +                sprintf(combuf, "oconv%s -f %s %s > %s", ocopts,
717 +                        vval(MATERIAL), illumtmp, oct1name);
718          else
719 <                sprintf(combuf, "oconv%s %s > %s", ocopts,
720 <                                vval(SCENE), vval(OCTREE));
537 <        
719 >                sprintf(combuf, "oconv%s -f %s > %s", ocopts,
720 >                        illumtmp, oct1name);
721          if (runcom(combuf)) {           /* run it */
722 <                fprintf(stderr, "%s: error generating octree\n\t%s removed\n",
723 <                                progname, vval(OCTREE));
724 <                unlink(vval(OCTREE));
722 >                fprintf(stderr,
723 >                        "%s: error generating octree\n\t%s removed\n",
724 >                                progname, oct1name);
725 >                unlink(oct1name);
726                  exit(1);
727          }
728 <        octreedate = time(0);
728 >        oct1date = time((unsigned long *)NULL);
729 >        rmfile(illumtmp);
730   }
731  
732  
# Line 567 | Line 752 | register char  *oo;
752   }
753  
754  
755 + mkillumopts(mo)                         /* get mkillum options */
756 + register char   *mo;
757 + {
758 +        /* BEWARE:  This may be called via setdefaults(), so no assumptions */
759 +
760 +        *mo = '\0';
761 +        if (vdef(MKILLUM))
762 +                addarg(mo, vval(MKILLUM));
763 + }
764 +
765 +
766   checkambfile()                  /* check date on ambient file */
767   {
768 <        long    afdate;
768 >        unsigned long   afdate;
769  
770          if (!vdef(AMBFILE))
771                  return;
772 <        if ((afdate = fdate(vval(AMBFILE))) < 0)
772 >        if (!(afdate = fdate(vval(AMBFILE))))
773                  return;
774 <        if (octreedate > afdate | matdate > afdate)
774 >        if (oct1date > afdate)
775                  rmfile(vval(AMBFILE));
776   }
777  
# Line 584 | Line 780 | double
780   ambval()                                /* compute ambient value */
781   {
782          if (vdef(EXPOSURE)) {
587                if (!isflt(vval(EXPOSURE)))
588                        badvalue(EXPOSURE);
783                  if (vval(EXPOSURE)[0] == '+' || vval(EXPOSURE)[0] == '-')
784                          return(.5/pow(2.,atof(vval(EXPOSURE))));
785                  return(.5/atof(vval(EXPOSURE)));
# Line 598 | Line 792 | ambval()                               /* compute ambient value */
792   }
793  
794  
795 + renderopts(op)                          /* set rendering options */
796 + char    *op;
797 + {
798 +        switch(vscale(QUALITY)) {
799 +        case LOW:
800 +                lowqopts(op);
801 +                break;
802 +        case MEDIUM:
803 +                medqopts(op);
804 +                break;
805 +        case HIGH:
806 +                hiqopts(op);
807 +                break;
808 +        }
809 + }
810 +
811 +
812   lowqopts(op)                            /* low quality rendering options */
813   register char   *op;
814   {
# Line 693 | Line 904 | register char  *op;
904          }
905          op = addarg(op, "-pt .08");
906          if (vbool(PENUMBRAS))
907 <                op = addarg(op, "-ds .2 -dj .35");
907 >                op = addarg(op, "-ds .2 -dj .5");
908          else
909                  op = addarg(op, "-ds .3");
910          op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1");
# Line 960 | Line 1171 | register char  *vs;
1171                          cp += strlen(cp);
1172                  }
1173          }
1174 <        strcpy(cp, vs);                 /* append any additional options */
1174 >        if (cp == viewopts)             /* append any additional options */
1175 >                vs++;           /* skip prefixed space if unneeded */
1176 >        strcpy(cp, vs);
1177   #ifdef MSDOS
1178          if (strlen(viewopts) > 40) {
1179                  setenv("VIEW", viewopts);
# Line 1015 | Line 1228 | char   *vn;            /* returned view name */
1228   printview(vopts)                        /* print out selected view */
1229   register char   *vopts;
1230   {
1231 <        extern char     *atos();
1231 >        extern char     *atos(), *getenv();
1232          char    buf[256];
1233          FILE    *fp;
1234          register char   *cp;
# Line 1050 | Line 1263 | register char  *vopts;
1263                          while (isspace(*vopts))
1264                                  vopts++;
1265                          putchar(' ');
1266 <                        while (*vopts && !isspace(*vopts))
1267 <                                putchar(*vopts++);
1266 > #ifdef MSDOS
1267 >                        if (*vopts == '$') {            /* expand env. var. */
1268 >                                if (!*atos(buf, sizeof(buf), vopts+1))
1269 >                                        return(-1);
1270 >                                if ((cp = getenv(buf)) == NULL)
1271 >                                        return(-1);
1272 >                                fputs(cp, stdout);
1273 >                                vopts = sskip(vopts);
1274 >                        } else
1275 > #endif
1276 >                                while (*vopts && !isspace(*vopts))
1277 >                                        putchar(*vopts++);
1278                  }
1279          } while (*vopts++);
1280          putchar('\n');
# Line 1072 | Line 1295 | char   *opts;
1295          sprintf(combuf, "rview %s%s -R %s ", vw, opts, rifname);
1296          if (rvdevice != NULL)
1297                  sprintf(combuf+strlen(combuf), "-o %s ", rvdevice);
1298 <        strcat(combuf, vval(OCTREE));
1298 >        if (vdef(EXPOSURE))
1299 >                sprintf(combuf+strlen(combuf), "-pe %s ", vval(EXPOSURE));
1300 >        strcat(combuf, oct1name);
1301          if (runcom(combuf)) {           /* run it */
1302                  fprintf(stderr, "%s: error running rview\n", progname);
1303                  exit(1);
# Line 1088 | Line 1313 | char   *opts;
1313          char    pfopts[128];
1314          char    vs[32], *vw;
1315          int     vn, mult;
1091        long    lastdate;
1316                                          /* get pfilt options */
1317          pfiltopts(pfopts);
1318                                          /* get resolution, reporting */
1319 <        mult = vscale(QUALITY)+1;
1319 >        switch (vscale(QUALITY)) {
1320 >        case LOW:
1321 >                mult = 1;
1322 >                break;
1323 >        case MEDIUM:
1324 >                mult = 2;
1325 >                break;
1326 >        case HIGH:
1327 >                mult = 3;
1328 >                break;
1329 >        }
1330          {
1331                  int     xres, yres;
1332                  double  aspect;
# Line 1119 | Line 1353 | char   *opts;
1353                  else
1354                          badvalue(REPORT);
1355          }
1122                                        /* get update time */
1123        lastdate = octreedate > matdate ? octreedate : matdate;
1356                                          /* do each view */
1357          vn = 0;
1358          while ((vw = getview(vn++, vs)) != NULL) {
# Line 1130 | Line 1362 | char   *opts;
1362                          sprintf(vs, "%d", vn);
1363                  sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs);
1364                                                  /* check date on picture */
1365 <                if (fdate(picfile) >= lastdate)
1365 >                if (fdate(picfile) >= oct1date)
1366                          continue;
1367                                                  /* build rpict command */
1368                  sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs);
1369 <                if (fdate(rawfile) >= octreedate)       /* recover */
1369 >                if (fdate(rawfile) >= oct1date)         /* recover */
1370                          sprintf(combuf, "rpict%s%s -ro %s %s",
1371 <                                        rep, opts, rawfile, vval(OCTREE));
1371 >                                        rep, opts, rawfile, oct1name);
1372                  else {
1373                          if (overture) {         /* run overture calculation */
1374                                  sprintf(combuf,
1375                                  "rpict%s %s%s -x 64 -y 64 -ps 1 %s > %s",
1376                                                  rep, vw, opts,
1377 <                                                vval(OCTREE), overfile);
1377 >                                                oct1name, overfile);
1378                                  if (runcom(combuf)) {
1379                                          fprintf(stderr,
1380                                          "%s: error in overture for view %s\n",
# Line 1155 | Line 1387 | char   *opts;
1387                          }
1388                          sprintf(combuf, "rpict%s %s %s%s %s > %s",
1389                                          rep, vw, res, opts,
1390 <                                        vval(OCTREE), rawfile);
1390 >                                oct1name, rawfile);
1391                  }
1392                  if (runcom(combuf)) {           /* run rpict */
1393                          fprintf(stderr, "%s: error rendering view %s\n",

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines