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)) { |
141 |
|
static long lastflush = 0; |
142 |
|
static RAY thisray; |
143 |
|
double h, v; |
141 |
– |
register int i; |
144 |
|
|
145 |
|
if (xmax - xmin <= 0 || ymax - ymin <= 0) { /* empty */ |
146 |
|
p->x = xmin; |
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 |
> |
samplendx++; |
161 |
> |
rayvalue(&thisray); |
162 |
> |
} |
163 |
|
|
164 |
|
p->x = h; |
165 |
|
p->y = v; |
179 |
|
{ |
180 |
|
/* free old image */ |
181 |
|
freepkids(&ptrunk); |
182 |
+ |
/* save reserve memory */ |
183 |
+ |
fillreserves(); |
184 |
|
/* compute resolution */ |
185 |
|
hresolu = dev->xsiz; |
186 |
|
vresolu = dev->ysiz; |
406 |
|
} |
407 |
|
|
408 |
|
|
409 |
< |
spinvector(vres, vorig, vnorm, theta) /* rotate vector around normal */ |
410 |
< |
FVECT vres, vorig, vnorm; |
411 |
< |
double theta; |
409 |
> |
zoomview(vp, zf) /* zoom in our out */ |
410 |
> |
register VIEW *vp; |
411 |
> |
double zf; |
412 |
|
{ |
413 |
< |
extern double sin(), cos(); |
414 |
< |
double sint, cost, dotp; |
415 |
< |
FVECT vperp; |
416 |
< |
register int i; |
417 |
< |
|
409 |
< |
if (theta == 0.0) { |
410 |
< |
VCOPY(vres, vorig); |
413 |
> |
switch (vp->type) { |
414 |
> |
case VT_PAR: /* parallel view */ |
415 |
> |
case VT_ANG: /* angular fisheye */ |
416 |
> |
vp->horiz /= zf; |
417 |
> |
vp->vert /= zf; |
418 |
|
return; |
419 |
+ |
case VT_PER: /* perspective view */ |
420 |
+ |
vp->horiz = atan(tan(vp->horiz*(PI/180./2.))/zf) / |
421 |
+ |
(PI/180./2.); |
422 |
+ |
vp->vert = atan(tan(vp->vert*(PI/180./2.))/zf) / |
423 |
+ |
(PI/180./2.); |
424 |
+ |
return; |
425 |
+ |
case VT_HEM: /* hemispherical fisheye */ |
426 |
+ |
vp->horiz = sin(vp->horiz*(PI/180./2.))/zf; |
427 |
+ |
if (vp->horiz >= 1.0-FTINY) |
428 |
+ |
vp->horiz = 180.; |
429 |
+ |
else |
430 |
+ |
vp->horiz = asin(vp->horiz) / (PI/180./2.); |
431 |
+ |
vp->vert = sin(vp->vert*(PI/180./2.))/zf; |
432 |
+ |
if (vp->vert >= 1.0-FTINY) |
433 |
+ |
vp->vert = 180.; |
434 |
+ |
else |
435 |
+ |
vp->vert = asin(vp->vert) / (PI/180./2.); |
436 |
+ |
return; |
437 |
|
} |
413 |
– |
sint = sin(theta); |
414 |
– |
cost = cos(theta); |
415 |
– |
dotp = DOT(vorig, vnorm); |
416 |
– |
fcross(vperp, vnorm, vorig); |
417 |
– |
for (i = 0; i < 3; i++) |
418 |
– |
vres[i] = vnorm[i]*dotp*(1.-cost) + |
419 |
– |
vorig[i]*cost + vperp[i]*sint; |
438 |
|
} |