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

Comparing ray/src/cv/mgf2rad.c (file contents):
Revision 2.24 by gwlarson, Wed Jun 9 14:06:00 1999 UTC vs.
Revision 2.25 by greg, Sat Feb 22 02:07:23 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1996 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Convert MGF (Materials and Geometry Format) to Radiance
6   */
7  
8   #include <stdio.h>
9 + #include <stdlib.h>
10   #include <math.h>
11   #include <string.h>
12   #include "mgflib/parser.h"
# Line 298 | Line 296 | int    ac;
296   char    **av;
297   {
298          static int      nfaces;
299 +        int             myi = invert;
300          char    *mat;
301          register int    i;
302          register C_VERTEX       *cv;
# Line 316 | Line 315 | char   **av;
315                          if (is0vect(cva[i-1]->n))
316                                  break;
317                  }
318 <                if (i == ac) {
318 >                if (i < ac)
319 >                        i = ISFLAT;
320 >                else
321                          i = flat_tri(cva[0]->p, cva[1]->p, cva[2]->p,
322                                          cva[0]->n, cva[1]->n, cva[2]->n);
323 <                        if (i < 0)
324 <                                return(MG_OK);  /* degenerate (error?) */
323 >                if (i == DEGEN)
324 >                        return(MG_OK);          /* degenerate (error?) */
325 >                if (i == RVBENT) {
326 >                        myi = !myi;
327 >                        i = ISBENT;
328 >                } else if (i == RVFLAT) {
329 >                        myi = !myi;
330 >                        i = ISFLAT;
331                  }
332 <                if (!i) {                       /* smoothed triangles */
333 <                        do_tri(mat, cva[0], cva[1], cva[2]);
332 >                if (i == ISBENT) {              /* smoothed triangles */
333 >                        do_tri(mat, cva[0], cva[1], cva[2], myi);
334                          if (ac == 5)
335 <                                do_tri(mat, cva[2], cva[3], cva[0]);
335 >                                do_tri(mat, cva[2], cva[3], cva[0], myi);
336                          return(MG_OK);
337                  }
338          }
# Line 333 | Line 340 | char   **av;
340          printf("\n%s polygon %sf%d\n", mat, object(), ++nfaces);
341          printf("0\n0\n%d\n", 3*(ac-1));
342          for (i = 1; i < ac; i++) {      /* get, transform, print each vertex */
343 <                if ((cv = c_getvert(av[invert ? ac-i : i])) == NULL)
343 >                if ((cv = c_getvert(av[myi ? ac-i : i])) == NULL)
344                          return(MG_EUNDEF);
345                  xf_xfmpoint(v, cv->p);
346                  putv(v);
# Line 407 | Line 414 | char   **av;
414   }
415  
416  
417 < do_tri(mat, cv1, cv2, cv3)              /* put out smoothed triangle */
417 > do_tri(mat, cv1, cv2, cv3, iv)          /* put out smoothed triangle */
418   char    *mat;
419   C_VERTEX        *cv1, *cv2, *cv3;
420 + int     iv;
421   {
422          static int      ntris;
423          BARYCCM bvecs;
# Line 419 | Line 427 | C_VERTEX       *cv1, *cv2, *cv3;
427          FVECT   n1, n2, n3;
428          register int    i;
429  
430 <        if (invert) {                   /* swap vertex order if inverted */
430 >        if (iv) {                       /* swap vertex order if inverted */
431                  cvt = cv1;
432                  cv1 = cv3;
433                  cv3 = cvt;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines