13 |
|
#include "resolu.h" |
14 |
|
#include "bsdfrep.h" |
15 |
|
|
16 |
+ |
#ifndef NINCIDENT |
17 |
|
#define NINCIDENT 37 /* number of samples/hemisphere */ |
18 |
< |
|
18 |
> |
#endif |
19 |
> |
#ifndef GRIDSTEP |
20 |
|
#define GRIDSTEP 2 /* our grid step size */ |
21 |
+ |
#endif |
22 |
|
#define SAMPRES (GRIDRES/GRIDSTEP) |
23 |
|
|
24 |
|
int front_comp = 0; /* front component flags (SDsamp*) */ |
27 |
|
double min_log10; /* smallest log10 value for plotting */ |
28 |
|
double overall_max = .0; /* overall maximum BSDF value */ |
29 |
|
|
30 |
< |
char ourTempDir[TEMPLEN] = ""; /* our temporary directory */ |
30 |
> |
char ourTempDir[TEMPLEN+1] = ""; /* our temporary directory */ |
31 |
|
|
32 |
|
const char frpref[] = "rf"; |
33 |
|
const char ftpref[] = "tf"; |
45 |
|
|
46 |
|
#define FEQ(a,b) ((a)-(b) <= 1e-7 && (b)-(a) <= 1e-7) |
47 |
|
|
48 |
< |
#define set_minlog() (min_log10 = log10(overall_min + 1e-5) - .1) |
48 |
> |
#define set_minlog() overall_min = (overall_min < 1e-5) ? 1e-5 : overall_min; \ |
49 |
> |
min_log10 = log10(overall_min) - .1 |
50 |
|
|
51 |
|
char *progname; |
52 |
|
|
80 |
|
static char * |
81 |
|
tfile_name(const char *prefix, const char *suffix, int i) |
82 |
|
{ |
83 |
< |
static char buf[128]; |
83 |
> |
static char buf[256]; |
84 |
|
|
85 |
|
if (!ourTempDir[0]) { /* create temporary directory */ |
86 |
|
mktemp(strcpy(ourTempDir,TEMPLATE)); |
278 |
|
{ |
279 |
|
const double arrow_len = 1.2*bsdf_rad; |
280 |
|
const double tip_len = 0.2*bsdf_rad; |
281 |
+ |
static int cnt = 1; |
282 |
|
FVECT refl; |
283 |
|
int i; |
284 |
|
|
286 |
|
refl[1] = 2.*nrm[2]*nrm[1]; |
287 |
|
refl[2] = 2.*nrm[2]*nrm[2] - 1.; |
288 |
|
|
289 |
< |
printf("\n# Mirror arrow\n"); |
290 |
< |
printf("\nshaft_mat cylinder inc_dir\n0\n0\n7"); |
289 |
> |
printf("\n# Mirror arrow #%d\n", cnt); |
290 |
> |
printf("\nshaft_mat cylinder inc_dir%d\n0\n0\n7", cnt); |
291 |
|
printf("\n\t%f %f %f\n\t%f %f %f\n\t%f\n", |
292 |
|
origin[0], origin[1], origin[2]+arrow_len, |
293 |
|
origin[0], origin[1], origin[2], |
294 |
|
arrow_rad); |
295 |
< |
printf("\nshaft_mat cylinder mir_dir\n0\n0\n7"); |
295 |
> |
printf("\nshaft_mat cylinder mir_dir%d\n0\n0\n7", cnt); |
296 |
|
printf("\n\t%f %f %f\n\t%f %f %f\n\t%f\n", |
297 |
|
origin[0], origin[1], origin[2], |
298 |
|
origin[0] + arrow_len*refl[0], |
299 |
|
origin[1] + arrow_len*refl[1], |
300 |
|
origin[2] + arrow_len*refl[2], |
301 |
|
arrow_rad); |
302 |
< |
printf("\ntip_mat cone mir_tip\n0\n0\n8"); |
302 |
> |
printf("\ntip_mat cone mir_tip%d\n0\n0\n8", cnt); |
303 |
|
printf("\n\t%f %f %f\n\t%f %f %f\n\t%f 0\n", |
304 |
|
origin[0] + (arrow_len-.5*tip_len)*refl[0], |
305 |
|
origin[1] + (arrow_len-.5*tip_len)*refl[1], |
308 |
|
origin[1] + (arrow_len+.5*tip_len)*refl[1], |
309 |
|
origin[2] + (arrow_len+.5*tip_len)*refl[2], |
310 |
|
2.*arrow_rad); |
311 |
+ |
++cnt; |
312 |
|
} |
313 |
|
|
314 |
|
/* Put out transmitted direction arrow for the given incident vector */ |
317 |
|
{ |
318 |
|
const double arrow_len = 1.2*bsdf_rad; |
319 |
|
const double tip_len = 0.2*bsdf_rad; |
320 |
+ |
static int cnt = 1; |
321 |
|
int i; |
322 |
|
|
323 |
< |
printf("\n# Transmission arrow\n"); |
324 |
< |
printf("\nshaft_mat cylinder trans_dir\n0\n0\n7"); |
323 |
> |
printf("\n# Transmission arrow #%d\n", cnt); |
324 |
> |
printf("\nshaft_mat cylinder trans_dir%d\n0\n0\n7", cnt); |
325 |
|
printf("\n\t%f %f %f\n\t%f %f %f\n\t%f\n", |
326 |
|
origin[0], origin[1], origin[2], |
327 |
|
origin[0], origin[1], origin[2]-arrow_len, |
328 |
|
arrow_rad); |
329 |
< |
printf("\ntip_mat cone trans_tip\n0\n0\n8"); |
329 |
> |
printf("\ntip_mat cone trans_tip%d\n0\n0\n8", cnt); |
330 |
|
printf("\n\t%f %f %f\n\t%f %f %f\n\t%f 0\n", |
331 |
|
origin[0], origin[1], origin[2]-arrow_len+.5*tip_len, |
332 |
|
origin[0], origin[1], origin[2]-arrow_len-.5*tip_len, |
333 |
< |
2.*arrow_rad); |
333 |
> |
2.*arrow_rad); |
334 |
> |
++cnt; |
335 |
|
} |
336 |
|
|
337 |
|
/* Compute rotation (x,y,z) => (xp,yp,zp) */ |
520 |
|
if (front_comp) { |
521 |
|
printf( |
522 |
|
"\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", |
523 |
< |
sph_fmat, nsegs, sph_rad, 0.495*PI, sph_xoffset); |
523 |
> |
sph_fmat, nsegs, sph_rad, 0.5*PI, sph_xoffset); |
524 |
|
printf("\nvoid brighttext front_text\n3 helvet.fnt . FRONT\n0\n"); |
525 |
|
printf("12\n\t%f %f 0\n\t%f 0 0\n\t0 %f 0\n\t.01 1 -.1\n", |
526 |
|
-.22*sph_rad + sph_xoffset, -1.4*sph_rad, |
536 |
|
if (back_comp) { |
537 |
|
printf( |
538 |
|
"\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", |
539 |
< |
sph_bmat, nsegs, sph_rad, 0.495*PI, -sph_xoffset); |
539 |
> |
sph_bmat, nsegs, sph_rad, 0.5*PI, -sph_xoffset); |
540 |
|
printf("\nvoid brighttext back_text\n3 helvet.fnt . BACK\n0\n"); |
541 |
|
printf("12\n\t%f %f 0\n\t%f 0 0\n\t0 %f 0\n\t.01 1 -.1\n", |
542 |
|
-.22*sph_rad - sph_xoffset, -1.4*sph_rad, |