1 |
< |
/* Copyright (c) 1987 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1994 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
19 |
|
#include "random.h" |
20 |
|
|
21 |
|
#ifndef WFLUSH |
22 |
< |
#define WFLUSH 30 /* flush after this many rays */ |
22 |
> |
#ifdef SPEED |
23 |
> |
#define WFLUSH (5*SPEED) |
24 |
> |
#else |
25 |
> |
#define WFLUSH 100 /* flush after this many rays */ |
26 |
|
#endif |
27 |
+ |
#endif |
28 |
|
|
29 |
|
#ifdef SMLFLT |
30 |
|
#define sscanvec(s,v) (sscanf(s,"%f %f %f",v,v+1,v+2)==3) |
103 |
|
(*dev->comout)("Pick view center\n"); |
104 |
|
if ((*dev->getcur)(&x, &y) == ABORT) |
105 |
|
return(-1); |
106 |
< |
if (viewray(thisray.rorg, thisray.rdir, &ourview, |
107 |
< |
(x+.5)/hresolu, (y+.5)/vresolu) < 0) { |
106 |
> |
if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir, |
107 |
> |
&ourview, (x+.5)/hresolu, (y+.5)/vresolu)) < -FTINY) { |
108 |
|
error(COMMAND, "not on image"); |
109 |
|
return(-1); |
110 |
|
} |
147 |
|
register PNODE *p; |
148 |
|
int xmin, ymin, xmax, ymax; |
149 |
|
{ |
150 |
< |
extern long nrays; |
151 |
< |
static long lastflush = 0; |
150 |
> |
extern unsigned long nrays; |
151 |
> |
static unsigned long lastflush = 0; |
152 |
|
static RAY thisray; |
153 |
|
double h, v; |
154 |
|
|
162 |
|
h = xmin + (xmax-xmin)*frandom(); |
163 |
|
v = ymin + (ymax-ymin)*frandom(); |
164 |
|
|
165 |
< |
if (viewray(thisray.rorg, thisray.rdir, &ourview, |
166 |
< |
h/hresolu, v/vresolu) < 0) { |
165 |
> |
if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir, &ourview, |
166 |
> |
h/hresolu, v/vresolu)) < -FTINY) { |
167 |
|
setcolor(thisray.rcol, 0.0, 0.0, 0.0); |
168 |
|
} else { |
169 |
|
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
385 |
|
double angle, elev, mag; |
386 |
|
FVECT vc; |
387 |
|
{ |
384 |
– |
extern double sqrt(), dist2(); |
388 |
|
double d; |
389 |
|
FVECT v1; |
390 |
|
VIEW nv; |
404 |
|
d = 0.0; /* don't move closer */ |
405 |
|
for (i = 0; i < 3; i++) |
406 |
|
d += (vc[i] - ourview.vp[i])*ourview.vdir[i]; |
407 |
+ |
nv.vfore = ourview.vfore; |
408 |
+ |
nv.vaft = ourview.vaft; |
409 |
|
} else { |
410 |
|
nv.horiz = ourview.horiz; |
411 |
|
nv.vert = ourview.vert; |
412 |
|
d = sqrt(dist2(ourview.vp, vc)) / mag; |
413 |
+ |
if ((nv.vfore = ourview.vfore) > FTINY) { |
414 |
+ |
nv.vfore += d - d*mag; |
415 |
+ |
if (nv.vfore < 0.0) nv.vfore = 0.0; |
416 |
+ |
} |
417 |
+ |
if ((nv.vaft = ourview.vaft) > FTINY) { |
418 |
+ |
nv.vaft += d - d*mag; |
419 |
+ |
if (nv.vaft <= nv.vfore) nv.vaft = 0.0; |
420 |
+ |
} |
421 |
|
} |
422 |
|
for (i = 0; i < 3; i++) |
423 |
|
nv.vp[i] = vc[i] - d*nv.vdir[i]; |
425 |
|
} |
426 |
|
|
427 |
|
|
428 |
< |
zoomview(vp, zf) /* zoom in our out */ |
428 |
> |
zoomview(vp, zf) /* zoom in or out */ |
429 |
|
register VIEW *vp; |
430 |
|
double zf; |
431 |
|
{ |
432 |
|
switch (vp->type) { |
433 |
|
case VT_PAR: /* parallel view */ |
434 |
+ |
vp->horiz /= zf; |
435 |
+ |
vp->vert /= zf; |
436 |
+ |
return; |
437 |
|
case VT_ANG: /* angular fisheye */ |
438 |
|
vp->horiz /= zf; |
439 |
+ |
if (vp->horiz > 360.) |
440 |
+ |
vp->horiz = 360.; |
441 |
|
vp->vert /= zf; |
442 |
+ |
if (vp->vert > 360.) |
443 |
+ |
vp->vert = 360.; |
444 |
+ |
return; |
445 |
+ |
case VT_CYL: /* cylindrical panorama */ |
446 |
+ |
vp->horiz /= zf; |
447 |
+ |
if (vp->horiz > 360.) |
448 |
+ |
vp->horiz = 360.; |
449 |
+ |
vp->vert = atan(tan(vp->vert*(PI/180./2.))/zf) / (PI/180./2.); |
450 |
|
return; |
451 |
|
case VT_PER: /* perspective view */ |
452 |
|
vp->horiz = atan(tan(vp->horiz*(PI/180./2.))/zf) / |