20 |
|
* All values default to ascii representation of real |
21 |
|
* numbers. Binary representations can be selected |
22 |
|
* with '-ff' for float or '-fd' for double. By default, |
23 |
< |
* radiance is computed. The '-i' option indicates that |
23 |
> |
* radiance is computed. The '-i' or '-I' options indicate that |
24 |
|
* irradiance values are desired. |
25 |
|
*/ |
26 |
|
|
27 |
|
#include "ray.h" |
28 |
|
|
29 |
+ |
#include "octree.h" |
30 |
+ |
|
31 |
|
#include "otypes.h" |
32 |
|
|
33 |
+ |
int dimlist[MAXDIM]; /* sampling dimensions */ |
34 |
+ |
int ndims = 0; /* number of sampling dimensions */ |
35 |
+ |
int samplendx = 0; /* index for this sample */ |
36 |
+ |
|
37 |
+ |
int imm_irrad = 0; /* compute immediate irradiance? */ |
38 |
+ |
|
39 |
|
int inform = 'a'; /* input format */ |
40 |
|
int outform = 'a'; /* output format */ |
41 |
|
char *outvals = "v"; /* output specification */ |
46 |
|
double dstrsrc = 0.0; /* square source distribution */ |
47 |
|
double shadthresh = .05; /* shadow threshold */ |
48 |
|
double shadcert = .5; /* shadow certainty */ |
49 |
+ |
int directrelay = 0; /* number of source relays */ |
50 |
+ |
int vspretest = 128; /* virtual source pretest density */ |
51 |
|
|
52 |
|
int maxdepth = 6; /* maximum recursion depth */ |
53 |
|
double minweight = 4e-3; /* minimum ray weight */ |
61 |
|
char *amblist[128]; /* ambient include/exclude list */ |
62 |
|
int ambincl = -1; /* include == 1, exclude == 0 */ |
63 |
|
|
64 |
+ |
extern OBJREC Lamb; /* a Lambertian surface */ |
65 |
+ |
|
66 |
|
static RAY thisray; /* for our convenience */ |
67 |
|
|
68 |
|
static int oputo(), oputd(), oputv(), oputl(), |
69 |
|
oputp(), oputn(), oputs(), oputw(), oputm(); |
70 |
|
|
71 |
|
static int (*ray_out[10])(), (*every_out[10])(); |
72 |
+ |
static int castonly; |
73 |
|
|
74 |
|
static int puta(), putf(), putd(); |
75 |
|
|
112 |
|
fflush(stdout); |
113 |
|
continue; |
114 |
|
} |
115 |
+ |
samplendx++; |
116 |
|
/* compute and print */ |
117 |
< |
if (outvals[0] == 'i') |
117 |
> |
if (imm_irrad) |
118 |
|
irrad(orig, direc); |
119 |
|
else |
120 |
< |
radiance(orig, direc); |
120 |
> |
traceray(orig, direc); |
121 |
|
/* flush if time */ |
122 |
|
if (--nextflush == 0) { |
123 |
|
fflush(stdout); |
140 |
|
extern int ourtrace(), (*trace)(); |
141 |
|
register int (**table)() = ray_out; |
142 |
|
|
143 |
+ |
castonly = 1; |
144 |
|
while (*vs) |
145 |
|
switch (*vs++) { |
146 |
|
case 't': /* trace */ |
147 |
|
*table = NULL; |
148 |
|
table = every_out; |
149 |
|
trace = ourtrace; |
150 |
+ |
castonly = 0; |
151 |
|
break; |
152 |
|
case 'o': /* origin */ |
153 |
|
*table++ = oputo; |
157 |
|
break; |
158 |
|
case 'v': /* value */ |
159 |
|
*table++ = oputv; |
160 |
+ |
castonly = 0; |
161 |
|
break; |
162 |
|
case 'l': /* length */ |
163 |
|
*table++ = oputl; |
164 |
+ |
castonly = 0; |
165 |
|
break; |
166 |
|
case 'p': /* point */ |
167 |
|
*table++ = oputp; |
183 |
|
} |
184 |
|
|
185 |
|
|
186 |
< |
radiance(org, dir) /* compute radiance value */ |
186 |
> |
traceray(org, dir) /* compute and print ray value(s) */ |
187 |
|
FVECT org, dir; |
188 |
|
{ |
189 |
|
register int (**tp)(); |
191 |
|
VCOPY(thisray.rorg, org); |
192 |
|
VCOPY(thisray.rdir, dir); |
193 |
|
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
194 |
< |
rayvalue(&thisray); |
194 |
> |
if (castonly) |
195 |
> |
localhit(&thisray, &thescene) || sourcehit(&thisray); |
196 |
> |
else |
197 |
> |
rayvalue(&thisray); |
198 |
|
|
199 |
|
if (ray_out[0] == NULL) |
200 |
|
return; |
205 |
|
} |
206 |
|
|
207 |
|
|
208 |
< |
irrad(org, dir) /* compute irradiance value */ |
208 |
> |
irrad(org, dir) /* compute immediate irradiance value */ |
209 |
|
FVECT org, dir; |
210 |
|
{ |
190 |
– |
static double Lambfa[5] = {PI, PI, PI, 0.0, 0.0}; |
191 |
– |
static OBJREC Lamb = { |
192 |
– |
OVOID, MAT_PLASTIC, "Lambertian", |
193 |
– |
{0, 5, NULL, Lambfa}, NULL, -1, |
194 |
– |
}; |
211 |
|
register int i; |
212 |
|
|
213 |
|
for (i = 0; i < 3; i++) { |