94 |
|
|
95 |
|
#define renderopts (*setqopts[vscale(QUALITY)]) |
96 |
|
|
97 |
+ |
/* overture calculation file */ |
98 |
+ |
#ifdef NIX |
99 |
+ |
char overfile[] = "overture.raw"; |
100 |
+ |
#else |
101 |
+ |
char overfile[] = "/dev/null"; |
102 |
+ |
#endif |
103 |
+ |
|
104 |
|
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 */ |
167 |
|
/* print all values if requested */ |
168 |
|
if (explicate) |
169 |
|
printvals(); |
170 |
< |
/* run simulation */ |
170 |
> |
/* build octree */ |
171 |
|
oconv(); |
172 |
+ |
/* check date on ambient file */ |
173 |
+ |
checkambfile(); |
174 |
+ |
/* run simulation */ |
175 |
|
renderopts(ropts); |
176 |
|
xferopts(ropts); |
177 |
|
if (rvdevice != NULL) |
310 |
|
{ |
311 |
|
register char *cp; |
312 |
|
|
313 |
< |
if (vp == NULL || n < 0 || n >= vp->nass) |
313 |
> |
if (vp == NULL | n < 0 | n >= vp->nass) |
314 |
|
return(NULL); |
315 |
|
cp = vp->value; |
316 |
|
while (n--) |
424 |
|
vnam(OCTREE), vnam(SCENE)); |
425 |
|
exit(1); |
426 |
|
} |
427 |
+ |
matdate = -1; |
428 |
+ |
if (vdef(MATERIAL)) |
429 |
+ |
matdate = checklast(vval(MATERIAL)); |
430 |
|
} |
431 |
|
|
432 |
|
|
561 |
|
} |
562 |
|
|
563 |
|
|
564 |
+ |
checkambfile() /* check date on ambient file */ |
565 |
+ |
{ |
566 |
+ |
long afdate; |
567 |
+ |
|
568 |
+ |
if (!vdef(AMBFILE)) |
569 |
+ |
return; |
570 |
+ |
if ((afdate = fdate(vval(AMBFILE))) < 0) |
571 |
+ |
return; |
572 |
+ |
if (octreedate > afdate | matdate > afdate) |
573 |
+ |
rmfile(vval(AMBFILE)); |
574 |
+ |
} |
575 |
+ |
|
576 |
+ |
|
577 |
|
double |
578 |
|
ambval() /* compute ambient value */ |
579 |
|
{ |
626 |
|
op = addarg(op, "-ds .4"); |
627 |
|
else |
628 |
|
op = addarg(op, "-ds 0"); |
629 |
< |
op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .7"); |
629 |
> |
op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .5"); |
630 |
|
if (vdef(AMBFILE)) { |
631 |
|
sprintf(op, " -af %s", vval(AMBFILE)); |
632 |
|
op += strlen(op); |
634 |
|
overture = 0; |
635 |
|
switch (vscale(VARIABILITY)) { |
636 |
|
case LOW: |
637 |
< |
op = addarg(op, "-aa .4 -ad 32"); |
637 |
> |
op = addarg(op, "-aa .4 -ad 64"); |
638 |
|
break; |
639 |
|
case MEDIUM: |
640 |
< |
op = addarg(op, "-aa .3 -ad 64"); |
640 |
> |
op = addarg(op, "-aa .3 -ad 128"); |
641 |
|
break; |
642 |
|
case HIGH: |
643 |
< |
op = addarg(op, "-aa .25 -ad 128"); |
643 |
> |
op = addarg(op, "-aa .25 -ad 256"); |
644 |
|
break; |
645 |
|
} |
646 |
|
op = addarg(op, "-as 0"); |
690 |
|
op = addarg(op, "-ds .2 -dj .35"); |
691 |
|
else |
692 |
|
op = addarg(op, "-ds .3"); |
693 |
< |
op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .15"); |
694 |
< |
sprintf(op, " -ab %d", overture=vint(INDIRECT)); |
695 |
< |
op += strlen(op); |
693 |
> |
op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1"); |
694 |
> |
if (overture = vint(INDIRECT)) { |
695 |
> |
sprintf(op, " -ab %d", overture); |
696 |
> |
op += strlen(op); |
697 |
> |
} |
698 |
|
if (vdef(AMBFILE)) { |
699 |
|
sprintf(op, " -af %s", vval(AMBFILE)); |
700 |
|
op += strlen(op); |
702 |
|
overture = 0; |
703 |
|
switch (vscale(VARIABILITY)) { |
704 |
|
case LOW: |
705 |
< |
op = addarg(op, "-aa .25 -ad 128 -as 0"); |
705 |
> |
op = addarg(op, "-aa .25 -ad 196 -as 0"); |
706 |
|
break; |
707 |
|
case MEDIUM: |
708 |
< |
op = addarg(op, "-aa .2 -ad 300 -as 64"); |
708 |
> |
op = addarg(op, "-aa .2 -ad 400 -as 64"); |
709 |
|
break; |
710 |
|
case HIGH: |
711 |
< |
op = addarg(op, "-aa .15 -ad 500 -as 128"); |
711 |
> |
op = addarg(op, "-aa .15 -ad 768 -as 196"); |
712 |
|
break; |
713 |
|
} |
714 |
|
d = ambval(); |
757 |
|
op = addarg(op, "-ds .1 -dj .7"); |
758 |
|
else |
759 |
|
op = addarg(op, "-ds .2"); |
760 |
< |
op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .03"); |
760 |
> |
op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01"); |
761 |
|
sprintf(op, " -ab %d", overture=vint(INDIRECT)+1); |
762 |
|
op += strlen(op); |
763 |
|
if (vdef(AMBFILE)) { |
767 |
|
overture = 0; |
768 |
|
switch (vscale(VARIABILITY)) { |
769 |
|
case LOW: |
770 |
< |
op = addarg(op, "-aa .15 -ad 200 -as 0"); |
770 |
> |
op = addarg(op, "-aa .15 -ad 256 -as 0"); |
771 |
|
break; |
772 |
|
case MEDIUM: |
773 |
< |
op = addarg(op, "-aa .125 -ad 512 -as 128"); |
773 |
> |
op = addarg(op, "-aa .125 -ad 512 -as 256"); |
774 |
|
break; |
775 |
|
case HIGH: |
776 |
< |
op = addarg(op, "-aa .08 -ad 850 -as 256"); |
776 |
> |
op = addarg(op, "-aa .08 -ad 1024 -as 512"); |
777 |
|
break; |
778 |
|
} |
779 |
|
d = ambval(); |
789 |
|
char *ro; |
790 |
|
{ |
791 |
|
int fd, n; |
792 |
+ |
register char *cp; |
793 |
|
|
794 |
|
n = strlen(ro); |
795 |
|
if (n < 2) |
796 |
|
return; |
797 |
|
if (vdef(OPTFILE)) { |
798 |
< |
if ((fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1) |
798 |
> |
for (cp = ro; cp[1]; cp++) |
799 |
> |
if (isspace(cp[1]) && cp[2] == '-' && isalpha(cp[3])) |
800 |
> |
*cp = '\n'; |
801 |
> |
else |
802 |
> |
*cp = cp[1]; |
803 |
> |
*cp = '\n'; |
804 |
> |
fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666); |
805 |
> |
if (fd < 0 || write(fd, ro, n) != n || close(fd) < 0) |
806 |
|
syserr(vval(OPTFILE)); |
807 |
< |
if (write(fd, ro+1, n-1) != n-1) |
771 |
< |
syserr(vval(OPTFILE)); |
772 |
< |
write(fd, "\n", 1); |
773 |
< |
close(fd); |
774 |
< |
sprintf(ro, " \"^%s\"", vval(OPTFILE)); |
807 |
> |
sprintf(ro, " @%s", vval(OPTFILE)); |
808 |
|
} |
809 |
|
#ifdef MSDOS |
810 |
|
else if (n > 50) { |
811 |
< |
register char *evp = bmalloc(n+6); |
779 |
< |
if (evp == NULL) |
780 |
< |
syserr(progname); |
781 |
< |
strcpy(evp, "ROPT="); |
782 |
< |
strcat(evp, ro); |
783 |
< |
if (putenv(evp) != 0) { |
784 |
< |
fprintf(stderr, "%s: out of environment space\n", |
785 |
< |
progname); |
786 |
< |
exit(1); |
787 |
< |
} |
811 |
> |
setenv("ROPT", ro+1); |
812 |
|
strcpy(ro, " $ROPT"); |
813 |
|
} |
814 |
|
#endif |
823 |
|
po = addarg(po, "-1 -e"); |
824 |
|
po = addarg(po, vval(EXPOSURE)); |
825 |
|
} |
826 |
< |
if (vscale(QUALITY) == HIGH) |
827 |
< |
po = addarg(po, "-r .65"); |
826 |
> |
switch (vscale(QUALITY)) { |
827 |
> |
case MEDIUM: |
828 |
> |
po = addarg(po, "-r 1"); |
829 |
> |
break; |
830 |
> |
case HIGH: |
831 |
> |
po = addarg(po, "-m .25"); |
832 |
> |
break; |
833 |
> |
} |
834 |
|
if (vdef(PFILT)) |
835 |
|
po = addarg(po, vval(PFILT)); |
836 |
|
} |
954 |
|
cp += strlen(cp); |
955 |
|
} |
956 |
|
} |
957 |
< |
/* append any additional options */ |
958 |
< |
strcpy(cp, vs); |
957 |
> |
strcpy(cp, vs); /* append any additional options */ |
958 |
> |
#ifdef MSDOS |
959 |
> |
if (strlen(viewopts) > 40) { |
960 |
> |
setenv("VIEW", viewopts); |
961 |
> |
return("$VIEW"); |
962 |
> |
} |
963 |
> |
#endif |
964 |
|
return(viewopts); |
965 |
|
} |
966 |
|
|
968 |
|
char * |
969 |
|
getview(n, vn) /* get view n, or NULL if none */ |
970 |
|
int n; |
971 |
< |
char *vn; |
971 |
> |
char *vn; /* returned view name */ |
972 |
|
{ |
973 |
|
register char *mv; |
974 |
|
|
975 |
< |
if (viewselect != NULL) { |
975 |
> |
if (viewselect != NULL) { /* command-line selected */ |
976 |
|
if (n) /* only do one */ |
977 |
|
return(NULL); |
978 |
|
if (viewselect[0] == '-') { /* already specified */ |
985 |
|
; |
986 |
|
*vn = '\0'; |
987 |
|
} |
988 |
+ |
/* view number? */ |
989 |
+ |
if (isdigit(viewselect[0])) |
990 |
+ |
return(specview(nvalue(vv+VIEW, atoi(viewselect)-1))); |
991 |
|
/* check list */ |
992 |
|
while ((mv = nvalue(vv+VIEW, n++)) != NULL) |
993 |
|
if (matchword(viewselect, mv)) |
994 |
|
return(specview(mv)); |
995 |
|
return(specview(viewselect)); /* standard view? */ |
996 |
|
} |
997 |
< |
if (vn != NULL && (mv = nvalue(vv+VIEW, n)) != NULL) { |
998 |
< |
if (*mv != '-') |
999 |
< |
while (*mv && !isspace(*mv)) |
1000 |
< |
*vn++ = *mv++; |
997 |
> |
mv = nvalue(vv+VIEW, n); /* use view n */ |
998 |
> |
if (vn != NULL & mv != NULL) { |
999 |
> |
register char *mv2 = mv; |
1000 |
> |
if (*mv2 != '-') |
1001 |
> |
while (*mv2 && !isspace(*mv2)) |
1002 |
> |
*vn++ = *mv2++; |
1003 |
|
*vn = '\0'; |
1004 |
|
} |
1005 |
< |
return(specview(nvalue(vv+VIEW, n))); /* use view n */ |
1005 |
> |
return(specview(mv)); |
1006 |
|
} |
1007 |
|
|
1008 |
|
|
1030 |
|
char pfopts[128]; |
1031 |
|
char vs[32], *vw; |
1032 |
|
int vn, mult; |
1033 |
+ |
long lastdate; |
1034 |
|
/* get pfilt options */ |
1035 |
|
pfiltopts(pfopts); |
1036 |
|
/* get resolution, reporting */ |
1061 |
|
else |
1062 |
|
badvalue(REPORT); |
1063 |
|
} |
1064 |
< |
/* check date on ambient file */ |
1065 |
< |
if (vdef(AMBFILE)) { |
1025 |
< |
long afdate = fdate(vval(AMBFILE)); |
1026 |
< |
if (afdate >= 0 & octreedate > afdate) |
1027 |
< |
rmfile(vval(AMBFILE)); |
1028 |
< |
} |
1064 |
> |
/* get update time */ |
1065 |
> |
lastdate = octreedate > matdate ? octreedate : matdate; |
1066 |
|
/* do each view */ |
1067 |
|
vn = 0; |
1068 |
|
while ((vw = getview(vn++, vs)) != NULL) { |
1070 |
|
sprintf(vs, "%d", vn); |
1071 |
|
sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs); |
1072 |
|
/* check date on picture */ |
1073 |
< |
if (fdate(picfile) > octreedate) |
1073 |
> |
if (fdate(picfile) >= lastdate) |
1074 |
|
continue; |
1075 |
|
/* build rpict command */ |
1076 |
|
sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs); |
1077 |
< |
if (fdate(rawfile) > octreedate) /* recover */ |
1077 |
> |
if (fdate(rawfile) >= octreedate) /* recover */ |
1078 |
|
sprintf(combuf, "rpict%s%s -ro %s %s", |
1079 |
|
rep, opts, rawfile, vval(OCTREE)); |
1080 |
|
else { |
1082 |
|
sprintf(combuf, |
1083 |
|
"rpict%s %s%s -x 64 -y 64 -ps 1 %s > %s", |
1084 |
|
rep, vw, opts, |
1085 |
< |
vval(OCTREE), rawfile); |
1085 |
> |
vval(OCTREE), overfile); |
1086 |
|
if (runcom(combuf)) { |
1087 |
|
fprintf(stderr, |
1088 |
< |
"%s: error in overture for view %s\n\t%s removed\n", |
1089 |
< |
progname, vs, rawfile); |
1053 |
< |
unlink(rawfile); |
1088 |
> |
"%s: error in overture for view %s\n", |
1089 |
> |
progname, vs); |
1090 |
|
exit(1); |
1091 |
|
} |
1092 |
+ |
#ifdef NIX |
1093 |
+ |
rmfile(overfile); |
1094 |
+ |
#endif |
1095 |
|
} |
1096 |
|
sprintf(combuf, "rpict%s %s %s%s %s > %s", |
1097 |
|
rep, vw, res, opts, |
1147 |
|
return(0); |
1148 |
|
return(unlink(fn)); |
1149 |
|
} |
1150 |
+ |
|
1151 |
+ |
|
1152 |
+ |
#ifdef MSDOS |
1153 |
+ |
setenv(vname, value) /* set an environment variable */ |
1154 |
+ |
char *vname, *value; |
1155 |
+ |
{ |
1156 |
+ |
register char *evp; |
1157 |
+ |
|
1158 |
+ |
evp = bmalloc(strlen(vname)+strlen(value)+2); |
1159 |
+ |
if (evp == NULL) |
1160 |
+ |
syserr(progname); |
1161 |
+ |
sprintf(evp, "%s=%s", vname, value); |
1162 |
+ |
if (putenv(evp) != 0) { |
1163 |
+ |
fprintf(stderr, "%s: out of environment space\n", progname); |
1164 |
+ |
exit(1); |
1165 |
+ |
} |
1166 |
+ |
if (!silent) |
1167 |
+ |
printf("set %s\n", evp); |
1168 |
+ |
} |
1169 |
+ |
#endif |
1170 |
|
|
1171 |
|
|
1172 |
|
badvalue(vc) /* report bad variable value and exit */ |