| 22 |
|
.5, 1., 1. |
| 23 |
|
}; |
| 24 |
|
|
| 25 |
+ |
#ifdef _WIN32 |
| 26 |
+ |
char validf[] = "-e \"valid(s,t)=X`SYS(s,t)^2+Y`SYS(s,t)^2+Z`SYS(s,t)^2-1e-7\""; |
| 27 |
+ |
#else |
| 28 |
+ |
char validf[] = "-e 'valid(s,t)=X`SYS(s,t)^2+Y`SYS(s,t)^2+Z`SYS(s,t)^2-1e-7'"; |
| 29 |
+ |
#endif |
| 30 |
+ |
|
| 31 |
|
char *progname; |
| 32 |
|
|
| 33 |
|
/* Produce a Radiance model plotting the indicated incident direction(s) */ |
| 100 |
|
min_log = log(bsdf_min*.5 + 1e-5); |
| 101 |
|
/* output BSDF rep. */ |
| 102 |
|
for (n = 0; (n < 6) & (2*n+3 < argc); n++) { |
| 103 |
< |
double theta = atof(argv[2*n+2]); |
| 103 |
> |
double theta = (M_PI/180.)*atof(argv[2*n+2]); |
| 104 |
> |
double phi = (M_PI/180.)*atof(argv[2*n+3]); |
| 105 |
> |
if (theta < -FTINY) { |
| 106 |
> |
fprintf(stderr, "%s: theta values must be positive\n", |
| 107 |
> |
progname); |
| 108 |
> |
return(1); |
| 109 |
> |
} |
| 110 |
|
if (inpXML) { |
| 111 |
< |
input_orient = (theta <= 90.) ? 1 : -1; |
| 111 |
> |
input_orient = (theta <= M_PI/2.) ? 1 : -1; |
| 112 |
|
output_orient = doTrans ? -input_orient : input_orient; |
| 113 |
|
} |
| 114 |
< |
idir[2] = sin((M_PI/180.)*theta); |
| 115 |
< |
idir[0] = idir[2] * cos((M_PI/180.)*atof(argv[2*n+3])); |
| 116 |
< |
idir[1] = idir[2] * sin((M_PI/180.)*atof(argv[2*n+3])); |
| 114 |
> |
idir[2] = sin(theta); |
| 115 |
> |
idir[0] = idir[2] * cos(phi); |
| 116 |
> |
idir[1] = idir[2] * sin(phi); |
| 117 |
|
idir[2] = input_orient * sqrt(1. - idir[2]*idir[2]); |
| 118 |
|
#ifdef DEBUG |
| 119 |
|
fprintf(stderr, "Computing BSDF for incident direction (%.1f,%.1f)\n", |
| 142 |
|
1.-colarr[n][0], 1.-colarr[n][1], 1.-colarr[n][2]); |
| 143 |
|
for (i = 0; i < rbf->nrbf; i++) { |
| 144 |
|
ovec_from_pos(odir, rbf->rbfa[i].gx, rbf->rbfa[i].gy); |
| 145 |
< |
bsdf = eval_rbfrep(rbf, odir) / (output_orient*odir[2]); |
| 145 |
> |
bsdf = eval_rbfrep(rbf, odir); |
| 146 |
|
bsdf = log(bsdf + 1e-5) - min_log; |
| 147 |
|
printf("pmat sphere p%d\n0\n0\n4 %f %f %f %f\n", |
| 148 |
|
i+1, odir[0]*bsdf, odir[1]*bsdf, odir[2]*bsdf, |
| 150 |
|
} |
| 151 |
|
} |
| 152 |
|
fflush(stdout); |
| 153 |
< |
sprintf(buf, "gensurf tmat bsdf%d - - - %d %d", n+1, |
| 154 |
< |
GRIDRES-1, GRIDRES-1); |
| 153 |
> |
sprintf(buf, "gensurf tmat bsdf%d - - - %d %d %s", n+1, |
| 154 |
> |
GRIDRES-1, GRIDRES-1, validf); |
| 155 |
|
fp = popen(buf, "w"); |
| 156 |
|
if (fp == NULL) { |
| 157 |
|
fprintf(stderr, "%s: cannot open '| %s'\n", progname, buf); |
| 167 |
|
return(1); |
| 168 |
|
bsdf = sval.cieY; |
| 169 |
|
} else |
| 170 |
< |
bsdf = eval_rbfrep(rbf, odir) / |
| 159 |
< |
(output_orient*odir[2]); |
| 170 |
> |
bsdf = eval_rbfrep(rbf, odir); |
| 171 |
|
bsdf = log(bsdf + 1e-5) - min_log; |
| 172 |
|
fprintf(fp, "%.8e %.8e %.8e\n", |
| 173 |
|
odir[0]*bsdf, odir[1]*bsdf, odir[2]*bsdf); |