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) |
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 |
|
{ |
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); |
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); |
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)); |
770 |
– |
if (write(fd, ro+1, n-1) != n-1) |
771 |
– |
syserr(vval(OPTFILE)); |
772 |
– |
write(fd, "\n", 1); |
773 |
– |
close(fd); |
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 |
948 |
|
cp += strlen(cp); |
949 |
|
} |
950 |
|
} |
951 |
< |
/* append any additional options */ |
952 |
< |
strcpy(cp, vs); |
951 |
> |
strcpy(cp, vs); /* append any additional options */ |
952 |
> |
#ifdef MSDOS |
953 |
> |
if (strlen(viewopts) > 40) { |
954 |
> |
setenv("VIEW", viewopts); |
955 |
> |
return("$VIEW"); |
956 |
> |
} |
957 |
> |
#endif |
958 |
|
return(viewopts); |
959 |
|
} |
960 |
|
|
962 |
|
char * |
963 |
|
getview(n, vn) /* get view n, or NULL if none */ |
964 |
|
int n; |
965 |
< |
char *vn; |
965 |
> |
char *vn; /* returned view name */ |
966 |
|
{ |
967 |
< |
register char *mv; |
967 |
> |
register char *mv = NULL; |
968 |
|
|
969 |
< |
if (viewselect != NULL) { |
969 |
> |
if (viewselect != NULL) { /* command-line selected */ |
970 |
|
if (n) /* only do one */ |
971 |
|
return(NULL); |
972 |
|
if (viewselect[0] == '-') { /* already specified */ |
985 |
|
return(specview(mv)); |
986 |
|
return(specview(viewselect)); /* standard view? */ |
987 |
|
} |
988 |
< |
if (vn != NULL && (mv = nvalue(vv+VIEW, n)) != NULL) { |
988 |
> |
mv = nvalue(vv+VIEW, n); /* use view n */ |
989 |
> |
if (vn != NULL & mv != NULL) { |
990 |
|
if (*mv != '-') |
991 |
|
while (*mv && !isspace(*mv)) |
992 |
|
*vn++ = *mv++; |
993 |
|
*vn = '\0'; |
994 |
|
} |
995 |
< |
return(specview(nvalue(vv+VIEW, n))); /* use view n */ |
995 |
> |
return(specview(mv)); |
996 |
|
} |
997 |
|
|
998 |
|
|
1050 |
|
else |
1051 |
|
badvalue(REPORT); |
1052 |
|
} |
1023 |
– |
/* check date on ambient file */ |
1024 |
– |
if (vdef(AMBFILE)) { |
1025 |
– |
long afdate = fdate(vval(AMBFILE)); |
1026 |
– |
if (afdate >= 0 & octreedate > afdate) |
1027 |
– |
rmfile(vval(AMBFILE)); |
1028 |
– |
} |
1053 |
|
/* do each view */ |
1054 |
|
vn = 0; |
1055 |
|
while ((vw = getview(vn++, vs)) != NULL) { |
1057 |
|
sprintf(vs, "%d", vn); |
1058 |
|
sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs); |
1059 |
|
/* check date on picture */ |
1060 |
< |
if (fdate(picfile) > octreedate) |
1060 |
> |
if (fdate(picfile) >= octreedate) |
1061 |
|
continue; |
1062 |
|
/* build rpict command */ |
1063 |
|
sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs); |
1064 |
< |
if (fdate(rawfile) > octreedate) /* recover */ |
1064 |
> |
if (fdate(rawfile) >= octreedate) /* recover */ |
1065 |
|
sprintf(combuf, "rpict%s%s -ro %s %s", |
1066 |
|
rep, opts, rawfile, vval(OCTREE)); |
1067 |
|
else { |
1069 |
|
sprintf(combuf, |
1070 |
|
"rpict%s %s%s -x 64 -y 64 -ps 1 %s > %s", |
1071 |
|
rep, vw, opts, |
1072 |
< |
vval(OCTREE), rawfile); |
1072 |
> |
vval(OCTREE), overfile); |
1073 |
|
if (runcom(combuf)) { |
1074 |
|
fprintf(stderr, |
1075 |
< |
"%s: error in overture for view %s\n\t%s removed\n", |
1076 |
< |
progname, vs, rawfile); |
1053 |
< |
unlink(rawfile); |
1075 |
> |
"%s: error in overture for view %s\n", |
1076 |
> |
progname, vs); |
1077 |
|
exit(1); |
1078 |
|
} |
1079 |
+ |
#ifdef NIX |
1080 |
+ |
rmfile(overfile); |
1081 |
+ |
#endif |
1082 |
|
} |
1083 |
|
sprintf(combuf, "rpict%s %s %s%s %s > %s", |
1084 |
|
rep, vw, res, opts, |
1134 |
|
return(0); |
1135 |
|
return(unlink(fn)); |
1136 |
|
} |
1137 |
+ |
|
1138 |
+ |
|
1139 |
+ |
#ifdef MSDOS |
1140 |
+ |
setenv(vname, value) /* set an environment variable */ |
1141 |
+ |
char *vname, *value; |
1142 |
+ |
{ |
1143 |
+ |
register char *evp; |
1144 |
+ |
|
1145 |
+ |
evp = bmalloc(strlen(vname)+strlen(value)+2); |
1146 |
+ |
if (evp == NULL) |
1147 |
+ |
syserr(progname); |
1148 |
+ |
sprintf(evp, "%s=%s", vname, value); |
1149 |
+ |
if (putenv(evp) != 0) { |
1150 |
+ |
fprintf(stderr, "%s: out of environment space\n", progname); |
1151 |
+ |
exit(1); |
1152 |
+ |
} |
1153 |
+ |
if (!silent) |
1154 |
+ |
printf("set %s\n", evp); |
1155 |
+ |
} |
1156 |
+ |
#endif |
1157 |
|
|
1158 |
|
|
1159 |
|
badvalue(vc) /* report bad variable value and exit */ |