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 |
|
|
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; |
171 |
|
/* print all values if requested */ |
172 |
|
if (explicate) |
173 |
|
printvals(); |
174 |
< |
/* run simulation */ |
174 |
> |
/* build octree */ |
175 |
|
oconv(); |
176 |
+ |
/* check date on ambient file */ |
177 |
+ |
checkambfile(); |
178 |
+ |
/* run simulation */ |
179 |
|
renderopts(ropts); |
180 |
|
xferopts(ropts); |
181 |
|
if (rvdevice != NULL) |
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--) |
428 |
|
vnam(OCTREE), vnam(SCENE)); |
429 |
|
exit(1); |
430 |
|
} |
431 |
+ |
matdate = -1; |
432 |
+ |
if (vdef(MATERIAL)) |
433 |
+ |
matdate = checklast(vval(MATERIAL)); |
434 |
|
} |
435 |
|
|
436 |
|
|
565 |
|
} |
566 |
|
|
567 |
|
|
568 |
+ |
checkambfile() /* check date on ambient file */ |
569 |
+ |
{ |
570 |
+ |
long afdate; |
571 |
+ |
|
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 |
+ |
|
581 |
|
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] == '.') |
564 |
< |
return(.5/atof(vval(EXPOSURE))); |
565 |
< |
badvalue(EXPOSURE); |
589 |
> |
return(.5/atof(vval(EXPOSURE))); |
590 |
|
} |
591 |
|
if (vlet(ZONE) == 'E') |
592 |
|
return(10.); |
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); |
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"); |
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); |
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(); |
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)) { |
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(); |
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) |
780 |
< |
syserr(vval(OPTFILE)); |
781 |
< |
write(fd, "\n", 1); |
782 |
< |
close(fd); |
783 |
< |
sprintf(ro, " \"^%s\"", vval(OPTFILE)); |
811 |
> |
sprintf(ro, " @%s", vval(OPTFILE)); |
812 |
|
} |
813 |
|
#ifdef MSDOS |
814 |
|
else if (n > 50) { |
815 |
< |
register char *evp = bmalloc(n+6); |
788 |
< |
if (evp == NULL) |
789 |
< |
syserr(progname); |
790 |
< |
strcpy(evp, "ROPT="); |
791 |
< |
strcat(evp, ro); |
792 |
< |
if (putenv(evp) != 0) { |
793 |
< |
fprintf(stderr, "%s: out of environment space\n", |
794 |
< |
progname); |
795 |
< |
exit(1); |
796 |
< |
} |
815 |
> |
setenv("ROPT", ro+1); |
816 |
|
strcpy(ro, " $ROPT"); |
817 |
|
} |
818 |
|
#endif |
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 |
|
} |
958 |
|
cp += strlen(cp); |
959 |
|
} |
960 |
|
} |
961 |
< |
/* append any additional options */ |
962 |
< |
strcpy(cp, vs); |
961 |
> |
strcpy(cp, vs); /* append any additional options */ |
962 |
> |
#ifdef MSDOS |
963 |
> |
if (strlen(viewopts) > 40) { |
964 |
> |
setenv("VIEW", viewopts); |
965 |
> |
return("$VIEW"); |
966 |
> |
} |
967 |
> |
#endif |
968 |
|
return(viewopts); |
969 |
|
} |
970 |
|
|
972 |
|
char * |
973 |
|
getview(n, vn) /* get view n, or NULL if none */ |
974 |
|
int n; |
975 |
< |
char *vn; |
975 |
> |
char *vn; /* returned view name */ |
976 |
|
{ |
977 |
|
register char *mv; |
978 |
|
|
979 |
< |
if (viewselect != NULL) { |
979 |
> |
if (viewselect != NULL) { /* command-line selected */ |
980 |
|
if (n) /* only do one */ |
981 |
|
return(NULL); |
982 |
|
if (viewselect[0] == '-') { /* already specified */ |
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)) |
998 |
|
return(specview(mv)); |
999 |
|
return(specview(viewselect)); /* standard view? */ |
1000 |
|
} |
1001 |
< |
if (vn != NULL && (mv = nvalue(vv+VIEW, n)) != NULL) { |
1002 |
< |
if (*mv != '-') |
1003 |
< |
while (*mv && !isspace(*mv)) |
1004 |
< |
*vn++ = *mv++; |
1001 |
> |
mv = nvalue(vv+VIEW, n); /* use view n */ |
1002 |
> |
if (vn != NULL & mv != NULL) { |
1003 |
> |
register char *mv2 = mv; |
1004 |
> |
if (*mv2 != '-') |
1005 |
> |
while (*mv2 && !isspace(*mv2)) |
1006 |
> |
*vn++ = *mv2++; |
1007 |
|
*vn = '\0'; |
1008 |
|
} |
1009 |
< |
return(specview(nvalue(vv+VIEW, n))); /* use view n */ |
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)); |
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 */ |
1117 |
|
else |
1118 |
|
badvalue(REPORT); |
1119 |
|
} |
1120 |
< |
/* check date on ambient file */ |
1121 |
< |
if (vdef(AMBFILE)) { |
1034 |
< |
long afdate = fdate(vval(AMBFILE)); |
1035 |
< |
if (afdate >= 0 & octreedate > afdate) |
1036 |
< |
rmfile(vval(AMBFILE)); |
1037 |
< |
} |
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 { |
1205 |
|
return(0); |
1206 |
|
return(unlink(fn)); |
1207 |
|
} |
1208 |
+ |
|
1209 |
+ |
|
1210 |
+ |
#ifdef MSDOS |
1211 |
+ |
setenv(vname, value) /* set an environment variable */ |
1212 |
+ |
char *vname, *value; |
1213 |
+ |
{ |
1214 |
+ |
register char *evp; |
1215 |
+ |
|
1216 |
+ |
evp = bmalloc(strlen(vname)+strlen(value)+2); |
1217 |
+ |
if (evp == NULL) |
1218 |
+ |
syserr(progname); |
1219 |
+ |
sprintf(evp, "%s=%s", vname, value); |
1220 |
+ |
if (putenv(evp) != 0) { |
1221 |
+ |
fprintf(stderr, "%s: out of environment space\n", progname); |
1222 |
+ |
exit(1); |
1223 |
+ |
} |
1224 |
+ |
if (!silent) |
1225 |
+ |
printf("set %s\n", evp); |
1226 |
+ |
} |
1227 |
+ |
#endif |
1228 |
|
|
1229 |
|
|
1230 |
|
badvalue(vc) /* report bad variable value and exit */ |