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

Comparing ray/src/cv/tmesh2rad.c (file contents):
Revision 2.9 by greg, Wed Jul 24 13:07:44 1996 UTC vs.
Revision 2.14 by schorsch, Sun Jul 27 22:12:02 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1994 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 a trianglular mesh into a Radiance description.
6   *
# Line 55 | Line 52 | typedef struct {
52   VERTEX  *vlist = NULL;          /* our vertex list */
53   int     nverts = 0;             /* number of vertices in our list */
54  
55 < #define novert(i)       ((i)<0|(i)>=nverts || !(vlist[i].flags&V_DEFINED))
55 > #define novert(i)       (((i)<0)|((i)>=nverts) || !(vlist[i].flags&V_DEFINED))
56  
57   #define CHUNKSIZ        128     /* vertex allocation chunk size */
58  
# Line 202 | Line 199 | triangle(pn, mod, obj, v1, v2, v3)     /* put out a triang
199   char    *pn, *mod, *obj;
200   register VERTEX *v1, *v2, *v3;
201   {
202 +        static char     vfmt[] = "%18.12g %18.12g %18.12g\n";
203          static int      ntri = 0;
204 +        int             flatness = ISFLAT;
205          BARYCCM bvecs;
206 <        FLOAT   bvm[3][3];
206 >        RREAL   bvm[3][3];
207          register int    i;
208                                          /* compute barycentric coordinates */
209          if (v1->flags & v2->flags & v3->flags & (V_HASINDX|V_HASNORM))
210                  if (comp_baryc(&bvecs, v1->pos, v2->pos, v3->pos) < 0)
211                          return;
212 +                                        /* check flatness */
213 +        if (v1->flags & v2->flags & v3->flags & V_HASNORM) {
214 +                flatness = flat_tri(v1->pos, v2->pos, v3->pos,
215 +                                        v1->nor, v2->nor, v3->nor);
216 +                if (flatness == DEGEN)
217 +                        return;
218 +        }
219                                          /* put out texture (if any) */
220 <        if (v1->flags & v2->flags & v3->flags & V_HASNORM &&
215 <                        !flat_tri(v1->pos, v2->pos, v3->pos,
216 <                                        v1->nor, v2->nor, v3->nor)) {
220 >        if (flatness == ISBENT || flatness == RVBENT) {
221                  printf("\n%s texfunc %s\n", mod, TEXNAME);
222                  mod = TEXNAME;
223                  printf("4 dx dy dz %s\n", TCALNAME);
# Line 238 | Line 242 | register VERTEX        *v1, *v2, *v3;
242                  }
243                  put_baryc(&bvecs, bvm, 2);
244          }
245 <                                        /* put out triangle */
245 >                                        /* put out (reversed) triangle */
246          printf("\n%s polygon %s.%d\n", mod, obj, ++ntri);
247          printf("0\n0\n9\n");
248 <        printf("%18.12g %18.12g %18.12g\n", v1->pos[0],v1->pos[1],v1->pos[2]);
249 <        printf("%18.12g %18.12g %18.12g\n", v2->pos[0],v2->pos[1],v2->pos[2]);
250 <        printf("%18.12g %18.12g %18.12g\n", v3->pos[0],v3->pos[1],v3->pos[2]);
248 >        if (flatness == RVFLAT || flatness == RVBENT) {
249 >                printf(vfmt, v3->pos[0],v3->pos[1],v3->pos[2]);
250 >                printf(vfmt, v2->pos[0],v2->pos[1],v2->pos[2]);
251 >                printf(vfmt, v1->pos[0],v1->pos[1],v1->pos[2]);
252 >        } else {
253 >                printf(vfmt, v1->pos[0],v1->pos[1],v1->pos[2]);
254 >                printf(vfmt, v2->pos[0],v2->pos[1],v2->pos[2]);
255 >                printf(vfmt, v3->pos[0],v3->pos[1],v3->pos[2]);
256 >        }
257   }
258  
259  
# Line 260 | Line 270 | double x, y, z;
270                  if (vlist == NULL)
271                          vlist = (VERTEX *)malloc(nverts*sizeof(VERTEX));
272                  else
273 <                        vlist = (VERTEX *)realloc((char *)vlist,
273 >                        vlist = (VERTEX *)realloc((void *)vlist,
274                                          nverts*sizeof(VERTEX));
275                  if (vlist == NULL) {
276                          fprintf(stderr,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines