1 |
greg |
2.19 |
/* RCSid $Id: ray.h,v 2.18 2003/06/26 00:58:10 schorsch Exp $ */ |
2 |
greg |
1.1 |
/* |
3 |
|
|
* ray.h - header file for routines using rays. |
4 |
greg |
2.12 |
*/ |
5 |
schorsch |
2.17 |
#ifndef _RAD_RAY_H_ |
6 |
|
|
#define _RAD_RAY_H_ |
7 |
|
|
#ifdef __cplusplus |
8 |
|
|
extern "C" { |
9 |
|
|
#endif |
10 |
greg |
1.1 |
|
11 |
|
|
#include "standard.h" |
12 |
|
|
|
13 |
greg |
2.12 |
#include "octree.h" |
14 |
|
|
|
15 |
greg |
1.1 |
#include "object.h" |
16 |
|
|
|
17 |
|
|
#include "color.h" |
18 |
|
|
|
19 |
greg |
2.6 |
#define MAXDIM 32 /* maximum number of dimensions */ |
20 |
|
|
|
21 |
greg |
1.1 |
/* ray type flags */ |
22 |
|
|
#define PRIMARY 01 /* original ray */ |
23 |
|
|
#define SHADOW 02 /* ray to light source */ |
24 |
|
|
#define REFLECTED 04 /* reflected ray */ |
25 |
|
|
#define REFRACTED 010 /* refracted (bent) ray */ |
26 |
|
|
#define TRANS 020 /* transmitted/transferred ray */ |
27 |
|
|
#define AMBIENT 040 /* ray scattered for interreflection */ |
28 |
greg |
2.2 |
#define SPECULAR 0100 /* ray scattered for specular */ |
29 |
greg |
1.1 |
|
30 |
|
|
/* reflected ray types */ |
31 |
greg |
2.2 |
#define RAYREFL (SHADOW|REFLECTED|AMBIENT|SPECULAR) |
32 |
greg |
1.1 |
|
33 |
|
|
typedef struct ray { |
34 |
greg |
2.3 |
unsigned long rno; /* unique ray number */ |
35 |
greg |
2.12 |
int rlvl; /* number of reflections for this ray */ |
36 |
|
|
float rweight; /* cumulative weight of this ray */ |
37 |
|
|
short rtype; /* ray type */ |
38 |
|
|
short crtype; /* cumulative ray type */ |
39 |
greg |
1.1 |
struct ray *parent; /* ray this originated from */ |
40 |
greg |
2.12 |
FVECT rorg; /* origin of ray */ |
41 |
|
|
FVECT rdir; /* normalized direction of ray */ |
42 |
|
|
double rmax; /* maximum distance (aft clipping plane) */ |
43 |
|
|
int rsrc; /* source we're aiming for */ |
44 |
|
|
OBJECT *clipset; /* set of objects currently clipped */ |
45 |
|
|
OBJECT *newcset; /* next clipset, used for transmission */ |
46 |
|
|
void (*revf)(); /* evaluation function for this ray */ |
47 |
greg |
2.14 |
void (*hitf)(); /* custom hit test for this traversal */ |
48 |
greg |
2.11 |
OBJECT robj; /* intersected object number */ |
49 |
greg |
2.12 |
OBJREC *ro; /* intersected object (one with material) */ |
50 |
|
|
double rot; /* distance to object */ |
51 |
|
|
FVECT rop; /* intersection point */ |
52 |
|
|
FVECT ron; /* intersection surface normal */ |
53 |
|
|
double rod; /* -DOT(rdir, ron) */ |
54 |
|
|
FULLXF *rox; /* object transformation */ |
55 |
schorsch |
2.18 |
RREAL uv[2]; /* local coordinates */ |
56 |
greg |
2.12 |
FVECT pert; /* surface normal perturbation */ |
57 |
|
|
COLOR pcol; /* pattern color */ |
58 |
|
|
COLOR rcol; /* returned ray value */ |
59 |
|
|
double rt; /* returned effective ray length */ |
60 |
|
|
COLOR cext; /* medium extinction coefficient */ |
61 |
|
|
COLOR albedo; /* medium scattering albedo */ |
62 |
|
|
float gecc; /* scattering eccentricity coefficient */ |
63 |
|
|
int *slights; /* list of lights to test for scattering */ |
64 |
greg |
1.1 |
} RAY; |
65 |
|
|
|
66 |
greg |
2.12 |
#define rayvalue(r) (*(r)->revf)(r) |
67 |
|
|
|
68 |
|
|
extern char VersionID[]; /* Radiance version ID string */ |
69 |
greg |
1.6 |
|
70 |
greg |
2.12 |
extern CUBE thescene; /* our scene */ |
71 |
|
|
extern OBJECT nsceneobjs; /* number of objects in our scene */ |
72 |
greg |
2.5 |
|
73 |
greg |
2.12 |
extern unsigned long raynum; /* next ray ID */ |
74 |
|
|
extern unsigned long nrays; /* total rays traced so far */ |
75 |
greg |
1.5 |
|
76 |
greg |
2.12 |
extern OBJREC Lamb; /* a Lambertian surface */ |
77 |
|
|
extern OBJREC Aftplane; /* aft clipping object */ |
78 |
|
|
|
79 |
|
|
extern void (*trace)(); /* global trace reporting callback */ |
80 |
|
|
|
81 |
|
|
extern int dimlist[]; /* dimension list for distribution */ |
82 |
|
|
extern int ndims; /* number of dimensions so far */ |
83 |
|
|
extern int samplendx; /* index for this sample */ |
84 |
|
|
|
85 |
|
|
extern int ray_savesiz; /* size of parameter save buffer */ |
86 |
|
|
|
87 |
|
|
extern int do_irrad; /* compute irradiance? */ |
88 |
|
|
|
89 |
|
|
extern double dstrsrc; /* square source distribution */ |
90 |
|
|
extern double shadthresh; /* shadow threshold */ |
91 |
|
|
extern double shadcert; /* shadow testing certainty */ |
92 |
|
|
extern int directrelay; /* number of source relays */ |
93 |
|
|
extern int vspretest; /* virtual source pretest density */ |
94 |
|
|
extern int directvis; /* light sources visible to eye? */ |
95 |
|
|
extern double srcsizerat; /* maximum source size/dist. ratio */ |
96 |
|
|
|
97 |
|
|
extern double specthresh; /* specular sampling threshold */ |
98 |
|
|
extern double specjitter; /* specular sampling jitter */ |
99 |
|
|
|
100 |
|
|
extern COLOR cextinction; /* global extinction coefficient */ |
101 |
|
|
extern COLOR salbedo; /* global scattering albedo */ |
102 |
|
|
extern double seccg; /* global scattering eccentricity */ |
103 |
|
|
extern double ssampdist; /* scatter sampling distance */ |
104 |
|
|
|
105 |
|
|
extern int backvis; /* back face visibility */ |
106 |
|
|
|
107 |
|
|
extern int maxdepth; /* maximum recursion depth */ |
108 |
|
|
extern double minweight; /* minimum ray weight */ |
109 |
|
|
|
110 |
|
|
extern char *ambfile; /* ambient file name */ |
111 |
|
|
extern COLOR ambval; /* ambient value */ |
112 |
|
|
extern int ambvwt; /* initial weight for ambient value */ |
113 |
|
|
extern double ambacc; /* ambient accuracy */ |
114 |
|
|
extern int ambres; /* ambient resolution */ |
115 |
|
|
extern int ambdiv; /* ambient divisions */ |
116 |
|
|
extern int ambssamp; /* ambient super-samples */ |
117 |
|
|
extern int ambounce; /* ambient bounces */ |
118 |
|
|
extern char *amblist[]; /* ambient include/exclude list */ |
119 |
|
|
extern int ambincl; /* include == 1, exclude == 0 */ |
120 |
|
|
|
121 |
|
|
extern int ray_pnprocs; /* number of child processes */ |
122 |
|
|
extern int ray_pnidle; /* number of idle processes */ |
123 |
|
|
|
124 |
|
|
#define AMBLLEN 128 /* max. ambient list length */ |
125 |
|
|
#define AMBWORD 8 /* average word length */ |
126 |
|
|
|
127 |
|
|
typedef struct { /* rendering parameter holder */ |
128 |
|
|
int do_irrad; |
129 |
|
|
double dstrsrc; |
130 |
|
|
double shadthresh; |
131 |
|
|
double shadcert; |
132 |
|
|
int directrelay; |
133 |
|
|
int vspretest; |
134 |
|
|
int directvis; |
135 |
|
|
double srcsizerat; |
136 |
|
|
COLOR cextinction; |
137 |
|
|
COLOR salbedo; |
138 |
|
|
double seccg; |
139 |
|
|
double ssampdist; |
140 |
|
|
double specthresh; |
141 |
|
|
double specjitter; |
142 |
|
|
int backvis; |
143 |
|
|
int maxdepth; |
144 |
|
|
double minweight; |
145 |
|
|
char ambfile[512]; |
146 |
|
|
COLOR ambval; |
147 |
|
|
int ambvwt; |
148 |
|
|
double ambacc; |
149 |
|
|
int ambres; |
150 |
|
|
int ambdiv; |
151 |
|
|
int ambssamp; |
152 |
|
|
int ambounce; |
153 |
|
|
int ambincl; |
154 |
|
|
short amblndx[AMBLLEN+1]; |
155 |
|
|
char amblval[AMBLLEN*AMBWORD]; |
156 |
|
|
} RAYPARAMS; |
157 |
|
|
|
158 |
|
|
#define rpambmod(p,i) ( (i)>=AMBLLEN||(p)->amblndx[i]<0 ? \ |
159 |
|
|
(char *)NULL : (p)->amblval+(p)->amblndx[i] ) |
160 |
|
|
|
161 |
|
|
/* defined in duphead.c */ |
162 |
|
|
extern void headclean(void); |
163 |
|
|
extern void openheader(void); |
164 |
|
|
extern void dupheader(void); |
165 |
|
|
extern void pfdetach(void); |
166 |
|
|
extern void pfclean(void); |
167 |
|
|
extern void pflock(int lf); |
168 |
|
|
extern void pfhold(void); |
169 |
|
|
extern void io_process(void); |
170 |
|
|
/* defined in freeobjmem.c */ |
171 |
|
|
extern int free_objs(OBJECT on, OBJECT no); |
172 |
|
|
extern void free_objmem(void); |
173 |
|
|
/* defined in preload.c */ |
174 |
|
|
extern int load_os(OBJREC *op); |
175 |
|
|
extern void preload_objs(void); |
176 |
|
|
/* defined in raycalls.c */ |
177 |
|
|
extern void ray_init(char *otnm); |
178 |
|
|
extern void ray_trace(RAY *r); |
179 |
|
|
extern void ray_done(int freall); |
180 |
|
|
extern void ray_save(RAYPARAMS *rp); |
181 |
|
|
extern void ray_restore(RAYPARAMS *rp); |
182 |
|
|
extern void ray_defaults(RAYPARAMS *rp); |
183 |
|
|
/* defined in raypcalls.c */ |
184 |
|
|
extern void ray_pinit(char *otnm, int nproc); |
185 |
|
|
extern void ray_psend(RAY *r); |
186 |
|
|
extern int ray_pqueue(RAY *r); |
187 |
|
|
extern int ray_presult(RAY *r, int poll); |
188 |
|
|
extern void ray_pdone(int freall); |
189 |
|
|
extern void ray_popen(int nadd); |
190 |
|
|
extern void ray_pclose(int nsub); |
191 |
|
|
/* defined in raytrace.c */ |
192 |
|
|
extern int rayorigin(RAY *r, RAY *ro, int rt, double rw); |
193 |
|
|
extern void rayclear(RAY *r); |
194 |
|
|
extern void raytrace(RAY *r); |
195 |
greg |
2.14 |
extern void rayhit(OBJECT *oset, RAY *r); |
196 |
greg |
2.12 |
extern void raycont(RAY *r); |
197 |
|
|
extern void raytrans(RAY *r); |
198 |
|
|
extern int rayshade(RAY *r, int mod); |
199 |
|
|
extern void rayparticipate(RAY *r); |
200 |
greg |
2.16 |
extern void raytexture(RAY *r, OBJECT mod); |
201 |
greg |
2.12 |
extern int raymixture(RAY *r, OBJECT fore, OBJECT back, double coef); |
202 |
|
|
extern double raydist(RAY *r, int flags); |
203 |
|
|
extern double raynormal(FVECT norm, RAY *r); |
204 |
|
|
extern void newrayxf(RAY *r); |
205 |
|
|
extern void flipsurface(RAY *r); |
206 |
|
|
extern int localhit(RAY *r, CUBE *scene); |
207 |
|
|
/* defined in renderopts.c */ |
208 |
|
|
extern int getrenderopt(int ac, char *av[]); |
209 |
|
|
extern void print_rdefaults(void); |
210 |
|
|
/* defined in srcdraw.c */ |
211 |
|
|
extern void drawsources(COLOR *pic[], float *zbf[], |
212 |
|
|
int x0, int xsiz, int y0, int ysiz); |
213 |
|
|
/* module main procedures */ |
214 |
|
|
extern void rtrace(char *fname); |
215 |
|
|
extern void rview(void); |
216 |
|
|
extern void rpict(int seq, char *pout, char *zout, char *prvr); |
217 |
greg |
1.6 |
|
218 |
schorsch |
2.17 |
|
219 |
|
|
#ifdef __cplusplus |
220 |
|
|
} |
221 |
greg |
2.12 |
#endif |
222 |
schorsch |
2.17 |
#endif /* _RAD_RAY_H_ */ |
223 |
|
|
|