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(); |
273 |
|
return(MG_EARGC); |
274 |
|
if ((mat = material()) == NULL) |
275 |
|
return(MG_EBADMAT); |
276 |
< |
if (ac < 5) { /* check for surface normals */ |
276 |
> |
if (ac <= 5) { /* check for surface normals */ |
277 |
|
for (i = 1; i < ac; i++) { |
278 |
|
if ((cv = c_getvert(av[i])) == NULL) |
279 |
|
return(MG_EUNDEF); |
354 |
|
char *mat, *vn1, *vn2, *vn3; |
355 |
|
{ |
356 |
|
static int ntris; |
364 |
– |
char *mod = mat; |
357 |
|
BARYCCM bvecs; |
358 |
|
FLOAT bcoor[3][3]; |
359 |
|
C_VERTEX *cv1, *cv2, *cv3; |
367 |
|
xf_xfmpoint(v1, cv1->p); |
368 |
|
xf_xfmpoint(v2, cv2->p); |
369 |
|
xf_xfmpoint(v3, cv3->p); |
370 |
< |
if (comp_baryc(&bvecs, v1, v2, v3) == 0) { |
371 |
< |
printf("\n%s texfunc T-nor\n", mod); |
372 |
< |
mod = "T-nor"; |
373 |
< |
printf("4 dx dy dz %s\n0\n", TCALNAME); |
374 |
< |
xf_rotvect(n1, cv1->n); |
375 |
< |
xf_rotvect(n2, cv2->n); |
376 |
< |
xf_rotvect(n3, cv3->n); |
377 |
< |
for (i = 0; i < 3; i++) { |
378 |
< |
bcoor[i][0] = n1[i]; |
379 |
< |
bcoor[i][1] = n2[i]; |
380 |
< |
bcoor[i][2] = n3[i]; |
389 |
< |
} |
390 |
< |
put_baryc(&bvecs, bcoor, 3); |
370 |
> |
if (comp_baryc(&bvecs, v1, v2, v3) < 0) |
371 |
> |
return; /* degenerate triangle! */ |
372 |
> |
printf("\n%s texfunc T-nor\n", mat); |
373 |
> |
printf("4 dx dy dz %s\n0\n", TCALNAME); |
374 |
> |
xf_rotvect(n1, cv1->n); |
375 |
> |
xf_rotvect(n2, cv2->n); |
376 |
> |
xf_rotvect(n3, cv3->n); |
377 |
> |
for (i = 0; i < 3; i++) { |
378 |
> |
bcoor[i][0] = n1[i]; |
379 |
> |
bcoor[i][1] = n2[i]; |
380 |
> |
bcoor[i][2] = n3[i]; |
381 |
|
} |
382 |
< |
printf("\n%s polygon %st%d\n", mod, object(), ++ntris); |
382 |
> |
put_baryc(&bvecs, bcoor, 3); |
383 |
> |
printf("\nT-nor polygon %st%d\n", object(), ++ntris); |
384 |
|
printf("0\n0\n9\n"); |
385 |
|
putv(v1); |
386 |
|
putv(v2); |
405 |
|
if (c_cmaterial->ed > .1) { /* emitter */ |
406 |
|
cvtcolor(radrgb, &c_cmaterial->ed_c, |
407 |
|
emult*c_cmaterial->ed/WHTEFFICACY); |
408 |
< |
if (glowdist < BIGFLT) { /* do a glow */ |
408 |
> |
if (glowdist < FHUGE) { /* do a glow */ |
409 |
|
printf("\nvoid glow %s\n0\n0\n", mname); |
410 |
|
printf("4 %f %f %f %f\n", colval(radrgb,RED), |
411 |
|
colval(radrgb,GRN), |