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 '-oi' or '-oI' options indicate that |
23 |
> |
* radiance is computed. The '-i' or '-I' options indicate that |
24 |
|
* irradiance values are desired. |
25 |
|
*/ |
26 |
|
|
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 = 1; /* number of source relays */ |
50 |
+ |
int vspretest = 512; /* virtual source pretest density */ |
51 |
+ |
int directinvis = 0; /* sources invisible? */ |
52 |
+ |
double srcsizerat = .25; /* maximum ratio source size/dist. */ |
53 |
|
|
54 |
|
int maxdepth = 6; /* maximum recursion depth */ |
55 |
|
double minweight = 4e-3; /* minimum ray weight */ |
63 |
|
char *amblist[128]; /* ambient include/exclude list */ |
64 |
|
int ambincl = -1; /* include == 1, exclude == 0 */ |
65 |
|
|
66 |
+ |
extern OBJREC Lamb; /* a Lambertian surface */ |
67 |
+ |
|
68 |
|
static RAY thisray; /* for our convenience */ |
69 |
|
|
70 |
|
static int oputo(), oputd(), oputv(), oputl(), |
77 |
|
|
78 |
|
static int (*putreal)(); |
79 |
|
|
68 |
– |
static double Lambfa[5] = {PI, PI, PI, 0.0, 0.0}; |
69 |
– |
static OBJREC Lamb = { |
70 |
– |
OVOID, MAT_PLASTIC, "Lambertian", |
71 |
– |
{0, 5, NULL, Lambfa}, NULL, -1, |
72 |
– |
}; /* a Lambertian surface */ |
80 |
|
|
74 |
– |
|
81 |
|
quit(code) /* quit program */ |
82 |
|
int code; |
83 |
|
{ |
114 |
|
fflush(stdout); |
115 |
|
continue; |
116 |
|
} |
117 |
+ |
samplendx++; |
118 |
|
/* compute and print */ |
119 |
< |
if (outvals[0] == 'i') |
119 |
> |
if (imm_irrad) |
120 |
|
irrad(orig, direc); |
114 |
– |
else if (outvals[0] == 'I') |
115 |
– |
Irrad(orig, direc); |
121 |
|
else |
122 |
< |
radiance(orig, direc); |
122 |
> |
traceray(orig, direc); |
123 |
|
/* flush if time */ |
124 |
|
if (--nextflush == 0) { |
125 |
|
fflush(stdout); |
185 |
|
} |
186 |
|
|
187 |
|
|
188 |
< |
radiance(org, dir) /* compute radiance value */ |
188 |
> |
traceray(org, dir) /* compute and print ray value(s) */ |
189 |
|
FVECT org, dir; |
190 |
|
{ |
191 |
|
register int (**tp)(); |
207 |
|
} |
208 |
|
|
209 |
|
|
210 |
< |
irrad(org, dir) /* compute irradiance value */ |
210 |
> |
irrad(org, dir) /* compute immediate irradiance value */ |
211 |
|
FVECT org, dir; |
212 |
|
{ |
213 |
|
register int i; |
231 |
|
} |
232 |
|
|
233 |
|
|
229 |
– |
Irrad(org, dir) /* compute irradiance value after intersection */ |
230 |
– |
FVECT org, dir; |
231 |
– |
{ |
232 |
– |
/* compute intersection */ |
233 |
– |
VCOPY(thisray.rorg, org); |
234 |
– |
VCOPY(thisray.rdir, dir); |
235 |
– |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
236 |
– |
localhit(&thisray, &thescene); |
237 |
– |
if (thisray.ro != NULL) /* pretend we hit Lambertian surf. */ |
238 |
– |
(*ofun[Lamb.otype].funp)(&Lamb, &thisray); |
239 |
– |
oputv(&thisray); |
240 |
– |
if (outform == 'a') |
241 |
– |
putchar('\n'); |
242 |
– |
} |
243 |
– |
|
244 |
– |
|
234 |
|
getvec(vec, fmt, fp) /* get a vector from fp */ |
235 |
|
register FVECT vec; |
236 |
|
int fmt; |
237 |
|
FILE *fp; |
238 |
|
{ |
239 |
+ |
extern char *fgetword(); |
240 |
|
static float vf[3]; |
241 |
+ |
char buf[32]; |
242 |
+ |
register int i; |
243 |
|
|
244 |
|
switch (fmt) { |
245 |
|
case 'a': /* ascii */ |
246 |
< |
if (fscanf(fp, "%lf %lf %lf", vec, vec+1, vec+2) != 3) |
247 |
< |
return(-1); |
246 |
> |
for (i = 0; i < 3; i++) { |
247 |
> |
if (fgetword(buf, sizeof(buf), fp) == NULL || |
248 |
> |
!isflt(buf)) |
249 |
> |
return(-1); |
250 |
> |
vec[i] = atof(buf); |
251 |
> |
} |
252 |
|
break; |
253 |
|
case 'f': /* binary float */ |
254 |
|
if (fread((char *)vf, sizeof(float), 3, fp) != 3) |