127 |
|
puts("</WindowElement>"); |
128 |
|
} |
129 |
|
|
130 |
< |
/* Load and resample XML BSDF description */ |
130 |
> |
/* Load and resample XML BSDF description using Klems basis */ |
131 |
|
static void |
132 |
|
eval_bsdf(const char *fname) |
133 |
|
{ |
233 |
|
exit(1); |
234 |
|
} |
235 |
|
|
236 |
< |
/* Interpolate and output a BSDF function */ |
236 |
> |
/* Interpolate and output a BSDF function using Klems basis */ |
237 |
|
static void |
238 |
|
eval_function(char *funame) |
239 |
|
{ |
253 |
|
bo_getvec(iovec+3, j+(n+frandom())/npsamps, abp); |
254 |
|
|
255 |
|
if (input_orient > 0) |
256 |
< |
fi_getvec(iovec, j+(n+frandom())/npsamps, abp); |
256 |
> |
fi_getvec(iovec, i+(n+frandom())/npsamps, abp); |
257 |
|
else |
258 |
< |
bi_getvec(iovec, j+(n+frandom())/npsamps, abp); |
258 |
> |
bi_getvec(iovec, i+(n+frandom())/npsamps, abp); |
259 |
|
|
260 |
|
sum += funvalue(funame, 6, iovec); |
261 |
|
} |
270 |
|
static void |
271 |
|
eval_rbf(void) |
272 |
|
{ |
273 |
+ |
#define MAXPATCHES 145 |
274 |
|
ANGLE_BASIS *abp = get_basis(kbasis); |
275 |
< |
double iovec[6]; |
275 |
> |
float bsdfarr[MAXPATCHES*MAXPATCHES]; |
276 |
> |
FVECT vin, vout; |
277 |
> |
RBFNODE *rbf; |
278 |
|
double sum; |
279 |
|
int i, j, n; |
280 |
+ |
/* sanity check */ |
281 |
+ |
if (abp->nangles > MAXPATCHES) { |
282 |
+ |
fprintf(stderr, "%s: too many patches!\n", progname); |
283 |
+ |
exit(1); |
284 |
+ |
} |
285 |
+ |
data_prologue(); /* begin output */ |
286 |
+ |
for (i = 0; i < abp->nangles; i++) { |
287 |
+ |
if (input_orient > 0) /* use incident patch center */ |
288 |
+ |
fi_getvec(vin, i+.5*(i>0), abp); |
289 |
+ |
else |
290 |
+ |
bi_getvec(vin, i+.5*(i>0), abp); |
291 |
|
|
292 |
< |
fprintf(stder, "%s: RBF evaluation currently unimplemented\n", progname); |
293 |
< |
exit(1); |
292 |
> |
rbf = advect_rbf(vin); /* compute radial basis func */ |
293 |
> |
|
294 |
> |
for (j = 0; j < abp->nangles; j++) { |
295 |
> |
sum = 0; /* sample over exiting patch */ |
296 |
> |
for (n = npsamps; n--; ) { |
297 |
> |
if (output_orient > 0) |
298 |
> |
fo_getvec(vout, j+(n+frandom())/npsamps, abp); |
299 |
> |
else |
300 |
> |
bo_getvec(vout, j+(n+frandom())/npsamps, abp); |
301 |
> |
|
302 |
> |
sum += eval_rbfrep(rbf, vout) / vout[2]; |
303 |
> |
} |
304 |
> |
bsdfarr[j*abp->nangles + i] = sum*output_orient/npsamps; |
305 |
> |
} |
306 |
> |
} |
307 |
> |
n = 0; /* write out our matrix */ |
308 |
> |
for (j = 0; j < abp->nangles; j++) { |
309 |
> |
for (i = 0; i < abp->nangles; i++) |
310 |
> |
printf("\t%.3e\n", bsdfarr[n++]); |
311 |
> |
putchar('\n'); |
312 |
> |
} |
313 |
> |
data_epilogue(); /* finish output */ |
314 |
> |
#undef MAXPATCHES |
315 |
|
} |
316 |
|
|
317 |
|
/* Read in BSDF and interpolate as Klems matrix representation */ |
327 |
|
esupport &= ~(E_INCHAN|E_OUTCHAN); |
328 |
|
scompile("PI:3.14159265358979323846", NULL, 0); |
329 |
|
biggerlib(); |
330 |
< |
for (i = 1; i < argc-1 && (argv[i][0] == '-') | (argv[i][0] == '+'); i++) |
330 |
> |
for (i = 1; i < argc && (argv[i][0] == '-') | (argv[i][0] == '+'); i++) |
331 |
|
switch (argv[i][1]) { /* get options */ |
332 |
|
case 'n': |
333 |
|
npsamps = atoi(argv[++i]); |
382 |
|
xml_epilogue(); /* finish XML output & exit */ |
383 |
|
return(0); |
384 |
|
} |
385 |
< |
if (i == argc-1 && (cp = strstr(argv[i], ".xml")) != NULL && |
386 |
< |
strlen(cp) == 4) { /* XML input? */ |
385 |
> |
/* XML input? */ |
386 |
> |
if (i == argc-1 && (cp = argv[i]+strlen(argv[i])-4) > argv[i] && |
387 |
> |
!strcasecmp(cp, ".xml")) { |
388 |
|
xml_prologue(argc, argv); /* start XML output */ |
389 |
|
eval_bsdf(argv[i]); /* load & resample BSDF */ |
390 |
|
xml_epilogue(); /* finish XML output & exit */ |