26 |
|
|
27 |
|
char ourTempDir[TEMPLEN] = ""; /* our temporary directory */ |
28 |
|
|
29 |
< |
const char frpref[] = "frefl"; |
30 |
< |
const char ftpref[] = "ftrans"; |
31 |
< |
const char brpref[] = "brefl"; |
32 |
< |
const char btpref[] = "btrans"; |
29 |
> |
const char frpref[] = "rf"; |
30 |
> |
const char ftpref[] = "tf"; |
31 |
> |
const char brpref[] = "rb"; |
32 |
> |
const char btpref[] = "tb"; |
33 |
|
const char dsuffix[] = ".txt"; |
34 |
|
|
35 |
|
const char sph_fmat[] = "fBSDFmat"; |
42 |
|
|
43 |
|
#define FEQ(a,b) ((a)-(b) <= 1e-7 && (b)-(a) <= 1e-7) |
44 |
|
|
45 |
< |
#define set_minlog() (min_log10 = log10(overall_min + 1e-5) - .1) |
45 |
> |
#define set_minlog() overall_min = (overall_min < 1e-5) ? 1e-5 : overall_min; \ |
46 |
> |
min_log10 = log10(overall_min) - .1 |
47 |
|
|
48 |
|
char *progname; |
49 |
|
|
275 |
|
{ |
276 |
|
const double arrow_len = 1.2*bsdf_rad; |
277 |
|
const double tip_len = 0.2*bsdf_rad; |
278 |
+ |
static int cnt = 1; |
279 |
|
FVECT refl; |
280 |
|
int i; |
281 |
|
|
283 |
|
refl[1] = 2.*nrm[2]*nrm[1]; |
284 |
|
refl[2] = 2.*nrm[2]*nrm[2] - 1.; |
285 |
|
|
286 |
< |
printf("\n# Mirror arrow\n"); |
287 |
< |
printf("\narrow_mat cylinder inc_dir\n0\n0\n7"); |
286 |
> |
printf("\n# Mirror arrow #%d\n", cnt); |
287 |
> |
printf("\nshaft_mat cylinder inc_dir%d\n0\n0\n7", cnt); |
288 |
|
printf("\n\t%f %f %f\n\t%f %f %f\n\t%f\n", |
289 |
|
origin[0], origin[1], origin[2]+arrow_len, |
290 |
|
origin[0], origin[1], origin[2], |
291 |
|
arrow_rad); |
292 |
< |
printf("\narrow_mat cylinder mir_dir\n0\n0\n7"); |
292 |
> |
printf("\nshaft_mat cylinder mir_dir%d\n0\n0\n7", cnt); |
293 |
|
printf("\n\t%f %f %f\n\t%f %f %f\n\t%f\n", |
294 |
|
origin[0], origin[1], origin[2], |
295 |
|
origin[0] + arrow_len*refl[0], |
296 |
|
origin[1] + arrow_len*refl[1], |
297 |
|
origin[2] + arrow_len*refl[2], |
298 |
|
arrow_rad); |
299 |
< |
printf("\narrow_mat cone mir_tip\n0\n0\n8"); |
299 |
> |
printf("\ntip_mat cone mir_tip%d\n0\n0\n8", cnt); |
300 |
|
printf("\n\t%f %f %f\n\t%f %f %f\n\t%f 0\n", |
301 |
|
origin[0] + (arrow_len-.5*tip_len)*refl[0], |
302 |
|
origin[1] + (arrow_len-.5*tip_len)*refl[1], |
305 |
|
origin[1] + (arrow_len+.5*tip_len)*refl[1], |
306 |
|
origin[2] + (arrow_len+.5*tip_len)*refl[2], |
307 |
|
2.*arrow_rad); |
308 |
+ |
++cnt; |
309 |
|
} |
310 |
|
|
311 |
|
/* Put out transmitted direction arrow for the given incident vector */ |
314 |
|
{ |
315 |
|
const double arrow_len = 1.2*bsdf_rad; |
316 |
|
const double tip_len = 0.2*bsdf_rad; |
317 |
+ |
static int cnt = 1; |
318 |
|
int i; |
319 |
|
|
320 |
< |
printf("\n# Transmission arrow\n"); |
321 |
< |
printf("\narrow_mat cylinder trans_dir\n0\n0\n7"); |
320 |
> |
printf("\n# Transmission arrow #%d\n", cnt); |
321 |
> |
printf("\nshaft_mat cylinder trans_dir%d\n0\n0\n7", cnt); |
322 |
|
printf("\n\t%f %f %f\n\t%f %f %f\n\t%f\n", |
323 |
|
origin[0], origin[1], origin[2], |
324 |
|
origin[0], origin[1], origin[2]-arrow_len, |
325 |
|
arrow_rad); |
326 |
< |
printf("\narrow_mat cone trans_tip\n0\n0\n8"); |
326 |
> |
printf("\ntip_mat cone trans_tip%d\n0\n0\n8", cnt); |
327 |
|
printf("\n\t%f %f %f\n\t%f %f %f\n\t%f 0\n", |
328 |
|
origin[0], origin[1], origin[2]-arrow_len+.5*tip_len, |
329 |
|
origin[0], origin[1], origin[2]-arrow_len-.5*tip_len, |
330 |
< |
2.*arrow_rad); |
330 |
> |
2.*arrow_rad); |
331 |
> |
++cnt; |
332 |
|
} |
333 |
|
|
334 |
|
/* Compute rotation (x,y,z) => (xp,yp,zp) */ |
383 |
|
printf("\n# Gensurf output corresponding to %d incident directions\n", |
384 |
|
NINCIDENT); |
385 |
|
|
386 |
< |
printf("\nvoid glow arrow_glow\n0\n0\n4 1 0 1 0\n"); |
387 |
< |
printf("\nvoid mixfunc arrow_mat\n4 arrow_glow void 0.25 .\n0\n0\n"); |
386 |
> |
printf("\nvoid glow tip_mat\n0\n0\n4 1 0 1 0\n"); |
387 |
> |
printf("\nvoid mixfunc shaft_mat\n4 tip_mat void 0.25 .\n0\n0\n"); |
388 |
|
|
384 |
– |
if (front_comp & SDsampR) /* front reflection */ |
389 |
|
for (i = 0; i < NINCIDENT; i++) { |
390 |
|
get_ivector(ivec, i); |
391 |
|
nrm[0] = -ivec[0]; nrm[1] = -ivec[1]; nrm[2] = ivec[2]; |
475 |
|
} |
476 |
|
switch (XMLfile[0]) { /* avoid RAYPATH search */ |
477 |
|
case '.': |
478 |
+ |
case '~': |
479 |
|
CASEDIRSEP: |
480 |
|
curdir = ""; |
481 |
|
break; |
517 |
|
if (front_comp) { |
518 |
|
printf( |
519 |
|
"\n!genrev %s Front \"R*sin(A*t)\" \"R*cos(A*t)\" %d -e \"R:%g;A:%f\" -s | xform -t %g 0 0\n", |
520 |
< |
sph_fmat, nsegs, sph_rad, 0.495*PI, sph_xoffset); |
520 |
> |
sph_fmat, nsegs, sph_rad, 0.5*PI, sph_xoffset); |
521 |
|
printf("\nvoid brighttext front_text\n3 helvet.fnt . FRONT\n0\n"); |
522 |
|
printf("12\n\t%f %f 0\n\t%f 0 0\n\t0 %f 0\n\t.01 1 -.1\n", |
523 |
|
-.22*sph_rad + sph_xoffset, -1.4*sph_rad, |
533 |
|
if (back_comp) { |
534 |
|
printf( |
535 |
|
"\n!genrev %s Back \"R*cos(A*t)\" \"R*sin(A*t)\" %d -e \"R:%g;A:%f\" -s | xform -t %g 0 0\n", |
536 |
< |
sph_bmat, nsegs, sph_rad, 0.495*PI, -sph_xoffset); |
536 |
> |
sph_bmat, nsegs, sph_rad, 0.5*PI, -sph_xoffset); |
537 |
|
printf("\nvoid brighttext back_text\n3 helvet.fnt . BACK\n0\n"); |
538 |
|
printf("12\n\t%f %f 0\n\t%f 0 0\n\t0 %f 0\n\t.01 1 -.1\n", |
539 |
|
-.22*sph_rad - sph_xoffset, -1.4*sph_rad, |
755 |
|
strcpy(bsdf_manuf, myBSDF.makr); |
756 |
|
put_matBSDF(argv[1]); |
757 |
|
} else { |
758 |
< |
FILE *fp; |
758 |
> |
FILE *fp[4]; |
759 |
> |
if (argc > 5) { |
760 |
> |
fprintf(stderr, "%s: more than 4 hemispheres!\n", progname); |
761 |
> |
return(1); |
762 |
> |
} |
763 |
|
for (n = 1; n < argc; n++) { |
764 |
< |
fp = fopen(argv[n], "rb"); |
765 |
< |
if (fp == NULL) { |
764 |
> |
fp[n-1] = fopen(argv[n], "rb"); |
765 |
> |
if (fp[n-1] == NULL) { |
766 |
|
fprintf(stderr, "%s: cannot open BSDF interpolant '%s'\n", |
767 |
|
progname, argv[n]); |
768 |
|
return(1); |
769 |
|
} |
770 |
< |
if (getheader(fp, rbf_headline, NULL) < 0) { |
770 |
> |
if (getheader(fp[n-1], rbf_headline, NULL) < 0) { |
771 |
|
fprintf(stderr, "%s: bad BSDF interpolant '%s'\n", |
772 |
|
progname, argv[n]); |
773 |
|
return(1); |
774 |
|
} |
766 |
– |
fclose(fp); |
775 |
|
} |
776 |
|
set_minlog(); |
777 |
|
for (n = 1; n < argc; n++) { |
778 |
< |
fp = fopen(argv[n], "rb"); |
779 |
< |
if (!load_bsdf_rep(fp)) |
778 |
> |
if (fseek(fp[n-1], 0L, SEEK_SET) < 0) { |
779 |
> |
fprintf(stderr, "%s: cannot seek on '%s'\n", |
780 |
> |
progname, argv[n]); |
781 |
|
return(1); |
782 |
< |
fclose(fp); |
782 |
> |
} |
783 |
> |
if (!load_bsdf_rep(fp[n-1])) |
784 |
> |
return(1); |
785 |
> |
fclose(fp[n-1]); |
786 |
|
if (!build_wRBF()) |
787 |
|
return(1); |
788 |
|
} |
793 |
|
put_scale(); |
794 |
|
if (inpXML && myBSDF.mgf) |
795 |
|
convert_mgf(myBSDF.mgf); |
796 |
< |
if (!put_BSDFs()) |
796 |
> |
if (!put_BSDFs()) /* most of the output happens here */ |
797 |
|
return(1); |
798 |
|
cleanup_tmp(); |
799 |
|
return(0); |