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 |
|
|
117 |
|
int overture = 0; /* overture calculation needed */ |
118 |
|
|
119 |
|
char *progname; /* global argv[0] */ |
120 |
+ |
char *rifname; /* global rad input file name */ |
121 |
|
|
122 |
|
char radname[MAXPATH]; /* root Radiance file name */ |
123 |
|
|
145 |
|
case 'o': |
146 |
|
rvdevice = argv[++i]; |
147 |
|
break; |
148 |
+ |
case 'V': |
149 |
+ |
sayview++; |
150 |
+ |
break; |
151 |
|
case 'v': |
152 |
|
viewselect = argv[++i]; |
153 |
|
break; |
156 |
|
} |
157 |
|
if (i >= argc) |
158 |
|
goto userr; |
159 |
+ |
rifname = argv[i]; |
160 |
|
/* assign Radiance root file name */ |
161 |
< |
rootname(radname, argv[i]); |
161 |
> |
rootname(radname, rifname); |
162 |
|
/* load variable values */ |
163 |
< |
load(argv[i]); |
163 |
> |
load(rifname); |
164 |
|
/* get any additional assignments */ |
165 |
|
for (i++; i < argc; i++) |
166 |
|
setvariable(argv[i]); |
208 |
|
} |
209 |
|
|
210 |
|
|
211 |
+ |
#define NOCHAR 127 /* constant for character to delete */ |
212 |
+ |
|
213 |
+ |
|
214 |
|
load(rfname) /* load Radiance simulation file */ |
215 |
|
char *rfname; |
216 |
|
{ |
226 |
|
for (cp = buf; *cp; cp++) { |
227 |
|
switch (*cp) { |
228 |
|
case '\\': |
229 |
< |
case '\n': |
220 |
< |
*cp = ' '; |
229 |
> |
*cp++ = NOCHAR; |
230 |
|
continue; |
231 |
|
case '#': |
232 |
|
*cp = '\0'; |
246 |
|
register char *ass; |
247 |
|
{ |
248 |
|
char varname[32]; |
249 |
+ |
char varval[512]; |
250 |
+ |
int n; |
251 |
|
register char *cp; |
252 |
|
register VARIABLE *vp; |
253 |
|
register int i; |
243 |
– |
int n; |
254 |
|
|
255 |
|
while (isspace(*ass)) /* skip leading space */ |
256 |
|
ass++; |
264 |
|
/* trim value */ |
265 |
|
while (isspace(*ass) || *ass == '=') |
266 |
|
ass++; |
267 |
< |
cp = ass + strlen(ass); |
268 |
< |
do |
269 |
< |
*cp-- = '\0'; |
260 |
< |
while (cp >= ass && isspace(*cp)); |
261 |
< |
n = cp - ass + 1; |
267 |
> |
for (n = strlen(ass); n > 0; n--) |
268 |
> |
if (!isspace(ass[n-1])) |
269 |
> |
break; |
270 |
|
if (!n) { |
271 |
|
fprintf(stderr, "%s: warning - missing value for variable '%s'\n", |
272 |
|
progname, varname); |
291 |
|
vp->value = malloc(n+1); |
292 |
|
if (vp->value == NULL) |
293 |
|
syserr(progname); |
294 |
< |
strcpy(vp->value+i, ass); |
294 |
> |
cp = vp->value+i; /* copy value, squeezing spaces */ |
295 |
> |
*cp = *ass; |
296 |
> |
for (i = 1; i <= n; i++) { |
297 |
> |
if (ass[i] == NOCHAR) |
298 |
> |
continue; |
299 |
> |
if (isspace(*cp)) |
300 |
> |
while (isspace(ass[i])) |
301 |
> |
i++; |
302 |
> |
*++cp = ass[i]; |
303 |
> |
} |
304 |
> |
*++cp = '\0'; |
305 |
|
vp->nass++; |
306 |
|
} |
307 |
|
|
327 |
|
{ |
328 |
|
register char *cp; |
329 |
|
|
330 |
< |
if (vp == NULL || n < 0 || n >= vp->nass) |
330 |
> |
if (vp == NULL | n < 0 | n >= vp->nass) |
331 |
|
return(NULL); |
332 |
|
cp = vp->value; |
333 |
|
while (n--) |
441 |
|
vnam(OCTREE), vnam(SCENE)); |
442 |
|
exit(1); |
443 |
|
} |
444 |
+ |
matdate = -1; |
445 |
+ |
if (vdef(MATERIAL)) |
446 |
+ |
matdate = checklast(vval(MATERIAL)); |
447 |
|
} |
448 |
|
|
449 |
|
|
582 |
|
{ |
583 |
|
long afdate; |
584 |
|
|
585 |
< |
if (vdef(AMBFILE)) { |
586 |
< |
afdate = fdate(vval(AMBFILE)); |
587 |
< |
if (afdate >= 0 & octreedate > afdate) |
588 |
< |
rmfile(vval(AMBFILE)); |
589 |
< |
} |
585 |
> |
if (!vdef(AMBFILE)) |
586 |
> |
return; |
587 |
> |
if ((afdate = fdate(vval(AMBFILE))) < 0) |
588 |
> |
return; |
589 |
> |
if (octreedate > afdate | matdate > afdate) |
590 |
> |
rmfile(vval(AMBFILE)); |
591 |
|
} |
592 |
|
|
593 |
|
|
595 |
|
ambval() /* compute ambient value */ |
596 |
|
{ |
597 |
|
if (vdef(EXPOSURE)) { |
598 |
+ |
if (!isflt(vval(EXPOSURE))) |
599 |
+ |
badvalue(EXPOSURE); |
600 |
|
if (vval(EXPOSURE)[0] == '+' || vval(EXPOSURE)[0] == '-') |
601 |
|
return(.5/pow(2.,atof(vval(EXPOSURE)))); |
602 |
< |
if (isdigit(vval(EXPOSURE)[0]) || vval(EXPOSURE)[0] == '.') |
579 |
< |
return(.5/atof(vval(EXPOSURE))); |
580 |
< |
badvalue(EXPOSURE); |
602 |
> |
return(.5/atof(vval(EXPOSURE))); |
603 |
|
} |
604 |
|
if (vlet(ZONE) == 'E') |
605 |
|
return(10.); |
623 |
|
d *= 3./(siz[0]+siz[1]+siz[2]); |
624 |
|
switch (vscale(DETAIL)) { |
625 |
|
case LOW: |
626 |
< |
op = addarg(op, "-ps 16 -dp 16"); |
626 |
> |
op = addarg(op, "-ps 16 -dp 64"); |
627 |
|
sprintf(op, " -ar %d", (int)(4*d)); |
628 |
|
op += strlen(op); |
629 |
|
break; |
630 |
|
case MEDIUM: |
631 |
< |
op = addarg(op, "-ps 8 -dp 32"); |
631 |
> |
op = addarg(op, "-ps 8 -dp 128"); |
632 |
|
sprintf(op, " -ar %d", (int)(8*d)); |
633 |
|
op += strlen(op); |
634 |
|
break; |
635 |
|
case HIGH: |
636 |
< |
op = addarg(op, "-ps 4 -dp 64"); |
636 |
> |
op = addarg(op, "-ps 4 -dp 256"); |
637 |
|
sprintf(op, " -ar %d", (int)(16*d)); |
638 |
|
op += strlen(op); |
639 |
|
break; |
643 |
|
op = addarg(op, "-ds .4"); |
644 |
|
else |
645 |
|
op = addarg(op, "-ds 0"); |
646 |
< |
op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .7"); |
646 |
> |
op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .5"); |
647 |
|
if (vdef(AMBFILE)) { |
648 |
|
sprintf(op, " -af %s", vval(AMBFILE)); |
649 |
|
op += strlen(op); |
651 |
|
overture = 0; |
652 |
|
switch (vscale(VARIABILITY)) { |
653 |
|
case LOW: |
654 |
< |
op = addarg(op, "-aa .4 -ad 32"); |
654 |
> |
op = addarg(op, "-aa .4 -ad 64"); |
655 |
|
break; |
656 |
|
case MEDIUM: |
657 |
< |
op = addarg(op, "-aa .3 -ad 64"); |
657 |
> |
op = addarg(op, "-aa .3 -ad 128"); |
658 |
|
break; |
659 |
|
case HIGH: |
660 |
< |
op = addarg(op, "-aa .25 -ad 128"); |
660 |
> |
op = addarg(op, "-aa .25 -ad 256"); |
661 |
|
break; |
662 |
|
} |
663 |
|
op = addarg(op, "-as 0"); |
685 |
|
switch (vscale(DETAIL)) { |
686 |
|
case LOW: |
687 |
|
op = addarg(op, vbool(PENUMBRAS) ? "-ps 4" : "-ps 8"); |
688 |
< |
op = addarg(op, "-dp 64"); |
688 |
> |
op = addarg(op, "-dp 256"); |
689 |
|
sprintf(op, " -ar %d", (int)(8*d)); |
690 |
|
op += strlen(op); |
691 |
|
break; |
692 |
|
case MEDIUM: |
693 |
|
op = addarg(op, vbool(PENUMBRAS) ? "-ps 3" : "-ps 6"); |
694 |
< |
op = addarg(op, "-dp 128"); |
694 |
> |
op = addarg(op, "-dp 512"); |
695 |
|
sprintf(op, " -ar %d", (int)(16*d)); |
696 |
|
op += strlen(op); |
697 |
|
break; |
698 |
|
case HIGH: |
699 |
|
op = addarg(op, vbool(PENUMBRAS) ? "-ps 2" : "-ps 4"); |
700 |
< |
op = addarg(op, "-dp 256"); |
700 |
> |
op = addarg(op, "-dp 1024"); |
701 |
|
sprintf(op, " -ar %d", (int)(32*d)); |
702 |
|
op += strlen(op); |
703 |
|
break; |
707 |
|
op = addarg(op, "-ds .2 -dj .35"); |
708 |
|
else |
709 |
|
op = addarg(op, "-ds .3"); |
710 |
< |
op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .15"); |
710 |
> |
op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1"); |
711 |
|
if (overture = vint(INDIRECT)) { |
712 |
|
sprintf(op, " -ab %d", overture); |
713 |
|
op += strlen(op); |
719 |
|
overture = 0; |
720 |
|
switch (vscale(VARIABILITY)) { |
721 |
|
case LOW: |
722 |
< |
op = addarg(op, "-aa .25 -ad 128 -as 0"); |
722 |
> |
op = addarg(op, "-aa .25 -ad 196 -as 0"); |
723 |
|
break; |
724 |
|
case MEDIUM: |
725 |
< |
op = addarg(op, "-aa .2 -ad 300 -as 64"); |
725 |
> |
op = addarg(op, "-aa .2 -ad 400 -as 64"); |
726 |
|
break; |
727 |
|
case HIGH: |
728 |
< |
op = addarg(op, "-aa .15 -ad 500 -as 128"); |
728 |
> |
op = addarg(op, "-aa .15 -ad 768 -as 196"); |
729 |
|
break; |
730 |
|
} |
731 |
|
d = ambval(); |
752 |
|
switch (vscale(DETAIL)) { |
753 |
|
case LOW: |
754 |
|
op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 8"); |
755 |
< |
op = addarg(op, "-dp 256"); |
755 |
> |
op = addarg(op, "-dp 1024"); |
756 |
|
sprintf(op, " -ar %d", (int)(16*d)); |
757 |
|
op += strlen(op); |
758 |
|
break; |
759 |
|
case MEDIUM: |
760 |
|
op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 5"); |
761 |
< |
op = addarg(op, "-dp 512"); |
761 |
> |
op = addarg(op, "-dp 2048"); |
762 |
|
sprintf(op, " -ar %d", (int)(32*d)); |
763 |
|
op += strlen(op); |
764 |
|
break; |
765 |
|
case HIGH: |
766 |
|
op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 3"); |
767 |
< |
op = addarg(op, "-dp 1024"); |
767 |
> |
op = addarg(op, "-dp 4096"); |
768 |
|
sprintf(op, " -ar %d", (int)(64*d)); |
769 |
|
op += strlen(op); |
770 |
|
break; |
774 |
|
op = addarg(op, "-ds .1 -dj .7"); |
775 |
|
else |
776 |
|
op = addarg(op, "-ds .2"); |
777 |
< |
op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .03"); |
777 |
> |
op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01"); |
778 |
|
sprintf(op, " -ab %d", overture=vint(INDIRECT)+1); |
779 |
|
op += strlen(op); |
780 |
|
if (vdef(AMBFILE)) { |
784 |
|
overture = 0; |
785 |
|
switch (vscale(VARIABILITY)) { |
786 |
|
case LOW: |
787 |
< |
op = addarg(op, "-aa .15 -ad 200 -as 0"); |
787 |
> |
op = addarg(op, "-aa .15 -ad 256 -as 0"); |
788 |
|
break; |
789 |
|
case MEDIUM: |
790 |
< |
op = addarg(op, "-aa .125 -ad 512 -as 128"); |
790 |
> |
op = addarg(op, "-aa .125 -ad 512 -as 256"); |
791 |
|
break; |
792 |
|
case HIGH: |
793 |
< |
op = addarg(op, "-aa .08 -ad 850 -as 256"); |
793 |
> |
op = addarg(op, "-aa .08 -ad 1024 -as 512"); |
794 |
|
break; |
795 |
|
} |
796 |
|
d = ambval(); |
806 |
|
char *ro; |
807 |
|
{ |
808 |
|
int fd, n; |
809 |
+ |
register char *cp; |
810 |
|
|
811 |
|
n = strlen(ro); |
812 |
|
if (n < 2) |
813 |
|
return; |
814 |
|
if (vdef(OPTFILE)) { |
815 |
< |
if ((fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1) |
815 |
> |
for (cp = ro; cp[1]; cp++) |
816 |
> |
if (isspace(cp[1]) && cp[2] == '-' && isalpha(cp[3])) |
817 |
> |
*cp = '\n'; |
818 |
> |
else |
819 |
> |
*cp = cp[1]; |
820 |
> |
*cp = '\n'; |
821 |
> |
fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666); |
822 |
> |
if (fd < 0 || write(fd, ro, n) != n || close(fd) < 0) |
823 |
|
syserr(vval(OPTFILE)); |
824 |
< |
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)); |
824 |
> |
sprintf(ro, " @%s", vval(OPTFILE)); |
825 |
|
} |
826 |
|
#ifdef MSDOS |
827 |
|
else if (n > 50) { |
840 |
|
po = addarg(po, "-1 -e"); |
841 |
|
po = addarg(po, vval(EXPOSURE)); |
842 |
|
} |
843 |
< |
if (vscale(QUALITY) == HIGH) |
844 |
< |
po = addarg(po, "-r .65"); |
843 |
> |
switch (vscale(QUALITY)) { |
844 |
> |
case MEDIUM: |
845 |
> |
po = addarg(po, "-r 1"); |
846 |
> |
break; |
847 |
> |
case HIGH: |
848 |
> |
po = addarg(po, "-m .25"); |
849 |
> |
break; |
850 |
> |
} |
851 |
|
if (vdef(PFILT)) |
852 |
|
po = addarg(po, vval(PFILT)); |
853 |
|
} |
987 |
|
int n; |
988 |
|
char *vn; /* returned view name */ |
989 |
|
{ |
990 |
< |
register char *mv = NULL; |
990 |
> |
register char *mv; |
991 |
|
|
992 |
|
if (viewselect != NULL) { /* command-line selected */ |
993 |
|
if (n) /* only do one */ |
1002 |
|
; |
1003 |
|
*vn = '\0'; |
1004 |
|
} |
1005 |
+ |
/* view number? */ |
1006 |
+ |
if (isint(viewselect)) |
1007 |
+ |
return(specview(nvalue(vv+VIEW, atoi(viewselect)-1))); |
1008 |
|
/* check list */ |
1009 |
|
while ((mv = nvalue(vv+VIEW, n++)) != NULL) |
1010 |
|
if (matchword(viewselect, mv)) |
1013 |
|
} |
1014 |
|
mv = nvalue(vv+VIEW, n); /* use view n */ |
1015 |
|
if (vn != NULL & mv != NULL) { |
1016 |
< |
if (*mv != '-') |
1017 |
< |
while (*mv && !isspace(*mv)) |
1018 |
< |
*vn++ = *mv++; |
1016 |
> |
register char *mv2 = mv; |
1017 |
> |
if (*mv2 != '-') |
1018 |
> |
while (*mv2 && !isspace(*mv2)) |
1019 |
> |
*vn++ = *mv2++; |
1020 |
|
*vn = '\0'; |
1021 |
|
} |
1022 |
|
return(specview(mv)); |
1023 |
|
} |
1024 |
|
|
1025 |
|
|
1026 |
+ |
printview(vopts) /* print out selected view */ |
1027 |
+ |
register char *vopts; |
1028 |
+ |
{ |
1029 |
+ |
extern char *atos(), *getenv(); |
1030 |
+ |
char buf[256]; |
1031 |
+ |
FILE *fp; |
1032 |
+ |
register char *cp; |
1033 |
+ |
|
1034 |
+ |
if (vopts == NULL) |
1035 |
+ |
return(-1); |
1036 |
+ |
fputs("VIEW=", stdout); |
1037 |
+ |
do { |
1038 |
+ |
if (matchword(vopts, "-vf")) { /* expand view file */ |
1039 |
+ |
vopts = sskip(vopts); |
1040 |
+ |
if (!*atos(buf, sizeof(buf), vopts)) |
1041 |
+ |
return(-1); |
1042 |
+ |
if ((fp = fopen(buf, "r")) == NULL) |
1043 |
+ |
return(-1); |
1044 |
+ |
for (buf[sizeof(buf)-2] = '\n'; |
1045 |
+ |
fgets(buf, sizeof(buf), fp) != NULL && |
1046 |
+ |
buf[0] != '\n'; |
1047 |
+ |
buf[sizeof(buf)-2] = '\n') { |
1048 |
+ |
if (buf[sizeof(buf)-2] != '\n') { |
1049 |
+ |
ungetc(buf[sizeof(buf)-2], fp); |
1050 |
+ |
buf[sizeof(buf)-2] = '\0'; |
1051 |
+ |
} |
1052 |
+ |
if (matchword(buf, "VIEW=") || |
1053 |
+ |
matchword(buf, "rview")) { |
1054 |
+ |
for (cp = sskip(buf); *cp && *cp != '\n'; cp++) |
1055 |
+ |
putchar(*cp); |
1056 |
+ |
} |
1057 |
+ |
} |
1058 |
+ |
fclose(fp); |
1059 |
+ |
vopts = sskip(vopts); |
1060 |
+ |
} else { |
1061 |
+ |
while (isspace(*vopts)) |
1062 |
+ |
vopts++; |
1063 |
+ |
putchar(' '); |
1064 |
+ |
#ifdef MSDOS |
1065 |
+ |
if (*vopts == '$') { /* expand env. var. */ |
1066 |
+ |
if (!*atos(buf, sizeof(buf), vopts+1)) |
1067 |
+ |
return(-1); |
1068 |
+ |
if ((cp = getenv(buf)) == NULL) |
1069 |
+ |
return(-1); |
1070 |
+ |
fputs(cp, stdout); |
1071 |
+ |
vopts = sskip(vopts); |
1072 |
+ |
} else |
1073 |
+ |
#endif |
1074 |
+ |
while (*vopts && !isspace(*vopts)) |
1075 |
+ |
putchar(*vopts++); |
1076 |
+ |
} |
1077 |
+ |
} while (*vopts++); |
1078 |
+ |
putchar('\n'); |
1079 |
+ |
return(0); |
1080 |
+ |
} |
1081 |
+ |
|
1082 |
+ |
|
1083 |
|
rview(opts) /* run rview with first view */ |
1084 |
|
char *opts; |
1085 |
|
{ |
1086 |
+ |
char *vw; |
1087 |
|
char combuf[512]; |
1088 |
|
/* build command */ |
1089 |
< |
sprintf(combuf, "rview %s%s ", getview(0, NULL), opts); |
1089 |
> |
if ((vw = getview(0, NULL)) == NULL) |
1090 |
> |
return; |
1091 |
> |
if (sayview) |
1092 |
> |
printview(vw); |
1093 |
> |
sprintf(combuf, "rview %s%s -R %s ", vw, opts, rifname); |
1094 |
|
if (rvdevice != NULL) |
1095 |
|
sprintf(combuf+strlen(combuf), "-o %s ", rvdevice); |
1096 |
|
strcat(combuf, vval(OCTREE)); |
1109 |
|
char pfopts[128]; |
1110 |
|
char vs[32], *vw; |
1111 |
|
int vn, mult; |
1112 |
+ |
long lastdate; |
1113 |
|
/* get pfilt options */ |
1114 |
|
pfiltopts(pfopts); |
1115 |
|
/* get resolution, reporting */ |
1140 |
|
else |
1141 |
|
badvalue(REPORT); |
1142 |
|
} |
1143 |
+ |
/* get update time */ |
1144 |
+ |
lastdate = octreedate > matdate ? octreedate : matdate; |
1145 |
|
/* do each view */ |
1146 |
|
vn = 0; |
1147 |
|
while ((vw = getview(vn++, vs)) != NULL) { |
1148 |
+ |
if (sayview) |
1149 |
+ |
printview(vw); |
1150 |
|
if (!vs[0]) |
1151 |
|
sprintf(vs, "%d", vn); |
1152 |
|
sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs); |
1153 |
|
/* check date on picture */ |
1154 |
< |
if (fdate(picfile) > octreedate) |
1154 |
> |
if (fdate(picfile) >= lastdate) |
1155 |
|
continue; |
1156 |
|
/* build rpict command */ |
1157 |
|
sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs); |
1158 |
< |
if (fdate(rawfile) > octreedate) /* recover */ |
1158 |
> |
if (fdate(rawfile) >= octreedate) /* recover */ |
1159 |
|
sprintf(combuf, "rpict%s%s -ro %s %s", |
1160 |
|
rep, opts, rawfile, vval(OCTREE)); |
1161 |
|
else { |