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; |
68 |
+ |
if (pframe.l > pframe.r) pframe.l = pframe.r; |
69 |
+ |
if (pframe.d > pframe.u) pframe.d = pframe.u; |
70 |
|
pdepth = 0; |
71 |
|
} |
72 |
|
|
77 |
|
FILE *fp; |
78 |
|
char buf[128]; |
79 |
|
char *fname, *getpath(); |
80 |
+ |
int change = 0; |
81 |
|
VIEW nv; |
82 |
|
|
83 |
|
if (sscanf(s, "%s", buf) == 1) { /* write parameters to a file */ |
87 |
|
error(COMMAND, errmsg); |
88 |
|
return; |
89 |
|
} |
90 |
< |
fputs(VIEWSTR, fp); |
90 |
> |
fputs(progname, fp); |
91 |
|
fprintview(&ourview, fp); |
92 |
|
fputs("\n", fp); |
93 |
|
fclose(fp); |
97 |
|
(*dev->comout)(buf); |
98 |
|
(*dev->comin)(buf); |
99 |
|
if (buf[0] == CTRL(C)) return; |
100 |
< |
if (buf[0]) |
100 |
> |
if (buf[0] && buf[0] != ourview.type) { |
101 |
|
nv.type = buf[0]; |
102 |
< |
else |
102 |
> |
change++; |
103 |
> |
} else |
104 |
|
nv.type = ourview.type; |
105 |
|
sprintf(buf, "view point (%.6g %.6g %.6g): ", |
106 |
|
ourview.vp[0], ourview.vp[1], ourview.vp[2]); |
107 |
|
(*dev->comout)(buf); |
108 |
|
(*dev->comin)(buf); |
109 |
|
if (buf[0] == CTRL(C)) return; |
110 |
< |
if (sscanf(buf, "%lf %lf %lf", &nv.vp[0], &nv.vp[1], &nv.vp[2]) != 3) |
110 |
> |
if (sscanf(buf, "%lf %lf %lf", &nv.vp[0], &nv.vp[1], &nv.vp[2]) == 3) |
111 |
> |
change++; |
112 |
> |
else |
113 |
|
VCOPY(nv.vp, ourview.vp); |
114 |
|
sprintf(buf, "view direction (%.6g %.6g %.6g): ", |
115 |
|
ourview.vdir[0], ourview.vdir[1], ourview.vdir[2]); |
116 |
|
(*dev->comout)(buf); |
117 |
|
(*dev->comin)(buf); |
118 |
|
if (buf[0] == CTRL(C)) return; |
119 |
< |
if (sscanf(buf,"%lf %lf %lf",&nv.vdir[0],&nv.vdir[1],&nv.vdir[2]) != 3) |
119 |
> |
if (sscanf(buf,"%lf %lf %lf",&nv.vdir[0],&nv.vdir[1],&nv.vdir[2]) == 3) |
120 |
> |
change++; |
121 |
> |
else |
122 |
|
VCOPY(nv.vdir, ourview.vdir); |
123 |
|
sprintf(buf, "view up (%.6g %.6g %.6g): ", |
124 |
|
ourview.vup[0], ourview.vup[1], ourview.vup[2]); |
125 |
|
(*dev->comout)(buf); |
126 |
|
(*dev->comin)(buf); |
127 |
|
if (buf[0] == CTRL(C)) return; |
128 |
< |
if (sscanf(buf,"%lf %lf %lf",&nv.vup[0],&nv.vup[1],&nv.vup[2]) != 3) |
128 |
> |
if (sscanf(buf,"%lf %lf %lf",&nv.vup[0],&nv.vup[1],&nv.vup[2]) == 3) |
129 |
> |
change++; |
130 |
> |
else |
131 |
|
VCOPY(nv.vup, ourview.vup); |
132 |
|
sprintf(buf, "view horiz and vert size (%.6g %.6g): ", |
133 |
|
ourview.horiz, ourview.vert); |
134 |
|
(*dev->comout)(buf); |
135 |
|
(*dev->comin)(buf); |
136 |
|
if (buf[0] == CTRL(C)) return; |
137 |
< |
if (sscanf(buf, "%lf %lf", &nv.horiz, &nv.vert) != 2) { |
137 |
> |
if (sscanf(buf, "%lf %lf", &nv.horiz, &nv.vert) == 2) |
138 |
> |
change++; |
139 |
> |
else { |
140 |
|
nv.horiz = ourview.horiz; nv.vert = ourview.vert; |
141 |
|
} |
142 |
|
sprintf(buf, "x and y resolution (%d %d): ", |
144 |
|
(*dev->comout)(buf); |
145 |
|
(*dev->comin)(buf); |
146 |
|
if (buf[0] == CTRL(C)) return; |
147 |
< |
if (sscanf(buf, "%d %d", &nv.hresolu, &nv.vresolu) != 2) { |
147 |
> |
if (sscanf(buf, "%d %d", &nv.hresolu, &nv.vresolu) == 2) |
148 |
> |
change++; |
149 |
> |
else { |
150 |
|
nv.hresolu = ourview.hresolu; nv.vresolu = ourview.vresolu; |
151 |
|
} |
152 |
< |
newview(&nv); |
152 |
> |
if (change) |
153 |
> |
newview(&nv); |
154 |
|
} |
155 |
|
|
156 |
|
|
267 |
|
|
268 |
|
if (getinterest(s, 0, vc, &mag) < 0) |
269 |
|
return; |
270 |
< |
moveview(0.0, mag, vc); |
270 |
> |
moveview(0.0, 0.0, mag, vc); |
271 |
|
} |
272 |
|
|
273 |
|
|
274 |
|
getrotate(s) /* rotate camera */ |
275 |
|
char *s; |
276 |
|
{ |
277 |
< |
extern double normalize(); |
277 |
> |
extern double normalize(), tan(), atan(); |
278 |
|
VIEW nv; |
279 |
|
FVECT v1; |
280 |
< |
double angle, elev; |
280 |
> |
double angle, elev, zfact; |
281 |
|
|
282 |
< |
elev = 0.0; |
283 |
< |
if (sscanf(s, "%lf %lf", &angle, &elev) < 1) { |
282 |
> |
elev = 0.0; zfact = 1.0; |
283 |
> |
if (sscanf(s, "%lf %lf %lf", &angle, &elev, &zfact) < 1) { |
284 |
|
error(COMMAND, "missing angle"); |
285 |
|
return; |
286 |
|
} |
272 |
– |
nv.type = ourview.type; |
287 |
|
VCOPY(nv.vp, ourview.vp); |
288 |
|
VCOPY(nv.vup, ourview.vup); |
275 |
– |
nv.horiz = ourview.horiz; nv.vert = ourview.vert; |
289 |
|
nv.hresolu = ourview.hresolu; nv.vresolu = ourview.vresolu; |
290 |
|
spinvector(nv.vdir, ourview.vdir, ourview.vup, angle*(PI/180.)); |
291 |
|
if (elev != 0.0) { |
293 |
|
normalize(v1); |
294 |
|
spinvector(nv.vdir, nv.vdir, v1, elev*(PI/180.)); |
295 |
|
} |
296 |
+ |
if ((nv.type = ourview.type) == VT_PAR) { |
297 |
+ |
nv.horiz = ourview.horiz / zfact; |
298 |
+ |
nv.vert = ourview.vert / zfact; |
299 |
+ |
} else { |
300 |
+ |
nv.horiz = atan(tan(ourview.horiz*(PI/180./2.))/zfact) / |
301 |
+ |
(PI/180./2.); |
302 |
+ |
nv.vert = atan(tan(ourview.vert*(PI/180./2.))/zfact) / |
303 |
+ |
(PI/180./2.); |
304 |
+ |
} |
305 |
|
newview(&nv); |
306 |
|
} |
307 |
|
|
310 |
|
register char *s; |
311 |
|
{ |
312 |
|
FVECT vc; |
313 |
< |
double angle, mag; |
313 |
> |
double angle, elev, mag; |
314 |
|
|
315 |
< |
if (sscanf(s, "%lf", &angle) != 1) { |
315 |
> |
elev = 0.0; |
316 |
> |
if (sscanf(s, "%lf %lf", &angle, &elev) < 1) { |
317 |
|
error(COMMAND, "missing angle"); |
318 |
|
return; |
319 |
|
} |
320 |
< |
if (getinterest(sskip(s), 0, vc, &mag) < 0) |
320 |
> |
if (getinterest(sskip(sskip(s)), 0, vc, &mag) < 0) |
321 |
|
return; |
322 |
< |
moveview(angle, mag, vc); |
322 |
> |
moveview(angle, elev, mag, vc); |
323 |
|
} |
324 |
|
|
325 |
|
|
371 |
|
e *= atof(cp); |
372 |
|
} |
373 |
|
if (p != NULL) { /* relative setting */ |
374 |
< |
if (intens(p->v) <= FTINY) { |
374 |
> |
if (bright(p->v) <= FTINY) { |
375 |
|
error(COMMAND, "cannot normalize to zero"); |
376 |
|
return; |
377 |
|
} |
378 |
< |
e *= 0.5 / intens(p->v); |
378 |
> |
e *= 0.5 / bright(p->v); |
379 |
|
} |
380 |
|
if (e <= FTINY || fabs(1.0 - e) <= FTINY) |
381 |
|
return; |
393 |
|
extern double minweight; |
394 |
|
extern int maxdepth; |
395 |
|
extern double dstrsrc; |
396 |
+ |
extern double shadthresh; |
397 |
+ |
extern double shadcert; |
398 |
|
extern COLOR ambval; |
399 |
|
extern double ambacc; |
400 |
|
extern double minarad; |
407 |
|
char buf[128]; |
408 |
|
|
409 |
|
if (s[0] == '\0') { |
410 |
< |
(*dev->comout)("aa ab ad ar as av ds lr lw sd sp: "); |
410 |
> |
(*dev->comout)("aa ab ad ar as av dc dj dt lr lw sp st: "); |
411 |
|
(*dev->comin)(buf); |
412 |
|
s = buf; |
413 |
|
} |
440 |
|
goto badparam; |
441 |
|
} |
442 |
|
break; |
443 |
< |
case 'd': /* distribute source */ |
444 |
< |
if (s[1] != 's') |
443 |
> |
case 'd': /* direct */ |
444 |
> |
switch (s[1]) { |
445 |
> |
case 'j': /* jitter */ |
446 |
> |
if (sscanf(s+2, "%lf", &d0) != 1) { |
447 |
> |
sprintf(buf, "direct jitter (%.6g): ", |
448 |
> |
dstrsrc); |
449 |
> |
(*dev->comout)(buf); |
450 |
> |
(*dev->comin)(buf); |
451 |
> |
if (sscanf(buf, "%lf", &d0) != 1) |
452 |
> |
break; |
453 |
> |
} |
454 |
> |
dstrsrc = d0; |
455 |
> |
break; |
456 |
> |
case 'c': /* certainty */ |
457 |
> |
if (sscanf(s+2, "%lf", &d0) != 1) { |
458 |
> |
sprintf(buf, "direct certainty (%.6g): ", |
459 |
> |
shadcert); |
460 |
> |
(*dev->comout)(buf); |
461 |
> |
(*dev->comin)(buf); |
462 |
> |
if (sscanf(buf, "%lf", &d0) != 1) |
463 |
> |
break; |
464 |
> |
} |
465 |
> |
shadcert = d0; |
466 |
> |
break; |
467 |
> |
case 't': /* threshold */ |
468 |
> |
if (sscanf(s+2, "%lf", &d0) != 1) { |
469 |
> |
sprintf(buf, "direct threshold (%.6g): ", |
470 |
> |
shadthresh); |
471 |
> |
(*dev->comout)(buf); |
472 |
> |
(*dev->comin)(buf); |
473 |
> |
if (sscanf(buf, "%lf", &d0) != 1) |
474 |
> |
break; |
475 |
> |
} |
476 |
> |
shadthresh = d0; |
477 |
> |
break; |
478 |
> |
default: |
479 |
|
goto badparam; |
421 |
– |
if (sscanf(s+2, "%lf", &d0) != 1) { |
422 |
– |
sprintf(buf, "distribute source (%.6g): ", dstrsrc); |
423 |
– |
(*dev->comout)(buf); |
424 |
– |
(*dev->comin)(buf); |
425 |
– |
if (sscanf(buf, "%lf", &d0) != 1) |
426 |
– |
break; |
480 |
|
} |
428 |
– |
dstrsrc = d0; |
481 |
|
break; |
482 |
|
case 'a': /* ambient */ |
483 |
|
switch (s[1]) { |
569 |
|
psample = i0; |
570 |
|
pdepth = 0; |
571 |
|
break; |
572 |
< |
case 'd': /* difference */ |
572 |
> |
case 't': /* threshold */ |
573 |
|
if (sscanf(s+2, "%lf", &d0) != 1) { |
574 |
< |
sprintf(buf, "sample difference (%.6g): ", |
574 |
> |
sprintf(buf, "sample threshold (%.6g): ", |
575 |
|
maxdiff); |
576 |
|
(*dev->comout)(buf); |
577 |
|
(*dev->comin)(buf); |