| 17 |
|
|
| 18 |
|
#define putv(v) printf("%18.12g %18.12g %18.12g\n",(v)[0],(v)[1],(v)[2]) |
| 19 |
|
|
| 20 |
< |
#define isgrey(cxy) ((cxy)->cx > .31 && (cxy)->cx < .35 && \ |
| 21 |
< |
(cxy)->cy > .31 && (cxy)->cy < .35) |
| 20 |
> |
double glowdist = FHUGE; /* glow test distance */ |
| 21 |
|
|
| 23 |
– |
#define is0vect(v) ((v)[0] == 0. && (v)[1] == 0. && (v)[2] == 0.) |
| 24 |
– |
|
| 25 |
– |
#define BIGFLT 1e8 |
| 26 |
– |
|
| 27 |
– |
double glowdist = 1.5*BIGFLT; /* glow test distance */ |
| 28 |
– |
|
| 22 |
|
double emult = 1.; /* emmitter multiplier */ |
| 23 |
|
|
| 24 |
|
int r_comment(), r_cone(), r_cyl(), r_face(), r_ies(), r_ring(), r_sph(); |
| 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; |
| 275 |
|
return(MG_EARGC); |
| 276 |
|
if ((mat = material()) == NULL) |
| 277 |
|
return(MG_EBADMAT); |
| 278 |
< |
if (ac < 5) { /* check for surface normals */ |
| 278 |
> |
if (ac <= 5) { /* check for surface normals */ |
| 279 |
|
for (i = 1; i < ac; i++) { |
| 280 |
|
if ((cv = c_getvert(av[i])) == NULL) |
| 281 |
|
return(MG_EUNDEF); |
| 339 |
|
/* put out xform command */ |
| 340 |
|
printf("\n!xform"); |
| 341 |
|
oname = object(); |
| 342 |
< |
if (*oname) |
| 343 |
< |
printf(" -n %s", oname); |
| 342 |
> |
if (*oname) { |
| 343 |
> |
printf(" -n "); |
| 344 |
> |
for (op = oname; op[1]; op++) /* remove trailing separator */ |
| 345 |
> |
putchar(*op); |
| 346 |
> |
} |
| 347 |
|
for (i = xa0; i < ac; i++) |
| 348 |
|
printf(" %s", av[i]); |
| 349 |
|
if (ac > xa0 && xf_argc > 0) |
| 359 |
|
char *mat, *vn1, *vn2, *vn3; |
| 360 |
|
{ |
| 361 |
|
static int ntris; |
| 364 |
– |
char *mod = mat; |
| 362 |
|
BARYCCM bvecs; |
| 363 |
|
FLOAT bcoor[3][3]; |
| 364 |
|
C_VERTEX *cv1, *cv2, *cv3; |
| 372 |
|
xf_xfmpoint(v1, cv1->p); |
| 373 |
|
xf_xfmpoint(v2, cv2->p); |
| 374 |
|
xf_xfmpoint(v3, cv3->p); |
| 375 |
< |
if (comp_baryc(&bvecs, v1, v2, v3) == 0) { |
| 376 |
< |
printf("\n%s texfunc T-nor\n", mod); |
| 377 |
< |
mod = "T-nor"; |
| 378 |
< |
printf("4 dx dy dz %s\n0\n", TCALNAME); |
| 379 |
< |
xf_rotvect(n1, cv1->n); |
| 380 |
< |
xf_rotvect(n2, cv2->n); |
| 381 |
< |
xf_rotvect(n3, cv3->n); |
| 382 |
< |
for (i = 0; i < 3; i++) { |
| 383 |
< |
bcoor[i][0] = n1[i]; |
| 384 |
< |
bcoor[i][1] = n2[i]; |
| 385 |
< |
bcoor[i][2] = n3[i]; |
| 389 |
< |
} |
| 390 |
< |
put_baryc(&bvecs, bcoor, 3); |
| 375 |
> |
if (comp_baryc(&bvecs, v1, v2, v3) < 0) |
| 376 |
> |
return; /* degenerate triangle! */ |
| 377 |
> |
printf("\n%s texfunc T-nor\n", mat); |
| 378 |
> |
printf("4 dx dy dz %s\n0\n", TCALNAME); |
| 379 |
> |
xf_rotvect(n1, cv1->n); |
| 380 |
> |
xf_rotvect(n2, cv2->n); |
| 381 |
> |
xf_rotvect(n3, cv3->n); |
| 382 |
> |
for (i = 0; i < 3; i++) { |
| 383 |
> |
bcoor[i][0] = n1[i]; |
| 384 |
> |
bcoor[i][1] = n2[i]; |
| 385 |
> |
bcoor[i][2] = n3[i]; |
| 386 |
|
} |
| 387 |
< |
printf("\n%s polygon %st%d\n", mod, object(), ++ntris); |
| 387 |
> |
put_baryc(&bvecs, bcoor, 3); |
| 388 |
> |
printf("\nT-nor polygon %st%d\n", object(), ++ntris); |
| 389 |
|
printf("0\n0\n9\n"); |
| 390 |
|
putv(v1); |
| 391 |
|
putv(v2); |
| 401 |
|
double d; |
| 402 |
|
register int i; |
| 403 |
|
|
| 404 |
< |
if (c_cmaterial->name != NULL) |
| 405 |
< |
mname = c_cmaterial->name; |
| 404 |
> |
if (c_cmname != NULL) |
| 405 |
> |
mname = c_cmname; |
| 406 |
|
if (!c_cmaterial->clock) |
| 407 |
|
return(mname); /* already current */ |
| 408 |
|
/* else update output */ |
| 410 |
|
if (c_cmaterial->ed > .1) { /* emitter */ |
| 411 |
|
cvtcolor(radrgb, &c_cmaterial->ed_c, |
| 412 |
|
emult*c_cmaterial->ed/WHTEFFICACY); |
| 413 |
< |
if (glowdist < BIGFLT) { /* do a glow */ |
| 413 |
> |
if (glowdist < FHUGE) { /* do a glow */ |
| 414 |
|
printf("\nvoid glow %s\n0\n0\n", mname); |
| 415 |
|
printf("4 %f %f %f %f\n", colval(radrgb,RED), |
| 416 |
|
colval(radrgb,GRN), |
| 427 |
|
c_cmaterial->rs + c_cmaterial->ts; |
| 428 |
|
if (d <= 0. | d >= 1.) |
| 429 |
|
return(NULL); |
| 430 |
< |
if (c_cmaterial->td > .01 || c_cmaterial->ts > .01) { /* trans */ |
| 430 |
> |
/* check for trans */ |
| 431 |
> |
if (c_cmaterial->td > .01 || c_cmaterial->ts > .01) { |
| 432 |
|
double ts, a5, a6; |
| 433 |
|
|
| 434 |
|
ts = sqrt(c_cmaterial->ts); /* because we use 2 sides */ |
| 456 |
|
ts/(ts + c_cmaterial->td)); |
| 457 |
|
return(mname); |
| 458 |
|
} |
| 459 |
< |
if (c_cmaterial->rs < .01 || isgrey(&c_cmaterial->rs_c)) { /* plastic */ |
| 459 |
> |
/* check for plastic */ |
| 460 |
> |
if (c_cmaterial->rs < .01 || c_isgrey(&c_cmaterial->rs_c)) { |
| 461 |
|
if (c_cmaterial->rs > .999) |
| 462 |
|
cvtcolor(radrgb, &c_cmaterial->rd_c, 1.); |
| 463 |
|
else |
| 493 |
|
{ |
| 494 |
|
static COLOR ciexyz; |
| 495 |
|
|
| 496 |
+ |
c_ccvt(ciec, C_CSXY); /* get xy representation */ |
| 497 |
|
ciexyz[1] = intensity; |
| 498 |
|
ciexyz[0] = ciec->cx/ciec->cy*ciexyz[1]; |
| 499 |
|
ciexyz[2] = ciexyz[1]*(1./ciec->cy - 1.) - ciexyz[0]; |