10 |
|
|
11 |
|
#include "mkillum.h" |
12 |
|
|
13 |
< |
#define brt(col) (.295*(col)[0] + .636*(col)[1] + .070*(col)[2]) |
13 |
> |
#define brt(col) (.263*(col)[0]+.655*(col)[1]+.082*(col)[2]) |
14 |
|
|
15 |
|
char DATORD[] = "RGB"; /* data ordering */ |
16 |
|
char DATSUF[] = ".dat"; /* data file suffix */ |
24 |
|
{ |
25 |
|
register int i; |
26 |
|
|
27 |
+ |
if (issurface(obj->otype) && !strcmp(mod, VOIDID)) |
28 |
+ |
return; /* don't print void surfaces */ |
29 |
|
printf("\n%s %s %s", mod, ofun[obj->otype].funame, obj->oname); |
30 |
|
printf("\n%d", obj->oargs.nsargs); |
31 |
|
for (i = 0; i < obj->oargs.nsargs; i++) |
96 |
|
FVECT u, v, w; |
97 |
|
{ |
98 |
|
FILE *dfp; |
99 |
+ |
float col[3]; |
100 |
|
int i; |
101 |
|
|
102 |
|
if (il->flags & IL_COLDST) { |
103 |
|
printf("\n%s %s %s%s", VOIDID, ofun[PAT_CDATA].funame, |
104 |
|
il->matname, DSTSUF); |
105 |
< |
printf("\n9 red green blue"); |
105 |
> |
printf("\n9 h_red h_grn h_blu"); |
106 |
|
for (i = 0; i < 3; i++) { |
107 |
|
dfp = dfopen(il, DATORD[i]); |
108 |
< |
fprintf(dfp, "2\n1 0 %d\n0 %f %d\n", n, 2.*PI, m); |
109 |
< |
colorout(i, da, n*m, 1./il->nsamps/il->col[i], dfp); |
108 |
> |
fprintf(dfp, "2\n%f %f %d\n%f %f %d\n", |
109 |
> |
1.-.5/n, .5/n, n, |
110 |
> |
0., 2.*PI, m+1); |
111 |
> |
colorout(i, da, n, m, 1./il->nsamps/il->col[i], dfp); |
112 |
|
fclose(dfp); |
113 |
|
printf(" %s", dfname(il, DATORD[i])); |
114 |
|
} |
115 |
|
} else { |
116 |
|
printf("\n%s %s %s%s", VOIDID, ofun[PAT_BDATA].funame, |
117 |
|
il->matname, DSTSUF); |
118 |
< |
printf("\n5 noop"); |
118 |
> |
printf("\n5 h_gry"); |
119 |
|
dfp = dfopen(il, 0); |
120 |
< |
fprintf(dfp, "2\n1 0 %d\n0 %f %d\n", n, 2.*PI, m); |
121 |
< |
brightout(da, n*m, 1./il->nsamps/brt(il->col), dfp); |
120 |
> |
fprintf(dfp, "2\n%f %f %d\n%f %f %d\n", 1.-.5/n, .5/n, n, |
121 |
> |
0., 2.*PI, m+1); |
122 |
> |
brightout(da, n, m, 1./il->nsamps/brt(il->col), dfp); |
123 |
|
fclose(dfp); |
124 |
|
printf(" %s", dfname(il, 0)); |
125 |
|
} |
126 |
|
printf("\n\t%s il_alth il_azih", FNCFNM); |
127 |
< |
printf("\n0\n9\n"); |
127 |
> |
printf("\n0\n13\n"); |
128 |
> |
compavg(col, da, m, il->nsamps); |
129 |
> |
printf("\t%f\t%f\t%f\t%f\n", col[0]/il->col[0], |
130 |
> |
col[1]/il->col[1], col[2]/il->col[2], 1.-.5/n); |
131 |
|
printf("\t%f\t%f\t%f\n", u[0], u[1], u[2]); |
132 |
|
printf("\t%f\t%f\t%f\n", v[0], v[1], v[2]); |
133 |
|
printf("\t%f\t%f\t%f\n", w[0], w[1], w[2]); |
141 |
|
int n, m; |
142 |
|
{ |
143 |
|
FILE *dfp; |
144 |
+ |
float col[3]; |
145 |
|
int i; |
146 |
|
|
147 |
|
if (il->flags & IL_COLDST) { |
148 |
|
printf("\n%s %s %s%s", VOIDID, ofun[PAT_CDATA].funame, |
149 |
|
il->matname, DSTSUF); |
150 |
< |
printf("\n9 red green blue"); |
150 |
> |
printf("\n9 s_red s_grn s_blu"); |
151 |
|
for (i = 0; i < 3; i++) { |
152 |
|
dfp = dfopen(il, DATORD[i]); |
153 |
< |
fprintf(dfp, "2\n1 -1 %d\n0 %f %d\n", n, 2.*PI, m); |
154 |
< |
colorout(i, da, n*m, 1./il->nsamps/il->col[i], dfp); |
153 |
> |
fprintf(dfp, "2\n%f %f %d\n%f %f %d\n", |
154 |
> |
1.-1./n, -1.+1./n, n, |
155 |
> |
0., 2.*PI, m+1); |
156 |
> |
colorout(i, da, n, m, 1./il->nsamps/il->col[i], dfp); |
157 |
|
fclose(dfp); |
158 |
|
printf(" %s", dfname(il, DATORD[i])); |
159 |
|
} |
160 |
|
} else { |
161 |
|
printf("\n%s %s %s%s", VOIDID, ofun[PAT_BDATA].funame, |
162 |
|
il->matname, DSTSUF); |
163 |
< |
printf("\n5 noop"); |
163 |
> |
printf("\n5 s_gry"); |
164 |
|
dfp = dfopen(il, 0); |
165 |
< |
fprintf(dfp, "2\n1 -1 %d\n0 %f %d\n", n, 2.*PI, m); |
166 |
< |
brightout(da, n*m, 1./il->nsamps/brt(il->col), dfp); |
165 |
> |
fprintf(dfp, "2\n%f %f %d\n%f %f %d\n", 1.-1./n, -1.+1./n, n, |
166 |
> |
0., 2.*PI, m+1); |
167 |
> |
brightout(da, n, m, 1./il->nsamps/brt(il->col), dfp); |
168 |
|
fclose(dfp); |
169 |
|
printf(" %s", dfname(il, 0)); |
170 |
|
} |
171 |
|
printf("\n\t%s il_alt il_azi", FNCFNM); |
172 |
< |
printf("\n0\n0\n"); |
172 |
> |
printf("\n0\n7\n"); |
173 |
> |
compavg(col, da, m, il->nsamps); /* north pole */ |
174 |
> |
printf("\t%f\t%f\t%f\n", col[0]/il->col[0], |
175 |
> |
col[1]/il->col[1], col[2]/il->col[2]); |
176 |
> |
compavg(col, da+(n-1)*m*3, m, il->nsamps); /* south pole */ |
177 |
> |
printf("\t%f\t%f\t%f\n", col[0]/il->col[0], |
178 |
> |
col[1]/il->col[1], col[2]/il->col[2]); |
179 |
> |
printf("\t%f\n", 1.-1./n); |
180 |
|
il->dfnum++; |
181 |
|
} |
182 |
|
|
210 |
|
} |
211 |
|
|
212 |
|
|
213 |
< |
average(il, da, n) /* compute average value for distribution */ |
214 |
< |
register struct illum_args *il; |
213 |
> |
compavg(col, da, n, ns) /* compute average for set of data values */ |
214 |
> |
float col[3]; |
215 |
|
register float *da; |
216 |
< |
int n; |
216 |
> |
int n, ns; |
217 |
|
{ |
218 |
|
register int i; |
219 |
|
|
220 |
< |
il->col[0] = il->col[1] = il->col[2] = 0.; |
220 |
> |
col[0] = col[1] = col[2] = 0.; |
221 |
|
i = n; |
222 |
|
while (i-- > 0) { |
223 |
< |
il->col[0] += *da++; |
224 |
< |
il->col[1] += *da++; |
225 |
< |
il->col[2] += *da++; |
223 |
> |
col[0] += *da++; |
224 |
> |
col[1] += *da++; |
225 |
> |
col[2] += *da++; |
226 |
|
} |
227 |
|
for (i = 0; i < 3; i++) |
228 |
< |
il->col[i] /= (double)n*il->nsamps; |
228 |
> |
col[i] /= (double)(n*ns); |
229 |
|
} |
230 |
|
|
231 |
|
|
232 |
< |
colorout(p, da, n, mult, fp) /* put out color distribution data */ |
232 |
> |
average(il, da, n) /* evaluate average value for distribution */ |
233 |
> |
register struct illum_args *il; |
234 |
> |
float *da; |
235 |
> |
int n; |
236 |
> |
{ |
237 |
> |
compavg(il->col, da, n, il->nsamps); |
238 |
> |
/* brighter than minimum? */ |
239 |
> |
return(brt(il->col) > il->minbrt+FTINY); |
240 |
> |
} |
241 |
> |
|
242 |
> |
|
243 |
> |
static int colmcnt = 0; /* count of columns written */ |
244 |
> |
|
245 |
> |
fputnum(d, fp) /* put out a number to fp */ |
246 |
> |
double d; |
247 |
> |
FILE *fp; |
248 |
> |
{ |
249 |
> |
if (colmcnt++ % 6 == 0) |
250 |
> |
putc('\n', fp); |
251 |
> |
fprintf(fp, " %11e", d); |
252 |
> |
} |
253 |
> |
|
254 |
> |
|
255 |
> |
fputeol(fp) /* write end of line to fp */ |
256 |
> |
register FILE *fp; |
257 |
> |
{ |
258 |
> |
putc('\n', fp); |
259 |
> |
colmcnt = 0; |
260 |
> |
} |
261 |
> |
|
262 |
> |
|
263 |
> |
colorout(p, da, n, m, mult, fp) /* put out color distribution data */ |
264 |
|
int p; |
265 |
|
register float *da; |
266 |
< |
int n; |
266 |
> |
int n, m; |
267 |
|
double mult; |
268 |
|
FILE *fp; |
269 |
|
{ |
270 |
< |
register int i; |
270 |
> |
register int i, j; |
271 |
|
|
272 |
|
for (i = 0; i < n; i++) { |
273 |
< |
if (i%6 == 0) |
274 |
< |
putc('\n', fp); |
275 |
< |
fprintf(fp, " %11e", mult*da[p]); |
276 |
< |
da += 3; |
273 |
> |
for (j = 0; j < m; j++) { |
274 |
> |
fputnum(mult*da[p], fp); |
275 |
> |
da += 3; |
276 |
> |
} |
277 |
> |
fputnum(mult*da[p-3*m], fp); /* wrap phi */ |
278 |
|
} |
279 |
< |
putc('\n', fp); |
279 |
> |
fputeol(fp); |
280 |
|
} |
281 |
|
|
282 |
|
|
283 |
< |
brightout(da, n, mult, fp) /* put out brightness distribution data */ |
283 |
> |
brightout(da, n, m, mult, fp) /* put out brightness distribution data */ |
284 |
|
register float *da; |
285 |
< |
int n; |
285 |
> |
int n, m; |
286 |
|
double mult; |
287 |
|
FILE *fp; |
288 |
|
{ |
289 |
< |
register int i; |
289 |
> |
register int i, j; |
290 |
|
|
291 |
|
for (i = 0; i < n; i++) { |
292 |
< |
if (i%6 == 0) |
293 |
< |
putc('\n', fp); |
294 |
< |
fprintf(fp, " %11e", mult*brt(da)); |
295 |
< |
da += 3; |
292 |
> |
for (j = 0; j < m; j++) { |
293 |
> |
fputnum(mult*brt(da), fp); |
294 |
> |
da += 3; |
295 |
> |
} |
296 |
> |
fputnum(mult*brt(da-3*m), fp); /* wrap phi */ |
297 |
|
} |
298 |
< |
putc('\n', fp); |
298 |
> |
fputeol(fp); |
299 |
|
} |