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.8 by greg, Tue May 18 13:07:56 1993 UTC vs.
Revision 2.26 by greg, Fri Sep 24 16:49:02 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 */
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 142 | 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 150 | 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 166 | 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 180 | 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 201 | 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 216 | Line 236 | char   *rfname;
236                  for (cp = buf; *cp; cp++) {
237                          switch (*cp) {
238                          case '\\':
239 <                        case '\n':
220 <                                *cp = ' ';
239 >                                *cp++ = NOCHAR;
240                                  continue;
241                          case '#':
242                                  *cp = '\0';
# Line 237 | 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;
243        int     n;
264  
265          while (isspace(*ass))           /* skip leading space */
266                  ass++;
# Line 254 | 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';
260 <        while (cp >= ass && isspace(*cp));
261 <        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 283 | 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 309 | 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 373 | 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 396 | 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 +        suffix = n = strlen(orig);              /* find start of suffix */
441 +        if ((cp = rindex(orig, '.')) != NULL)
442 +                suffix = cp - orig;
443 +        if ((cp = bmalloc(n+2)) == NULL)
444 +                syserr(progname);
445 +        strncpy(cp, orig, suffix);
446 +        cp[suffix] = pred;                      /* root name + pred + suffix */
447 +        strcpy(cp+suffix+1, orig+suffix);
448 +        return(cp);
449 + }
450 +
451 +
452   checkfiles()                    /* check for existence and modified times */
453   {
454 <        char    *cp;
402 <        long    objdate;
454 >        unsigned long   objdate;
455  
456          if (!vdef(OCTREE)) {
457 <                if ((cp = bmalloc(strlen(radname)+5)) == NULL)
457 >                if ((vval(OCTREE) = bmalloc(strlen(radname)+5)) == NULL)
458                          syserr(progname);
459 <                sprintf(cp, "%s.oct", radname);
408 <                vval(OCTREE) = cp;
459 >                sprintf(vval(OCTREE), "%s.oct", radname);
460                  vdef(OCTREE)++;
461          }
462          octreedate = fdate(vval(OCTREE));
463 <        scenedate = -1;
464 <        if (vdef(SCENE)) {
465 <                scenedate = checklast(vval(SCENE));
466 <                if (vdef(OBJECT)) {
467 <                        objdate = checklast(vval(OBJECT));
468 <                        if (objdate > scenedate)
469 <                                scenedate = objdate;
470 <                }
471 <        }
472 <        if (octreedate < 0 & scenedate < 0) {
473 <                fprintf(stderr, "%s: need '%s' or '%s'\n", progname,
474 <                                vnam(OCTREE), vnam(SCENE));
463 >        if (vdef(ILLUM)) {              /* illum requires secondary octrees */
464 >                oct0name = newfname(vval(OCTREE), '0');
465 >                oct1name = newfname(vval(OCTREE), '1');
466 >                oct0date = fdate(oct0name);
467 >                oct1date = fdate(oct1name);
468 >        } else
469 >                oct0name = oct1name = vval(OCTREE);
470 >        if ((scenedate = checklast(vval(SCENE))) &&
471 >                        (objdate = checklast(vval(OBJECT))) > scenedate)
472 >                scenedate = objdate;
473 >        illumdate = checklast(vval(ILLUM));
474 >        if (!octreedate & !scenedate & !illumdate) {
475 >                fprintf(stderr, "%s: need '%s' or '%s' or '%s'\n", progname,
476 >                                vnam(OCTREE), vnam(SCENE), vnam(ILLUM));
477                  exit(1);
478          }
479 +        matdate = checklast(vval(MATERIAL));
480   }      
481  
482  
# Line 431 | Line 485 | double org[3], *sizp;
485   {
486          extern FILE     *popen();
487          static double   oorg[3], osiz = 0.;
488 <        char    buf[MAXPATH+16];
488 >        double  min[3], max[3];
489 >        char    buf[512];
490          FILE    *fp;
491 +        register int    i;
492  
493 <        if (osiz <= FTINY) {
494 <                oconv();                /* does nothing if done already */
495 <                sprintf(buf, "getinfo -d < %s", vval(OCTREE));
496 <                if ((fp = popen(buf, "r")) == NULL)
497 <                        syserr("getinfo");
498 <                if (fscanf(fp, "%lf %lf %lf %lf", &oorg[0], &oorg[1],
499 <                                &oorg[2], &osiz) != 4) {
500 <                        fprintf(stderr,
493 >        if (osiz <= FTINY)
494 >                if (noaction && fdate(oct1name) <
495 >                                (scenedate>illumdate?scenedate:illumdate)) {
496 >                                                        /* run getbbox */
497 >                        sprintf(buf, "getbbox -w -h %s",
498 >                                vdef(SCENE) ? vval(SCENE) : vval(ILLUM));
499 >                        if ((fp = popen(buf, "r")) == NULL)
500 >                                syserr("getbbox");
501 >                        if (fscanf(fp, "%lf %lf %lf %lf %lf %lf",
502 >                                        &min[0], &max[0], &min[1], &max[1],
503 >                                        &min[2], &max[2]) != 6) {
504 >                                fprintf(stderr,
505 >                        "%s: error reading bounding box from getbbox\n",
506 >                                                progname);
507 >                                exit(1);
508 >                        }
509 >                        for (i = 0; i < 3; i++)
510 >                                if (max[i] - min[i] > osiz)
511 >                                        osiz = max[i] - min[i];
512 >                        for (i = 0; i < 3; i++)
513 >                                oorg[i] = (max[i]+min[i]-osiz)*.5;
514 >                        pclose(fp);
515 >                } else {                                /* from octree */
516 >                        oconv();        /* does nothing if done already */
517 >                        sprintf(buf, "getinfo -d < %s", oct1name);
518 >                        if ((fp = popen(buf, "r")) == NULL)
519 >                                syserr("getinfo");
520 >                        if (fscanf(fp, "%lf %lf %lf %lf", &oorg[0], &oorg[1],
521 >                                        &oorg[2], &osiz) != 4) {
522 >                                fprintf(stderr,
523                          "%s: error reading bounding cube from getinfo\n",
524 <                                        progname);
525 <                        exit(1);
524 >                                                progname);
525 >                                exit(1);
526 >                        }
527 >                        pclose(fp);
528                  }
449                pclose(fp);
450        }
529          org[0] = oorg[0]; org[1] = oorg[1]; org[2] = oorg[2]; *sizp = osiz;
530   }
531  
# Line 510 | Line 588 | printvals()                    /* print variable values */
588   }
589  
590  
591 < oconv()                         /* run oconv if necessary */
591 > oconv()                         /* run oconv and mkillum if necessary */
592   {
593 <        char    combuf[512], ocopts[64];
593 >        static char     illumtmp[] = "ilXXXXXX";
594 >        char    combuf[512], ocopts[64], mkopts[64];
595  
596 <        if (octreedate >= scenedate)    /* check dates */
597 <                return;
598 <                                        /* build command */
599 <        oconvopts(ocopts);
600 <        if (vdef(MATERIAL))
522 <                sprintf(combuf, "oconv%s %s %s > %s", ocopts,
596 >        oconvopts(ocopts);              /* get options */
597 >        if (octreedate < scenedate) {   /* check date on original octree */
598 >                                                /* build command */
599 >                if (vdef(MATERIAL))
600 >                        sprintf(combuf, "oconv%s %s %s > %s", ocopts,
601                                  vval(MATERIAL), vval(SCENE), vval(OCTREE));
602 +                else
603 +                        sprintf(combuf, "oconv%s %s > %s", ocopts,
604 +                                        vval(SCENE), vval(OCTREE));
605 +                
606 +                if (runcom(combuf)) {           /* run it */
607 +                        fprintf(stderr,
608 +                                "%s: error generating octree\n\t%s removed\n",
609 +                                        progname, vval(OCTREE));
610 +                        unlink(vval(OCTREE));
611 +                        exit(1);
612 +                }
613 +                octreedate = time(0);
614 +        }
615 +        if (oct1name == vval(OCTREE))           /* no mkillum? */
616 +                oct1date = octreedate > matdate ? octreedate : matdate;
617 +        if (oct1date >= octreedate & oct1date >= matdate
618 +                        & oct1date >= illumdate)        /* all done */
619 +                return;
620 +                                                /* make octree0 */
621 +        if (oct0date < scenedate | oct0date < illumdate) {
622 +                                                /* build command */
623 +                if (octreedate)
624 +                        sprintf(combuf, "oconv%s -i %s %s > %s", ocopts,
625 +                                vval(OCTREE), vval(ILLUM), oct0name);
626 +                else if (vdef(MATERIAL))
627 +                        sprintf(combuf, "oconv%s %s %s > %s", ocopts,
628 +                                vval(MATERIAL), vval(ILLUM), oct0name);
629 +                else
630 +                        sprintf(combuf, "oconv%s %s > %s", ocopts,
631 +                                vval(ILLUM), oct0name);
632 +                if (runcom(combuf)) {           /* run it */
633 +                        fprintf(stderr,
634 +                                "%s: error generating octree\n\t%s removed\n",
635 +                                        progname, oct0name);
636 +                        unlink(oct0name);
637 +                        exit(1);
638 +                }
639 +                oct0date = time(0);
640 +        }
641 +        mkillumopts(mkopts);                    /* build mkillum command */
642 +        mktemp(illumtmp);
643 +        sprintf(combuf, "mkillum%s %s \"<\" %s > %s", mkopts,
644 +                        oct0name, vval(ILLUM), illumtmp);
645 +        if (runcom(combuf)) {                   /* run it */
646 +                fprintf(stderr, "%s: error running mkillum\n", progname);
647 +                unlink(illumtmp);
648 +                exit(1);
649 +        }
650 +                                                /* make octree1 (frozen) */
651 +        if (octreedate)
652 +                sprintf(combuf, "oconv%s -f -i %s %s > %s", ocopts,
653 +                        vval(OCTREE), illumtmp, oct1name);
654 +        else if (vdef(MATERIAL))
655 +                sprintf(combuf, "oconv%s -f %s %s > %s", ocopts,
656 +                        vval(MATERIAL), illumtmp, oct1name);
657          else
658 <                sprintf(combuf, "oconv%s %s > %s", ocopts,
659 <                                vval(SCENE), vval(OCTREE));
527 <        
658 >                sprintf(combuf, "oconv%s -f %s > %s", ocopts,
659 >                        illumtmp, oct1name);
660          if (runcom(combuf)) {           /* run it */
661 <                fprintf(stderr, "%s: error generating octree\n\t%s removed\n",
662 <                                progname, vval(OCTREE));
663 <                unlink(vval(OCTREE));
661 >                fprintf(stderr,
662 >                        "%s: error generating octree\n\t%s removed\n",
663 >                                progname, oct1name);
664 >                unlink(oct1name);
665                  exit(1);
666          }
667 <        octreedate = time(0);
667 >        oct1date = time(0);
668 >        rmfile(illumtmp);
669   }
670  
671  
# Line 557 | Line 691 | register char  *oo;
691   }
692  
693  
694 + mkillumopts(mo)                         /* get mkillum options */
695 + register char   *mo;
696 + {
697 +        /* BEWARE:  This may be called via setdefaults(), so no assumptions */
698 +
699 +        *mo = '\0';
700 +        if (vdef(MKILLUM))
701 +                addarg(mo, vval(MKILLUM));
702 + }
703 +
704 +
705   checkambfile()                  /* check date on ambient file */
706   {
707 <        long    afdate;
707 >        unsigned long   afdate;
708  
709 <        if (vdef(AMBFILE)) {
710 <                afdate = fdate(vval(AMBFILE));
711 <                if (afdate >= 0 & octreedate > afdate)
712 <                        rmfile(vval(AMBFILE));
713 <        }
709 >        if (!vdef(AMBFILE))
710 >                return;
711 >        if (!(afdate = fdate(vval(AMBFILE))))
712 >                return;
713 >        if (oct1date > afdate)
714 >                rmfile(vval(AMBFILE));
715   }
716  
717  
# Line 573 | Line 719 | double
719   ambval()                                /* compute ambient value */
720   {
721          if (vdef(EXPOSURE)) {
722 +                if (!isflt(vval(EXPOSURE)))
723 +                        badvalue(EXPOSURE);
724                  if (vval(EXPOSURE)[0] == '+' || vval(EXPOSURE)[0] == '-')
725                          return(.5/pow(2.,atof(vval(EXPOSURE))));
726 <                if (isdigit(vval(EXPOSURE)[0]) || vval(EXPOSURE)[0] == '.')
579 <                        return(.5/atof(vval(EXPOSURE)));
580 <                badvalue(EXPOSURE);
726 >                return(.5/atof(vval(EXPOSURE)));
727          }
728          if (vlet(ZONE) == 'E')
729                  return(10.);
# Line 601 | Line 747 | register char  *op;
747          d *= 3./(siz[0]+siz[1]+siz[2]);
748          switch (vscale(DETAIL)) {
749          case LOW:
750 <                op = addarg(op, "-ps 16 -dp 16");
750 >                op = addarg(op, "-ps 16 -dp 64");
751                  sprintf(op, " -ar %d", (int)(4*d));
752                  op += strlen(op);
753                  break;
754          case MEDIUM:
755 <                op = addarg(op, "-ps 8 -dp 32");
755 >                op = addarg(op, "-ps 8 -dp 128");
756                  sprintf(op, " -ar %d", (int)(8*d));
757                  op += strlen(op);
758                  break;
759          case HIGH:
760 <                op = addarg(op, "-ps 4 -dp 64");
760 >                op = addarg(op, "-ps 4 -dp 256");
761                  sprintf(op, " -ar %d", (int)(16*d));
762                  op += strlen(op);
763                  break;
# Line 621 | Line 767 | register char  *op;
767                  op = addarg(op, "-ds .4");
768          else
769                  op = addarg(op, "-ds 0");
770 <        op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .7");
770 >        op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .5");
771          if (vdef(AMBFILE)) {
772                  sprintf(op, " -af %s", vval(AMBFILE));
773                  op += strlen(op);
# Line 629 | Line 775 | register char  *op;
775                  overture = 0;
776          switch (vscale(VARIABILITY)) {
777          case LOW:
778 <                op = addarg(op, "-aa .4 -ad 32");
778 >                op = addarg(op, "-aa .4 -ad 64");
779                  break;
780          case MEDIUM:
781 <                op = addarg(op, "-aa .3 -ad 64");
781 >                op = addarg(op, "-aa .3 -ad 128");
782                  break;
783          case HIGH:
784 <                op = addarg(op, "-aa .25 -ad 128");
784 >                op = addarg(op, "-aa .25 -ad 256");
785                  break;
786          }
787          op = addarg(op, "-as 0");
# Line 663 | Line 809 | register char  *op;
809          switch (vscale(DETAIL)) {
810          case LOW:
811                  op = addarg(op, vbool(PENUMBRAS) ? "-ps 4" : "-ps 8");
812 <                op = addarg(op, "-dp 64");
812 >                op = addarg(op, "-dp 256");
813                  sprintf(op, " -ar %d", (int)(8*d));
814                  op += strlen(op);
815                  break;
816          case MEDIUM:
817                  op = addarg(op, vbool(PENUMBRAS) ? "-ps 3" : "-ps 6");
818 <                op = addarg(op, "-dp 128");
818 >                op = addarg(op, "-dp 512");
819                  sprintf(op, " -ar %d", (int)(16*d));
820                  op += strlen(op);
821                  break;
822          case HIGH:
823                  op = addarg(op, vbool(PENUMBRAS) ? "-ps 2" : "-ps 4");
824 <                op = addarg(op, "-dp 256");
824 >                op = addarg(op, "-dp 1024");
825                  sprintf(op, " -ar %d", (int)(32*d));
826                  op += strlen(op);
827                  break;
# Line 685 | Line 831 | register char  *op;
831                  op = addarg(op, "-ds .2 -dj .35");
832          else
833                  op = addarg(op, "-ds .3");
834 <        op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .15");
834 >        op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1");
835          if (overture = vint(INDIRECT)) {
836                  sprintf(op, " -ab %d", overture);
837                  op += strlen(op);
# Line 697 | Line 843 | register char  *op;
843                  overture = 0;
844          switch (vscale(VARIABILITY)) {
845          case LOW:
846 <                op = addarg(op, "-aa .25 -ad 128 -as 0");
846 >                op = addarg(op, "-aa .25 -ad 196 -as 0");
847                  break;
848          case MEDIUM:
849 <                op = addarg(op, "-aa .2 -ad 300 -as 64");
849 >                op = addarg(op, "-aa .2 -ad 400 -as 64");
850                  break;
851          case HIGH:
852 <                op = addarg(op, "-aa .15 -ad 500 -as 128");
852 >                op = addarg(op, "-aa .15 -ad 768 -as 196");
853                  break;
854          }
855          d = ambval();
# Line 730 | Line 876 | register char  *op;
876          switch (vscale(DETAIL)) {
877          case LOW:
878                  op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 8");
879 <                op = addarg(op, "-dp 256");
879 >                op = addarg(op, "-dp 1024");
880                  sprintf(op, " -ar %d", (int)(16*d));
881                  op += strlen(op);
882                  break;
883          case MEDIUM:
884                  op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 5");
885 <                op = addarg(op, "-dp 512");
885 >                op = addarg(op, "-dp 2048");
886                  sprintf(op, " -ar %d", (int)(32*d));
887                  op += strlen(op);
888                  break;
889          case HIGH:
890                  op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 3");
891 <                op = addarg(op, "-dp 1024");
891 >                op = addarg(op, "-dp 4096");
892                  sprintf(op, " -ar %d", (int)(64*d));
893                  op += strlen(op);
894                  break;
# Line 752 | Line 898 | register char  *op;
898                  op = addarg(op, "-ds .1 -dj .7");
899          else
900                  op = addarg(op, "-ds .2");
901 <        op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .03");
901 >        op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01");
902          sprintf(op, " -ab %d", overture=vint(INDIRECT)+1);
903          op += strlen(op);
904          if (vdef(AMBFILE)) {
# Line 762 | Line 908 | register char  *op;
908                  overture = 0;
909          switch (vscale(VARIABILITY)) {
910          case LOW:
911 <                op = addarg(op, "-aa .15 -ad 200 -as 0");
911 >                op = addarg(op, "-aa .15 -ad 256 -as 0");
912                  break;
913          case MEDIUM:
914 <                op = addarg(op, "-aa .125 -ad 512 -as 128");
914 >                op = addarg(op, "-aa .125 -ad 512 -as 256");
915                  break;
916          case HIGH:
917 <                op = addarg(op, "-aa .08 -ad 850 -as 256");
917 >                op = addarg(op, "-aa .08 -ad 1024 -as 512");
918                  break;
919          }
920          d = ambval();
# Line 784 | Line 930 | xferopts(ro)                           /* transfer options if indicated */
930   char    *ro;
931   {
932          int     fd, n;
933 +        register char   *cp;
934          
935          n = strlen(ro);
936          if (n < 2)
937                  return;
938          if (vdef(OPTFILE)) {
939 <                if ((fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1)
939 >                for (cp = ro; cp[1]; cp++)
940 >                        if (isspace(cp[1]) && cp[2] == '-' && isalpha(cp[3]))
941 >                                *cp = '\n';
942 >                        else
943 >                                *cp = cp[1];
944 >                *cp = '\n';
945 >                fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666);
946 >                if (fd < 0 || write(fd, ro, n) != n || close(fd) < 0)
947                          syserr(vval(OPTFILE));
948 <                if (write(fd, ro+1, n-1) != n-1)
795 <                        syserr(vval(OPTFILE));
796 <                write(fd, "\n", 1);
797 <                close(fd);
798 <                sprintf(ro, " \"^%s\"", vval(OPTFILE));
948 >                sprintf(ro, " @%s", vval(OPTFILE));
949          }
950   #ifdef MSDOS
951          else if (n > 50) {
# Line 814 | Line 964 | register char  *po;
964                  po = addarg(po, "-1 -e");
965                  po = addarg(po, vval(EXPOSURE));
966          }
967 <        if (vscale(QUALITY) == HIGH)
968 <                po = addarg(po, "-r .65");
967 >        switch (vscale(QUALITY)) {
968 >        case MEDIUM:
969 >                po = addarg(po, "-r 1");
970 >                break;
971 >        case HIGH:
972 >                po = addarg(po, "-m .25");
973 >                break;
974 >        }
975          if (vdef(PFILT))
976                  po = addarg(po, vval(PFILT));
977   }
# Line 845 | Line 1001 | register char  *vs;
1001          register int    i;
1002          double  cent[3], dim[3], mult, d;
1003  
1004 <        if (*vs == '-')
1004 >        if (vs == NULL || *vs == '-')
1005                  return(vs);
1006          upax = 0;                       /* get the up vector */
1007          if (vdef(UP)) {
# Line 939 | Line 1095 | register char  *vs;
1095                          cp += strlen(cp);
1096                  }
1097          }
1098 <        strcpy(cp, vs);                 /* append any additional options */
1098 >        if (cp == viewopts)             /* append any additional options */
1099 >                vs++;           /* skip prefixed space if unneeded */
1100 >        strcpy(cp, vs);
1101   #ifdef MSDOS
1102          if (strlen(viewopts) > 40) {
1103                  setenv("VIEW", viewopts);
# Line 955 | Line 1113 | getview(n, vn)                         /* get view n, or NULL if none */
1113   int     n;
1114   char    *vn;            /* returned view name */
1115   {
1116 <        register char   *mv = NULL;
1116 >        register char   *mv;
1117  
1118          if (viewselect != NULL) {               /* command-line selected */
1119                  if (n)                          /* only do one */
# Line 970 | Line 1128 | char   *vn;            /* returned view name */
1128                                  ;
1129                          *vn = '\0';
1130                  }
1131 +                                                /* view number? */
1132 +                if (isint(viewselect))
1133 +                        return(specview(nvalue(vv+VIEW, atoi(viewselect)-1)));
1134                                                  /* check list */
1135                  while ((mv = nvalue(vv+VIEW, n++)) != NULL)
1136                          if (matchword(viewselect, mv))
# Line 978 | Line 1139 | char   *vn;            /* returned view name */
1139          }
1140          mv = nvalue(vv+VIEW, n);                /* use view n */
1141          if (vn != NULL & mv != NULL) {
1142 <                if (*mv != '-')
1143 <                        while (*mv && !isspace(*mv))
1144 <                                *vn++ = *mv++;
1142 >                register char   *mv2 = mv;
1143 >                if (*mv2 != '-')
1144 >                        while (*mv2 && !isspace(*mv2))
1145 >                                *vn++ = *mv2++;
1146                  *vn = '\0';
1147          }
1148          return(specview(mv));
1149   }
1150  
1151  
1152 + printview(vopts)                        /* print out selected view */
1153 + register char   *vopts;
1154 + {
1155 +        extern char     *atos(), *getenv();
1156 +        char    buf[256];
1157 +        FILE    *fp;
1158 +        register char   *cp;
1159 +
1160 +        if (vopts == NULL)
1161 +                return(-1);
1162 +        fputs("VIEW=", stdout);
1163 +        do {
1164 +                if (matchword(vopts, "-vf")) {          /* expand view file */
1165 +                        vopts = sskip(vopts);
1166 +                        if (!*atos(buf, sizeof(buf), vopts))
1167 +                                return(-1);
1168 +                        if ((fp = fopen(buf, "r")) == NULL)
1169 +                                return(-1);
1170 +                        for (buf[sizeof(buf)-2] = '\n';
1171 +                                        fgets(buf, sizeof(buf), fp) != NULL &&
1172 +                                                buf[0] != '\n';
1173 +                                        buf[sizeof(buf)-2] = '\n') {
1174 +                                if (buf[sizeof(buf)-2] != '\n') {
1175 +                                        ungetc(buf[sizeof(buf)-2], fp);
1176 +                                        buf[sizeof(buf)-2] = '\0';
1177 +                                }
1178 +                                if (matchword(buf, "VIEW=") ||
1179 +                                                matchword(buf, "rview")) {
1180 +                                        for (cp = sskip(buf); *cp && *cp != '\n'; cp++)
1181 +                                                putchar(*cp);
1182 +                                }
1183 +                        }
1184 +                        fclose(fp);
1185 +                        vopts = sskip(vopts);
1186 +                } else {
1187 +                        while (isspace(*vopts))
1188 +                                vopts++;
1189 +                        putchar(' ');
1190 + #ifdef MSDOS
1191 +                        if (*vopts == '$') {            /* expand env. var. */
1192 +                                if (!*atos(buf, sizeof(buf), vopts+1))
1193 +                                        return(-1);
1194 +                                if ((cp = getenv(buf)) == NULL)
1195 +                                        return(-1);
1196 +                                fputs(cp, stdout);
1197 +                                vopts = sskip(vopts);
1198 +                        } else
1199 + #endif
1200 +                                while (*vopts && !isspace(*vopts))
1201 +                                        putchar(*vopts++);
1202 +                }
1203 +        } while (*vopts++);
1204 +        putchar('\n');
1205 +        return(0);
1206 + }
1207 +
1208 +
1209   rview(opts)                             /* run rview with first view */
1210   char    *opts;
1211   {
1212 +        char    *vw;
1213          char    combuf[512];
1214                                          /* build command */
1215 <        sprintf(combuf, "rview %s%s ", getview(0, NULL), opts);
1215 >        if ((vw = getview(0, NULL)) == NULL)
1216 >                return;
1217 >        if (sayview)
1218 >                printview(vw);
1219 >        sprintf(combuf, "rview %s%s -R %s ", vw, opts, rifname);
1220          if (rvdevice != NULL)
1221                  sprintf(combuf+strlen(combuf), "-o %s ", rvdevice);
1222 <        strcat(combuf, vval(OCTREE));
1222 >        strcat(combuf, oct1name);
1223          if (runcom(combuf)) {           /* run it */
1224                  fprintf(stderr, "%s: error running rview\n", progname);
1225                  exit(1);
# Line 1044 | Line 1268 | char   *opts;
1268                                          /* do each view */
1269          vn = 0;
1270          while ((vw = getview(vn++, vs)) != NULL) {
1271 +                if (sayview)
1272 +                        printview(vw);
1273                  if (!vs[0])
1274                          sprintf(vs, "%d", vn);
1275                  sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs);
1276                                                  /* check date on picture */
1277 <                if (fdate(picfile) > octreedate)
1277 >                if (fdate(picfile) >= oct1date)
1278                          continue;
1279                                                  /* build rpict command */
1280                  sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs);
1281 <                if (fdate(rawfile) > octreedate)        /* recover */
1281 >                if (fdate(rawfile) >= oct1date)         /* recover */
1282                          sprintf(combuf, "rpict%s%s -ro %s %s",
1283 <                                        rep, opts, rawfile, vval(OCTREE));
1283 >                                        rep, opts, rawfile, oct1name);
1284                  else {
1285                          if (overture) {         /* run overture calculation */
1286                                  sprintf(combuf,
1287                                  "rpict%s %s%s -x 64 -y 64 -ps 1 %s > %s",
1288                                                  rep, vw, opts,
1289 <                                                vval(OCTREE), overfile);
1289 >                                                oct1name, overfile);
1290                                  if (runcom(combuf)) {
1291                                          fprintf(stderr,
1292                                          "%s: error in overture for view %s\n",
# Line 1073 | Line 1299 | char   *opts;
1299                          }
1300                          sprintf(combuf, "rpict%s %s %s%s %s > %s",
1301                                          rep, vw, res, opts,
1302 <                                        vval(OCTREE), rawfile);
1302 >                                        oct1name, rawfile);
1303                  }
1304                  if (runcom(combuf)) {           /* run rpict */
1305                          fprintf(stderr, "%s: error rendering view %s\n",

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines