| 1 |
gwlarson |
3.1 |
/* Copyright (c) 1999 Silicon Graphics, Inc. */
|
| 2 |
|
|
|
| 3 |
|
|
#ifndef lint
|
| 4 |
|
|
static char SCCSid[] = "$SunId$ SGI";
|
| 5 |
|
|
#endif
|
| 6 |
|
|
|
| 7 |
|
|
/*
|
| 8 |
|
|
* Rendering routines for rhpict.
|
| 9 |
|
|
*/
|
| 10 |
|
|
|
| 11 |
|
|
#include "holo.h"
|
| 12 |
|
|
#include "view.h"
|
| 13 |
|
|
|
| 14 |
|
|
extern VIEW myview; /* current output view */
|
| 15 |
|
|
extern COLOR *mypixel; /* pixels being rendered */
|
| 16 |
|
|
extern float *myweight; /* weights (used to compute final pixels) */
|
| 17 |
|
|
extern int hres, vres; /* current horizontal and vertical res. */
|
| 18 |
|
|
|
| 19 |
|
|
|
| 20 |
|
|
render_beam(bp, hb) /* render a particular beam */
|
| 21 |
|
|
BEAM *bp;
|
| 22 |
|
|
register HDBEAMI *hb;
|
| 23 |
|
|
{
|
| 24 |
|
|
GCOORD gc[2];
|
| 25 |
|
|
register RAYVAL *rv;
|
| 26 |
|
|
FVECT rorg, rdir, wp, ip;
|
| 27 |
|
|
double d, prox;
|
| 28 |
|
|
COLOR col;
|
| 29 |
|
|
int n, p;
|
| 30 |
|
|
|
| 31 |
|
|
if (!hdbcoord(gc, hb->h, hb->b))
|
| 32 |
|
|
error(CONSISTENCY, "bad beam in render_beam");
|
| 33 |
|
|
for (n = bp->nrm, rv = hdbray(bp); n--; rv++) {
|
| 34 |
|
|
/* reproject each sample */
|
| 35 |
|
|
hdray(rorg, rdir, hb->h, gc, rv->r);
|
| 36 |
|
|
if (rv->d < DCINF) {
|
| 37 |
|
|
d = hddepth(hb->h, rv->d);
|
| 38 |
|
|
VSUM(wp, rorg, rdir, d);
|
| 39 |
|
|
VSUB(ip, wp, myview.vp);
|
| 40 |
|
|
d = DOT(ip,rdir);
|
| 41 |
|
|
prox = 1. - d*d/DOT(ip,ip); /* sin(diff_angle)^2 */
|
| 42 |
|
|
} else {
|
| 43 |
|
|
if (myview.type == VT_PAR || myview.vaft > FTINY)
|
| 44 |
|
|
continue; /* inf. off view */
|
| 45 |
|
|
VSUM(wp, myview.vp, rdir, FHUGE);
|
| 46 |
|
|
prox = 0.;
|
| 47 |
|
|
}
|
| 48 |
|
|
viewloc(ip, &myview, wp); /* frustum clipping */
|
| 49 |
|
|
if (ip[2] < 0.)
|
| 50 |
|
|
continue;
|
| 51 |
|
|
if (ip[0] < 0. || ip[0] >= 1.)
|
| 52 |
|
|
continue;
|
| 53 |
|
|
if (ip[1] < 0. || ip[1] >= 1.)
|
| 54 |
|
|
continue;
|
| 55 |
|
|
if (myview.vaft > FTINY && ip[2] > myview.vaft - myview.vfore)
|
| 56 |
|
|
continue;
|
| 57 |
|
|
/* we're in! */
|
| 58 |
|
|
p = (int)(ip[1]*vres)*hres + (int)(ip[0]*hres);
|
| 59 |
|
|
colr_color(col, rv->v);
|
| 60 |
|
|
addcolor(mypixel[p], col);
|
| 61 |
|
|
myweight[p] += 1.0;
|
| 62 |
|
|
}
|
| 63 |
|
|
}
|