ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cv/obj2rad.c
(Generate patch)

Comparing ray/src/cv/obj2rad.c (file contents):
Revision 2.6 by greg, Thu Apr 14 04:29:10 1994 UTC vs.
Revision 2.8 by greg, Tue Jun 14 14:30:38 1994 UTC

# Line 10 | Line 10 | static char SCCSid[] = "$SunId$ LBL";
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"
# Line 70 | Line 70 | RULEHD *ourmapping = NULL;
70   char    *defmat = DEFMAT;       /* default (starting) material name */
71   char    *defobj = DEFOBJ;       /* default (starting) object name */
72  
73 + int     flatten = 0;            /* discard surface normal information */
74 +
75   char    *getmtl(), *getonm();
76  
77   char    mapname[128];           /* current picture file */
# Line 99 | Line 101 | char   *argv[];
101                  case 'm':               /* use custom mapfile */
102                          ourmapping = getmapping(argv[++i], &qlist);
103                          break;
104 +                case 'f':               /* flatten surfaces */
105 +                        flatten++;
106 +                        break;
107                  default:
108                          goto userr;
109                  }
# Line 254 | Line 259 | FILE   *fp;
259                                  if (!strcmp(argv[1], "off"))
260                                          mapname[0] = '\0';
261                                  else
262 <                                        strcpy(mapname, argv[1]);
262 >                                        sprintf(mapname, "%s.pic", argv[1]);
263                          } else
264                                  goto unknown;
265                          break;
# Line 273 | Line 278 | FILE   *fp;
278                          group[i-1][0] = '\0';
279                          break;
280                  case '#':               /* comment */
281 +                        printargs(argc, argv, stdout);
282                          break;
283                  default:;               /* something we don't deal with */
284                  unknown:
# Line 527 | Line 533 | int    ac;
533   register char   **av;
534   {
535          VNDX    vi;
536 <        char    *mod;
536 >        char    *cp;
537          register int    i;
538  
539          if (nonplanar(ac, av)) {        /* break into quads and triangles */
540                  while (ac > 3) {
541                          if (!putquad(av[0], av[1], av[2], av[3]))
542                                  return(0);
543 <                                        /* remove two vertices & rotate */
544 <                        av[ac -= 2] = av[0];
545 <                        for (i = 0; i <= ac; i++)
546 <                                av[i] = av[i+2];
543 >                        ac -= 2;        /* remove two vertices & rotate */
544 >                        cp = av[0];
545 >                        for (i = 0; i < ac-1; i++)
546 >                                av[i] = av[i+3];
547 >                        av[i] = cp;
548                  }
549                  if (ac == 3 && !puttri(av[0], av[1], av[2]))
550                          return(0);
551                  return(1);
552          }
553 <        if ((mod = getmtl()) == NULL)
553 >        if ((cp = getmtl()) == NULL)
554                  return(-1);
555 <        printf("\n%s polygon %s.%d\n", mod, getonm(), faceno);
555 >        printf("\n%s polygon %s.%d\n", cp, getonm(), faceno);
556          printf("0\n0\n%d\n", 3*ac);
557          for (i = 0; i < ac; i++) {
558                  if (!cvtndx(vi, av[i]))
# Line 570 | Line 577 | char   *v1, *v2, *v3;
577          if (!cvtndx(v1i, v1) || !cvtndx(v2i, v2) || !cvtndx(v3i, v3))
578                  return(0);
579                                          /* compute barycentric coordinates */
580 <        texOK = (v1i[2]>=0 && v2i[2]>=0 && v3i[2]>=0);
580 >        texOK = !flatten && (v1i[2]>=0 && v2i[2]>=0 && v3i[2]>=0);
581 > #ifdef TEXMAPS
582          patOK = mapname[0] && (v1i[1]>=0 && v2i[1]>=0 && v3i[1]>=0);
583 + #else
584 +        patOK = 0;
585 + #endif
586          if (texOK | patOK)
587                  if (comp_baryc(bvecs, vlist[v1i[0]], vlist[v2i[0]],
588                                  vlist[v3i[0]]) < 0)
# Line 593 | Line 604 | char   *v1, *v2, *v3;
604                                  vnlist[v1i[2]][2], vnlist[v2i[2]][2],
605                                  vnlist[v3i[2]][2]);
606          }
607 + #ifdef TEXMAPS
608                                          /* put out pattern (if any) */
609          if (patOK) {
610                  printf("\n%s colorpict %s\n", mod, PATNAME);
# Line 605 | Line 617 | char   *v1, *v2, *v3;
617                  printf("\t%f %f %f\n", vtlist[v1i[1]][1],
618                                  vtlist[v2i[1]][1], vtlist[v3i[1]][1]);
619          }
620 + #endif
621                                          /* put out triangle */
622          printf("\n%s polygon %s.%d\n", mod, getonm(), faceno);
623          printf("0\n0\n9\n");
# Line 676 | Line 689 | char  *p0, *p1, *p3, *p2;              /* names correspond to bina
689          FVECT  v1, v2, vc1, vc2;
690          int  ok1, ok2;
691  
692 + #ifdef TEXMAPS
693 +        /* also should output texture index coordinates,
694 +         * which will require new .cal file
695 +         */
696 + #endif
697          if ((mod = getmtl()) == NULL)
698                  return(-1);
699          name = getonm();
# Line 776 | Line 794 | register VNDX  p0i, p1i, p2i, p3i;
794          FVECT  v1;
795          register int  i, j;
796  
797 <        if (!(p0i[2]>=0 && p1i[2]>=0 && p2i[2]>=0 && p3i[2]>=0))
797 > #ifdef TEXMAPS
798 >        /* also check for texture indices */
799 > #endif
800 >        if (flatten || !(p0i[2]>=0 && p1i[2]>=0 && p2i[2]>=0 && p3i[2]>=0))
801                  return(-1);
802                                          /* find dominant axis */
803          VCOPY(v1, vnlist[p0i[2]]);
# Line 812 | Line 833 | register VNDX  p0i, p1i, p2i, p3i;
833                                          eqnmat[j][1]*vnlist[p1i[2]][i] +
834                                          eqnmat[j][2]*vnlist[p2i[2]][i] +
835                                          eqnmat[j][3]*vnlist[p3i[2]][i];
836 + #ifdef TEXMAPS
837 +        /* compute result matrix for texture indices */
838 + #endif
839          return(ax);
840  
841   #undef u

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines