34 |
|
mg_ehand[MG_E_COMMENT] = r_comment; |
35 |
|
mg_ehand[MG_E_COLOR] = c_hcolor; |
36 |
|
mg_ehand[MG_E_CONE] = r_cone; |
37 |
+ |
mg_ehand[MG_E_CMIX] = c_hcolor; |
38 |
+ |
mg_ehand[MG_E_CSPEC] = c_hcolor; |
39 |
|
mg_ehand[MG_E_CXY] = c_hcolor; |
40 |
|
mg_ehand[MG_E_CYL] = r_cyl; |
41 |
|
mg_ehand[MG_E_ED] = c_hmaterial; |
48 |
|
mg_ehand[MG_E_RD] = c_hmaterial; |
49 |
|
mg_ehand[MG_E_RING] = r_ring; |
50 |
|
mg_ehand[MG_E_RS] = c_hmaterial; |
51 |
+ |
mg_ehand[MG_E_SIDES] = c_hmaterial; |
52 |
|
mg_ehand[MG_E_SPH] = r_sph; |
53 |
|
mg_ehand[MG_E_TD] = c_hmaterial; |
54 |
|
mg_ehand[MG_E_TS] = c_hmaterial; |
100 |
|
register int ac; |
101 |
|
register char **av; |
102 |
|
{ |
103 |
< |
fputs("\n#", stdout); /* use Radiance comment character */ |
103 |
> |
putchar('#'); /* use Radiance comment character */ |
104 |
|
while (--ac) { |
105 |
|
putchar(' '); |
106 |
|
fputs(*++av, stdout); |
340 |
|
/* put out xform command */ |
341 |
|
printf("\n!xform"); |
342 |
|
oname = object(); |
343 |
< |
if (*oname) |
344 |
< |
printf(" -n %s", oname); |
343 |
> |
if (*oname) { |
344 |
> |
printf(" -n "); |
345 |
> |
for (op = oname; op[1]; op++) /* remove trailing separator */ |
346 |
> |
putchar(*op); |
347 |
> |
} |
348 |
|
for (i = xa0; i < ac; i++) |
349 |
|
printf(" %s", av[i]); |
350 |
|
if (ac > xa0 && xf_argc > 0) |
402 |
|
double d; |
403 |
|
register int i; |
404 |
|
|
405 |
< |
if (c_cmaterial->name != NULL) |
406 |
< |
mname = c_cmaterial->name; |
405 |
> |
if (c_cmname != NULL) |
406 |
> |
mname = c_cmname; |
407 |
|
if (!c_cmaterial->clock) |
408 |
|
return(mname); /* already current */ |
409 |
|
/* else update output */ |
426 |
|
} |
427 |
|
d = c_cmaterial->rd + c_cmaterial->td + |
428 |
|
c_cmaterial->rs + c_cmaterial->ts; |
429 |
< |
if (d <= 0. | d >= 1.) |
429 |
> |
if (d < 0. | d > 1.) |
430 |
|
return(NULL); |
431 |
< |
if (c_cmaterial->td > .01 || c_cmaterial->ts > .01) { /* trans */ |
431 |
> |
/* check for trans */ |
432 |
> |
if (c_cmaterial->td > .01 || c_cmaterial->ts > .01) { |
433 |
|
double ts, a5, a6; |
434 |
|
|
435 |
< |
ts = sqrt(c_cmaterial->ts); /* because we use 2 sides */ |
435 |
> |
if (c_cmaterial->sided) { |
436 |
> |
ts = sqrt(c_cmaterial->ts); /* approximate */ |
437 |
> |
a5 = .5; |
438 |
> |
} else { |
439 |
> |
ts = c_cmaterial->ts; |
440 |
> |
a5 = 1.; |
441 |
> |
} |
442 |
|
/* average colors */ |
443 |
|
d = c_cmaterial->rd + c_cmaterial->td + ts; |
444 |
|
cvtcolor(radrgb, &c_cmaterial->rd_c, c_cmaterial->rd/d); |
448 |
|
addcolor(radrgb, c2); |
449 |
|
if (c_cmaterial->rs + ts > .0001) |
450 |
|
a5 = (c_cmaterial->rs*c_cmaterial->rs_a + |
451 |
< |
ts*.5*c_cmaterial->ts_a) / |
451 |
> |
ts*a5*c_cmaterial->ts_a) / |
452 |
|
(c_cmaterial->rs + ts); |
453 |
|
a6 = (c_cmaterial->td + ts) / |
454 |
|
(c_cmaterial->rd + c_cmaterial->td + ts); |
455 |
< |
if (a6 < .999) { |
455 |
> |
if (a6 < .999) |
456 |
|
d = c_cmaterial->rd/(1. - c_cmaterial->rs)/(1. - a6); |
457 |
< |
scalecolor(radrgb, d); |
458 |
< |
} |
457 |
> |
else |
458 |
> |
d = c_cmaterial->td + ts; |
459 |
> |
scalecolor(radrgb, d); |
460 |
|
printf("\nvoid trans %s\n0\n0\n", mname); |
461 |
|
printf("7 %f %f %f\n", colval(radrgb,RED), |
462 |
|
colval(radrgb,GRN), colval(radrgb,BLU)); |
464 |
|
ts/(ts + c_cmaterial->td)); |
465 |
|
return(mname); |
466 |
|
} |
467 |
< |
if (c_cmaterial->rs < .01 || isgrey(&c_cmaterial->rs_c)) { /* plastic */ |
468 |
< |
if (c_cmaterial->rs > .999) |
469 |
< |
cvtcolor(radrgb, &c_cmaterial->rd_c, 1.); |
470 |
< |
else |
457 |
< |
cvtcolor(radrgb, &c_cmaterial->rd_c, |
467 |
> |
/* check for plastic */ |
468 |
> |
if (c_cmaterial->rs < .1 && (c_cmaterial->rs < .01 || |
469 |
> |
c_isgrey(&c_cmaterial->rs_c))) { |
470 |
> |
cvtcolor(radrgb, &c_cmaterial->rd_c, |
471 |
|
c_cmaterial->rd/(1.-c_cmaterial->rs)); |
472 |
|
printf("\nvoid plastic %s\n0\n0\n", mname); |
473 |
|
printf("5 %f %f %f %f %f\n", colval(radrgb,RED), |
476 |
|
return(mname); |
477 |
|
} |
478 |
|
/* else it's metal */ |
479 |
< |
d = c_cmaterial->rd + c_cmaterial->rs; /* average colors */ |
480 |
< |
cvtcolor(radrgb, &c_cmaterial->rd_c, c_cmaterial->rd/d); |
481 |
< |
cvtcolor(c2, &c_cmaterial->rs_c, c_cmaterial->rs/d); |
479 |
> |
/* average colors */ |
480 |
> |
cvtcolor(radrgb, &c_cmaterial->rd_c, c_cmaterial->rd); |
481 |
> |
cvtcolor(c2, &c_cmaterial->rs_c, c_cmaterial->rs); |
482 |
|
addcolor(radrgb, c2); |
470 |
– |
if (c_cmaterial->rs < .999) { |
471 |
– |
d = c_cmaterial->rd/(1. - c_cmaterial->rs); |
472 |
– |
scalecolor(radrgb, d); |
473 |
– |
} |
483 |
|
printf("\nvoid metal %s\n0\n0\n", mname); |
484 |
|
printf("5 %f %f %f %f %f\n", colval(radrgb,RED), |
485 |
|
colval(radrgb,GRN), colval(radrgb,BLU), |
486 |
< |
c_cmaterial->rs, c_cmaterial->rs_a); |
486 |
> |
c_cmaterial->rs/(c_cmaterial->rd + c_cmaterial->rs), |
487 |
> |
c_cmaterial->rs_a); |
488 |
|
return(mname); |
489 |
|
} |
490 |
|
|
496 |
|
{ |
497 |
|
static COLOR ciexyz; |
498 |
|
|
499 |
+ |
c_ccvt(ciec, C_CSXY); /* get xy representation */ |
500 |
|
ciexyz[1] = intensity; |
501 |
|
ciexyz[0] = ciec->cx/ciec->cy*ciexyz[1]; |
502 |
|
ciexyz[2] = ciexyz[1]*(1./ciec->cy - 1.) - ciexyz[0]; |