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.35 by greg, Tue Nov 23 09:26:38 1993 UTC

# 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     explicate = 0;          /* explicate variables */
118   int     silent = 0;             /* do work silently */
119   int     noaction = 0;           /* don't do anything */
# Line 173 | Line 180 | char   *argv[];
180                                  /* print all values if requested */
181          if (explicate)
182                  printvals();
183 <                                /* build octree */
183 >                                /* build octree (and run mkillum) */
184          oconv();
185                                  /* check date on ambient file */
186          checkambfile();
# Line 187 | Line 194 | char   *argv[];
194          exit(0);
195   userr:
196          fprintf(stderr,
197 <        "Usage: %s [-s][-n][-e][-v view][-o dev] rfile [VAR=value ..]\n",
197 >        "Usage: %s [-s][-n][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n",
198                          progname);
199          exit(1);
200   }
# Line 208 | Line 215 | register char  *rn, *fn;
215   }
216  
217  
218 + #define NOCHAR  127             /* constant for character to delete */
219 +
220 +
221   load(rfname)                    /* load Radiance simulation file */
222   char    *rfname;
223   {
# Line 223 | Line 233 | char   *rfname;
233                  for (cp = buf; *cp; cp++) {
234                          switch (*cp) {
235                          case '\\':
236 <                        case '\n':
227 <                                *cp = ' ';
236 >                                *cp++ = NOCHAR;
237                                  continue;
238                          case '#':
239                                  *cp = '\0';
# Line 244 | Line 253 | setvariable(ass)               /* assign variable according to stri
253   register char   *ass;
254   {
255          char    varname[32];
256 +        int     n;
257          register char   *cp;
258          register VARIABLE       *vp;
259          register int    i;
250        int     n;
260  
261          while (isspace(*ass))           /* skip leading space */
262                  ass++;
# Line 261 | Line 270 | register char  *ass;
270                                          /* trim value */
271          while (isspace(*ass) || *ass == '=')
272                  ass++;
273 <        cp = ass + strlen(ass);
274 <        do
275 <                *cp-- = '\0';
267 <        while (cp >= ass && isspace(*cp));
268 <        n = cp - ass + 1;
273 >        for (n = strlen(ass); n > 0; n--)
274 >                if (!isspace(ass[n-1]))
275 >                        break;
276          if (!n) {
277                  fprintf(stderr, "%s: warning - missing value for variable '%s'\n",
278                                  progname, varname);
# Line 290 | Line 297 | register char  *ass;
297                  vp->value = malloc(n+1);
298          if (vp->value == NULL)
299                  syserr(progname);
300 <        strcpy(vp->value+i, ass);
300 >        cp = vp->value+i;               /* copy value, squeezing spaces */
301 >        *cp = *ass;
302 >        for (i = 1; i <= n; i++) {
303 >                if (ass[i] == NOCHAR)
304 >                        continue;
305 >                if (isspace(*cp))
306 >                        while (isspace(ass[i]))
307 >                                i++;
308 >                *++cp = ass[i];
309 >        }
310 >        if (isspace(*cp))               /* remove trailing space */
311 >                *cp = '\0';
312          vp->nass++;
313   }
314  
# Line 326 | Line 344 | register int   n;
344   }
345  
346  
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
347   checkvalues()                   /* check assignments */
348   {
349          register int    i;
# Line 380 | Line 382 | register VARIABLE      *vp;
382   }
383  
384  
385 < long
385 > int
386 > badmatch(tv, cv)                /* case insensitive truncated comparison */
387 > register char   *tv, *cv;
388 > {
389 >        if (!*tv) return(1);            /* null string cannot match */
390 >        do
391 >                if (UPPER(*tv) != *cv++)
392 >                        return(1);
393 >        while (*++tv);
394 >        return(0);              /* OK */
395 > }
396 >
397 >
398 > boolvalue(vp)                   /* check boolean for legal values */
399 > register VARIABLE       *vp;
400 > {
401 >        if (!vp->nass) return;
402 >        onevalue(vp);
403 >        switch (UPPER(vp->value[0])) {
404 >        case 'T':
405 >                if (badmatch(vp->value, "TRUE")) break;
406 >                return;
407 >        case 'F':
408 >                if (badmatch(vp->value, "FALSE")) break;
409 >                return;
410 >        }
411 >        fprintf(stderr, "%s: illegal value for boolean variable '%s'\n",
412 >                        progname, vp->name);
413 >        exit(1);
414 > }
415 >
416 >
417 > qualvalue(vp)                   /* check qualitative var. for legal values */
418 > register VARIABLE       *vp;
419 > {
420 >        if (!vp->nass) return;
421 >        onevalue(vp);
422 >        switch (UPPER(vp->value[0])) {
423 >        case 'L':
424 >                if (badmatch(vp->value, "LOW")) break;
425 >                return;
426 >        case 'M':
427 >                if (badmatch(vp->value, "MEDIUM")) break;
428 >                return;
429 >        case 'H':
430 >                if (badmatch(vp->value, "HIGH")) break;
431 >                return;
432 >        }
433 >        fprintf(stderr, "%s: illegal value for qualitative variable '%s'\n",
434 >                        progname, vp->name);
435 >        exit(1);
436 > }
437 >
438 >
439 > intvalue(vp)                    /* check integer variable for legal values */
440 > register VARIABLE       *vp;
441 > {
442 >        if (!vp->nass) return;
443 >        onevalue(vp);
444 >        if (isint(vp->value)) return;
445 >        fprintf(stderr, "%s: illegal value for integer variable '%s'\n",
446 >                        progname, vp->name);
447 >        exit(1);
448 > }
449 >
450 >
451 > fltvalue(vp)                    /* check float variable for legal values */
452 > register VARIABLE       *vp;
453 > {
454 >        if (!vp->nass) return;
455 >        onevalue(vp);
456 >        if (isflt(vp->value)) return;
457 >        fprintf(stderr, "%s: illegal value for real variable '%s'\n",
458 >                        progname, vp->name);
459 >        exit(1);
460 > }
461 >
462 >
463 > time_t
464   checklast(fnames)                       /* check files and find most recent */
465   register char   *fnames;
466   {
467          char    thisfile[MAXPATH];
468 <        long    thisdate, lastdate = -1;
468 >        time_t  thisdate, lastdate = 0;
469          register char   *cp;
470  
471 +        if (fnames == NULL)
472 +                return(0);
473          while (*fnames) {
474                  while (isspace(*fnames)) fnames++;
475                  cp = thisfile;
476                  while (*fnames && !isspace(*fnames))
477                          *cp++ = *fnames++;
478                  *cp = '\0';
479 <                if ((thisdate = fdate(thisfile)) < 0)
479 >                if (!(thisdate = fdate(thisfile)))
480                          syserr(thisfile);
481                  if (thisdate > lastdate)
482                          lastdate = thisdate;
# Line 403 | Line 485 | register char  *fnames;
485   }
486  
487  
488 + char *
489 + newfname(orig, pred)            /* create modified file name */
490 + char    *orig;
491 + int     pred;
492 + {
493 +        extern char     *rindex();
494 +        register char   *cp;
495 +        register int    n;
496 +        int     suffix;
497 +
498 +        n = 0; cp = orig; suffix = -1;          /* suffix position, length */
499 +        while (*cp) {
500 +                if (*cp == '.') suffix = n;
501 +                else if (ISDIRSEP(*cp)) suffix = -1;
502 +                cp++; n++;
503 +        }
504 +        if (suffix == -1) suffix = n;
505 +        if ((cp = bmalloc(n+2)) == NULL)
506 +                syserr(progname);
507 +        strncpy(cp, orig, suffix);
508 +        cp[suffix] = pred;                      /* root name + pred + suffix */
509 +        strcpy(cp+suffix+1, orig+suffix);
510 +        return(cp);
511 + }
512 +
513 +
514   checkfiles()                    /* check for existence and modified times */
515   {
516 <        char    *cp;
409 <        long    objdate;
516 >        time_t  objdate;
517  
518          if (!vdef(OCTREE)) {
519 <                if ((cp = bmalloc(strlen(radname)+5)) == NULL)
519 >                if ((vval(OCTREE) = bmalloc(strlen(radname)+5)) == NULL)
520                          syserr(progname);
521 <                sprintf(cp, "%s.oct", radname);
415 <                vval(OCTREE) = cp;
521 >                sprintf(vval(OCTREE), "%s.oct", radname);
522                  vdef(OCTREE)++;
523          }
524          octreedate = fdate(vval(OCTREE));
525 <        scenedate = -1;
526 <        if (vdef(SCENE)) {
527 <                scenedate = checklast(vval(SCENE));
528 <                if (vdef(OBJECT)) {
529 <                        objdate = checklast(vval(OBJECT));
530 <                        if (objdate > scenedate)
531 <                                scenedate = objdate;
532 <                }
533 <        }
534 <        if (octreedate < 0 & scenedate < 0) {
535 <                fprintf(stderr, "%s: need '%s' or '%s'\n", progname,
536 <                                vnam(OCTREE), vnam(SCENE));
525 >        if (vdef(ILLUM)) {              /* illum requires secondary octrees */
526 >                oct0name = newfname(vval(OCTREE), '0');
527 >                oct1name = newfname(vval(OCTREE), '1');
528 >                oct0date = fdate(oct0name);
529 >                oct1date = fdate(oct1name);
530 >        } else
531 >                oct0name = oct1name = vval(OCTREE);
532 >        if ((scenedate = checklast(vval(SCENE))) &&
533 >                        (objdate = checklast(vval(OBJECT))) > scenedate)
534 >                scenedate = objdate;
535 >        illumdate = checklast(vval(ILLUM));
536 >        if (!octreedate & !scenedate & !illumdate) {
537 >                fprintf(stderr, "%s: need '%s' or '%s' or '%s'\n", progname,
538 >                                vnam(OCTREE), vnam(SCENE), vnam(ILLUM));
539                  exit(1);
540          }
541 <        matdate = -1;
434 <        if (vdef(MATERIAL))
435 <                matdate = checklast(vval(MATERIAL));
541 >        matdate = checklast(vval(MATERIAL));
542   }      
543  
544  
# Line 441 | Line 547 | double org[3], *sizp;
547   {
548          extern FILE     *popen();
549          static double   oorg[3], osiz = 0.;
550 <        char    buf[MAXPATH+16];
550 >        double  min[3], max[3];
551 >        char    buf[512];
552          FILE    *fp;
553 +        register int    i;
554  
555 <        if (osiz <= FTINY) {
556 <                oconv();                /* does nothing if done already */
557 <                sprintf(buf, "getinfo -d < %s", vval(OCTREE));
558 <                if ((fp = popen(buf, "r")) == NULL)
559 <                        syserr("getinfo");
560 <                if (fscanf(fp, "%lf %lf %lf %lf", &oorg[0], &oorg[1],
561 <                                &oorg[2], &osiz) != 4) {
562 <                        fprintf(stderr,
555 >        if (osiz <= FTINY)
556 >                if (noaction && fdate(oct1name) <
557 >                                (scenedate>illumdate?scenedate:illumdate)) {
558 >                                                        /* run getbbox */
559 >                        sprintf(buf, "getbbox -w -h %s",
560 >                                vdef(SCENE) ? vval(SCENE) : vval(ILLUM));
561 >                        if ((fp = popen(buf, "r")) == NULL)
562 >                                syserr("getbbox");
563 >                        if (fscanf(fp, "%lf %lf %lf %lf %lf %lf",
564 >                                        &min[0], &max[0], &min[1], &max[1],
565 >                                        &min[2], &max[2]) != 6) {
566 >                                fprintf(stderr,
567 >                        "%s: error reading bounding box from getbbox\n",
568 >                                                progname);
569 >                                exit(1);
570 >                        }
571 >                        for (i = 0; i < 3; i++)
572 >                                if (max[i] - min[i] > osiz)
573 >                                        osiz = max[i] - min[i];
574 >                        for (i = 0; i < 3; i++)
575 >                                oorg[i] = (max[i]+min[i]-osiz)*.5;
576 >                        pclose(fp);
577 >                } else {                                /* from octree */
578 >                        oconv();        /* does nothing if done already */
579 >                        sprintf(buf, "getinfo -d < %s", oct1name);
580 >                        if ((fp = popen(buf, "r")) == NULL)
581 >                                syserr("getinfo");
582 >                        if (fscanf(fp, "%lf %lf %lf %lf", &oorg[0], &oorg[1],
583 >                                        &oorg[2], &osiz) != 4) {
584 >                                fprintf(stderr,
585                          "%s: error reading bounding cube from getinfo\n",
586 <                                        progname);
587 <                        exit(1);
586 >                                                progname);
587 >                                exit(1);
588 >                        }
589 >                        pclose(fp);
590                  }
459                pclose(fp);
460        }
591          org[0] = oorg[0]; org[1] = oorg[1]; org[2] = oorg[2]; *sizp = osiz;
592   }
593  
# Line 520 | Line 650 | printvals()                    /* print variable values */
650   }
651  
652  
653 < oconv()                         /* run oconv if necessary */
653 > oconv()                         /* run oconv and mkillum if necessary */
654   {
655 <        char    combuf[512], ocopts[64];
655 >        static char     illumtmp[] = "ilXXXXXX";
656 >        char    combuf[512], ocopts[64], mkopts[64];
657  
658 <        if (octreedate >= scenedate)    /* check dates */
659 <                return;
660 <                                        /* build command */
661 <        oconvopts(ocopts);
662 <        if (vdef(MATERIAL))
532 <                sprintf(combuf, "oconv%s %s %s > %s", ocopts,
658 >        oconvopts(ocopts);              /* get options */
659 >        if (octreedate < scenedate) {   /* check date on original octree */
660 >                                                /* build command */
661 >                if (vdef(MATERIAL))
662 >                        sprintf(combuf, "oconv%s %s %s > %s", ocopts,
663                                  vval(MATERIAL), vval(SCENE), vval(OCTREE));
664 +                else
665 +                        sprintf(combuf, "oconv%s %s > %s", ocopts,
666 +                                        vval(SCENE), vval(OCTREE));
667 +                
668 +                if (runcom(combuf)) {           /* run it */
669 +                        fprintf(stderr,
670 +                                "%s: error generating octree\n\t%s removed\n",
671 +                                        progname, vval(OCTREE));
672 +                        unlink(vval(OCTREE));
673 +                        exit(1);
674 +                }
675 +                octreedate = time((time_t *)NULL);
676 +        }
677 +        if (oct1name == vval(OCTREE))           /* no mkillum? */
678 +                oct1date = octreedate > matdate ? octreedate : matdate;
679 +        if (oct1date >= octreedate & oct1date >= matdate
680 +                        & oct1date >= illumdate)        /* all done */
681 +                return;
682 +                                                /* make octree0 */
683 +        if (oct0date < scenedate | oct0date < illumdate) {
684 +                                                /* build command */
685 +                if (octreedate)
686 +                        sprintf(combuf, "oconv%s -i %s %s > %s", ocopts,
687 +                                vval(OCTREE), vval(ILLUM), oct0name);
688 +                else if (vdef(MATERIAL))
689 +                        sprintf(combuf, "oconv%s %s %s > %s", ocopts,
690 +                                vval(MATERIAL), vval(ILLUM), oct0name);
691 +                else
692 +                        sprintf(combuf, "oconv%s %s > %s", ocopts,
693 +                                vval(ILLUM), oct0name);
694 +                if (runcom(combuf)) {           /* run it */
695 +                        fprintf(stderr,
696 +                                "%s: error generating octree\n\t%s removed\n",
697 +                                        progname, oct0name);
698 +                        unlink(oct0name);
699 +                        exit(1);
700 +                }
701 +                oct0date = time((time_t *)NULL);
702 +        }
703 +        mkillumopts(mkopts);                    /* build mkillum command */
704 +        mktemp(illumtmp);
705 +        sprintf(combuf, "mkillum%s %s \"<\" %s > %s", mkopts,
706 +                        oct0name, vval(ILLUM), illumtmp);
707 +        if (runcom(combuf)) {                   /* run it */
708 +                fprintf(stderr, "%s: error running mkillum\n", progname);
709 +                unlink(illumtmp);
710 +                exit(1);
711 +        }
712 +                                                /* make octree1 (frozen) */
713 +        if (octreedate)
714 +                sprintf(combuf, "oconv%s -f -i %s %s > %s", ocopts,
715 +                        vval(OCTREE), illumtmp, oct1name);
716 +        else if (vdef(MATERIAL))
717 +                sprintf(combuf, "oconv%s -f %s %s > %s", ocopts,
718 +                        vval(MATERIAL), illumtmp, oct1name);
719          else
720 <                sprintf(combuf, "oconv%s %s > %s", ocopts,
721 <                                vval(SCENE), vval(OCTREE));
537 <        
720 >                sprintf(combuf, "oconv%s -f %s > %s", ocopts,
721 >                        illumtmp, oct1name);
722          if (runcom(combuf)) {           /* run it */
723 <                fprintf(stderr, "%s: error generating octree\n\t%s removed\n",
724 <                                progname, vval(OCTREE));
725 <                unlink(vval(OCTREE));
723 >                fprintf(stderr,
724 >                        "%s: error generating octree\n\t%s removed\n",
725 >                                progname, oct1name);
726 >                unlink(oct1name);
727                  exit(1);
728          }
729 <        octreedate = time(0);
729 >        oct1date = time((time_t *)NULL);
730 >        rmfile(illumtmp);
731   }
732  
733  
# Line 567 | Line 753 | register char  *oo;
753   }
754  
755  
756 + mkillumopts(mo)                         /* get mkillum options */
757 + register char   *mo;
758 + {
759 +        /* BEWARE:  This may be called via setdefaults(), so no assumptions */
760 +
761 +        *mo = '\0';
762 +        if (vdef(MKILLUM))
763 +                addarg(mo, vval(MKILLUM));
764 + }
765 +
766 +
767   checkambfile()                  /* check date on ambient file */
768   {
769 <        long    afdate;
769 >        time_t  afdate;
770  
771          if (!vdef(AMBFILE))
772                  return;
773 <        if ((afdate = fdate(vval(AMBFILE))) < 0)
773 >        if (!(afdate = fdate(vval(AMBFILE))))
774                  return;
775 <        if (octreedate > afdate | matdate > afdate)
775 >        if (oct1date > afdate)
776                  rmfile(vval(AMBFILE));
777   }
778  
# Line 584 | Line 781 | double
781   ambval()                                /* compute ambient value */
782   {
783          if (vdef(EXPOSURE)) {
587                if (!isflt(vval(EXPOSURE)))
588                        badvalue(EXPOSURE);
784                  if (vval(EXPOSURE)[0] == '+' || vval(EXPOSURE)[0] == '-')
785                          return(.5/pow(2.,atof(vval(EXPOSURE))));
786                  return(.5/atof(vval(EXPOSURE)));
# Line 598 | Line 793 | ambval()                               /* compute ambient value */
793   }
794  
795  
796 + renderopts(op)                          /* set rendering options */
797 + char    *op;
798 + {
799 +        switch(vscale(QUALITY)) {
800 +        case LOW:
801 +                lowqopts(op);
802 +                break;
803 +        case MEDIUM:
804 +                medqopts(op);
805 +                break;
806 +        case HIGH:
807 +                hiqopts(op);
808 +                break;
809 +        }
810 + }
811 +
812 +
813   lowqopts(op)                            /* low quality rendering options */
814   register char   *op;
815   {
# Line 693 | Line 905 | register char  *op;
905          }
906          op = addarg(op, "-pt .08");
907          if (vbool(PENUMBRAS))
908 <                op = addarg(op, "-ds .2 -dj .35");
908 >                op = addarg(op, "-ds .2 -dj .5");
909          else
910                  op = addarg(op, "-ds .3");
911          op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1");
# Line 960 | Line 1172 | register char  *vs;
1172                          cp += strlen(cp);
1173                  }
1174          }
1175 <        strcpy(cp, vs);                 /* append any additional options */
1175 >        if (cp == viewopts)             /* append any additional options */
1176 >                vs++;           /* skip prefixed space if unneeded */
1177 >        strcpy(cp, vs);
1178   #ifdef MSDOS
1179          if (strlen(viewopts) > 40) {
1180                  setenv("VIEW", viewopts);
# Line 1082 | Line 1296 | char   *opts;
1296          sprintf(combuf, "rview %s%s -R %s ", vw, opts, rifname);
1297          if (rvdevice != NULL)
1298                  sprintf(combuf+strlen(combuf), "-o %s ", rvdevice);
1299 <        strcat(combuf, vval(OCTREE));
1299 >        if (vdef(EXPOSURE))
1300 >                sprintf(combuf+strlen(combuf), "-pe %s ", vval(EXPOSURE));
1301 >        strcat(combuf, oct1name);
1302          if (runcom(combuf)) {           /* run it */
1303                  fprintf(stderr, "%s: error running rview\n", progname);
1304                  exit(1);
# Line 1098 | Line 1314 | char   *opts;
1314          char    pfopts[128];
1315          char    vs[32], *vw;
1316          int     vn, mult;
1101        long    lastdate;
1317                                          /* get pfilt options */
1318          pfiltopts(pfopts);
1319                                          /* get resolution, reporting */
1320 <        mult = vscale(QUALITY)+1;
1320 >        switch (vscale(QUALITY)) {
1321 >        case LOW:
1322 >                mult = 1;
1323 >                break;
1324 >        case MEDIUM:
1325 >                mult = 2;
1326 >                break;
1327 >        case HIGH:
1328 >                mult = 3;
1329 >                break;
1330 >        }
1331          {
1332                  int     xres, yres;
1333                  double  aspect;
# Line 1129 | Line 1354 | char   *opts;
1354                  else
1355                          badvalue(REPORT);
1356          }
1132                                        /* get update time */
1133        lastdate = octreedate > matdate ? octreedate : matdate;
1357                                          /* do each view */
1358          vn = 0;
1359          while ((vw = getview(vn++, vs)) != NULL) {
# Line 1140 | Line 1363 | char   *opts;
1363                          sprintf(vs, "%d", vn);
1364                  sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs);
1365                                                  /* check date on picture */
1366 <                if (fdate(picfile) >= lastdate)
1366 >                if (fdate(picfile) >= oct1date)
1367                          continue;
1368                                                  /* build rpict command */
1369                  sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs);
1370 <                if (fdate(rawfile) >= octreedate)       /* recover */
1370 >                if (fdate(rawfile) >= oct1date)         /* recover */
1371                          sprintf(combuf, "rpict%s%s -ro %s %s",
1372 <                                        rep, opts, rawfile, vval(OCTREE));
1372 >                                        rep, opts, rawfile, oct1name);
1373                  else {
1374                          if (overture) {         /* run overture calculation */
1375                                  sprintf(combuf,
1376                                  "rpict%s %s%s -x 64 -y 64 -ps 1 %s > %s",
1377                                                  rep, vw, opts,
1378 <                                                vval(OCTREE), overfile);
1378 >                                                oct1name, overfile);
1379                                  if (runcom(combuf)) {
1380                                          fprintf(stderr,
1381                                          "%s: error in overture for view %s\n",
# Line 1165 | Line 1388 | char   *opts;
1388                          }
1389                          sprintf(combuf, "rpict%s %s %s%s %s > %s",
1390                                          rep, vw, res, opts,
1391 <                                        vval(OCTREE), rawfile);
1391 >                                oct1name, rawfile);
1392                  }
1393                  if (runcom(combuf)) {           /* run rpict */
1394                          fprintf(stderr, "%s: error rendering view %s\n",

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines