| 1 |
gregl |
3.1 |
/* Copyright (c) 1997 Silicon Graphics, Inc. */ |
| 2 |
|
|
|
| 3 |
|
|
#ifndef lint |
| 4 |
|
|
static char SCCSid[] = "$SunId$ SGI"; |
| 5 |
|
|
#endif |
| 6 |
|
|
|
| 7 |
|
|
/* |
| 8 |
|
|
* Rtrace support routines for holodeck rendering |
| 9 |
|
|
*/ |
| 10 |
|
|
|
| 11 |
|
|
#include "rholo.h" |
| 12 |
|
|
#include "random.h" |
| 13 |
|
|
|
| 14 |
|
|
|
| 15 |
|
|
packrays(rod, p) /* pack ray origins and directions */ |
| 16 |
|
|
register float *rod; |
| 17 |
|
|
register PACKET *p; |
| 18 |
|
|
{ |
| 19 |
|
|
static FVECT ro, rd; |
| 20 |
|
|
BCOORD gc; |
| 21 |
|
|
double d; |
| 22 |
|
|
register int i; |
| 23 |
|
|
|
| 24 |
|
|
if (!hdbcoord(gc, hdlist[p->hd], p->bi)) |
| 25 |
|
|
error(CONSISTENCY, "bad beam index in packrays"); |
| 26 |
|
|
for (i = 0; i < p->nr; i++) { |
| 27 |
|
|
*(long *)p->ra[i].r = random()<<16 ^ random(); |
| 28 |
|
|
d = hdray(ro, rd, hdlist[p->hd], gc, p->ra[i].r); |
| 29 |
|
|
if (p->offset != NULL) { |
| 30 |
|
|
VSUM(ro, ro, rd, d); /* exterior only */ |
| 31 |
|
|
p->offset[i] = d; |
| 32 |
|
|
} |
| 33 |
|
|
VCOPY(rod, ro); |
| 34 |
|
|
rod += 3; |
| 35 |
|
|
VCOPY(rod, rd); |
| 36 |
|
|
rod += 3; |
| 37 |
|
|
} |
| 38 |
|
|
} |
| 39 |
|
|
|
| 40 |
|
|
|
| 41 |
|
|
donerays(p, rvl) /* encode finished ray computations */ |
| 42 |
|
|
register PACKET *p; |
| 43 |
|
|
register float *rvl; |
| 44 |
|
|
{ |
| 45 |
|
|
double d; |
| 46 |
|
|
register int i; |
| 47 |
|
|
|
| 48 |
|
|
for (i = 0; i < p->nr; i++) { |
| 49 |
|
|
setcolr(p->ra[i].v, rvl[0], rvl[1], rvl[2]); |
| 50 |
|
|
d = rvl[3]; |
| 51 |
|
|
if (p->offset != NULL) |
| 52 |
|
|
d += p->offset[i]; |
| 53 |
|
|
p->ra[i].d = hdcode(hdlist[p->hd], d); |
| 54 |
|
|
rvl += 4; |
| 55 |
|
|
} |
| 56 |
|
|
} |