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.9 by greg, Wed May 26 11:37:42 1993 UTC vs.
Revision 2.21 by greg, Tue Aug 24 22:14:21 1993 UTC

# Line 105 | Line 105 | extern long    fdate(), time();
105  
106   long    scenedate;              /* date of latest scene or object file */
107   long    octreedate;             /* date of octree */
108 + long    matdate;                /* date of latest material file */
109  
110   int     explicate = 0;          /* explicate variables */
111   int     silent = 0;             /* do work silently */
112   int     noaction = 0;           /* don't do anything */
113 + int     sayview = 0;            /* print view out */
114   char    *rvdevice = NULL;       /* rview output device */
115   char    *viewselect = NULL;     /* specific view only */
116  
# Line 142 | Line 144 | char   *argv[];
144                  case 'o':
145                          rvdevice = argv[++i];
146                          break;
147 +                case 'V':
148 +                        sayview++;
149 +                        break;
150                  case 'v':
151                          viewselect = argv[++i];
152                          break;
# Line 309 | Line 314 | register int   n;
314   {
315          register char   *cp;
316  
317 <        if (vp == NULL || n < 0 || n >= vp->nass)
317 >        if (vp == NULL | n < 0 | n >= vp->nass)
318                  return(NULL);
319          cp = vp->value;
320          while (n--)
# Line 423 | Line 428 | checkfiles()                   /* check for existence and modified tim
428                                  vnam(OCTREE), vnam(SCENE));
429                  exit(1);
430          }
431 +        matdate = -1;
432 +        if (vdef(MATERIAL))
433 +                matdate = checklast(vval(MATERIAL));
434   }      
435  
436  
# Line 561 | Line 569 | checkambfile()                 /* check date on ambient file */
569   {
570          long    afdate;
571  
572 <        if (vdef(AMBFILE)) {
573 <                afdate = fdate(vval(AMBFILE));
574 <                if (afdate >= 0 & octreedate > afdate)
575 <                        rmfile(vval(AMBFILE));
576 <        }
572 >        if (!vdef(AMBFILE))
573 >                return;
574 >        if ((afdate = fdate(vval(AMBFILE))) < 0)
575 >                return;
576 >        if (octreedate > afdate | matdate > afdate)
577 >                rmfile(vval(AMBFILE));
578   }
579  
580  
# Line 573 | Line 582 | double
582   ambval()                                /* compute ambient value */
583   {
584          if (vdef(EXPOSURE)) {
585 +                if (!isflt(vval(EXPOSURE)))
586 +                        badvalue(EXPOSURE);
587                  if (vval(EXPOSURE)[0] == '+' || vval(EXPOSURE)[0] == '-')
588                          return(.5/pow(2.,atof(vval(EXPOSURE))));
589 <                if (isdigit(vval(EXPOSURE)[0]) || vval(EXPOSURE)[0] == '.')
579 <                        return(.5/atof(vval(EXPOSURE)));
580 <                badvalue(EXPOSURE);
589 >                return(.5/atof(vval(EXPOSURE)));
590          }
591          if (vlet(ZONE) == 'E')
592                  return(10.);
# Line 621 | Line 630 | register char  *op;
630                  op = addarg(op, "-ds .4");
631          else
632                  op = addarg(op, "-ds 0");
633 <        op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .7");
633 >        op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .5");
634          if (vdef(AMBFILE)) {
635                  sprintf(op, " -af %s", vval(AMBFILE));
636                  op += strlen(op);
# Line 629 | Line 638 | register char  *op;
638                  overture = 0;
639          switch (vscale(VARIABILITY)) {
640          case LOW:
641 <                op = addarg(op, "-aa .4 -ad 32");
641 >                op = addarg(op, "-aa .4 -ad 64");
642                  break;
643          case MEDIUM:
644 <                op = addarg(op, "-aa .3 -ad 64");
644 >                op = addarg(op, "-aa .3 -ad 128");
645                  break;
646          case HIGH:
647 <                op = addarg(op, "-aa .25 -ad 128");
647 >                op = addarg(op, "-aa .25 -ad 256");
648                  break;
649          }
650          op = addarg(op, "-as 0");
# Line 685 | Line 694 | register char  *op;
694                  op = addarg(op, "-ds .2 -dj .35");
695          else
696                  op = addarg(op, "-ds .3");
697 <        op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .15");
697 >        op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1");
698          if (overture = vint(INDIRECT)) {
699                  sprintf(op, " -ab %d", overture);
700                  op += strlen(op);
# Line 697 | Line 706 | register char  *op;
706                  overture = 0;
707          switch (vscale(VARIABILITY)) {
708          case LOW:
709 <                op = addarg(op, "-aa .25 -ad 128 -as 0");
709 >                op = addarg(op, "-aa .25 -ad 196 -as 0");
710                  break;
711          case MEDIUM:
712 <                op = addarg(op, "-aa .2 -ad 300 -as 64");
712 >                op = addarg(op, "-aa .2 -ad 400 -as 64");
713                  break;
714          case HIGH:
715 <                op = addarg(op, "-aa .15 -ad 500 -as 128");
715 >                op = addarg(op, "-aa .15 -ad 768 -as 196");
716                  break;
717          }
718          d = ambval();
# Line 752 | Line 761 | register char  *op;
761                  op = addarg(op, "-ds .1 -dj .7");
762          else
763                  op = addarg(op, "-ds .2");
764 <        op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .03");
764 >        op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01");
765          sprintf(op, " -ab %d", overture=vint(INDIRECT)+1);
766          op += strlen(op);
767          if (vdef(AMBFILE)) {
# Line 762 | Line 771 | register char  *op;
771                  overture = 0;
772          switch (vscale(VARIABILITY)) {
773          case LOW:
774 <                op = addarg(op, "-aa .15 -ad 200 -as 0");
774 >                op = addarg(op, "-aa .15 -ad 256 -as 0");
775                  break;
776          case MEDIUM:
777 <                op = addarg(op, "-aa .125 -ad 512 -as 128");
777 >                op = addarg(op, "-aa .125 -ad 512 -as 256");
778                  break;
779          case HIGH:
780 <                op = addarg(op, "-aa .08 -ad 850 -as 256");
780 >                op = addarg(op, "-aa .08 -ad 1024 -as 512");
781                  break;
782          }
783          d = ambval();
# Line 784 | Line 793 | xferopts(ro)                           /* transfer options if indicated */
793   char    *ro;
794   {
795          int     fd, n;
796 +        register char   *cp;
797          
798          n = strlen(ro);
799          if (n < 2)
800                  return;
801          if (vdef(OPTFILE)) {
802 <                if ((fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1)
802 >                for (cp = ro; cp[1]; cp++)
803 >                        if (isspace(cp[1]) && cp[2] == '-' && isalpha(cp[3]))
804 >                                *cp = '\n';
805 >                        else
806 >                                *cp = cp[1];
807 >                *cp = '\n';
808 >                fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666);
809 >                if (fd < 0 || write(fd, ro, n) != n || close(fd) < 0)
810                          syserr(vval(OPTFILE));
811 <                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));
811 >                sprintf(ro, " @%s", vval(OPTFILE));
812          }
813   #ifdef MSDOS
814          else if (n > 50) {
# Line 814 | Line 827 | register char  *po;
827                  po = addarg(po, "-1 -e");
828                  po = addarg(po, vval(EXPOSURE));
829          }
830 <        if (vscale(QUALITY) == HIGH)
831 <                po = addarg(po, "-r .65");
830 >        switch (vscale(QUALITY)) {
831 >        case MEDIUM:
832 >                po = addarg(po, "-r 1");
833 >                break;
834 >        case HIGH:
835 >                po = addarg(po, "-m .25");
836 >                break;
837 >        }
838          if (vdef(PFILT))
839                  po = addarg(po, vval(PFILT));
840   }
# Line 955 | Line 974 | getview(n, vn)                         /* get view n, or NULL if none */
974   int     n;
975   char    *vn;            /* returned view name */
976   {
977 <        register char   *mv = NULL;
977 >        register char   *mv;
978  
979          if (viewselect != NULL) {               /* command-line selected */
980                  if (n)                          /* only do one */
# Line 970 | Line 989 | char   *vn;            /* returned view name */
989                                  ;
990                          *vn = '\0';
991                  }
992 +                                                /* view number? */
993 +                if (isint(viewselect))
994 +                        return(specview(nvalue(vv+VIEW, atoi(viewselect)-1)));
995                                                  /* check list */
996                  while ((mv = nvalue(vv+VIEW, n++)) != NULL)
997                          if (matchword(viewselect, mv))
# Line 978 | Line 1000 | char   *vn;            /* returned view name */
1000          }
1001          mv = nvalue(vv+VIEW, n);                /* use view n */
1002          if (vn != NULL & mv != NULL) {
1003 <                if (*mv != '-')
1004 <                        while (*mv && !isspace(*mv))
1005 <                                *vn++ = *mv++;
1003 >                register char   *mv2 = mv;
1004 >                if (*mv2 != '-')
1005 >                        while (*mv2 && !isspace(*mv2))
1006 >                                *vn++ = *mv2++;
1007                  *vn = '\0';
1008          }
1009          return(specview(mv));
1010   }
1011  
1012  
1013 + printview(vopts)                        /* print out selected view */
1014 + register char   *vopts;
1015 + {
1016 +        extern char     *atos();
1017 +        char    buf[256];
1018 +        FILE    *fp;
1019 +        register char   *cp;
1020 +
1021 +        if (vopts == NULL)
1022 +                return(-1);
1023 +        fputs("VIEW=", stdout);
1024 +        do {
1025 +                if (matchword(vopts, "-vf")) {          /* expand view file */
1026 +                        vopts = sskip(vopts);
1027 +                        if (!*atos(buf, sizeof(buf), vopts))
1028 +                                return(-1);
1029 +                        if ((fp = fopen(buf, "r")) == NULL)
1030 +                                return(-1);
1031 +                        for (buf[sizeof(buf)-2] = '\n';
1032 +                                        fgets(buf, sizeof(buf), fp) != NULL &&
1033 +                                                buf[0] != '\n';
1034 +                                        buf[sizeof(buf)-2] = '\n') {
1035 +                                if (buf[sizeof(buf)-2] != '\n') {
1036 +                                        ungetc(buf[sizeof(buf)-2], fp);
1037 +                                        buf[sizeof(buf)-2] = '\0';
1038 +                                }
1039 +                                if (matchword(buf, "VIEW=") ||
1040 +                                                matchword(buf, "rview")) {
1041 +                                        for (cp = sskip(buf); *cp && *cp != '\n'; cp++)
1042 +                                                putchar(*cp);
1043 +                                }
1044 +                        }
1045 +                        fclose(fp);
1046 +                        vopts = sskip(vopts);
1047 +                } else {
1048 +                        while (isspace(*vopts))
1049 +                                vopts++;
1050 +                        putchar(' ');
1051 +                        while (*vopts && !isspace(*vopts))
1052 +                                putchar(*vopts++);
1053 +                }
1054 +        } while (*vopts++);
1055 +        putchar('\n');
1056 +        return(0);
1057 + }
1058 +
1059 +
1060   rview(opts)                             /* run rview with first view */
1061   char    *opts;
1062   {
1063 +        char    *vw;
1064          char    combuf[512];
1065                                          /* build command */
1066 <        sprintf(combuf, "rview %s%s ", getview(0, NULL), opts);
1066 >        if ((vw = getview(0, NULL)) == NULL)
1067 >                return;
1068 >        if (sayview)
1069 >                printview(vw);
1070 >        sprintf(combuf, "rview %s%s ", vw, opts);
1071          if (rvdevice != NULL)
1072                  sprintf(combuf+strlen(combuf), "-o %s ", rvdevice);
1073          strcat(combuf, vval(OCTREE));
# Line 1011 | Line 1086 | char   *opts;
1086          char    pfopts[128];
1087          char    vs[32], *vw;
1088          int     vn, mult;
1089 +        long    lastdate;
1090                                          /* get pfilt options */
1091          pfiltopts(pfopts);
1092                                          /* get resolution, reporting */
# Line 1041 | Line 1117 | char   *opts;
1117                  else
1118                          badvalue(REPORT);
1119          }
1120 +                                        /* get update time */
1121 +        lastdate = octreedate > matdate ? octreedate : matdate;
1122                                          /* do each view */
1123          vn = 0;
1124          while ((vw = getview(vn++, vs)) != NULL) {
1125 +                if (sayview)
1126 +                        printview(vw);
1127                  if (!vs[0])
1128                          sprintf(vs, "%d", vn);
1129                  sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs);
1130                                                  /* check date on picture */
1131 <                if (fdate(picfile) > octreedate)
1131 >                if (fdate(picfile) >= lastdate)
1132                          continue;
1133                                                  /* build rpict command */
1134                  sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs);
1135 <                if (fdate(rawfile) > octreedate)        /* recover */
1135 >                if (fdate(rawfile) >= octreedate)       /* recover */
1136                          sprintf(combuf, "rpict%s%s -ro %s %s",
1137                                          rep, opts, rawfile, vval(OCTREE));
1138                  else {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines