| 21 |
|
|
| 22 |
|
typedef struct { |
| 23 |
|
const char *fname; /* input file path */ |
| 24 |
< |
double theta, phi; /* input angles */ |
| 24 |
> |
double theta, phi; /* input angles (degrees) */ |
| 25 |
> |
double up_phi; /* azimuth for "up" direction */ |
| 26 |
|
int igp[2]; /* input grid position */ |
| 27 |
|
int isDSF; /* data is DSF (rather than BSDF)? */ |
| 28 |
|
long dstart; /* data start offset in file */ |
| 61 |
|
} |
| 62 |
|
inpfile[i].fname = fname; |
| 63 |
|
inpfile[i].isDSF = -1; |
| 64 |
+ |
inpfile[i].up_phi = 0; |
| 65 |
|
inpfile[i].theta = inpfile[i].phi = -10001.; |
| 66 |
|
/* read header information */ |
| 67 |
|
while ((c = getc(fp)) == '#' || c == EOF) { |
| 86 |
|
continue; |
| 87 |
|
} |
| 88 |
|
} |
| 89 |
+ |
if (sscanf(buf, "upphi %lf", &inpfile[i].up_phi) == 1) |
| 90 |
+ |
continue; |
| 91 |
|
if (sscanf(buf, "intheta %lf", &inpfile[i].theta) == 1) |
| 92 |
|
continue; |
| 93 |
|
if (sscanf(buf, "inphi %lf", &inpfile[i].phi) == 1) |
| 108 |
|
fputs(": unknown incident angle\n", stderr); |
| 109 |
|
return(0); |
| 110 |
|
} |
| 111 |
+ |
/* convert to Y-up orientation */ |
| 112 |
+ |
inpfile[i].phi += 90.-inpfile[i].up_phi; |
| 113 |
|
/* convert angle to grid position */ |
| 114 |
|
dv[2] = sin(M_PI/180.*inpfile[i].theta); |
| 115 |
|
dv[0] = cos(M_PI/180.*inpfile[i].phi)*dv[2]; |
| 147 |
|
#endif |
| 148 |
|
/* read scattering data */ |
| 149 |
|
while (fscanf(fp, "%lf %lf %lf\n", &theta_out, &phi_out, &val) == 3) |
| 150 |
< |
add_bsdf_data(theta_out, phi_out, val, inpfile[i].isDSF); |
| 150 |
> |
add_bsdf_data(theta_out, phi_out+90.-inpfile[i].up_phi, |
| 151 |
> |
val, inpfile[i].isDSF); |
| 152 |
|
n = 0; |
| 153 |
|
while ((c = getc(fp)) != EOF) |
| 154 |
|
n += !isspace(c); |