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