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) |
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 |
|
{ |
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) |
780 |
< |
syserr(vval(OPTFILE)); |
781 |
< |
write(fd, "\n", 1); |
782 |
< |
close(fd); |
783 |
< |
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); |
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 |
< |
} |
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; |
973 |
> |
register char *mv = NULL; |
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 */ |
991 |
|
return(specview(mv)); |
992 |
|
return(specview(viewselect)); /* standard view? */ |
993 |
|
} |
994 |
< |
if (vn != NULL && (mv = nvalue(vv+VIEW, n)) != NULL) { |
994 |
> |
mv = nvalue(vv+VIEW, n); /* use view n */ |
995 |
> |
if (vn != NULL & mv != NULL) { |
996 |
|
if (*mv != '-') |
997 |
|
while (*mv && !isspace(*mv)) |
998 |
|
*vn++ = *mv++; |
999 |
|
*vn = '\0'; |
1000 |
|
} |
1001 |
< |
return(specview(nvalue(vv+VIEW, n))); /* use view n */ |
1001 |
> |
return(specview(mv)); |
1002 |
|
} |
1003 |
|
|
1004 |
|
|
1026 |
|
char pfopts[128]; |
1027 |
|
char vs[32], *vw; |
1028 |
|
int vn, mult; |
1029 |
+ |
long lastdate; |
1030 |
|
/* get pfilt options */ |
1031 |
|
pfiltopts(pfopts); |
1032 |
|
/* get resolution, reporting */ |
1057 |
|
else |
1058 |
|
badvalue(REPORT); |
1059 |
|
} |
1060 |
< |
/* check date on ambient file */ |
1061 |
< |
if (vdef(AMBFILE)) { |
1034 |
< |
long afdate = fdate(vval(AMBFILE)); |
1035 |
< |
if (afdate >= 0 & octreedate > afdate) |
1036 |
< |
rmfile(vval(AMBFILE)); |
1037 |
< |
} |
1060 |
> |
/* get update time */ |
1061 |
> |
lastdate = octreedate > matdate ? octreedate : matdate; |
1062 |
|
/* do each view */ |
1063 |
|
vn = 0; |
1064 |
|
while ((vw = getview(vn++, vs)) != NULL) { |
1066 |
|
sprintf(vs, "%d", vn); |
1067 |
|
sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs); |
1068 |
|
/* check date on picture */ |
1069 |
< |
if (fdate(picfile) > octreedate) |
1069 |
> |
if (fdate(picfile) >= lastdate) |
1070 |
|
continue; |
1071 |
|
/* build rpict command */ |
1072 |
|
sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs); |
1073 |
< |
if (fdate(rawfile) > octreedate) /* recover */ |
1073 |
> |
if (fdate(rawfile) >= octreedate) /* recover */ |
1074 |
|
sprintf(combuf, "rpict%s%s -ro %s %s", |
1075 |
|
rep, opts, rawfile, vval(OCTREE)); |
1076 |
|
else { |
1143 |
|
return(0); |
1144 |
|
return(unlink(fn)); |
1145 |
|
} |
1146 |
+ |
|
1147 |
+ |
|
1148 |
+ |
#ifdef MSDOS |
1149 |
+ |
setenv(vname, value) /* set an environment variable */ |
1150 |
+ |
char *vname, *value; |
1151 |
+ |
{ |
1152 |
+ |
register char *evp; |
1153 |
+ |
|
1154 |
+ |
evp = bmalloc(strlen(vname)+strlen(value)+2); |
1155 |
+ |
if (evp == NULL) |
1156 |
+ |
syserr(progname); |
1157 |
+ |
sprintf(evp, "%s=%s", vname, value); |
1158 |
+ |
if (putenv(evp) != 0) { |
1159 |
+ |
fprintf(stderr, "%s: out of environment space\n", progname); |
1160 |
+ |
exit(1); |
1161 |
+ |
} |
1162 |
+ |
if (!silent) |
1163 |
+ |
printf("set %s\n", evp); |
1164 |
+ |
} |
1165 |
+ |
#endif |
1166 |
|
|
1167 |
|
|
1168 |
|
badvalue(vc) /* report bad variable value and exit */ |