ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/ray.h
Revision: 2.15
Committed: Tue Mar 11 17:08:55 2003 UTC (21 years, 1 month ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R5
Changes since 2.14: +1 -0 lines
Log Message:
First working version of new "mesh" primitive, obj2mesh converter

File Contents

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