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.5 by greg, Wed Apr 13 17:24:24 1994 UTC vs.
Revision 2.15 by greg, Wed Jun 22 12:35:59 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"
17  
18   #include "trans.h"
19  
20 + #include "tmesh.h"
21 +
22   #include <ctype.h>
23  
22 #define TCALNAME        "tmesh.cal"     /* triangle interp. file */
23 #define QCALNAME        "surf.cal"      /* quad interp. file */
24   #define PATNAME         "M-pat"         /* mesh pattern name (reused) */
25   #define TEXNAME         "M-nor"         /* mesh texture name (reused) */
26   #define DEFOBJ          "unnamed"       /* default object name */
27   #define DEFMAT          "white"         /* default material name */
28  
29 #define  ABS(x)         ((x)>=0 ? (x) : -(x))
30
29   #define pvect(v)        printf("%18.12g %18.12g %18.12g\n",(v)[0],(v)[1],(v)[2])
30  
31   FVECT   *vlist;                 /* our vertex list */
# Line 37 | Line 35 | int    nvns;
35   FLOAT   (*vtlist)[2];           /* map vertex list */
36   int     nvts;
37  
40 typedef FLOAT   BARYCCM[3][4];  /* barycentric coordinate system */
41
38   typedef int     VNDX[3];        /* vertex index (point,map,normal) */
39  
40   #define CHUNKSIZ        256     /* vertex allocation chunk size */
# Line 69 | Line 65 | RULEHD *ourmapping = NULL;
65  
66   char    *defmat = DEFMAT;       /* default (starting) material name */
67   char    *defobj = DEFOBJ;       /* default (starting) object name */
72 int     donames = 0;            /* only get qualifier names */
68  
69 + int     flatten = 0;            /* discard surface normal information */
70 +
71   char    *getmtl(), *getonm();
72  
73   char    mapname[128];           /* current picture file */
74   char    matname[64];            /* current material name */
75   char    group[16][32];          /* current group names */
76   char    objname[128];           /* current object name */
77 + char    *inpfile;               /* input file name */
78   int     lineno;                 /* current line number */
79 < int     faceno;                 /* number of faces read */
79 > int     faceno;                 /* current face number */
80  
81  
82   main(argc, argv)                /* read in .obj file and convert */
83   int     argc;
84   char    *argv[];
85   {
86 <        char    *fname;
86 >        int     donames = 0;
87          int     i;
88  
89          for (i = 1; i < argc && argv[i][0] == '-'; i++)
# Line 99 | Line 97 | char   *argv[];
97                  case 'm':               /* use custom mapfile */
98                          ourmapping = getmapping(argv[++i], &qlist);
99                          break;
100 +                case 'f':               /* flatten surfaces */
101 +                        flatten++;
102 +                        break;
103                  default:
104                          goto userr;
105                  }
106          if (i > argc | i < argc-1)
107                  goto userr;
108          if (i == argc)
109 <                fname = "<stdin>";
110 <        else if (freopen(fname=argv[i], "r", stdin) == NULL) {
111 <                fprintf(stderr, "%s: cannot open\n", fname);
109 >                inpfile = "<stdin>";
110 >        else if (freopen(inpfile=argv[i], "r", stdin) == NULL) {
111 >                fprintf(stderr, "%s: cannot open\n", inpfile);
112                  exit(1);
113          }
114          if (donames) {                          /* scan for ids */
115                  getnames(stdin);
116 <                printf("filename \"%s\"\n", fname);
116 >                printf("filename \"%s\"\n", inpfile);
117                  printf("filetype \"Wavefront\"\n");
118                  write_quals(&qlist, qual, stdout);
119                  printf("qualifier %s begin\n", qlist.qual[Q_FAC]);
# Line 121 | Line 122 | char   *argv[];
122          } else {                                /* translate file */
123                  printf("# ");
124                  printargs(argc, argv, stdout);
125 <                convert(fname, stdin);
125 >                convert(stdin);
126          }
127          exit(0);
128   userr:
129 <        fprintf(stderr, "Usage: %s [-o obj][-m mapping][-n] [file.obj]\n",
129 >        fprintf(stderr, "Usage: %s [-o obj][-m mapping][-n][-f] [file.obj]\n",
130                          argv[0]);
131          exit(1);
132   }
# Line 180 | Line 181 | FILE   *fp;
181   }
182  
183  
184 < convert(fname, fp)              /* convert a T-mesh */
184 < char    *fname;
184 > convert(fp)                     /* convert a T-mesh */
185   FILE    *fp;
186   {
187          char    *argv[MAXARG];
188          int     argc;
189          int     nstats, nunknown;
190          register int    i;
191 <                                        /* start fresh */
192 <        freeverts();
193 <        mapname[0] = '\0';
194 <        strcpy(matname, defmat);
195 <        strcpy(objname, defobj);
196 <        lineno = 0;
191 >
192          nstats = nunknown = 0;
193                                          /* scan until EOF */
194          while (argc = getstmt(argv, fp)) {
# Line 202 | Line 197 | FILE   *fp;
197                          switch (argv[0][1]) {
198                          case '\0':                      /* point */
199                                  if (badarg(argc-1,argv+1,"fff"))
200 <                                        syntax(fname, lineno, "Bad vertex");
200 >                                        syntax("Bad vertex");
201                                  newv(atof(argv[1]), atof(argv[2]),
202                                                  atof(argv[3]));
203                                  break;
# Line 210 | Line 205 | FILE   *fp;
205                                  if (argv[0][2])
206                                          goto unknown;
207                                  if (badarg(argc-1,argv+1,"fff"))
208 <                                        syntax(fname, lineno, "Bad normal");
208 >                                        syntax("Bad normal");
209                                  if (!newvn(atof(argv[1]), atof(argv[2]),
210                                                  atof(argv[3])))
211 <                                        syntax(fname, lineno, "Zero normal");
211 >                                        syntax("Zero normal");
212                                  break;
213                          case 't':                       /* texture map */
214                                  if (argv[0][2])
# Line 232 | Line 227 | FILE   *fp;
227                          faceno++;
228                          switch (argc-1) {
229                          case 0: case 1: case 2:
230 <                                syntax(fname, lineno, "Too few vertices");
230 >                                syntax("Too few vertices");
231                                  break;
232                          case 3:
233                                  if (!puttri(argv[1], argv[2], argv[3]))
234 <                                        syntax(fname, lineno, "Bad triangle");
234 >                                        syntax("Bad triangle");
235                                  break;
241                        case 4:
242                                if (!putquad(argv[1], argv[2],
243                                                argv[3], argv[4]))
244                                        syntax(fname, lineno, "Bad quad");
245                                break;
236                          default:
237                                  if (!putface(argc-1, argv+1))
238 <                                        syntax(fname, lineno, "Bad face");
238 >                                        syntax("Bad face");
239                                  break;
240                          }
241                          break;
# Line 260 | Line 250 | FILE   *fp;
250                                  if (!strcmp(argv[1], "off"))
251                                          mapname[0] = '\0';
252                                  else
253 <                                        strcpy(mapname, argv[1]);
253 >                                        sprintf(mapname, "%s.pic", argv[1]);
254                          } else
255                                  goto unknown;
256                          break;
# Line 279 | Line 269 | FILE   *fp;
269                          group[i-1][0] = '\0';
270                          break;
271                  case '#':               /* comment */
272 +                        printargs(argc, argv, stdout);
273                          break;
274                  default:;               /* something we don't deal with */
275                  unknown:
# Line 287 | Line 278 | FILE   *fp;
278                  }
279                  nstats++;
280          }
281 <        printf("\n# Done processing file: %s\n", fname);
281 >        printf("\n# Done processing file: %s\n", inpfile);
282          printf("# %d lines, %d statements, %d unrecognized\n",
283                          lineno, nstats, nunknown);
284   }
# Line 332 | Line 323 | getmtl()                               /* figure material for this face */
323   {
324          register RULEHD *rp = ourmapping;
325  
326 <        if (rp == NULL)                 /* no rule set */
327 <                return(matname);
326 >        if (rp == NULL) {               /* no rule set */
327 >                if (matname[0])
328 >                        return(matname);
329 >                if (group[0][0])
330 >                        return(group[0]);
331 >                return(defmat);
332 >        }
333                                          /* check for match */
334          do {
335                  if (matchrule(rp)) {
# Line 354 | Line 350 | getonm()                               /* invent a good name for object */
350          static char     name[64];
351          register char   *cp1, *cp2;
352          register int    i;
353 <
354 <        if (!group[0][0] || strcmp(objname, DEFOBJ))
355 <                return(objname);        /* good enough for us */
356 <
353 >                                        /* check for preset */
354 >        if (objname[0])
355 >                return(objname);
356 >        if (!group[0][0])
357 >                return(defobj);
358          cp1 = name;                     /* else make name out of groups */
359          for (i = 0; group[i][0]; i++) {
360                  cp2 = group[i];
# Line 381 | Line 378 | register RULEHD        *rp;
378          register int    i;
379  
380          if (rp->qflg & FL(Q_MTL)) {
381 +                if (!matname[0])
382 +                        return(0);
383                  tmpid.number = 0;
384                  tmpid.name = matname;
385                  if (!matchid(&tmpid, &idm(rp)[Q_MTL]))
386                          return(0);
387          }
388          if (rp->qflg & FL(Q_MAP)) {
389 +                if (!mapname[0])
390 +                        return(0);
391                  tmpid.number = 0;
392                  tmpid.name = mapname;
393                  if (!matchid(&tmpid, &idm(rp)[Q_MAP]))
# Line 403 | Line 404 | register RULEHD        *rp;
404                          return(0);
405          }
406          if (rp->qflg & FL(Q_OBJ)) {
407 +                if (!objname[0])
408 +                        return(0);
409                  tmpid.number = 0;
410                  tmpid.name = objname;
411                  if (!matchid(&tmpid, &idm(rp)[Q_OBJ]))
# Line 428 | Line 431 | register char  *vs;
431                  if (vi[0]-- > nvs)
432                          return(0);
433          } else if (vi[0] < 0) {
434 <                vi[0] = nvs + vi[0];
434 >                vi[0] += nvs;
435                  if (vi[0] < 0)
436                          return(0);
437          } else
# Line 442 | Line 445 | register char  *vs;
445                  if (vi[1]-- > nvts)
446                          return(0);
447          } else if (vi[1] < 0) {
448 <                vi[1] = nvts + vi[1];
448 >                vi[1] += nvts;
449                  if (vi[1] < 0)
450                          return(0);
451          } else
# Line 456 | Line 459 | register char  *vs;
459                  if (vi[2]-- > nvns)
460                          return(0);
461          } else if (vi[2] < 0) {
462 <                vi[2] = nvns + vi[2];
462 >                vi[2] += nvns;
463                  if (vi[2] < 0)
464                          return(0);
465          } else
# Line 465 | Line 468 | register char  *vs;
468   }
469  
470  
471 < nonplanar(ac, av)                       /* are vertices are non-planar? */
471 > nonplanar(ac, av)                       /* are vertices non-planar? */
472   register int    ac;
473   register char   **av;
474   {
# Line 477 | Line 480 | register char  **av;
480  
481          if (!cvtndx(vi, av[0]))
482                  return(0);
483 <        if (vi[2] >= 0)
483 >        if (!flatten && vi[2] >= 0)
484                  return(1);              /* has interpolated normals */
485          if (ac < 4)
486                  return(0);              /* it's a triangle! */
# Line 521 | Line 524 | int    ac;
524   register char   **av;
525   {
526          VNDX    vi;
527 <        char    *mod;
527 >        char    *cp;
528          register int    i;
529  
530 <        if (nonplanar(ac, av)) {        /* break into quads and triangles */
531 <                while (ac > 3) {
532 <                        if (!putquad(av[0], av[1], av[2], av[3]))
530 >        if (nonplanar(ac, av)) {        /* break into triangles */
531 >                while (ac > 2) {
532 >                        if (!puttri(av[0], av[1], av[2]))
533                                  return(0);
534 <                        ac -= 2;                /* remove two vertices */
535 <                        for (i = 1; i < ac; i++)
534 >                        ac--;           /* remove vertex & rotate */
535 >                        cp = av[0];
536 >                        for (i = 0; i < ac-1; i++)
537                                  av[i] = av[i+2];
538 +                        av[i] = cp;
539                  }
535                if (ac == 3 && !puttri(av[0], av[1], av[2]))
536                        return(0);
540                  return(1);
541          }
542 <        if ((mod = getmtl()) == NULL)
542 >        if ((cp = getmtl()) == NULL)
543                  return(-1);
544 <        printf("\n%s polygon %s.%d\n", mod, getonm(), faceno);
544 >        printf("\n%s polygon %s.%d\n", cp, getonm(), faceno);
545          printf("0\n0\n%d\n", 3*ac);
546          for (i = 0; i < ac; i++) {
547                  if (!cvtndx(vi, av[i]))
# Line 555 | Line 558 | char   *v1, *v2, *v3;
558          char    *mod;
559          VNDX    v1i, v2i, v3i;
560          BARYCCM bvecs;
561 +        FLOAT   bcoor[3][3];
562          int     texOK, patOK;
563 +        register int    i;
564  
565          if ((mod = getmtl()) == NULL)
566                  return(-1);
# Line 563 | Line 568 | char   *v1, *v2, *v3;
568          if (!cvtndx(v1i, v1) || !cvtndx(v2i, v2) || !cvtndx(v3i, v3))
569                  return(0);
570                                          /* compute barycentric coordinates */
571 <        texOK = (v1i[2]>=0 && v2i[2]>=0 && v3i[2]>=0);
571 >        texOK = !flatten && (v1i[2]>=0 && v2i[2]>=0 && v3i[2]>=0);
572 > #ifdef TEXMAPS
573          patOK = mapname[0] && (v1i[1]>=0 && v2i[1]>=0 && v3i[1]>=0);
574 + #else
575 +        patOK = 0;
576 + #endif
577          if (texOK | patOK)
578 <                if (comp_baryc(bvecs, vlist[v1i[0]], vlist[v2i[0]],
578 >                if (comp_baryc(&bvecs, vlist[v1i[0]], vlist[v2i[0]],
579                                  vlist[v3i[0]]) < 0)
580                          return(-1);
581                                          /* put out texture (if any) */
# Line 574 | Line 583 | char   *v1, *v2, *v3;
583                  printf("\n%s texfunc %s\n", mod, TEXNAME);
584                  mod = TEXNAME;
585                  printf("4 dx dy dz %s\n", TCALNAME);
586 <                printf("0\n21\n");
587 <                put_baryc(bvecs);
588 <                printf("\t%14.12g %14.12g %14.12g\n",
589 <                                vnlist[v1i[2]][0], vnlist[v2i[2]][0],
590 <                                vnlist[v3i[2]][0]);
591 <                printf("\t%14.12g %14.12g %14.12g\n",
592 <                                vnlist[v1i[2]][1], vnlist[v2i[2]][1],
584 <                                vnlist[v3i[2]][1]);
585 <                printf("\t%14.12g %14.12g %14.12g\n",
586 <                                vnlist[v1i[2]][2], vnlist[v2i[2]][2],
587 <                                vnlist[v3i[2]][2]);
586 >                printf("0\n");
587 >                for (i = 0; i < 3; i++) {
588 >                        bcoor[i][0] = vnlist[v1i[2]][i];
589 >                        bcoor[i][1] = vnlist[v2i[2]][i];
590 >                        bcoor[i][2] = vnlist[v3i[2]][i];
591 >                }
592 >                put_baryc(&bvecs, bcoor, 3);
593          }
594 + #ifdef TEXMAPS
595                                          /* put out pattern (if any) */
596          if (patOK) {
597                  printf("\n%s colorpict %s\n", mod, PATNAME);
598                  mod = PATNAME;
599                  printf("7 noneg noneg noneg %s %s u v\n", mapname, TCALNAME);
600 <                printf("0\n18\n");
601 <                put_baryc(bvecs);
602 <                printf("\t%f %f %f\n", vtlist[v1i[1]][0],
603 <                                vtlist[v2i[1]][0], vtlist[v3i[1]][0]);
604 <                printf("\t%f %f %f\n", vtlist[v1i[1]][1],
605 <                                vtlist[v2i[1]][1], vtlist[v3i[1]][1]);
600 >                printf("0\n");
601 >                for (i = 0; i < 2; i++) {
602 >                        bcoor[i][0] = vtlist[v1i[1]][i];
603 >                        bcoor[i][1] = vtlist[v2i[1]][i];
604 >                        bcoor[i][2] = vtlist[v3i[1]][i];
605 >                }
606 >                put_baryc(&bvecs, bcoor, 2);
607          }
608 + #endif
609                                          /* put out triangle */
610          printf("\n%s polygon %s.%d\n", mod, getonm(), faceno);
611          printf("0\n0\n9\n");
# Line 609 | Line 617 | char   *v1, *v2, *v3;
617   }
618  
619  
612 int
613 comp_baryc(bcm, v1, v2, v3)             /* compute barycentric vectors */
614 register BARYCCM        bcm;
615 FLOAT   *v1, *v2, *v3;
616 {
617        FLOAT   *vt;
618        FVECT   va, vab, vcb;
619        double  d;
620        register int    i, j;
621
622        for (j = 0; j < 3; j++) {
623                for (i = 0; i < 3; i++) {
624                        vab[i] = v1[i] - v2[i];
625                        vcb[i] = v3[i] - v2[i];
626                }
627                d = DOT(vcb,vcb);
628                if (d <= FTINY)
629                        return(-1);
630                d = DOT(vcb,vab)/d;
631                for (i = 0; i < 3; i++)
632                        va[i] = vab[i] - vcb[i]*d;
633                d = DOT(va,va);
634                if (d <= FTINY)
635                        return(-1);
636                for (i = 0; i < 3; i++) {
637                        va[i] /= d;
638                        bcm[j][i] = va[i];
639                }
640                bcm[j][3] = -DOT(v2,va);
641                                        /* rotate vertices */
642                vt = v1;
643                v1 = v2;
644                v2 = v3;
645                v3 = vt;
646        }
647        return(0);
648 }
649
650
651 put_baryc(bcm)                          /* put barycentric coord. vectors */
652 register BARYCCM        bcm;
653 {
654        register int    i;
655
656        for (i = 0; i < 3; i++)
657                printf("%14.8f %14.8f %14.8f %14.8f\n",
658                                bcm[i][0], bcm[i][1], bcm[i][2], bcm[i][3]);
659 }
660
661
662 putquad(p0, p1, p3, p2)                 /* put out a quadrilateral */
663 char  *p0, *p1, *p3, *p2;               /* names correspond to binary pos. */
664 {
665        VNDX  p0i, p1i, p2i, p3i;
666        FVECT  norm[4];
667        char  *mod, *name;
668        int  axis;
669        FVECT  v1, v2, vc1, vc2;
670        int  ok1, ok2;
671
672        if ((mod = getmtl()) == NULL)
673                return(-1);
674        name = getonm();
675                                        /* get actual indices */
676        if (!cvtndx(p0i,p0) || !cvtndx(p1i,p1) ||
677                        !cvtndx(p2i,p2) || !cvtndx(p3i,p3))
678                return(0);
679                                        /* compute exact normals */
680        fvsum(v1, vlist[p1i[0]], vlist[p0i[0]], -1.0);
681        fvsum(v2, vlist[p2i[0]], vlist[p0i[0]], -1.0);
682        fcross(vc1, v1, v2);
683        ok1 = normalize(vc1) != 0.0;
684        fvsum(v1, vlist[p2i[0]], vlist[p3i[0]], -1.0);
685        fvsum(v2, vlist[p1i[0]], vlist[p3i[0]], -1.0);
686        fcross(vc2, v1, v2);
687        ok2 = normalize(vc2) != 0.0;
688        if (!(ok1 | ok2))
689                return(-1);
690                                        /* compute normal interpolation */
691        axis = norminterp(norm, p0i, p1i, p2i, p3i);
692
693                                        /* put out quadrilateral? */
694        if (ok1 & ok2 && fabs(fdot(vc1,vc2)) >= 1.0-FTINY) {
695                printf("\n%s ", mod);
696                if (axis != -1) {
697                        printf("texfunc %s\n", TEXNAME);
698                        printf("4 surf_dx surf_dy surf_dz %s\n", QCALNAME);
699                        printf("0\n13\t%d\n", axis);
700                        pvect(norm[0]);
701                        pvect(norm[1]);
702                        pvect(norm[2]);
703                        fvsum(v1, norm[3], vc1, -0.5);
704                        fvsum(v1, v1, vc2, -0.5);
705                        pvect(v1);
706                        printf("\n%s ", TEXNAME);
707                }
708                printf("polygon %s.%d\n", name, faceno);
709                printf("0\n0\n12\n");
710                pvect(vlist[p0i[0]]);
711                pvect(vlist[p1i[0]]);
712                pvect(vlist[p3i[0]]);
713                pvect(vlist[p2i[0]]);
714                return(1);
715        }
716                                        /* put out triangles? */
717        if (ok1) {
718                printf("\n%s ", mod);
719                if (axis != -1) {
720                        printf("texfunc %s\n", TEXNAME);
721                        printf("4 surf_dx surf_dy surf_dz %s\n", QCALNAME);
722                        printf("0\n13\t%d\n", axis);
723                        pvect(norm[0]);
724                        pvect(norm[1]);
725                        pvect(norm[2]);
726                        fvsum(v1, norm[3], vc1, -1.0);
727                        pvect(v1);
728                        printf("\n%s ", TEXNAME);
729                }
730                printf("polygon %s.%da\n", name, faceno);
731                printf("0\n0\n9\n");
732                pvect(vlist[p0i[0]]);
733                pvect(vlist[p1i[0]]);
734                pvect(vlist[p2i[0]]);
735        }
736        if (ok2) {
737                printf("\n%s ", mod);
738                if (axis != -1) {
739                        printf("texfunc %s\n", TEXNAME);
740                        printf("4 surf_dx surf_dy surf_dz %s\n", QCALNAME);
741                        printf("0\n13\t%d\n", axis);
742                        pvect(norm[0]);
743                        pvect(norm[1]);
744                        pvect(norm[2]);
745                        fvsum(v2, norm[3], vc2, -1.0);
746                        pvect(v2);
747                        printf("\n%s ", TEXNAME);
748                }
749                printf("polygon %s.%db\n", name, faceno);
750                printf("0\n0\n9\n");
751                pvect(vlist[p2i[0]]);
752                pvect(vlist[p1i[0]]);
753                pvect(vlist[p3i[0]]);
754        }
755        return(1);
756 }
757
758
759 int
760 norminterp(resmat, p0i, p1i, p2i, p3i)  /* compute normal interpolation */
761 register FVECT  resmat[4];
762 register VNDX  p0i, p1i, p2i, p3i;
763 {
764 #define u  ((ax+1)%3)
765 #define v  ((ax+2)%3)
766
767        register int  ax;
768        MAT4  eqnmat;
769        FVECT  v1;
770        register int  i, j;
771
772        if (!(p0i[2]>=0 && p1i[2]>=0 && p2i[2]>=0 && p3i[2]>=0))
773                return(-1);
774                                        /* find dominant axis */
775        VCOPY(v1, vnlist[p0i[2]]);
776        fvsum(v1, v1, vnlist[p1i[2]], 1.0);
777        fvsum(v1, v1, vnlist[p2i[2]], 1.0);
778        fvsum(v1, v1, vnlist[p3i[2]], 1.0);
779        ax = ABS(v1[0]) > ABS(v1[1]) ? 0 : 1;
780        ax = ABS(v1[ax]) > ABS(v1[2]) ? ax : 2;
781                                        /* assign equation matrix */
782        eqnmat[0][0] = vlist[p0i[0]][u]*vlist[p0i[0]][v];
783        eqnmat[0][1] = vlist[p0i[0]][u];
784        eqnmat[0][2] = vlist[p0i[0]][v];
785        eqnmat[0][3] = 1.0;
786        eqnmat[1][0] = vlist[p1i[0]][u]*vlist[p1i[0]][v];
787        eqnmat[1][1] = vlist[p1i[0]][u];
788        eqnmat[1][2] = vlist[p1i[0]][v];
789        eqnmat[1][3] = 1.0;
790        eqnmat[2][0] = vlist[p2i[0]][u]*vlist[p2i[0]][v];
791        eqnmat[2][1] = vlist[p2i[0]][u];
792        eqnmat[2][2] = vlist[p2i[0]][v];
793        eqnmat[2][3] = 1.0;
794        eqnmat[3][0] = vlist[p3i[0]][u]*vlist[p3i[0]][v];
795        eqnmat[3][1] = vlist[p3i[0]][u];
796        eqnmat[3][2] = vlist[p3i[0]][v];
797        eqnmat[3][3] = 1.0;
798                                        /* invert matrix (solve system) */
799        if (!invmat4(eqnmat, eqnmat))
800                return(-1);                     /* no solution */
801                                        /* compute result matrix */
802        for (j = 0; j < 4; j++)
803                for (i = 0; i < 3; i++)
804                        resmat[j][i] =  eqnmat[j][0]*vnlist[p0i[2]][i] +
805                                        eqnmat[j][1]*vnlist[p1i[2]][i] +
806                                        eqnmat[j][2]*vnlist[p2i[2]][i] +
807                                        eqnmat[j][3]*vnlist[p3i[2]][i];
808        return(ax);
809
810 #undef u
811 #undef v
812 }
813
814
620   freeverts()                     /* free all vertices */
621   {
622          if (nvs) {
# Line 903 | Line 708 | double x, y;
708   }
709  
710  
711 < syntax(fn, ln, er)                      /* report syntax error and exit */
907 < char    *fn;
908 < int     ln;
711 > syntax(er)                      /* report syntax error and exit */
712   char    *er;
713   {
714          fprintf(stderr, "%s: Wavefront syntax error near line %d: %s\n",
715 <                        fn, ln, er);
715 >                        inpfile, lineno, er);
716          exit(1);
717   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines