28 |
|
getframe(s) /* get a new frame */ |
29 |
|
char *s; |
30 |
|
{ |
31 |
< |
int x0, y0, x1, y1; |
32 |
< |
|
33 |
< |
if (!strcmp("all", s)) { |
34 |
< |
pframe.l = pframe.d = 0; |
35 |
< |
pframe.r = ourview.hresolu; |
36 |
< |
pframe.u = ourview.vresolu; |
37 |
< |
pdepth = 0; |
31 |
> |
if (getrect(s, &pframe) < 0) |
32 |
|
return; |
39 |
– |
} |
40 |
– |
if (sscanf(s, "%d %d %d %d", &x0, &y0, &x1, &y1) != 4) { |
41 |
– |
if (dev->getcur == NULL) |
42 |
– |
return; |
43 |
– |
(*dev->comout)("Pick first corner\n"); |
44 |
– |
if ((*dev->getcur)(&x0, &y0) == ABORT) |
45 |
– |
return; |
46 |
– |
(*dev->comout)("Pick second corner\n"); |
47 |
– |
if ((*dev->getcur)(&x1, &y1) == ABORT) |
48 |
– |
return; |
49 |
– |
} |
50 |
– |
if (x0 < x1) { |
51 |
– |
pframe.l = x0; |
52 |
– |
pframe.r = x1; |
53 |
– |
} else { |
54 |
– |
pframe.l = x1; |
55 |
– |
pframe.r = x0; |
56 |
– |
} |
57 |
– |
if (y0 < y1) { |
58 |
– |
pframe.d = y0; |
59 |
– |
pframe.u = y1; |
60 |
– |
} else { |
61 |
– |
pframe.d = y1; |
62 |
– |
pframe.u = y0; |
63 |
– |
} |
64 |
– |
if (pframe.l < 0) pframe.l = 0; |
65 |
– |
if (pframe.d < 0) pframe.d = 0; |
66 |
– |
if (pframe.r > ourview.hresolu) pframe.r = ourview.hresolu; |
67 |
– |
if (pframe.u > ourview.vresolu) pframe.u = ourview.vresolu; |
33 |
|
pdepth = 0; |
34 |
|
} |
35 |
|
|
36 |
|
|
37 |
+ |
getrepaint(s) /* get area and repaint */ |
38 |
+ |
char *s; |
39 |
+ |
{ |
40 |
+ |
RECT box; |
41 |
+ |
|
42 |
+ |
if (getrect(s, &box) < 0) |
43 |
+ |
return; |
44 |
+ |
paintrect(&ptrunk, 0, 0, ourview.hresolu, ourview.vresolu, &box); |
45 |
+ |
} |
46 |
+ |
|
47 |
+ |
|
48 |
|
getview(s) /* get/show view parameters */ |
49 |
|
char *s; |
50 |
|
{ |
51 |
|
FILE *fp; |
52 |
|
char buf[128]; |
53 |
< |
char *fname, *getpath(); |
53 |
> |
char *fname; |
54 |
|
int change = 0; |
55 |
|
VIEW nv; |
56 |
|
|
57 |
|
if (sscanf(s, "%s", buf) == 1) { /* write parameters to a file */ |
58 |
< |
if ((fname = getpath(buf, NULL)) == NULL || |
58 |
> |
if ((fname = getpath(buf, NULL, 0)) == NULL || |
59 |
|
(fp = fopen(fname, "a")) == NULL) { |
60 |
|
sprintf(errmsg, "cannot open \"%s\"", buf); |
61 |
|
error(COMMAND, errmsg); |
132 |
|
char *s; |
133 |
|
{ |
134 |
|
char buf[128]; |
135 |
< |
char *fname, *getpath(); |
135 |
> |
char *fname; |
136 |
|
int success; |
137 |
|
VIEW nv; |
138 |
|
|
139 |
|
if (sscanf(s, "%s", buf) == 1) { /* get parameters from a file */ |
140 |
|
bcopy(&stdview, &nv, sizeof(VIEW)); |
141 |
< |
if ((fname = getpath(buf, NULL)) == NULL || |
141 |
> |
if ((fname = getpath(buf, NULL, 0)) == NULL || |
142 |
|
(success = viewfile(fname, &nv)) == -1) { |
143 |
|
sprintf(errmsg, "cannot open \"%s\"", buf); |
144 |
|
error(COMMAND, errmsg); |
161 |
|
} |
162 |
|
|
163 |
|
|
188 |
– |
getinterest(s, direc, vec, mp) /* get area of interest */ |
189 |
– |
char *s; |
190 |
– |
int direc; |
191 |
– |
FVECT vec; |
192 |
– |
double *mp; |
193 |
– |
{ |
194 |
– |
int x, y; |
195 |
– |
RAY thisray; |
196 |
– |
register int i; |
197 |
– |
|
198 |
– |
if (sscanf(s, "%lf", mp) != 1) |
199 |
– |
*mp = 1.0; |
200 |
– |
else if (*mp < -FTINY) /* negative zoom is reduction */ |
201 |
– |
*mp = -1.0 / *mp; |
202 |
– |
else if (*mp <= FTINY) { /* too small */ |
203 |
– |
error(COMMAND, "illegal magnification"); |
204 |
– |
return(-1); |
205 |
– |
} |
206 |
– |
if (sscanf(s, "%*lf %lf %lf %lf", &vec[0], &vec[1], &vec[2]) != 3) { |
207 |
– |
if (dev->getcur == NULL) |
208 |
– |
return(-1); |
209 |
– |
(*dev->comout)("Pick view center\n"); |
210 |
– |
if ((*dev->getcur)(&x, &y) == ABORT) |
211 |
– |
return(-1); |
212 |
– |
rayview(thisray.rorg, thisray.rdir, &ourview, x+.5, y+.5); |
213 |
– |
if (!direc || ourview.type == VT_PAR) { |
214 |
– |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
215 |
– |
if (!localhit(&thisray, &thescene)) { |
216 |
– |
error(COMMAND, "not a local object"); |
217 |
– |
return(-1); |
218 |
– |
} |
219 |
– |
} |
220 |
– |
if (direc) |
221 |
– |
if (ourview.type == VT_PAR) |
222 |
– |
for (i = 0; i < 3; i++) |
223 |
– |
vec[i] = thisray.rop[i] - ourview.vp[i]; |
224 |
– |
else |
225 |
– |
VCOPY(vec, thisray.rdir); |
226 |
– |
else |
227 |
– |
VCOPY(vec, thisray.rop); |
228 |
– |
} else if (direc) |
229 |
– |
for (i = 0; i < 3; i++) |
230 |
– |
vec[i] -= ourview.vp[i]; |
231 |
– |
return(0); |
232 |
– |
} |
233 |
– |
|
234 |
– |
|
164 |
|
getaim(s) /* aim camera */ |
165 |
|
char *s; |
166 |
|
{ |
321 |
|
extern int maxdepth; |
322 |
|
extern double dstrsrc; |
323 |
|
extern double shadthresh; |
324 |
+ |
extern double shadcert; |
325 |
|
extern COLOR ambval; |
326 |
|
extern double ambacc; |
327 |
|
extern double minarad; |
334 |
|
char buf[128]; |
335 |
|
|
336 |
|
if (s[0] == '\0') { |
337 |
< |
(*dev->comout)("aa ab ad ar as av dj dt lr lw sd sp: "); |
337 |
> |
(*dev->comout)("aa ab ad ar as av dc dj dt lr lw sp st: "); |
338 |
|
(*dev->comin)(buf); |
339 |
|
s = buf; |
340 |
|
} |
380 |
|
} |
381 |
|
dstrsrc = d0; |
382 |
|
break; |
383 |
+ |
case 'c': /* certainty */ |
384 |
+ |
if (sscanf(s+2, "%lf", &d0) != 1) { |
385 |
+ |
sprintf(buf, "direct certainty (%.6g): ", |
386 |
+ |
shadcert); |
387 |
+ |
(*dev->comout)(buf); |
388 |
+ |
(*dev->comin)(buf); |
389 |
+ |
if (sscanf(buf, "%lf", &d0) != 1) |
390 |
+ |
break; |
391 |
+ |
} |
392 |
+ |
shadcert = d0; |
393 |
+ |
break; |
394 |
|
case 't': /* threshold */ |
395 |
|
if (sscanf(s+2, "%lf", &d0) != 1) { |
396 |
|
sprintf(buf, "direct threshold (%.6g): ", |
496 |
|
psample = i0; |
497 |
|
pdepth = 0; |
498 |
|
break; |
499 |
< |
case 'd': /* difference */ |
499 |
> |
case 't': /* threshold */ |
500 |
|
if (sscanf(s+2, "%lf", &d0) != 1) { |
501 |
< |
sprintf(buf, "sample difference (%.6g): ", |
501 |
> |
sprintf(buf, "sample threshold (%.6g): ", |
502 |
|
maxdiff); |
503 |
|
(*dev->comout)(buf); |
504 |
|
(*dev->comin)(buf); |
582 |
|
char *s; |
583 |
|
{ |
584 |
|
static char buf[128]; |
585 |
< |
char *fname, *getpath(); |
585 |
> |
char *fname; |
586 |
|
FILE *fp; |
587 |
|
COLR *scanline; |
588 |
|
int y; |
591 |
|
error(COMMAND, "no file"); |
592 |
|
return; |
593 |
|
} |
594 |
< |
if ((fname = getpath(buf, NULL)) == NULL || |
594 |
> |
if ((fname = getpath(buf, NULL, 0)) == NULL || |
595 |
|
(fp = fopen(fname, "w")) == NULL) { |
596 |
|
sprintf(errmsg, "cannot open \"%s\"", buf); |
597 |
|
error(COMMAND, errmsg); |
603 |
|
/* write header */ |
604 |
|
fputs(progname, fp); |
605 |
|
fprintview(&ourview, fp); |
606 |
< |
fputs("\n", fp); |
606 |
> |
putc('\n', fp); |
607 |
|
if (exposure != 1.0) |
608 |
|
fprintf(fp, "EXPOSURE=%e\n", exposure); |
609 |
< |
fprintf(fp, "\n-Y %d +X %d\n", ourview.vresolu, ourview.hresolu); |
609 |
> |
putc('\n', fp); |
610 |
> |
fputresolu(YMAJOR|YDECR, ourview.hresolu, ourview.vresolu, fp); |
611 |
|
|
612 |
|
scanline = (COLR *)malloc(ourview.hresolu*sizeof(COLR)); |
613 |
|
if (scanline == NULL) |