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 |
gregl |
3.3 |
GCOORD gc[2]; |
21 |
gregl |
3.4 |
int ila[2], hsh; |
22 |
|
|
double d, sl[4]; |
23 |
gregl |
3.1 |
register int i; |
24 |
|
|
|
25 |
|
|
if (!hdbcoord(gc, hdlist[p->hd], p->bi)) |
26 |
|
|
error(CONSISTENCY, "bad beam index in packrays"); |
27 |
gregl |
3.4 |
ila[0] = p->hd; ila[1] = p->bi; |
28 |
|
|
hsh = ilhash(ila,2) + p->nc; |
29 |
gregl |
3.1 |
for (i = 0; i < p->nr; i++) { |
30 |
gregl |
3.4 |
multisamp(sl, 4, urand(hsh+i)); |
31 |
|
|
p->ra[i].r[0][0] = sl[0] * 256.; |
32 |
|
|
p->ra[i].r[0][1] = sl[1] * 256.; |
33 |
|
|
p->ra[i].r[1][0] = sl[2] * 256.; |
34 |
|
|
p->ra[i].r[1][1] = sl[3] * 256.; |
35 |
gregl |
3.1 |
d = hdray(ro, rd, hdlist[p->hd], gc, p->ra[i].r); |
36 |
|
|
if (p->offset != NULL) { |
37 |
|
|
VSUM(ro, ro, rd, d); /* exterior only */ |
38 |
|
|
p->offset[i] = d; |
39 |
|
|
} |
40 |
|
|
VCOPY(rod, ro); |
41 |
|
|
rod += 3; |
42 |
|
|
VCOPY(rod, rd); |
43 |
|
|
rod += 3; |
44 |
|
|
} |
45 |
|
|
} |
46 |
|
|
|
47 |
|
|
|
48 |
|
|
donerays(p, rvl) /* encode finished ray computations */ |
49 |
|
|
register PACKET *p; |
50 |
|
|
register float *rvl; |
51 |
|
|
{ |
52 |
|
|
double d; |
53 |
|
|
register int i; |
54 |
|
|
|
55 |
|
|
for (i = 0; i < p->nr; i++) { |
56 |
|
|
setcolr(p->ra[i].v, rvl[0], rvl[1], rvl[2]); |
57 |
|
|
d = rvl[3]; |
58 |
|
|
if (p->offset != NULL) |
59 |
|
|
d += p->offset[i]; |
60 |
|
|
p->ra[i].d = hdcode(hdlist[p->hd], d); |
61 |
|
|
rvl += 4; |
62 |
|
|
} |
63 |
gregl |
3.4 |
p->nc += p->nr; |
64 |
gregl |
3.1 |
} |