93 |
|
(*dev->comout)("Pick view center\n"); |
94 |
|
if ((*dev->getcur)(&x, &y) == ABORT) |
95 |
|
return(-1); |
96 |
< |
viewray(thisray.rorg, thisray.rdir, &ourview, |
97 |
< |
(x+.5)/hresolu, (y+.5)/vresolu); |
96 |
> |
if (viewray(thisray.rorg, thisray.rdir, &ourview, |
97 |
> |
(x+.5)/hresolu, (y+.5)/vresolu) < 0) { |
98 |
> |
error(COMMAND, "not on image"); |
99 |
> |
return(-1); |
100 |
> |
} |
101 |
|
if (!direc || ourview.type == VT_PAR) { |
102 |
|
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
103 |
|
if (!localhit(&thisray, &thescene)) { |
152 |
|
h = xmin + (xmax-xmin)*frandom(); |
153 |
|
v = ymin + (ymax-ymin)*frandom(); |
154 |
|
|
155 |
< |
viewray(thisray.rorg, thisray.rdir, &ourview, h/hresolu, v/vresolu); |
156 |
< |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
157 |
< |
rayvalue(&thisray); |
155 |
> |
if (viewray(thisray.rorg, thisray.rdir, &ourview, |
156 |
> |
h/hresolu, v/vresolu) < 0) { |
157 |
> |
setcolor(thisray.rcol, 0.0, 0.0, 0.0); |
158 |
> |
} else { |
159 |
> |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
160 |
> |
rayvalue(&thisray); |
161 |
> |
} |
162 |
|
|
163 |
|
p->x = h; |
164 |
|
p->y = v; |
400 |
|
for (i = 0; i < 3; i++) |
401 |
|
nv.vp[i] = vc[i] - d*nv.vdir[i]; |
402 |
|
newview(&nv); |
403 |
+ |
} |
404 |
+ |
|
405 |
+ |
|
406 |
+ |
zoomview(vp, zf) /* zoom in our out */ |
407 |
+ |
register VIEW *vp; |
408 |
+ |
double zf; |
409 |
+ |
{ |
410 |
+ |
switch (vp->type) { |
411 |
+ |
case VT_PAR: /* parallel view */ |
412 |
+ |
case VT_ANG: /* angular fisheye */ |
413 |
+ |
vp->horiz /= zf; |
414 |
+ |
vp->vert /= zf; |
415 |
+ |
return; |
416 |
+ |
case VT_PER: /* perspective view */ |
417 |
+ |
vp->horiz = atan(tan(vp->horiz*(PI/180./2.))/zf) / |
418 |
+ |
(PI/180./2.); |
419 |
+ |
vp->vert = atan(tan(vp->vert*(PI/180./2.))/zf) / |
420 |
+ |
(PI/180./2.); |
421 |
+ |
return; |
422 |
+ |
case VT_HEM: /* hemispherical fisheye */ |
423 |
+ |
vp->horiz = sin(vp->horiz*(PI/180./2.))/zf; |
424 |
+ |
if (vp->horiz >= 1.0-FTINY) |
425 |
+ |
vp->horiz = 180.; |
426 |
+ |
else |
427 |
+ |
vp->horiz = asin(vp->horiz) / (PI/180./2.); |
428 |
+ |
vp->vert = sin(vp->vert*(PI/180./2.))/zf; |
429 |
+ |
if (vp->vert >= 1.0-FTINY) |
430 |
+ |
vp->vert = 180.; |
431 |
+ |
else |
432 |
+ |
vp->vert = asin(vp->vert) / (PI/180./2.); |
433 |
+ |
return; |
434 |
+ |
} |
435 |
|
} |
436 |
|
|
437 |
|
|