1 |
< |
/* Copyright (c) 1994 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1995 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
23 |
|
|
24 |
|
double emult = 1.; /* emitter multiplier */ |
25 |
|
|
26 |
+ |
FILE *matfp = stdout; /* material output file */ |
27 |
+ |
|
28 |
|
int r_comment(), r_cone(), r_cyl(), r_face(), r_ies(), r_ring(), r_sph(); |
29 |
|
char *material(), *object(), *addarg(); |
30 |
|
|
35 |
|
{ |
36 |
|
int i, rv; |
37 |
|
/* initialize dispatch table */ |
38 |
< |
mg_ehand[MG_E_COMMENT] = r_comment; |
39 |
< |
mg_ehand[MG_E_COLOR] = c_hcolor; |
40 |
< |
mg_ehand[MG_E_CONE] = r_cone; |
41 |
< |
mg_ehand[MG_E_CMIX] = c_hcolor; |
42 |
< |
mg_ehand[MG_E_CSPEC] = c_hcolor; |
43 |
< |
mg_ehand[MG_E_CXY] = c_hcolor; |
44 |
< |
mg_ehand[MG_E_CYL] = r_cyl; |
45 |
< |
mg_ehand[MG_E_ED] = c_hmaterial; |
46 |
< |
mg_ehand[MG_E_FACE] = r_face; |
47 |
< |
mg_ehand[MG_E_IES] = r_ies; |
48 |
< |
mg_ehand[MG_E_MATERIAL] = c_hmaterial; |
49 |
< |
mg_ehand[MG_E_NORMAL] = c_hvertex; |
50 |
< |
mg_ehand[MG_E_OBJECT] = obj_handler; |
51 |
< |
mg_ehand[MG_E_POINT] = c_hvertex; |
52 |
< |
mg_ehand[MG_E_RD] = c_hmaterial; |
53 |
< |
mg_ehand[MG_E_RING] = r_ring; |
54 |
< |
mg_ehand[MG_E_RS] = c_hmaterial; |
55 |
< |
mg_ehand[MG_E_SIDES] = c_hmaterial; |
56 |
< |
mg_ehand[MG_E_SPH] = r_sph; |
57 |
< |
mg_ehand[MG_E_TD] = c_hmaterial; |
58 |
< |
mg_ehand[MG_E_TS] = c_hmaterial; |
59 |
< |
mg_ehand[MG_E_VERTEX] = c_hvertex; |
60 |
< |
mg_ehand[MG_E_XF] = xf_handler; |
38 |
> |
mg_ehand[MG_E_COMMENT] = r_comment; /* we pass comments */ |
39 |
> |
mg_ehand[MG_E_COLOR] = c_hcolor; /* they get color */ |
40 |
> |
mg_ehand[MG_E_CONE] = r_cone; /* we do cones */ |
41 |
> |
mg_ehand[MG_E_CMIX] = c_hcolor; /* they mix colors */ |
42 |
> |
mg_ehand[MG_E_CSPEC] = c_hcolor; /* they get spectra */ |
43 |
> |
mg_ehand[MG_E_CXY] = c_hcolor; /* they get chromaticities */ |
44 |
> |
mg_ehand[MG_E_CCT] = c_hcolor; /* they get color temp's */ |
45 |
> |
mg_ehand[MG_E_CYL] = r_cyl; /* we do cylinders */ |
46 |
> |
mg_ehand[MG_E_ED] = c_hmaterial; /* they get emission */ |
47 |
> |
mg_ehand[MG_E_FACE] = r_face; /* we do faces */ |
48 |
> |
mg_ehand[MG_E_IES] = r_ies; /* we do IES files */ |
49 |
> |
mg_ehand[MG_E_IR] = c_hmaterial; /* they get refractive index */ |
50 |
> |
mg_ehand[MG_E_MATERIAL] = c_hmaterial; /* they get materials */ |
51 |
> |
mg_ehand[MG_E_NORMAL] = c_hvertex; /* they get normals */ |
52 |
> |
mg_ehand[MG_E_OBJECT] = obj_handler; /* they track object names */ |
53 |
> |
mg_ehand[MG_E_POINT] = c_hvertex; /* they get points */ |
54 |
> |
mg_ehand[MG_E_RD] = c_hmaterial; /* they get diffuse refl. */ |
55 |
> |
mg_ehand[MG_E_RING] = r_ring; /* we do rings */ |
56 |
> |
mg_ehand[MG_E_RS] = c_hmaterial; /* they get specular refl. */ |
57 |
> |
mg_ehand[MG_E_SIDES] = c_hmaterial; /* they get # sides */ |
58 |
> |
mg_ehand[MG_E_SPH] = r_sph; /* we do spheres */ |
59 |
> |
mg_ehand[MG_E_TD] = c_hmaterial; /* they get diffuse trans. */ |
60 |
> |
mg_ehand[MG_E_TS] = c_hmaterial; /* they get specular trans. */ |
61 |
> |
mg_ehand[MG_E_VERTEX] = c_hvertex; /* they get vertices */ |
62 |
> |
mg_ehand[MG_E_XF] = xf_handler; /* they track transforms */ |
63 |
|
mg_init(); /* initialize the parser */ |
64 |
< |
/* get options & print header */ |
64 |
> |
/* get our options & print header */ |
65 |
|
printf("## %s", argv[0]); |
66 |
|
for (i = 1; i < argc && argv[i][0] == '-'; i++) { |
67 |
|
printf(" %s", argv[i]); |
68 |
|
switch (argv[i][1]) { |
69 |
|
case 'g': /* glow distance (meters) */ |
70 |
< |
if (argv[i][2] || badarg(argc-i, argv+i, "f")) |
70 |
> |
if (argv[i][2] || badarg(argc-i-1, argv+i+1, "f")) |
71 |
|
goto userr; |
72 |
|
glowdist = atof(argv[++i]); |
73 |
|
printf(" %s", argv[i]); |
74 |
|
break; |
75 |
|
case 'e': /* emitter multiplier */ |
76 |
< |
if (argv[i][2] || badarg(argc-i, argv+i, "f")) |
76 |
> |
if (argv[i][2] || badarg(argc-i-1, argv+i+1, "f")) |
77 |
|
goto userr; |
78 |
|
emult = atof(argv[++i]); |
79 |
|
printf(" %s", argv[i]); |
80 |
|
break; |
81 |
+ |
case 'm': /* materials file */ |
82 |
+ |
matfp = fopen(argv[++i], "a"); |
83 |
+ |
if (matfp == NULL) { |
84 |
+ |
fprintf(stderr, "%s: cannot append\n", argv[i]); |
85 |
+ |
exit(1); |
86 |
+ |
} |
87 |
+ |
printf(" %s", argv[i]); |
88 |
+ |
break; |
89 |
|
default: |
90 |
|
goto userr; |
91 |
|
} |
94 |
|
if (i == argc) { /* convert stdin */ |
95 |
|
if ((rv = mg_load(NULL)) != MG_OK) |
96 |
|
exit(1); |
97 |
+ |
if (mg_nunknown) |
98 |
+ |
printf("## %s: %u unknown entities\n", |
99 |
+ |
argv[0], mg_nunknown); |
100 |
|
} else /* convert each file */ |
101 |
|
for ( ; i < argc; i++) { |
102 |
|
printf("## %s %s ##############################\n", |
103 |
|
argv[0], argv[i]); |
104 |
|
if ((rv = mg_load(argv[i])) != MG_OK) |
105 |
|
exit(1); |
106 |
+ |
if (mg_nunknown) { |
107 |
+ |
printf("## %s %s: %u unknown entities\n", |
108 |
+ |
argv[0], argv[i], mg_nunknown); |
109 |
+ |
mg_nunknown = 0; |
110 |
+ |
} |
111 |
|
} |
112 |
|
exit(0); |
113 |
|
userr: |
114 |
< |
fprintf(stderr, "Usage: %s [-g dist][-m mult] [file.mgf] ..\n", |
114 |
> |
fprintf(stderr, "Usage: %s [-g dist][-e mult][-m matf] [file.mgf] ..\n", |
115 |
|
argv[0]); |
116 |
|
exit(1); |
117 |
|
} |
123 |
|
register char **av; |
124 |
|
{ |
125 |
|
putchar('#'); /* use Radiance comment character */ |
126 |
< |
while (--ac) { |
126 |
> |
while (--ac) { /* pass through verbatim */ |
127 |
|
putchar(' '); |
128 |
|
fputs(*++av, stdout); |
129 |
|
} |
143 |
|
C_VERTEX *cv1, *cv2; |
144 |
|
FVECT p1, p2; |
145 |
|
int inv; |
146 |
< |
|
146 |
> |
/* check argument count and type */ |
147 |
|
if (ac != 5) |
148 |
|
return(MG_EARGC); |
149 |
|
if (!isflt(av[2]) || !isflt(av[4])) |
150 |
|
return(MG_ETYPE); |
151 |
+ |
/* get the endpoint vertices */ |
152 |
|
if ((cv1 = c_getvert(av[1])) == NULL || |
153 |
|
(cv2 = c_getvert(av[3])) == NULL) |
154 |
|
return(MG_EUNDEF); |
155 |
< |
xf_xfmpoint(p1, cv1->p); |
155 |
> |
xf_xfmpoint(p1, cv1->p); /* transform endpoints */ |
156 |
|
xf_xfmpoint(p2, cv2->p); |
157 |
< |
r1 = xf_scale(atof(av[2])); |
157 |
> |
r1 = xf_scale(atof(av[2])); /* scale radii */ |
158 |
|
r2 = xf_scale(atof(av[4])); |
159 |
< |
inv = r1 < 0.; |
160 |
< |
if (r1 == 0.) { |
159 |
> |
inv = r1 < 0.; /* check for inverted cone */ |
160 |
> |
if (r1 == 0.) { /* check for illegal radii */ |
161 |
|
if (r2 == 0.) |
162 |
|
return(MG_EILL); |
163 |
|
inv = r2 < 0.; |
167 |
|
r1 = -r1; |
168 |
|
r2 = -r2; |
169 |
|
} |
170 |
< |
if ((mat = material()) == NULL) |
170 |
> |
if ((mat = material()) == NULL) /* get material */ |
171 |
|
return(MG_EBADMAT); |
172 |
+ |
/* spit the sucker out */ |
173 |
|
printf("\n%s %s %sc%d\n", mat, inv ? "cup" : "cone", |
174 |
|
object(), ++ncones); |
175 |
|
printf("0\n0\n8\n"); |
191 |
|
C_VERTEX *cv1, *cv2; |
192 |
|
FVECT p1, p2; |
193 |
|
int inv; |
194 |
< |
|
194 |
> |
/* check argument count and type */ |
195 |
|
if (ac != 4) |
196 |
|
return(MG_EARGC); |
197 |
|
if (!isflt(av[2])) |
198 |
|
return(MG_ETYPE); |
199 |
+ |
/* get the endpoint vertices */ |
200 |
|
if ((cv1 = c_getvert(av[1])) == NULL || |
201 |
|
(cv2 = c_getvert(av[3])) == NULL) |
202 |
|
return(MG_EUNDEF); |
203 |
< |
xf_xfmpoint(p1, cv1->p); |
203 |
> |
xf_xfmpoint(p1, cv1->p); /* transform endpoints */ |
204 |
|
xf_xfmpoint(p2, cv2->p); |
205 |
< |
rad = xf_scale(atof(av[2])); |
206 |
< |
if ((inv = rad < 0.)) |
205 |
> |
rad = xf_scale(atof(av[2])); /* scale radius */ |
206 |
> |
if ((inv = rad < 0.)) /* check for inverted cylinder */ |
207 |
|
rad = -rad; |
208 |
< |
if ((mat = material()) == NULL) |
208 |
> |
if ((mat = material()) == NULL) /* get material */ |
209 |
|
return(MG_EBADMAT); |
210 |
+ |
/* spit out the primitive */ |
211 |
|
printf("\n%s %s %scy%d\n", mat, inv ? "tube" : "cylinder", |
212 |
|
object(), ++ncyls); |
213 |
|
printf("0\n0\n7\n"); |
229 |
|
C_VERTEX *cv; |
230 |
|
FVECT cent; |
231 |
|
int inv; |
232 |
< |
|
232 |
> |
/* check argument count and type */ |
233 |
|
if (ac != 3) |
234 |
|
return(MG_EARGC); |
235 |
|
if (!isflt(av[2])) |
236 |
|
return(MG_ETYPE); |
237 |
< |
if ((cv = c_getvert(av[1])) == NULL) |
237 |
> |
if ((cv = c_getvert(av[1])) == NULL) /* get center vertex */ |
238 |
|
return(MG_EUNDEF); |
239 |
< |
xf_xfmpoint(cent, cv->p); |
240 |
< |
rad = xf_scale(atof(av[2])); |
241 |
< |
if ((inv = rad < 0.)) |
239 |
> |
xf_xfmpoint(cent, cv->p); /* transform center */ |
240 |
> |
rad = xf_scale(atof(av[2])); /* scale radius */ |
241 |
> |
if ((inv = rad < 0.)) /* check for inversion */ |
242 |
|
rad = -rad; |
243 |
< |
if ((mat = material()) == NULL) |
243 |
> |
if ((mat = material()) == NULL) /* get material */ |
244 |
|
return(MG_EBADMAT); |
245 |
+ |
/* spit out primitive */ |
246 |
|
printf("\n%s %s %ss%d\n", mat, inv ? "bubble" : "sphere", |
247 |
|
object(), ++nsphs); |
248 |
|
printf("0\n0\n4 %18.12g %18.12g %18.12g %18.12g\n", |
261 |
|
double r1, r2; |
262 |
|
C_VERTEX *cv; |
263 |
|
FVECT cent, norm; |
264 |
< |
|
264 |
> |
/* check argument count and type */ |
265 |
|
if (ac != 4) |
266 |
|
return(MG_EARGC); |
267 |
|
if (!isflt(av[2]) || !isflt(av[3])) |
268 |
|
return(MG_ETYPE); |
269 |
< |
if ((cv = c_getvert(av[1])) == NULL) |
269 |
> |
if ((cv = c_getvert(av[1])) == NULL) /* get center vertex */ |
270 |
|
return(MG_EUNDEF); |
271 |
< |
if (is0vect(cv->n)) |
271 |
> |
if (is0vect(cv->n)) /* make sure we have normal */ |
272 |
|
return(MG_EILL); |
273 |
< |
xf_xfmpoint(cent, cv->p); |
274 |
< |
xf_rotvect(norm, cv->n); |
275 |
< |
r1 = xf_scale(atof(av[2])); |
273 |
> |
xf_xfmpoint(cent, cv->p); /* transform center */ |
274 |
> |
xf_rotvect(norm, cv->n); /* rotate normal */ |
275 |
> |
r1 = xf_scale(atof(av[2])); /* scale radii */ |
276 |
|
r2 = xf_scale(atof(av[3])); |
277 |
|
if (r1 < 0. | r2 <= r1) |
278 |
|
return(MG_EILL); |
279 |
< |
if ((mat = material()) == NULL) |
279 |
> |
if ((mat = material()) == NULL) /* get material */ |
280 |
|
return(MG_EBADMAT); |
281 |
+ |
/* spit out primitive */ |
282 |
|
printf("\n%s ring %sr%d\n", mat, object(), ++nrings); |
283 |
|
printf("0\n0\n8\n"); |
284 |
|
putv(cent); |
299 |
|
register C_VERTEX *cv; |
300 |
|
FVECT v; |
301 |
|
int rv; |
302 |
< |
|
302 |
> |
/* check argument count and type */ |
303 |
|
if (ac < 4) |
304 |
|
return(MG_EARGC); |
305 |
< |
if ((mat = material()) == NULL) |
305 |
> |
if ((mat = material()) == NULL) /* get material */ |
306 |
|
return(MG_EBADMAT); |
307 |
< |
if (ac <= 5) { /* check for surface normals */ |
307 |
> |
if (ac <= 5) { /* check for smoothing */ |
308 |
|
for (i = 1; i < ac; i++) { |
309 |
|
if ((cv = c_getvert(av[i])) == NULL) |
310 |
|
return(MG_EUNDEF); |
318 |
|
return(MG_OK); |
319 |
|
} |
320 |
|
} |
321 |
+ |
/* spit out unsmoothed primitive */ |
322 |
|
printf("\n%s polygon %sf%d\n", mat, object(), ++nfaces); |
323 |
|
printf("0\n0\n%d\n", 3*(ac-1)); |
324 |
< |
for (i = 1; i < ac; i++) { |
324 |
> |
for (i = 1; i < ac; i++) { /* get, transform, print each vertex */ |
325 |
|
if ((cv = c_getvert(av[invert ? ac-i : i])) == NULL) |
326 |
|
return(MG_EUNDEF); |
327 |
|
xf_xfmpoint(v, cv->p); |
331 |
|
} |
332 |
|
|
333 |
|
|
334 |
+ |
int |
335 |
|
r_ies(ac, av) /* convert an IES luminaire file */ |
336 |
|
int ac; |
337 |
|
char **av; |
338 |
|
{ |
339 |
|
int xa0 = 2; |
340 |
< |
char combuf[72]; |
340 |
> |
char combuf[128]; |
341 |
|
char fname[48]; |
342 |
|
char *oname; |
343 |
|
register char *op; |
344 |
|
register int i; |
345 |
< |
|
345 |
> |
/* check argument count */ |
346 |
|
if (ac < 2) |
347 |
|
return(MG_EARGC); |
348 |
< |
(void)strcpy(combuf, "ies2rad"); |
321 |
< |
op = combuf + 7; |
322 |
< |
if (ac-xa0 >= 2 && !strcmp(av[xa0], "-m")) { |
323 |
< |
if (!isflt(av[xa0+1])) |
324 |
< |
return(MG_ETYPE); |
325 |
< |
op = addarg(addarg(op, "-m"), av[xa0+1]); |
326 |
< |
xa0 += 2; |
327 |
< |
} |
328 |
< |
if (access(av[1], 0) == -1) |
329 |
< |
return(MG_ENOFILE); |
330 |
< |
*op++ = ' '; /* IES filename goes last */ |
331 |
< |
(void)strcpy(op, av[1]); |
332 |
< |
system(combuf); /* run ies2rad */ |
333 |
< |
/* now let's find the output file */ |
348 |
> |
/* construct output file name */ |
349 |
|
if ((op = strrchr(av[1], '/')) == NULL) |
350 |
|
op = av[1]; |
351 |
|
(void)strcpy(fname, op); |
352 |
|
if ((op = strrchr(fname, '.')) == NULL) |
353 |
|
op = fname + strlen(fname); |
354 |
|
(void)strcpy(op, ".rad"); |
355 |
< |
if (access(fname, 0) == -1) |
356 |
< |
return(MG_EINCL); |
357 |
< |
/* put out xform command */ |
358 |
< |
printf("\n!xform"); |
355 |
> |
/* see if we need to run ies2rad */ |
356 |
> |
if (access(fname, 0) == -1) { |
357 |
> |
(void)strcpy(combuf, "ies2rad");/* build ies2rad command */ |
358 |
> |
op = combuf + 7; /* get -m option (first) */ |
359 |
> |
if (ac-xa0 >= 2 && !strcmp(av[xa0], "-m")) { |
360 |
> |
if (!isflt(av[xa0+1])) |
361 |
> |
return(MG_ETYPE); |
362 |
> |
op = addarg(addarg(op, "-m"), av[xa0+1]); |
363 |
> |
xa0 += 2; |
364 |
> |
} |
365 |
> |
*op++ = ' '; /* build IES filename */ |
366 |
> |
i = 0; |
367 |
> |
if (mg_file != NULL && |
368 |
> |
(oname = strrchr(mg_file->fname,'/')) != NULL) { |
369 |
> |
i = oname - mg_file->fname + 1; |
370 |
> |
(void)strcpy(op, mg_file->fname); |
371 |
> |
} |
372 |
> |
(void)strcpy(op+i, av[1]); |
373 |
> |
if (access(op, 0) == -1) /* check for file existence */ |
374 |
> |
return(MG_ENOFILE); |
375 |
> |
system(combuf); /* run ies2rad */ |
376 |
> |
if (access(fname, 0) == -1) /* check success */ |
377 |
> |
return(MG_EINCL); |
378 |
> |
} |
379 |
> |
printf("\n!xform"); /* put out xform command */ |
380 |
|
oname = object(); |
381 |
|
if (*oname) { |
382 |
|
printf(" -n "); |
416 |
|
xf_xfmpoint(v1, cv1->p); |
417 |
|
xf_xfmpoint(v2, cv2->p); |
418 |
|
xf_xfmpoint(v3, cv3->p); |
419 |
+ |
/* compute barycentric coords. */ |
420 |
|
if (comp_baryc(&bvecs, v1, v2, v3) < 0) |
421 |
|
return; /* degenerate triangle! */ |
422 |
< |
printf("\n%s texfunc T-nor\n", mat); |
422 |
> |
printf("\n%s texfunc T-nor\n", mat); /* put out texture */ |
423 |
|
printf("4 dx dy dz %s\n0\n", TCALNAME); |
424 |
|
xf_rotvect(n1, cv1->n); |
425 |
|
xf_rotvect(n2, cv2->n); |
430 |
|
bcoor[i][2] = n3[i]; |
431 |
|
} |
432 |
|
put_baryc(&bvecs, bcoor, 3); |
433 |
+ |
/* put out triangle */ |
434 |
|
printf("\nT-nor polygon %st%d\n", object(), ++ntris); |
435 |
|
printf("0\n0\n9\n"); |
436 |
|
putv(v1); |
455 |
|
c_cmaterial->clock = 0; |
456 |
|
if (c_cmaterial->ed > .1) { /* emitter */ |
457 |
|
cvtcolor(radrgb, &c_cmaterial->ed_c, |
458 |
< |
emult*c_cmaterial->ed/WHTEFFICACY); |
458 |
> |
emult*c_cmaterial->ed/(PI*WHTEFFICACY)); |
459 |
|
if (glowdist < FHUGE) { /* do a glow */ |
460 |
< |
printf("\nvoid glow %s\n0\n0\n", mname); |
461 |
< |
printf("4 %f %f %f %f\n", colval(radrgb,RED), |
460 |
> |
fprintf(matfp, "\nvoid glow %s\n0\n0\n", mname); |
461 |
> |
fprintf(matfp, "4 %f %f %f %f\n", colval(radrgb,RED), |
462 |
|
colval(radrgb,GRN), |
463 |
|
colval(radrgb,BLU), glowdist); |
464 |
|
} else { |
465 |
< |
printf("\nvoid light %s\n0\n0\n", mname); |
466 |
< |
printf("3 %f %f %f\n", colval(radrgb,RED), |
465 |
> |
fprintf(matfp, "\nvoid light %s\n0\n0\n", mname); |
466 |
> |
fprintf(matfp, "3 %f %f %f\n", colval(radrgb,RED), |
467 |
|
colval(radrgb,GRN), |
468 |
|
colval(radrgb,BLU)); |
469 |
|
} |
473 |
|
c_cmaterial->rs + c_cmaterial->ts; |
474 |
|
if (d < 0. | d > 1.) |
475 |
|
return(NULL); |
476 |
+ |
/* check for glass/dielectric */ |
477 |
+ |
if (c_cmaterial->nr > 1.1 && |
478 |
+ |
c_cmaterial->ts > .25 && c_cmaterial->rs <= .125 && |
479 |
+ |
c_cmaterial->td <= .01 && c_cmaterial->rd <= .01 && |
480 |
+ |
c_cmaterial->rs_a <= .01 && c_cmaterial->ts_a <= .01) { |
481 |
+ |
cvtcolor(radrgb, &c_cmaterial->ts_c, |
482 |
+ |
c_cmaterial->ts + c_cmaterial->rs); |
483 |
+ |
if (c_cmaterial->sided) { /* dielectric */ |
484 |
+ |
colval(radrgb,RED) = pow(colval(radrgb,RED), |
485 |
+ |
1./C_1SIDEDTHICK); |
486 |
+ |
colval(radrgb,GRN) = pow(colval(radrgb,GRN), |
487 |
+ |
1./C_1SIDEDTHICK); |
488 |
+ |
colval(radrgb,BLU) = pow(colval(radrgb,BLU), |
489 |
+ |
1./C_1SIDEDTHICK); |
490 |
+ |
fprintf(matfp, "\nvoid dielectric %s\n0\n0\n", mname); |
491 |
+ |
fprintf(matfp, "5 %g %g %g %f 0\n", colval(radrgb,RED), |
492 |
+ |
colval(radrgb,GRN), colval(radrgb,BLU), |
493 |
+ |
c_cmaterial->nr); |
494 |
+ |
return(mname); |
495 |
+ |
} |
496 |
+ |
/* glass */ |
497 |
+ |
fprintf(matfp, "\nvoid glass %s\n0\n0\n", mname); |
498 |
+ |
fprintf(matfp, "4 %f %f %f %f\n", colval(radrgb,RED), |
499 |
+ |
colval(radrgb,GRN), colval(radrgb,BLU), |
500 |
+ |
c_cmaterial->nr); |
501 |
+ |
return(mname); |
502 |
+ |
} |
503 |
|
/* check for trans */ |
504 |
|
if (c_cmaterial->td > .01 || c_cmaterial->ts > .01) { |
505 |
|
double ts, a5, a6; |
529 |
|
else |
530 |
|
d = c_cmaterial->td + ts; |
531 |
|
scalecolor(radrgb, d); |
532 |
< |
printf("\nvoid trans %s\n0\n0\n", mname); |
533 |
< |
printf("7 %f %f %f\n", colval(radrgb,RED), |
532 |
> |
fprintf(matfp, "\nvoid trans %s\n0\n0\n", mname); |
533 |
> |
fprintf(matfp, "7 %f %f %f\n", colval(radrgb,RED), |
534 |
|
colval(radrgb,GRN), colval(radrgb,BLU)); |
535 |
< |
printf("\t%f %f %f %f\n", c_cmaterial->rs, a5, a6, |
535 |
> |
fprintf(matfp, "\t%f %f %f %f\n", c_cmaterial->rs, a5, a6, |
536 |
|
ts/(ts + c_cmaterial->td)); |
537 |
|
return(mname); |
538 |
|
} |
541 |
|
c_isgrey(&c_cmaterial->rs_c))) { |
542 |
|
cvtcolor(radrgb, &c_cmaterial->rd_c, |
543 |
|
c_cmaterial->rd/(1.-c_cmaterial->rs)); |
544 |
< |
printf("\nvoid plastic %s\n0\n0\n", mname); |
545 |
< |
printf("5 %f %f %f %f %f\n", colval(radrgb,RED), |
544 |
> |
fprintf(matfp, "\nvoid plastic %s\n0\n0\n", mname); |
545 |
> |
fprintf(matfp, "5 %f %f %f %f %f\n", colval(radrgb,RED), |
546 |
|
colval(radrgb,GRN), colval(radrgb,BLU), |
547 |
|
c_cmaterial->rs, c_cmaterial->rs_a); |
548 |
|
return(mname); |
552 |
|
cvtcolor(radrgb, &c_cmaterial->rd_c, c_cmaterial->rd); |
553 |
|
cvtcolor(c2, &c_cmaterial->rs_c, c_cmaterial->rs); |
554 |
|
addcolor(radrgb, c2); |
555 |
< |
printf("\nvoid metal %s\n0\n0\n", mname); |
556 |
< |
printf("5 %f %f %f %f %f\n", colval(radrgb,RED), |
555 |
> |
fprintf(matfp, "\nvoid metal %s\n0\n0\n", mname); |
556 |
> |
fprintf(matfp, "5 %f %f %f %f %f\n", colval(radrgb,RED), |
557 |
|
colval(radrgb,GRN), colval(radrgb,BLU), |
558 |
|
c_cmaterial->rs/(c_cmaterial->rd + c_cmaterial->rs), |
559 |
|
c_cmaterial->rs_a); |
561 |
|
} |
562 |
|
|
563 |
|
|
564 |
< |
cvtcolor(radrgb, ciec, intensity) /* convert a CIE color to Radiance */ |
564 |
> |
cvtcolor(radrgb, ciec, intensity) /* convert a CIE XYZ color to RGB */ |
565 |
|
COLOR radrgb; |
566 |
|
register C_COLOR *ciec; |
567 |
|
double intensity; |
583 |
|
register int i; |
584 |
|
register char *cp; |
585 |
|
int len; |
586 |
< |
|
586 |
> |
/* tracked by obj_handler */ |
587 |
|
i = obj_nnames - sizeof(objbuf)/16; |
588 |
|
if (i < 0) |
589 |
|
i = 0; |