| 75 |
|
FILE *fp; |
| 76 |
|
char buf[128]; |
| 77 |
|
char *fname, *getpath(); |
| 78 |
+ |
int change = 0; |
| 79 |
|
VIEW nv; |
| 80 |
|
|
| 81 |
|
if (sscanf(s, "%s", buf) == 1) { /* write parameters to a file */ |
| 95 |
|
(*dev->comout)(buf); |
| 96 |
|
(*dev->comin)(buf); |
| 97 |
|
if (buf[0] == CTRL(C)) return; |
| 98 |
< |
if (buf[0]) |
| 98 |
> |
if (buf[0] && buf[0] != ourview.type) { |
| 99 |
|
nv.type = buf[0]; |
| 100 |
< |
else |
| 100 |
> |
change++; |
| 101 |
> |
} else |
| 102 |
|
nv.type = ourview.type; |
| 103 |
|
sprintf(buf, "view point (%.6g %.6g %.6g): ", |
| 104 |
|
ourview.vp[0], ourview.vp[1], ourview.vp[2]); |
| 105 |
|
(*dev->comout)(buf); |
| 106 |
|
(*dev->comin)(buf); |
| 107 |
|
if (buf[0] == CTRL(C)) return; |
| 108 |
< |
if (sscanf(buf, "%lf %lf %lf", &nv.vp[0], &nv.vp[1], &nv.vp[2]) != 3) |
| 108 |
> |
if (sscanf(buf, "%lf %lf %lf", &nv.vp[0], &nv.vp[1], &nv.vp[2]) == 3) |
| 109 |
> |
change++; |
| 110 |
> |
else |
| 111 |
|
VCOPY(nv.vp, ourview.vp); |
| 112 |
|
sprintf(buf, "view direction (%.6g %.6g %.6g): ", |
| 113 |
|
ourview.vdir[0], ourview.vdir[1], ourview.vdir[2]); |
| 114 |
|
(*dev->comout)(buf); |
| 115 |
|
(*dev->comin)(buf); |
| 116 |
|
if (buf[0] == CTRL(C)) return; |
| 117 |
< |
if (sscanf(buf,"%lf %lf %lf",&nv.vdir[0],&nv.vdir[1],&nv.vdir[2]) != 3) |
| 117 |
> |
if (sscanf(buf,"%lf %lf %lf",&nv.vdir[0],&nv.vdir[1],&nv.vdir[2]) == 3) |
| 118 |
> |
change++; |
| 119 |
> |
else |
| 120 |
|
VCOPY(nv.vdir, ourview.vdir); |
| 121 |
|
sprintf(buf, "view up (%.6g %.6g %.6g): ", |
| 122 |
|
ourview.vup[0], ourview.vup[1], ourview.vup[2]); |
| 123 |
|
(*dev->comout)(buf); |
| 124 |
|
(*dev->comin)(buf); |
| 125 |
|
if (buf[0] == CTRL(C)) return; |
| 126 |
< |
if (sscanf(buf,"%lf %lf %lf",&nv.vup[0],&nv.vup[1],&nv.vup[2]) != 3) |
| 126 |
> |
if (sscanf(buf,"%lf %lf %lf",&nv.vup[0],&nv.vup[1],&nv.vup[2]) == 3) |
| 127 |
> |
change++; |
| 128 |
> |
else |
| 129 |
|
VCOPY(nv.vup, ourview.vup); |
| 130 |
|
sprintf(buf, "view horiz and vert size (%.6g %.6g): ", |
| 131 |
|
ourview.horiz, ourview.vert); |
| 132 |
|
(*dev->comout)(buf); |
| 133 |
|
(*dev->comin)(buf); |
| 134 |
|
if (buf[0] == CTRL(C)) return; |
| 135 |
< |
if (sscanf(buf, "%lf %lf", &nv.horiz, &nv.vert) != 2) { |
| 135 |
> |
if (sscanf(buf, "%lf %lf", &nv.horiz, &nv.vert) == 2) |
| 136 |
> |
change++; |
| 137 |
> |
else { |
| 138 |
|
nv.horiz = ourview.horiz; nv.vert = ourview.vert; |
| 139 |
|
} |
| 140 |
|
sprintf(buf, "x and y resolution (%d %d): ", |
| 142 |
|
(*dev->comout)(buf); |
| 143 |
|
(*dev->comin)(buf); |
| 144 |
|
if (buf[0] == CTRL(C)) return; |
| 145 |
< |
if (sscanf(buf, "%d %d", &nv.hresolu, &nv.vresolu) != 2) { |
| 145 |
> |
if (sscanf(buf, "%d %d", &nv.hresolu, &nv.vresolu) == 2) |
| 146 |
> |
change++; |
| 147 |
> |
else { |
| 148 |
|
nv.hresolu = ourview.hresolu; nv.vresolu = ourview.vresolu; |
| 149 |
|
} |
| 150 |
< |
newview(&nv); |
| 150 |
> |
if (change) |
| 151 |
> |
newview(&nv); |
| 152 |
|
} |
| 153 |
|
|
| 154 |
|
|
| 265 |
|
|
| 266 |
|
if (getinterest(s, 0, vc, &mag) < 0) |
| 267 |
|
return; |
| 268 |
< |
moveview(0.0, mag, vc); |
| 268 |
> |
moveview(0.0, 0.0, mag, vc); |
| 269 |
|
} |
| 270 |
|
|
| 271 |
|
|
| 272 |
|
getrotate(s) /* rotate camera */ |
| 273 |
|
char *s; |
| 274 |
|
{ |
| 275 |
< |
extern double normalize(); |
| 275 |
> |
extern double normalize(), tan(), atan(); |
| 276 |
|
VIEW nv; |
| 277 |
|
FVECT v1; |
| 278 |
< |
double angle, elev; |
| 278 |
> |
double angle, elev, zfact; |
| 279 |
|
|
| 280 |
< |
elev = 0.0; |
| 281 |
< |
if (sscanf(s, "%lf %lf", &angle, &elev) < 1) { |
| 280 |
> |
elev = 0.0; zfact = 1.0; |
| 281 |
> |
if (sscanf(s, "%lf %lf %lf", &angle, &elev, &zfact) < 1) { |
| 282 |
|
error(COMMAND, "missing angle"); |
| 283 |
|
return; |
| 284 |
|
} |
| 272 |
– |
nv.type = ourview.type; |
| 285 |
|
VCOPY(nv.vp, ourview.vp); |
| 286 |
|
VCOPY(nv.vup, ourview.vup); |
| 275 |
– |
nv.horiz = ourview.horiz; nv.vert = ourview.vert; |
| 287 |
|
nv.hresolu = ourview.hresolu; nv.vresolu = ourview.vresolu; |
| 288 |
|
spinvector(nv.vdir, ourview.vdir, ourview.vup, angle*(PI/180.)); |
| 289 |
|
if (elev != 0.0) { |
| 291 |
|
normalize(v1); |
| 292 |
|
spinvector(nv.vdir, nv.vdir, v1, elev*(PI/180.)); |
| 293 |
|
} |
| 294 |
+ |
if ((nv.type = ourview.type) == VT_PAR) { |
| 295 |
+ |
nv.horiz = ourview.horiz / zfact; |
| 296 |
+ |
nv.vert = ourview.vert / zfact; |
| 297 |
+ |
} else { |
| 298 |
+ |
nv.horiz = atan(tan(ourview.horiz*(PI/180./2.))/zfact) / |
| 299 |
+ |
(PI/180./2.); |
| 300 |
+ |
nv.vert = atan(tan(ourview.vert*(PI/180./2.))/zfact) / |
| 301 |
+ |
(PI/180./2.); |
| 302 |
+ |
} |
| 303 |
|
newview(&nv); |
| 304 |
|
} |
| 305 |
|
|
| 308 |
|
register char *s; |
| 309 |
|
{ |
| 310 |
|
FVECT vc; |
| 311 |
< |
double angle, mag; |
| 311 |
> |
double angle, elev, mag; |
| 312 |
|
|
| 313 |
< |
if (sscanf(s, "%lf", &angle) != 1) { |
| 313 |
> |
elev = 0.0; |
| 314 |
> |
if (sscanf(s, "%lf %lf", &angle, &elev) < 1) { |
| 315 |
|
error(COMMAND, "missing angle"); |
| 316 |
|
return; |
| 317 |
|
} |
| 318 |
< |
if (getinterest(sskip(s), 0, vc, &mag) < 0) |
| 318 |
> |
if (getinterest(sskip(sskip(s)), 0, vc, &mag) < 0) |
| 319 |
|
return; |
| 320 |
< |
moveview(angle, mag, vc); |
| 320 |
> |
moveview(angle, elev, mag, vc); |
| 321 |
|
} |
| 322 |
|
|
| 323 |
|
|
| 369 |
|
e *= atof(cp); |
| 370 |
|
} |
| 371 |
|
if (p != NULL) { /* relative setting */ |
| 372 |
< |
if (intens(p->v) <= FTINY) { |
| 372 |
> |
if (bright(p->v) <= FTINY) { |
| 373 |
|
error(COMMAND, "cannot normalize to zero"); |
| 374 |
|
return; |
| 375 |
|
} |
| 376 |
< |
e *= 0.5 / intens(p->v); |
| 376 |
> |
e *= 0.5 / bright(p->v); |
| 377 |
|
} |
| 378 |
|
if (e <= FTINY || fabs(1.0 - e) <= FTINY) |
| 379 |
|
return; |
| 391 |
|
extern double minweight; |
| 392 |
|
extern int maxdepth; |
| 393 |
|
extern double dstrsrc; |
| 394 |
+ |
extern double shadthresh; |
| 395 |
|
extern COLOR ambval; |
| 396 |
|
extern double ambacc; |
| 397 |
|
extern double minarad; |
| 404 |
|
char buf[128]; |
| 405 |
|
|
| 406 |
|
if (s[0] == '\0') { |
| 407 |
< |
(*dev->comout)("aa ab ad ar as av ds lr lw sd sp: "); |
| 407 |
> |
(*dev->comout)("aa ab ad ar as av dj dt lr lw sp st: "); |
| 408 |
|
(*dev->comin)(buf); |
| 409 |
|
s = buf; |
| 410 |
|
} |
| 437 |
|
goto badparam; |
| 438 |
|
} |
| 439 |
|
break; |
| 440 |
< |
case 'd': /* distribute source */ |
| 441 |
< |
if (s[1] != 's') |
| 440 |
> |
case 'd': /* direct */ |
| 441 |
> |
switch (s[1]) { |
| 442 |
> |
case 'j': /* jitter */ |
| 443 |
> |
if (sscanf(s+2, "%lf", &d0) != 1) { |
| 444 |
> |
sprintf(buf, "direct jitter (%.6g): ", |
| 445 |
> |
dstrsrc); |
| 446 |
> |
(*dev->comout)(buf); |
| 447 |
> |
(*dev->comin)(buf); |
| 448 |
> |
if (sscanf(buf, "%lf", &d0) != 1) |
| 449 |
> |
break; |
| 450 |
> |
} |
| 451 |
> |
dstrsrc = d0; |
| 452 |
> |
break; |
| 453 |
> |
case 't': /* threshold */ |
| 454 |
> |
if (sscanf(s+2, "%lf", &d0) != 1) { |
| 455 |
> |
sprintf(buf, "direct threshold (%.6g): ", |
| 456 |
> |
shadthresh); |
| 457 |
> |
(*dev->comout)(buf); |
| 458 |
> |
(*dev->comin)(buf); |
| 459 |
> |
if (sscanf(buf, "%lf", &d0) != 1) |
| 460 |
> |
break; |
| 461 |
> |
} |
| 462 |
> |
shadthresh = d0; |
| 463 |
> |
break; |
| 464 |
> |
default: |
| 465 |
|
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; |
| 466 |
|
} |
| 428 |
– |
dstrsrc = d0; |
| 467 |
|
break; |
| 468 |
|
case 'a': /* ambient */ |
| 469 |
|
switch (s[1]) { |
| 555 |
|
psample = i0; |
| 556 |
|
pdepth = 0; |
| 557 |
|
break; |
| 558 |
< |
case 'd': /* difference */ |
| 558 |
> |
case 't': /* threshold */ |
| 559 |
|
if (sscanf(s+2, "%lf", &d0) != 1) { |
| 560 |
< |
sprintf(buf, "sample difference (%.6g): ", |
| 560 |
> |
sprintf(buf, "sample threshold (%.6g): ", |
| 561 |
|
maxdiff); |
| 562 |
|
(*dev->comout)(buf); |
| 563 |
|
(*dev->comin)(buf); |