1 |
/* Copyright (c) 1995 Regents of the University of California */ |
2 |
|
3 |
/* SCCSid "$SunId$ LBL" */ |
4 |
|
5 |
/* |
6 |
* ray.h - header file for routines using rays. |
7 |
* |
8 |
* 8/7/85 |
9 |
*/ |
10 |
|
11 |
#include "standard.h" |
12 |
|
13 |
#include "object.h" |
14 |
|
15 |
#include "color.h" |
16 |
|
17 |
#define MAXDIM 32 /* maximum number of dimensions */ |
18 |
|
19 |
/* ray type flags */ |
20 |
#define PRIMARY 01 /* original ray */ |
21 |
#define SHADOW 02 /* ray to light source */ |
22 |
#define REFLECTED 04 /* reflected ray */ |
23 |
#define REFRACTED 010 /* refracted (bent) ray */ |
24 |
#define TRANS 020 /* transmitted/transferred ray */ |
25 |
#define AMBIENT 040 /* ray scattered for interreflection */ |
26 |
#define SPECULAR 0100 /* ray scattered for specular */ |
27 |
|
28 |
/* reflected ray types */ |
29 |
#define RAYREFL (SHADOW|REFLECTED|AMBIENT|SPECULAR) |
30 |
|
31 |
typedef struct ray { |
32 |
unsigned long rno; /* unique ray number */ |
33 |
int rlvl; /* number of reflections for this ray */ |
34 |
float rweight; /* cumulative weight of this ray */ |
35 |
short rtype; /* ray type */ |
36 |
short crtype; /* cumulative ray type */ |
37 |
struct ray *parent; /* ray this originated from */ |
38 |
FVECT rorg; /* origin of ray */ |
39 |
FVECT rdir; /* normalized direction of ray */ |
40 |
double rmax; /* maximum distance (aft clipping plane) */ |
41 |
int rsrc; /* source we're aiming for */ |
42 |
OBJECT *clipset; /* set of objects currently clipped */ |
43 |
OBJECT *newcset; /* next clipset, used for transmission */ |
44 |
int (*revf)(); /* evaluation function for this ray */ |
45 |
OBJECT robj; /* object number from octree */ |
46 |
OBJREC *ro; /* intersected object (for material) */ |
47 |
double rot; /* distance to object */ |
48 |
FVECT rop; /* intersection point */ |
49 |
FVECT ron; /* intersection surface normal */ |
50 |
double rod; /* -DOT(rdir, ron) */ |
51 |
FULLXF *rox; /* object transformation */ |
52 |
FVECT pert; /* surface normal perturbation */ |
53 |
COLOR pcol; /* pattern color */ |
54 |
COLOR rcol; /* returned ray value */ |
55 |
double rt; /* returned effective ray length */ |
56 |
COLOR cext; /* medium extinction coefficient */ |
57 |
COLOR albedo; /* medium scattering albedo */ |
58 |
float gecc; /* scattering eccentricity coefficient */ |
59 |
int *slights; /* list of lights to test for scattering */ |
60 |
} RAY; |
61 |
|
62 |
extern int raytrace(); |
63 |
|
64 |
extern double raynormal(); |
65 |
|
66 |
extern double raydist(); |
67 |
|
68 |
extern int dimlist[]; /* dimension list for distribution */ |
69 |
extern int ndims; /* number of dimensions so far */ |
70 |
extern int samplendx; /* index for this sample */ |
71 |
|
72 |
#define rayvalue(r) (*(r)->revf)(r) |