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 "ray.h" |
10 |
> |
#include "copyright.h" |
11 |
|
|
12 |
< |
#include "octree.h" |
12 |
> |
#include <string.h> |
13 |
|
|
14 |
+ |
#include "ray.h" |
15 |
|
#include "rpaint.h" |
18 |
– |
|
16 |
|
#include "random.h" |
17 |
|
|
18 |
|
#ifndef WFLUSH |
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; |
125 |
|
} else if (direc) |
126 |
|
for (i = 0; i < 3; i++) |
127 |
|
vec[i] -= ourview.vp[i]; |
128 |
+ |
if (normalize(vec) == 0.0) |
129 |
+ |
return(-1); |
130 |
|
return(0); |
131 |
|
} |
132 |
|
|
144 |
|
} |
145 |
|
|
146 |
|
|
147 |
+ |
void |
148 |
|
paint(p, xmin, ymin, xmax, ymax) /* compute and paint a rectangle */ |
149 |
|
register PNODE *p; |
150 |
|
int xmin, ymin, xmax, ymax; |
151 |
|
{ |
150 |
– |
extern unsigned long nrays; |
152 |
|
static unsigned long lastflush = 0; |
153 |
|
static RAY thisray; |
154 |
|
double h, v; |
186 |
|
} |
187 |
|
|
188 |
|
|
189 |
+ |
void |
190 |
|
newimage() /* start a new image */ |
191 |
|
{ |
192 |
|
/* free old image */ |
207 |
|
} |
208 |
|
|
209 |
|
|
210 |
+ |
void |
211 |
|
redraw() /* redraw the image */ |
212 |
|
{ |
213 |
|
(*dev->clear)(hresolu, vresolu); |
217 |
|
} |
218 |
|
|
219 |
|
|
220 |
+ |
void |
221 |
|
repaint(xmin, ymin, xmax, ymax) /* repaint a region */ |
222 |
|
int xmin, ymin, xmax, ymax; |
223 |
|
{ |
230 |
|
} |
231 |
|
|
232 |
|
|
233 |
+ |
void |
234 |
|
paintrect(p, xmin, ymin, xmax, ymax, r) /* paint picture rectangle */ |
235 |
|
register PNODE *p; |
236 |
|
int xmin, ymin, xmax, ymax; |
301 |
|
} |
302 |
|
|
303 |
|
|
304 |
+ |
void |
305 |
|
scalepict(p, sf) /* scale picture values */ |
306 |
|
register PNODE *p; |
307 |
|
double sf; |
318 |
|
} |
319 |
|
|
320 |
|
|
321 |
+ |
void |
322 |
|
getpictcolrs(yoff, scan, p, xsiz, ysiz) /* get scanline from picture */ |
323 |
|
int yoff; |
324 |
|
register COLR *scan; |
349 |
|
} |
350 |
|
|
351 |
|
|
352 |
< |
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 |
< |
|
352 |
> |
void |
353 |
|
freepkids(p) /* free pnode's children */ |
354 |
|
register PNODE *p; |
355 |
|
{ |
359 |
|
freepkids(p->kid+DR); |
360 |
|
freepkids(p->kid+UL); |
361 |
|
freepkids(p->kid+UR); |
362 |
< |
free((char *)p->kid); |
362 |
> |
free((void *)p->kid); |
363 |
|
p->kid = NULL; |
364 |
|
} |
365 |
|
|
366 |
|
|
367 |
+ |
void |
368 |
|
newview(vp) /* change viewing parameters */ |
369 |
|
register VIEW *vp; |
370 |
|
{ |
373 |
|
if ((err = setview(vp)) != NULL) { |
374 |
|
sprintf(errmsg, "view not set - %s", err); |
375 |
|
error(COMMAND, errmsg); |
376 |
< |
} else if (bcmp((char *)vp, (char *)&ourview, sizeof(VIEW))) { |
377 |
< |
copystruct(&oldview, &ourview); |
378 |
< |
copystruct(&ourview, vp); |
376 |
> |
} else if (memcmp((char *)vp, (char *)&ourview, sizeof(VIEW))) { |
377 |
> |
oldview = ourview; |
378 |
> |
ourview = *vp; |
379 |
|
newimage(); |
380 |
|
} |
381 |
|
} |
382 |
|
|
383 |
|
|
384 |
+ |
void |
385 |
|
moveview(angle, elev, mag, vc) /* move viewpoint */ |
386 |
|
double angle, elev, mag; |
387 |
|
FVECT vc; |
388 |
|
{ |
389 |
|
double d; |
390 |
|
FVECT v1; |
391 |
< |
VIEW nv; |
391 |
> |
VIEW nv = ourview; |
392 |
|
register int i; |
393 |
|
|
393 |
– |
VCOPY(nv.vup, ourview.vup); |
394 |
– |
nv.hoff = ourview.hoff; nv.voff = ourview.voff; |
394 |
|
spinvector(nv.vdir, ourview.vdir, ourview.vup, angle*(PI/180.)); |
395 |
|
if (elev != 0.0) { |
396 |
|
fcross(v1, ourview.vup, nv.vdir); |
403 |
|
d = 0.0; /* don't move closer */ |
404 |
|
for (i = 0; i < 3; i++) |
405 |
|
d += (vc[i] - ourview.vp[i])*ourview.vdir[i]; |
407 |
– |
nv.vfore = ourview.vfore; |
408 |
– |
nv.vaft = ourview.vaft; |
406 |
|
} else { |
410 |
– |
nv.horiz = ourview.horiz; |
411 |
– |
nv.vert = ourview.vert; |
407 |
|
d = sqrt(dist2(ourview.vp, vc)) / mag; |
408 |
|
if ((nv.vfore = ourview.vfore) > FTINY) { |
409 |
|
nv.vfore += d - d*mag; |
420 |
|
} |
421 |
|
|
422 |
|
|
423 |
+ |
void |
424 |
+ |
pcopy(p1, p2) /* copy paint node p1 into p2 */ |
425 |
+ |
register PNODE *p1, *p2; |
426 |
+ |
{ |
427 |
+ |
copycolor(p2->v, p1->v); |
428 |
+ |
p2->x = p1->x; |
429 |
+ |
p2->y = p1->y; |
430 |
+ |
} |
431 |
+ |
|
432 |
+ |
|
433 |
+ |
void |
434 |
|
zoomview(vp, zf) /* zoom in or out */ |
435 |
|
register VIEW *vp; |
436 |
|
double zf; |