| 10 |
|
* Currently, we support only polygonal geometry. Non-planar |
| 11 |
|
* faces are broken rather haphazardly into triangles. |
| 12 |
|
* Also, texture map indices only work for triangles, though |
| 13 |
< |
* I'm not sure they work correctly. |
| 13 |
> |
* I'm not sure they work correctly. (Taken out -- see TEXMAPS defines.) |
| 14 |
|
*/ |
| 15 |
|
|
| 16 |
|
#include "standard.h" |
| 254 |
|
if (!strcmp(argv[1], "off")) |
| 255 |
|
mapname[0] = '\0'; |
| 256 |
|
else |
| 257 |
< |
strcpy(mapname, argv[1]); |
| 257 |
> |
sprintf(mapname, "%s.pic", argv[1]); |
| 258 |
|
} else |
| 259 |
|
goto unknown; |
| 260 |
|
break; |
| 273 |
|
group[i-1][0] = '\0'; |
| 274 |
|
break; |
| 275 |
|
case '#': /* comment */ |
| 276 |
+ |
printargs(argc, argv, stdout); |
| 277 |
|
break; |
| 278 |
|
default:; /* something we don't deal with */ |
| 279 |
|
unknown: |
| 528 |
|
register char **av; |
| 529 |
|
{ |
| 530 |
|
VNDX vi; |
| 531 |
< |
char *mod; |
| 531 |
> |
char *cp; |
| 532 |
|
register int i; |
| 533 |
|
|
| 534 |
|
if (nonplanar(ac, av)) { /* break into quads and triangles */ |
| 535 |
|
while (ac > 3) { |
| 536 |
|
if (!putquad(av[0], av[1], av[2], av[3])) |
| 537 |
|
return(0); |
| 538 |
< |
/* remove two vertices & rotate */ |
| 539 |
< |
av[ac -= 2] = av[0]; |
| 540 |
< |
for (i = 0; i <= ac; i++) |
| 541 |
< |
av[i] = av[i+2]; |
| 538 |
> |
ac -= 2; /* remove two vertices & rotate */ |
| 539 |
> |
cp = av[0]; |
| 540 |
> |
for (i = 0; i < ac-1; i++) |
| 541 |
> |
av[i] = av[i+3]; |
| 542 |
> |
av[i] = cp; |
| 543 |
|
} |
| 544 |
|
if (ac == 3 && !puttri(av[0], av[1], av[2])) |
| 545 |
|
return(0); |
| 546 |
|
return(1); |
| 547 |
|
} |
| 548 |
< |
if ((mod = getmtl()) == NULL) |
| 548 |
> |
if ((cp = getmtl()) == NULL) |
| 549 |
|
return(-1); |
| 550 |
< |
printf("\n%s polygon %s.%d\n", mod, getonm(), faceno); |
| 550 |
> |
printf("\n%s polygon %s.%d\n", cp, getonm(), faceno); |
| 551 |
|
printf("0\n0\n%d\n", 3*ac); |
| 552 |
|
for (i = 0; i < ac; i++) { |
| 553 |
|
if (!cvtndx(vi, av[i])) |
| 573 |
|
return(0); |
| 574 |
|
/* compute barycentric coordinates */ |
| 575 |
|
texOK = (v1i[2]>=0 && v2i[2]>=0 && v3i[2]>=0); |
| 576 |
+ |
#ifdef TEXMAPS |
| 577 |
|
patOK = mapname[0] && (v1i[1]>=0 && v2i[1]>=0 && v3i[1]>=0); |
| 578 |
+ |
#else |
| 579 |
+ |
patOK = 0; |
| 580 |
+ |
#endif |
| 581 |
|
if (texOK | patOK) |
| 582 |
|
if (comp_baryc(bvecs, vlist[v1i[0]], vlist[v2i[0]], |
| 583 |
|
vlist[v3i[0]]) < 0) |
| 599 |
|
vnlist[v1i[2]][2], vnlist[v2i[2]][2], |
| 600 |
|
vnlist[v3i[2]][2]); |
| 601 |
|
} |
| 602 |
+ |
#ifdef TEXMAPS |
| 603 |
|
/* put out pattern (if any) */ |
| 604 |
|
if (patOK) { |
| 605 |
|
printf("\n%s colorpict %s\n", mod, PATNAME); |
| 612 |
|
printf("\t%f %f %f\n", vtlist[v1i[1]][1], |
| 613 |
|
vtlist[v2i[1]][1], vtlist[v3i[1]][1]); |
| 614 |
|
} |
| 615 |
+ |
#endif |
| 616 |
|
/* put out triangle */ |
| 617 |
|
printf("\n%s polygon %s.%d\n", mod, getonm(), faceno); |
| 618 |
|
printf("0\n0\n9\n"); |
| 684 |
|
FVECT v1, v2, vc1, vc2; |
| 685 |
|
int ok1, ok2; |
| 686 |
|
|
| 687 |
+ |
#ifdef TEXMAPS |
| 688 |
+ |
/* also should output texture index coordinates, |
| 689 |
+ |
* which will require new .cal file |
| 690 |
+ |
*/ |
| 691 |
+ |
#endif |
| 692 |
|
if ((mod = getmtl()) == NULL) |
| 693 |
|
return(-1); |
| 694 |
|
name = getonm(); |
| 789 |
|
FVECT v1; |
| 790 |
|
register int i, j; |
| 791 |
|
|
| 792 |
+ |
#ifdef TEXMAPS |
| 793 |
+ |
/* also check for texture indices */ |
| 794 |
+ |
#endif |
| 795 |
|
if (!(p0i[2]>=0 && p1i[2]>=0 && p2i[2]>=0 && p3i[2]>=0)) |
| 796 |
|
return(-1); |
| 797 |
|
/* find dominant axis */ |
| 828 |
|
eqnmat[j][1]*vnlist[p1i[2]][i] + |
| 829 |
|
eqnmat[j][2]*vnlist[p2i[2]][i] + |
| 830 |
|
eqnmat[j][3]*vnlist[p3i[2]][i]; |
| 831 |
+ |
#ifdef TEXMAPS |
| 832 |
+ |
/* compute result matrix for texture indices */ |
| 833 |
+ |
#endif |
| 834 |
|
return(ax); |
| 835 |
|
|
| 836 |
|
#undef u |