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.14 by greg, Thu Jul 15 18:32:57 1993 UTC vs.
Revision 2.27 by greg, Sat Sep 25 13:21:35 1993 UTC

# Line 27 | Line 27 | int    onevalue(), catvalues();
27   #define OBJECT          0               /* object files */
28   #define SCENE           1               /* scene files */
29   #define MATERIAL        2               /* material files */
30 < #define RENDER          3               /* rendering options */
31 < #define OCONV           4               /* oconv options */
32 < #define PFILT           5               /* pfilt options */
33 < #define VIEW            6               /* view(s) for picture(s) */
34 < #define ZONE            7               /* simulation zone */
35 < #define QUALITY         8               /* desired rendering quality */
36 < #define OCTREE          9               /* octree file name */
37 < #define PICTURE         10              /* picture file name */
38 < #define AMBFILE         11              /* ambient file name */
39 < #define OPTFILE         12              /* rendering options file */
40 < #define EXPOSURE        13              /* picture exposure setting */
41 < #define RESOLUTION      14              /* maximum picture resolution */
42 < #define UP              15              /* view up (X, Y or Z) */
43 < #define INDIRECT        16              /* indirection in lighting */
44 < #define DETAIL          17              /* level of scene detail */
45 < #define PENUMBRAS       18              /* shadow penumbras are desired */
46 < #define VARIABILITY     19              /* level of light variability */
47 < #define REPORT          20              /* report frequency and errfile */
30 > #define ILLUM           3               /* mkillum input files */
31 > #define MKILLUM         4               /* mkillum options */
32 > #define RENDER          5               /* rendering options */
33 > #define OCONV           6               /* oconv options */
34 > #define PFILT           7               /* pfilt options */
35 > #define VIEW            8               /* view(s) for picture(s) */
36 > #define ZONE            9               /* simulation zone */
37 > #define QUALITY         10              /* desired rendering quality */
38 > #define OCTREE          11              /* octree file name */
39 > #define PICTURE         12              /* picture file name */
40 > #define AMBFILE         13              /* ambient file name */
41 > #define OPTFILE         14              /* rendering options file */
42 > #define EXPOSURE        15              /* picture exposure setting */
43 > #define RESOLUTION      16              /* maximum picture resolution */
44 > #define UP              17              /* view up (X, Y or Z) */
45 > #define INDIRECT        18              /* indirection in lighting */
46 > #define DETAIL          19              /* level of scene detail */
47 > #define PENUMBRAS       20              /* shadow penumbras are desired */
48 > #define VARIABILITY     21              /* level of light variability */
49 > #define REPORT          22              /* report frequency and errfile */
50                                  /* total number of variables */
51 < #define NVARS           21
51 > #define NVARS           23
52  
53   VARIABLE        vv[NVARS] = {           /* variable-value pairs */
54          {"objects",     3,      0,      NULL,   catvalues},
55          {"scene",       3,      0,      NULL,   catvalues},
56          {"materials",   3,      0,      NULL,   catvalues},
57 +        {"illum",       3,      0,      NULL,   catvalues},
58 +        {"mkillum",     3,      0,      NULL,   catvalues},
59          {"render",      3,      0,      NULL,   catvalues},
60          {"oconv",       3,      0,      NULL,   catvalues},
61          {"pfilt",       2,      0,      NULL,   catvalues},
# Line 101 | Line 105 | char   overfile[] = "overture.raw";
105   char    overfile[] = "/dev/null";
106   #endif
107  
108 < extern long     fdate(), time();
108 > extern unsigned long    fdate(), time();
109  
110 < long    scenedate;              /* date of latest scene or object file */
111 < long    octreedate;             /* date of octree */
112 < long    matdate;                /* date of latest material file */
110 > unsigned long   scenedate;      /* date of latest scene or object file */
111 > unsigned long   octreedate;     /* date of octree */
112 > unsigned long   matdate;        /* date of latest material file */
113 > unsigned long   illumdate;      /* date of last illum file */
114  
115 + char    *oct0name;              /* name of pre-mkillum octree */
116 + unsigned long   oct0date;       /* date of pre-mkillum octree */
117 + char    *oct1name;              /* name of post-mkillum octree */
118 + unsigned long   oct1date;       /* date of post-mkillum octree (>= matdate) */
119 +
120   int     explicate = 0;          /* explicate variables */
121   int     silent = 0;             /* do work silently */
122   int     noaction = 0;           /* don't do anything */
123 + int     sayview = 0;            /* print view out */
124   char    *rvdevice = NULL;       /* rview output device */
125   char    *viewselect = NULL;     /* specific view only */
126  
127   int     overture = 0;           /* overture calculation needed */
128  
129   char    *progname;              /* global argv[0] */
130 + char    *rifname;               /* global rad input file name */
131  
132   char    radname[MAXPATH];       /* root Radiance file name */
133  
# Line 143 | Line 155 | char   *argv[];
155                  case 'o':
156                          rvdevice = argv[++i];
157                          break;
158 +                case 'V':
159 +                        sayview++;
160 +                        break;
161                  case 'v':
162                          viewselect = argv[++i];
163                          break;
# Line 151 | Line 166 | char   *argv[];
166                  }
167          if (i >= argc)
168                  goto userr;
169 +        rifname = argv[i];
170                                  /* assign Radiance root file name */
171 <        rootname(radname, argv[i]);
171 >        rootname(radname, rifname);
172                                  /* load variable values */
173 <        load(argv[i]);
173 >        load(rifname);
174                                  /* get any additional assignments */
175          for (i++; i < argc; i++)
176                  setvariable(argv[i]);
# Line 167 | Line 183 | char   *argv[];
183                                  /* print all values if requested */
184          if (explicate)
185                  printvals();
186 <                                /* build octree */
186 >                                /* build octree (and run mkillum) */
187          oconv();
188                                  /* check date on ambient file */
189          checkambfile();
# Line 181 | Line 197 | char   *argv[];
197          exit(0);
198   userr:
199          fprintf(stderr,
200 <        "Usage: %s [-s][-n][-e][-v view][-o dev] rfile [VAR=value ..]\n",
200 >        "Usage: %s [-s][-n][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n",
201                          progname);
202          exit(1);
203   }
# Line 202 | Line 218 | register char  *rn, *fn;
218   }
219  
220  
221 + #define NOCHAR  127             /* constant for character to delete */
222 +
223 +
224   load(rfname)                    /* load Radiance simulation file */
225   char    *rfname;
226   {
# Line 217 | Line 236 | char   *rfname;
236                  for (cp = buf; *cp; cp++) {
237                          switch (*cp) {
238                          case '\\':
239 <                        case '\n':
221 <                                *cp = ' ';
239 >                                *cp++ = NOCHAR;
240                                  continue;
241                          case '#':
242                                  *cp = '\0';
# Line 238 | Line 256 | setvariable(ass)               /* assign variable according to stri
256   register char   *ass;
257   {
258          char    varname[32];
259 +        char    varval[512];
260 +        int     n;
261          register char   *cp;
262          register VARIABLE       *vp;
263          register int    i;
244        int     n;
264  
265          while (isspace(*ass))           /* skip leading space */
266                  ass++;
# Line 255 | 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';
261 <        while (cp >= ass && isspace(*cp));
262 <        n = cp - ass + 1;
277 >        for (n = strlen(ass); n > 0; n--)
278 >                if (!isspace(ass[n-1]))
279 >                        break;
280          if (!n) {
281                  fprintf(stderr, "%s: warning - missing value for variable '%s'\n",
282                                  progname, varname);
# Line 284 | 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 310 | Line 338 | register int   n;
338   {
339          register char   *cp;
340  
341 <        if (vp == NULL || n < 0 || n >= vp->nass)
341 >        if (vp == NULL | n < 0 | n >= vp->nass)
342                  return(NULL);
343          cp = vp->value;
344          while (n--)
# Line 374 | Line 402 | register VARIABLE      *vp;
402   }
403  
404  
405 < long
405 > unsigned long
406   checklast(fnames)                       /* check files and find most recent */
407   register char   *fnames;
408   {
409          char    thisfile[MAXPATH];
410 <        long    thisdate, lastdate = -1;
410 >        unsigned long   thisdate, lastdate = 0;
411          register char   *cp;
412  
413 +        if (fnames == NULL)
414 +                return(0);
415          while (*fnames) {
416                  while (isspace(*fnames)) fnames++;
417                  cp = thisfile;
418                  while (*fnames && !isspace(*fnames))
419                          *cp++ = *fnames++;
420                  *cp = '\0';
421 <                if ((thisdate = fdate(thisfile)) < 0)
421 >                if (!(thisdate = fdate(thisfile)))
422                          syserr(thisfile);
423                  if (thisdate > lastdate)
424                          lastdate = thisdate;
# Line 397 | Line 427 | register char  *fnames;
427   }
428  
429  
430 + char *
431 + newfname(orig, pred)            /* create modified file name */
432 + char    *orig;
433 + int     pred;
434 + {
435 +        extern char     *rindex();
436 +        register char   *cp;
437 +        register int    n;
438 +        int     suffix;
439 +
440 +        n = 0; cp = orig; suffix = -1;          /* suffix position, length */
441 +        while (*cp) {
442 +                if (*cp == '.') suffix = n;
443 +                else if (ISDIRSEP(*cp)) suffix = -1;
444 +                cp++; n++;
445 +        }
446 +        if (suffix == -1) suffix = n;
447 +        if ((cp = bmalloc(n+2)) == NULL)
448 +                syserr(progname);
449 +        strncpy(cp, orig, suffix);
450 +        cp[suffix] = pred;                      /* root name + pred + suffix */
451 +        strcpy(cp+suffix+1, orig+suffix);
452 +        return(cp);
453 + }
454 +
455 +
456   checkfiles()                    /* check for existence and modified times */
457   {
458 <        char    *cp;
403 <        long    objdate;
458 >        unsigned long   objdate;
459  
460          if (!vdef(OCTREE)) {
461 <                if ((cp = bmalloc(strlen(radname)+5)) == NULL)
461 >                if ((vval(OCTREE) = bmalloc(strlen(radname)+5)) == NULL)
462                          syserr(progname);
463 <                sprintf(cp, "%s.oct", radname);
409 <                vval(OCTREE) = cp;
463 >                sprintf(vval(OCTREE), "%s.oct", radname);
464                  vdef(OCTREE)++;
465          }
466          octreedate = fdate(vval(OCTREE));
467 <        scenedate = -1;
468 <        if (vdef(SCENE)) {
469 <                scenedate = checklast(vval(SCENE));
470 <                if (vdef(OBJECT)) {
471 <                        objdate = checklast(vval(OBJECT));
472 <                        if (objdate > scenedate)
473 <                                scenedate = objdate;
474 <                }
475 <        }
476 <        if (octreedate < 0 & scenedate < 0) {
477 <                fprintf(stderr, "%s: need '%s' or '%s'\n", progname,
478 <                                vnam(OCTREE), vnam(SCENE));
467 >        if (vdef(ILLUM)) {              /* illum requires secondary octrees */
468 >                oct0name = newfname(vval(OCTREE), '0');
469 >                oct1name = newfname(vval(OCTREE), '1');
470 >                oct0date = fdate(oct0name);
471 >                oct1date = fdate(oct1name);
472 >        } else
473 >                oct0name = oct1name = vval(OCTREE);
474 >        if ((scenedate = checklast(vval(SCENE))) &&
475 >                        (objdate = checklast(vval(OBJECT))) > scenedate)
476 >                scenedate = objdate;
477 >        illumdate = checklast(vval(ILLUM));
478 >        if (!octreedate & !scenedate & !illumdate) {
479 >                fprintf(stderr, "%s: need '%s' or '%s' or '%s'\n", progname,
480 >                                vnam(OCTREE), vnam(SCENE), vnam(ILLUM));
481                  exit(1);
482          }
483 <        matdate = -1;
428 <        if (vdef(MATERIAL))
429 <                matdate = checklast(vval(MATERIAL));
483 >        matdate = checklast(vval(MATERIAL));
484   }      
485  
486  
# Line 435 | Line 489 | double org[3], *sizp;
489   {
490          extern FILE     *popen();
491          static double   oorg[3], osiz = 0.;
492 <        char    buf[MAXPATH+16];
492 >        double  min[3], max[3];
493 >        char    buf[512];
494          FILE    *fp;
495 +        register int    i;
496  
497 <        if (osiz <= FTINY) {
498 <                oconv();                /* does nothing if done already */
499 <                sprintf(buf, "getinfo -d < %s", vval(OCTREE));
500 <                if ((fp = popen(buf, "r")) == NULL)
501 <                        syserr("getinfo");
502 <                if (fscanf(fp, "%lf %lf %lf %lf", &oorg[0], &oorg[1],
503 <                                &oorg[2], &osiz) != 4) {
504 <                        fprintf(stderr,
497 >        if (osiz <= FTINY)
498 >                if (noaction && fdate(oct1name) <
499 >                                (scenedate>illumdate?scenedate:illumdate)) {
500 >                                                        /* run getbbox */
501 >                        sprintf(buf, "getbbox -w -h %s",
502 >                                vdef(SCENE) ? vval(SCENE) : vval(ILLUM));
503 >                        if ((fp = popen(buf, "r")) == NULL)
504 >                                syserr("getbbox");
505 >                        if (fscanf(fp, "%lf %lf %lf %lf %lf %lf",
506 >                                        &min[0], &max[0], &min[1], &max[1],
507 >                                        &min[2], &max[2]) != 6) {
508 >                                fprintf(stderr,
509 >                        "%s: error reading bounding box from getbbox\n",
510 >                                                progname);
511 >                                exit(1);
512 >                        }
513 >                        for (i = 0; i < 3; i++)
514 >                                if (max[i] - min[i] > osiz)
515 >                                        osiz = max[i] - min[i];
516 >                        for (i = 0; i < 3; i++)
517 >                                oorg[i] = (max[i]+min[i]-osiz)*.5;
518 >                        pclose(fp);
519 >                } else {                                /* from octree */
520 >                        oconv();        /* does nothing if done already */
521 >                        sprintf(buf, "getinfo -d < %s", oct1name);
522 >                        if ((fp = popen(buf, "r")) == NULL)
523 >                                syserr("getinfo");
524 >                        if (fscanf(fp, "%lf %lf %lf %lf", &oorg[0], &oorg[1],
525 >                                        &oorg[2], &osiz) != 4) {
526 >                                fprintf(stderr,
527                          "%s: error reading bounding cube from getinfo\n",
528 <                                        progname);
529 <                        exit(1);
528 >                                                progname);
529 >                                exit(1);
530 >                        }
531 >                        pclose(fp);
532                  }
453                pclose(fp);
454        }
533          org[0] = oorg[0]; org[1] = oorg[1]; org[2] = oorg[2]; *sizp = osiz;
534   }
535  
# Line 514 | Line 592 | printvals()                    /* print variable values */
592   }
593  
594  
595 < oconv()                         /* run oconv if necessary */
595 > oconv()                         /* run oconv and mkillum if necessary */
596   {
597 <        char    combuf[512], ocopts[64];
597 >        static char     illumtmp[] = "ilXXXXXX";
598 >        char    combuf[512], ocopts[64], mkopts[64];
599  
600 <        if (octreedate >= scenedate)    /* check dates */
601 <                return;
602 <                                        /* build command */
603 <        oconvopts(ocopts);
604 <        if (vdef(MATERIAL))
526 <                sprintf(combuf, "oconv%s %s %s > %s", ocopts,
600 >        oconvopts(ocopts);              /* get options */
601 >        if (octreedate < scenedate) {   /* check date on original octree */
602 >                                                /* build command */
603 >                if (vdef(MATERIAL))
604 >                        sprintf(combuf, "oconv%s %s %s > %s", ocopts,
605                                  vval(MATERIAL), vval(SCENE), vval(OCTREE));
606 +                else
607 +                        sprintf(combuf, "oconv%s %s > %s", ocopts,
608 +                                        vval(SCENE), vval(OCTREE));
609 +                
610 +                if (runcom(combuf)) {           /* run it */
611 +                        fprintf(stderr,
612 +                                "%s: error generating octree\n\t%s removed\n",
613 +                                        progname, vval(OCTREE));
614 +                        unlink(vval(OCTREE));
615 +                        exit(1);
616 +                }
617 +                octreedate = time(0);
618 +        }
619 +        if (oct1name == vval(OCTREE))           /* no mkillum? */
620 +                oct1date = octreedate > matdate ? octreedate : matdate;
621 +        if (oct1date >= octreedate & oct1date >= matdate
622 +                        & oct1date >= illumdate)        /* all done */
623 +                return;
624 +                                                /* make octree0 */
625 +        if (oct0date < scenedate | oct0date < illumdate) {
626 +                                                /* build command */
627 +                if (octreedate)
628 +                        sprintf(combuf, "oconv%s -i %s %s > %s", ocopts,
629 +                                vval(OCTREE), vval(ILLUM), oct0name);
630 +                else if (vdef(MATERIAL))
631 +                        sprintf(combuf, "oconv%s %s %s > %s", ocopts,
632 +                                vval(MATERIAL), vval(ILLUM), oct0name);
633 +                else
634 +                        sprintf(combuf, "oconv%s %s > %s", ocopts,
635 +                                vval(ILLUM), oct0name);
636 +                if (runcom(combuf)) {           /* run it */
637 +                        fprintf(stderr,
638 +                                "%s: error generating octree\n\t%s removed\n",
639 +                                        progname, oct0name);
640 +                        unlink(oct0name);
641 +                        exit(1);
642 +                }
643 +                oct0date = time(0);
644 +        }
645 +        mkillumopts(mkopts);                    /* build mkillum command */
646 +        mktemp(illumtmp);
647 +        sprintf(combuf, "mkillum%s %s \"<\" %s > %s", mkopts,
648 +                        oct0name, vval(ILLUM), illumtmp);
649 +        if (runcom(combuf)) {                   /* run it */
650 +                fprintf(stderr, "%s: error running mkillum\n", progname);
651 +                unlink(illumtmp);
652 +                exit(1);
653 +        }
654 +                                                /* make octree1 (frozen) */
655 +        if (octreedate)
656 +                sprintf(combuf, "oconv%s -f -i %s %s > %s", ocopts,
657 +                        vval(OCTREE), illumtmp, oct1name);
658 +        else if (vdef(MATERIAL))
659 +                sprintf(combuf, "oconv%s -f %s %s > %s", ocopts,
660 +                        vval(MATERIAL), illumtmp, oct1name);
661          else
662 <                sprintf(combuf, "oconv%s %s > %s", ocopts,
663 <                                vval(SCENE), vval(OCTREE));
531 <        
662 >                sprintf(combuf, "oconv%s -f %s > %s", ocopts,
663 >                        illumtmp, oct1name);
664          if (runcom(combuf)) {           /* run it */
665 <                fprintf(stderr, "%s: error generating octree\n\t%s removed\n",
666 <                                progname, vval(OCTREE));
667 <                unlink(vval(OCTREE));
665 >                fprintf(stderr,
666 >                        "%s: error generating octree\n\t%s removed\n",
667 >                                progname, oct1name);
668 >                unlink(oct1name);
669                  exit(1);
670          }
671 <        octreedate = time(0);
671 >        oct1date = time(0);
672 >        rmfile(illumtmp);
673   }
674  
675  
# Line 561 | Line 695 | register char  *oo;
695   }
696  
697  
698 + mkillumopts(mo)                         /* get mkillum options */
699 + register char   *mo;
700 + {
701 +        /* BEWARE:  This may be called via setdefaults(), so no assumptions */
702 +
703 +        *mo = '\0';
704 +        if (vdef(MKILLUM))
705 +                addarg(mo, vval(MKILLUM));
706 + }
707 +
708 +
709   checkambfile()                  /* check date on ambient file */
710   {
711 <        long    afdate;
711 >        unsigned long   afdate;
712  
713          if (!vdef(AMBFILE))
714                  return;
715 <        if ((afdate = fdate(vval(AMBFILE))) < 0)
715 >        if (!(afdate = fdate(vval(AMBFILE))))
716                  return;
717 <        if (octreedate > afdate | matdate > afdate)
717 >        if (oct1date > afdate)
718                  rmfile(vval(AMBFILE));
719   }
720  
# Line 578 | Line 723 | double
723   ambval()                                /* compute ambient value */
724   {
725          if (vdef(EXPOSURE)) {
726 +                if (!isflt(vval(EXPOSURE)))
727 +                        badvalue(EXPOSURE);
728                  if (vval(EXPOSURE)[0] == '+' || vval(EXPOSURE)[0] == '-')
729                          return(.5/pow(2.,atof(vval(EXPOSURE))));
730 <                if (isdigit(vval(EXPOSURE)[0]) || vval(EXPOSURE)[0] == '.')
584 <                        return(.5/atof(vval(EXPOSURE)));
585 <                badvalue(EXPOSURE);
730 >                return(.5/atof(vval(EXPOSURE)));
731          }
732          if (vlet(ZONE) == 'E')
733                  return(10.);
# Line 606 | Line 751 | register char  *op;
751          d *= 3./(siz[0]+siz[1]+siz[2]);
752          switch (vscale(DETAIL)) {
753          case LOW:
754 <                op = addarg(op, "-ps 16 -dp 16");
754 >                op = addarg(op, "-ps 16 -dp 64");
755                  sprintf(op, " -ar %d", (int)(4*d));
756                  op += strlen(op);
757                  break;
758          case MEDIUM:
759 <                op = addarg(op, "-ps 8 -dp 32");
759 >                op = addarg(op, "-ps 8 -dp 128");
760                  sprintf(op, " -ar %d", (int)(8*d));
761                  op += strlen(op);
762                  break;
763          case HIGH:
764 <                op = addarg(op, "-ps 4 -dp 64");
764 >                op = addarg(op, "-ps 4 -dp 256");
765                  sprintf(op, " -ar %d", (int)(16*d));
766                  op += strlen(op);
767                  break;
# Line 626 | Line 771 | register char  *op;
771                  op = addarg(op, "-ds .4");
772          else
773                  op = addarg(op, "-ds 0");
774 <        op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .7");
774 >        op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .5");
775          if (vdef(AMBFILE)) {
776                  sprintf(op, " -af %s", vval(AMBFILE));
777                  op += strlen(op);
# Line 634 | Line 779 | register char  *op;
779                  overture = 0;
780          switch (vscale(VARIABILITY)) {
781          case LOW:
782 <                op = addarg(op, "-aa .4 -ad 32");
782 >                op = addarg(op, "-aa .4 -ad 64");
783                  break;
784          case MEDIUM:
785 <                op = addarg(op, "-aa .3 -ad 64");
785 >                op = addarg(op, "-aa .3 -ad 128");
786                  break;
787          case HIGH:
788 <                op = addarg(op, "-aa .25 -ad 128");
788 >                op = addarg(op, "-aa .25 -ad 256");
789                  break;
790          }
791          op = addarg(op, "-as 0");
# Line 668 | Line 813 | register char  *op;
813          switch (vscale(DETAIL)) {
814          case LOW:
815                  op = addarg(op, vbool(PENUMBRAS) ? "-ps 4" : "-ps 8");
816 <                op = addarg(op, "-dp 64");
816 >                op = addarg(op, "-dp 256");
817                  sprintf(op, " -ar %d", (int)(8*d));
818                  op += strlen(op);
819                  break;
820          case MEDIUM:
821                  op = addarg(op, vbool(PENUMBRAS) ? "-ps 3" : "-ps 6");
822 <                op = addarg(op, "-dp 128");
822 >                op = addarg(op, "-dp 512");
823                  sprintf(op, " -ar %d", (int)(16*d));
824                  op += strlen(op);
825                  break;
826          case HIGH:
827                  op = addarg(op, vbool(PENUMBRAS) ? "-ps 2" : "-ps 4");
828 <                op = addarg(op, "-dp 256");
828 >                op = addarg(op, "-dp 1024");
829                  sprintf(op, " -ar %d", (int)(32*d));
830                  op += strlen(op);
831                  break;
# Line 690 | Line 835 | register char  *op;
835                  op = addarg(op, "-ds .2 -dj .35");
836          else
837                  op = addarg(op, "-ds .3");
838 <        op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .15");
838 >        op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1");
839          if (overture = vint(INDIRECT)) {
840                  sprintf(op, " -ab %d", overture);
841                  op += strlen(op);
# Line 702 | Line 847 | register char  *op;
847                  overture = 0;
848          switch (vscale(VARIABILITY)) {
849          case LOW:
850 <                op = addarg(op, "-aa .25 -ad 128 -as 0");
850 >                op = addarg(op, "-aa .25 -ad 196 -as 0");
851                  break;
852          case MEDIUM:
853 <                op = addarg(op, "-aa .2 -ad 300 -as 64");
853 >                op = addarg(op, "-aa .2 -ad 400 -as 64");
854                  break;
855          case HIGH:
856 <                op = addarg(op, "-aa .15 -ad 500 -as 128");
856 >                op = addarg(op, "-aa .15 -ad 768 -as 196");
857                  break;
858          }
859          d = ambval();
# Line 735 | Line 880 | register char  *op;
880          switch (vscale(DETAIL)) {
881          case LOW:
882                  op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 8");
883 <                op = addarg(op, "-dp 256");
883 >                op = addarg(op, "-dp 1024");
884                  sprintf(op, " -ar %d", (int)(16*d));
885                  op += strlen(op);
886                  break;
887          case MEDIUM:
888                  op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 5");
889 <                op = addarg(op, "-dp 512");
889 >                op = addarg(op, "-dp 2048");
890                  sprintf(op, " -ar %d", (int)(32*d));
891                  op += strlen(op);
892                  break;
893          case HIGH:
894                  op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 3");
895 <                op = addarg(op, "-dp 1024");
895 >                op = addarg(op, "-dp 4096");
896                  sprintf(op, " -ar %d", (int)(64*d));
897                  op += strlen(op);
898                  break;
# Line 757 | Line 902 | register char  *op;
902                  op = addarg(op, "-ds .1 -dj .7");
903          else
904                  op = addarg(op, "-ds .2");
905 <        op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .03");
905 >        op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01");
906          sprintf(op, " -ab %d", overture=vint(INDIRECT)+1);
907          op += strlen(op);
908          if (vdef(AMBFILE)) {
# Line 767 | Line 912 | register char  *op;
912                  overture = 0;
913          switch (vscale(VARIABILITY)) {
914          case LOW:
915 <                op = addarg(op, "-aa .15 -ad 200 -as 0");
915 >                op = addarg(op, "-aa .15 -ad 256 -as 0");
916                  break;
917          case MEDIUM:
918 <                op = addarg(op, "-aa .125 -ad 512 -as 128");
918 >                op = addarg(op, "-aa .125 -ad 512 -as 256");
919                  break;
920          case HIGH:
921 <                op = addarg(op, "-aa .08 -ad 850 -as 256");
921 >                op = addarg(op, "-aa .08 -ad 1024 -as 512");
922                  break;
923          }
924          d = ambval();
# Line 804 | Line 949 | char   *ro;
949                  fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666);
950                  if (fd < 0 || write(fd, ro, n) != n || close(fd) < 0)
951                          syserr(vval(OPTFILE));
952 <                sprintf(ro, " \"^%s\"", vval(OPTFILE));
952 >                sprintf(ro, " @%s", vval(OPTFILE));
953          }
954   #ifdef MSDOS
955          else if (n > 50) {
# Line 954 | Line 1099 | register char  *vs;
1099                          cp += strlen(cp);
1100                  }
1101          }
1102 <        strcpy(cp, vs);                 /* append any additional options */
1102 >        if (cp == viewopts)             /* append any additional options */
1103 >                vs++;           /* skip prefixed space if unneeded */
1104 >        strcpy(cp, vs);
1105   #ifdef MSDOS
1106          if (strlen(viewopts) > 40) {
1107                  setenv("VIEW", viewopts);
# Line 970 | Line 1117 | getview(n, vn)                         /* get view n, or NULL if none */
1117   int     n;
1118   char    *vn;            /* returned view name */
1119   {
1120 <        register char   *mv = NULL;
1120 >        register char   *mv;
1121  
1122          if (viewselect != NULL) {               /* command-line selected */
1123                  if (n)                          /* only do one */
# Line 985 | Line 1132 | char   *vn;            /* returned view name */
1132                                  ;
1133                          *vn = '\0';
1134                  }
1135 +                                                /* view number? */
1136 +                if (isint(viewselect))
1137 +                        return(specview(nvalue(vv+VIEW, atoi(viewselect)-1)));
1138                                                  /* check list */
1139                  while ((mv = nvalue(vv+VIEW, n++)) != NULL)
1140                          if (matchword(viewselect, mv))
# Line 993 | Line 1143 | char   *vn;            /* returned view name */
1143          }
1144          mv = nvalue(vv+VIEW, n);                /* use view n */
1145          if (vn != NULL & mv != NULL) {
1146 <                if (*mv != '-')
1147 <                        while (*mv && !isspace(*mv))
1148 <                                *vn++ = *mv++;
1146 >                register char   *mv2 = mv;
1147 >                if (*mv2 != '-')
1148 >                        while (*mv2 && !isspace(*mv2))
1149 >                                *vn++ = *mv2++;
1150                  *vn = '\0';
1151          }
1152          return(specview(mv));
1153   }
1154  
1155  
1156 + printview(vopts)                        /* print out selected view */
1157 + register char   *vopts;
1158 + {
1159 +        extern char     *atos(), *getenv();
1160 +        char    buf[256];
1161 +        FILE    *fp;
1162 +        register char   *cp;
1163 +
1164 +        if (vopts == NULL)
1165 +                return(-1);
1166 +        fputs("VIEW=", stdout);
1167 +        do {
1168 +                if (matchword(vopts, "-vf")) {          /* expand view file */
1169 +                        vopts = sskip(vopts);
1170 +                        if (!*atos(buf, sizeof(buf), vopts))
1171 +                                return(-1);
1172 +                        if ((fp = fopen(buf, "r")) == NULL)
1173 +                                return(-1);
1174 +                        for (buf[sizeof(buf)-2] = '\n';
1175 +                                        fgets(buf, sizeof(buf), fp) != NULL &&
1176 +                                                buf[0] != '\n';
1177 +                                        buf[sizeof(buf)-2] = '\n') {
1178 +                                if (buf[sizeof(buf)-2] != '\n') {
1179 +                                        ungetc(buf[sizeof(buf)-2], fp);
1180 +                                        buf[sizeof(buf)-2] = '\0';
1181 +                                }
1182 +                                if (matchword(buf, "VIEW=") ||
1183 +                                                matchword(buf, "rview")) {
1184 +                                        for (cp = sskip(buf); *cp && *cp != '\n'; cp++)
1185 +                                                putchar(*cp);
1186 +                                }
1187 +                        }
1188 +                        fclose(fp);
1189 +                        vopts = sskip(vopts);
1190 +                } else {
1191 +                        while (isspace(*vopts))
1192 +                                vopts++;
1193 +                        putchar(' ');
1194 + #ifdef MSDOS
1195 +                        if (*vopts == '$') {            /* expand env. var. */
1196 +                                if (!*atos(buf, sizeof(buf), vopts+1))
1197 +                                        return(-1);
1198 +                                if ((cp = getenv(buf)) == NULL)
1199 +                                        return(-1);
1200 +                                fputs(cp, stdout);
1201 +                                vopts = sskip(vopts);
1202 +                        } else
1203 + #endif
1204 +                                while (*vopts && !isspace(*vopts))
1205 +                                        putchar(*vopts++);
1206 +                }
1207 +        } while (*vopts++);
1208 +        putchar('\n');
1209 +        return(0);
1210 + }
1211 +
1212 +
1213   rview(opts)                             /* run rview with first view */
1214   char    *opts;
1215   {
1216 +        char    *vw;
1217          char    combuf[512];
1218                                          /* build command */
1219 <        sprintf(combuf, "rview %s%s ", getview(0, NULL), opts);
1219 >        if ((vw = getview(0, NULL)) == NULL)
1220 >                return;
1221 >        if (sayview)
1222 >                printview(vw);
1223 >        sprintf(combuf, "rview %s%s -R %s ", vw, opts, rifname);
1224          if (rvdevice != NULL)
1225                  sprintf(combuf+strlen(combuf), "-o %s ", rvdevice);
1226 <        strcat(combuf, vval(OCTREE));
1226 >        strcat(combuf, oct1name);
1227          if (runcom(combuf)) {           /* run it */
1228                  fprintf(stderr, "%s: error running rview\n", progname);
1229                  exit(1);
# Line 1026 | Line 1239 | char   *opts;
1239          char    pfopts[128];
1240          char    vs[32], *vw;
1241          int     vn, mult;
1029        long    lastdate;
1242                                          /* get pfilt options */
1243          pfiltopts(pfopts);
1244                                          /* get resolution, reporting */
# Line 1057 | Line 1269 | char   *opts;
1269                  else
1270                          badvalue(REPORT);
1271          }
1060                                        /* get update time */
1061        lastdate = octreedate > matdate ? octreedate : matdate;
1272                                          /* do each view */
1273          vn = 0;
1274          while ((vw = getview(vn++, vs)) != NULL) {
1275 +                if (sayview)
1276 +                        printview(vw);
1277                  if (!vs[0])
1278                          sprintf(vs, "%d", vn);
1279                  sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs);
1280                                                  /* check date on picture */
1281 <                if (fdate(picfile) >= lastdate)
1281 >                if (fdate(picfile) >= oct1date)
1282                          continue;
1283                                                  /* build rpict command */
1284                  sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs);
1285 <                if (fdate(rawfile) >= octreedate)       /* recover */
1285 >                if (fdate(rawfile) >= oct1date)         /* recover */
1286                          sprintf(combuf, "rpict%s%s -ro %s %s",
1287 <                                        rep, opts, rawfile, vval(OCTREE));
1287 >                                        rep, opts, rawfile, oct1name);
1288                  else {
1289                          if (overture) {         /* run overture calculation */
1290                                  sprintf(combuf,
1291                                  "rpict%s %s%s -x 64 -y 64 -ps 1 %s > %s",
1292                                                  rep, vw, opts,
1293 <                                                vval(OCTREE), overfile);
1293 >                                                oct1name, overfile);
1294                                  if (runcom(combuf)) {
1295                                          fprintf(stderr,
1296                                          "%s: error in overture for view %s\n",
# Line 1091 | Line 1303 | char   *opts;
1303                          }
1304                          sprintf(combuf, "rpict%s %s %s%s %s > %s",
1305                                          rep, vw, res, opts,
1306 <                                        vval(OCTREE), rawfile);
1306 >                                        oct1name, rawfile);
1307                  }
1308                  if (runcom(combuf)) {           /* run rpict */
1309                          fprintf(stderr, "%s: error rendering view %s\n",

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines