1 |
– |
/* Copyright (c) 1994 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* rv3.c - miscellaneous routines for rview. |
6 |
|
* |
7 |
< |
* 5/11/87 |
7 |
> |
* External symbols declared in rpaint.h |
8 |
|
*/ |
9 |
|
|
10 |
+ |
#include "copyright.h" |
11 |
+ |
|
12 |
|
#include "ray.h" |
13 |
|
|
15 |
– |
#include "octree.h" |
16 |
– |
|
14 |
|
#include "rpaint.h" |
15 |
|
|
16 |
|
#include "random.h" |
30 |
|
#endif |
31 |
|
|
32 |
|
|
33 |
+ |
int |
34 |
|
getrect(s, r) /* get a box */ |
35 |
|
char *s; |
36 |
|
register RECT *r; |
77 |
|
} |
78 |
|
|
79 |
|
|
80 |
+ |
int |
81 |
|
getinterest(s, direc, vec, mp) /* get area of interest */ |
82 |
|
char *s; |
83 |
|
int direc; |
142 |
|
} |
143 |
|
|
144 |
|
|
145 |
+ |
void |
146 |
|
paint(p, xmin, ymin, xmax, ymax) /* compute and paint a rectangle */ |
147 |
|
register PNODE *p; |
148 |
|
int xmin, ymin, xmax, ymax; |
149 |
|
{ |
150 |
– |
extern unsigned long nrays; |
150 |
|
static unsigned long lastflush = 0; |
151 |
|
static RAY thisray; |
152 |
|
double h, v; |
184 |
|
} |
185 |
|
|
186 |
|
|
187 |
+ |
void |
188 |
|
newimage() /* start a new image */ |
189 |
|
{ |
190 |
|
/* free old image */ |
205 |
|
} |
206 |
|
|
207 |
|
|
208 |
+ |
void |
209 |
|
redraw() /* redraw the image */ |
210 |
|
{ |
211 |
|
(*dev->clear)(hresolu, vresolu); |
215 |
|
} |
216 |
|
|
217 |
|
|
218 |
+ |
void |
219 |
|
repaint(xmin, ymin, xmax, ymax) /* repaint a region */ |
220 |
|
int xmin, ymin, xmax, ymax; |
221 |
|
{ |
228 |
|
} |
229 |
|
|
230 |
|
|
231 |
+ |
void |
232 |
|
paintrect(p, xmin, ymin, xmax, ymax, r) /* paint picture rectangle */ |
233 |
|
register PNODE *p; |
234 |
|
int xmin, ymin, xmax, ymax; |
299 |
|
} |
300 |
|
|
301 |
|
|
302 |
+ |
void |
303 |
|
scalepict(p, sf) /* scale picture values */ |
304 |
|
register PNODE *p; |
305 |
|
double sf; |
316 |
|
} |
317 |
|
|
318 |
|
|
319 |
+ |
void |
320 |
|
getpictcolrs(yoff, scan, p, xsiz, ysiz) /* get scanline from picture */ |
321 |
|
int yoff; |
322 |
|
register COLR *scan; |
347 |
|
} |
348 |
|
|
349 |
|
|
350 |
< |
pcopy(p1, p2) /* copy paint node p1 into p2 */ |
346 |
< |
register PNODE *p1, *p2; |
347 |
< |
{ |
348 |
< |
copycolor(p2->v, p1->v); |
349 |
< |
p2->x = p1->x; |
350 |
< |
p2->y = p1->y; |
351 |
< |
} |
352 |
< |
|
353 |
< |
|
350 |
> |
void |
351 |
|
freepkids(p) /* free pnode's children */ |
352 |
|
register PNODE *p; |
353 |
|
{ |
357 |
|
freepkids(p->kid+DR); |
358 |
|
freepkids(p->kid+UL); |
359 |
|
freepkids(p->kid+UR); |
360 |
< |
free((char *)p->kid); |
360 |
> |
free((void *)p->kid); |
361 |
|
p->kid = NULL; |
362 |
|
} |
363 |
|
|
364 |
|
|
365 |
+ |
void |
366 |
|
newview(vp) /* change viewing parameters */ |
367 |
|
register VIEW *vp; |
368 |
|
{ |
379 |
|
} |
380 |
|
|
381 |
|
|
382 |
+ |
void |
383 |
|
moveview(angle, elev, mag, vc) /* move viewpoint */ |
384 |
|
double angle, elev, mag; |
385 |
|
FVECT vc; |
409 |
|
nv.horiz = ourview.horiz; |
410 |
|
nv.vert = ourview.vert; |
411 |
|
d = sqrt(dist2(ourview.vp, vc)) / mag; |
412 |
< |
nv.vfore = ourview.vfore + d - d*mag; |
413 |
< |
if (nv.vfore < 0.0) nv.vfore = 0.0; |
414 |
< |
nv.vaft = ourview.vaft + d - d*mag; |
415 |
< |
if (nv.vaft < nv.vfore) nv.vaft = 0.0; |
412 |
> |
if ((nv.vfore = ourview.vfore) > FTINY) { |
413 |
> |
nv.vfore += d - d*mag; |
414 |
> |
if (nv.vfore < 0.0) nv.vfore = 0.0; |
415 |
> |
} |
416 |
> |
if ((nv.vaft = ourview.vaft) > FTINY) { |
417 |
> |
nv.vaft += d - d*mag; |
418 |
> |
if (nv.vaft <= nv.vfore) nv.vaft = 0.0; |
419 |
> |
} |
420 |
|
} |
421 |
|
for (i = 0; i < 3; i++) |
422 |
|
nv.vp[i] = vc[i] - d*nv.vdir[i]; |
424 |
|
} |
425 |
|
|
426 |
|
|
427 |
< |
zoomview(vp, zf) /* zoom in our out */ |
427 |
> |
void |
428 |
> |
pcopy(p1, p2) /* copy paint node p1 into p2 */ |
429 |
> |
register PNODE *p1, *p2; |
430 |
> |
{ |
431 |
> |
copycolor(p2->v, p1->v); |
432 |
> |
p2->x = p1->x; |
433 |
> |
p2->y = p1->y; |
434 |
> |
} |
435 |
> |
|
436 |
> |
|
437 |
> |
void |
438 |
> |
zoomview(vp, zf) /* zoom in or out */ |
439 |
|
register VIEW *vp; |
440 |
|
double zf; |
441 |
|
{ |
442 |
|
switch (vp->type) { |
443 |
|
case VT_PAR: /* parallel view */ |
444 |
+ |
vp->horiz /= zf; |
445 |
+ |
vp->vert /= zf; |
446 |
+ |
return; |
447 |
|
case VT_ANG: /* angular fisheye */ |
448 |
|
vp->horiz /= zf; |
449 |
+ |
if (vp->horiz > 360.) |
450 |
+ |
vp->horiz = 360.; |
451 |
|
vp->vert /= zf; |
452 |
+ |
if (vp->vert > 360.) |
453 |
+ |
vp->vert = 360.; |
454 |
+ |
return; |
455 |
+ |
case VT_CYL: /* cylindrical panorama */ |
456 |
+ |
vp->horiz /= zf; |
457 |
+ |
if (vp->horiz > 360.) |
458 |
+ |
vp->horiz = 360.; |
459 |
+ |
vp->vert = atan(tan(vp->vert*(PI/180./2.))/zf) / (PI/180./2.); |
460 |
|
return; |
461 |
|
case VT_PER: /* perspective view */ |
462 |
|
vp->horiz = atan(tan(vp->horiz*(PI/180./2.))/zf) / |