ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/mesh.h
(Generate patch)

Comparing ray/src/common/mesh.h (file contents):
Revision 2.1 by greg, Tue Mar 11 17:08:55 2003 UTC vs.
Revision 2.5 by schorsch, Fri Jun 6 16:38:47 2003 UTC

# Line 4 | Line 4
4   *
5   *  Include after standard.h, object.h and octree.h
6   */
7 + #ifndef _RAD_MESH_H_
8 + #define _RAD_MESH_H_
9 + #ifdef __cplusplus
10 + extern "C" {
11 + #endif
12  
13   #include "copyright.h"
14  
15 + #include "lookup.h"
16 +
17   #ifndef uint4
18   #define uint4   unsigned int4
19   #endif
# Line 26 | Line 33
33   * never generates 0, so we can use this for unspecified normals.
34   *
35   * Vertex ID's are encoded using the bottom 8 bits of a 4-byte integer
36 < * to index a vertex in a patch indicated by the 20 bits above (9-29).
37 < * For triangle ID's, the top 10 bits (11-31) indicate the patch, and
38 < * the 10th bit indicates whether the triangle joins patches.
36 > * to index a vertex in a patch indicated by the 22 bits above (8-29).
37 > * For triangle ID's, the top 22 bits (10-31) indicate the patch, and
38 > * the bit 9 (0x200) indicates whether the triangle joins patches.
39   * If not, then the bottom 9 bits index into the local PTri array.
40 < * If it's a joiner, then the 9th bit indicates whether the triangle joins
40 > * If it's a joiner, then the 8th bit indicates whether the triangle joins
41   * two patches, in which case the bottom 8 bits index the PJoin2 array.
42   * Otherwise, the bottom 8 bits index the PJoin1 array.
43   *
# Line 40 | Line 47
47   * a lot of effort, but it can reduce mesh storage by a factor of 3
48   * or more.  This is important, as the whole point is to model very
49   * complicated geometry with this structure, and memory is the main
50 < * limitation.  (We also optimize intersection tests for triangles.)
50 > * limitation.
51   */
52  
53   /* A triangle mesh patch */
# Line 51 | Line 58 | typedef struct {
58          struct PTri {
59                  BYTE            v1, v2, v3;     /* local vertices */
60          }               *tri;           /* local triangles */
61 +        short           solemat;        /* sole material */
62 +        int2            *trimat;        /* or local material indices */
63          struct PJoin1 {
64                  int4            v1j;            /* non-local vertex */
65 +                int2            mat;            /* material index */
66                  BYTE            v2, v3;         /* local vertices */
67          }               *j1tri;         /* joiner triangles */
68          struct PJoin2 {
69                  int4            v1j, v2j;       /* non-local vertices */
70 +                int2            mat;            /* material index */
71                  BYTE            v3;             /* local vertex */
72          }               *j2tri;         /* double joiner triangles */
73          short           nverts;         /* vertex count */
# Line 72 | Line 83 | typedef struct mesh {
83          int             ldflags;        /* what we've loaded */
84          CUBE            mcube;          /* bounds and octree */
85          FLOAT           uvlim[2][2];    /* local coordinate extrema */
86 +        OBJECT          mat0;           /* base material index */
87 +        OBJECT          nmats;          /* number of materials */
88          MESHPATCH       *patch;         /* mesh patch list */
89          int             npatches;       /* number of mesh patches */
90 <        char            *cdata;         /* opaque client data pointer */
90 >        OBJREC          *pseudo;        /* mesh pseudo objects */
91 >        LUTAB           lut;            /* vertex lookup table */
92          struct mesh     *next;          /* next mesh in list */
93   } MESH;
94  
# Line 101 | Line 115 | typedef struct {
115                                  /* mesh format identifier */
116   #define MESHFMT         "Radiance_tmesh"
117                                  /* magic number for mesh files */
118 < #define MESHMAGIC       ( 0 *MAXOBJSIZ+311)     /* increment first value */
118 > #define MESHMAGIC       ( 1 *MAXOBJSIZ+311)     /* increment first value */
119  
106 #ifdef NOPROTO
120  
108 extern MESH     *getmesh();
109 extern INSTANCE *getmeshinst();
110 extern int      getmeshtrivid();
111 extern int      getmeshvert();
112 extern int      getmeshtri();
113 extern int4     addmeshvert();
114 extern OBJECT   addmeshtri();
115 extern void     printmeshstats();
116 extern void     freemesh();
117 extern void     freemeshinst();
118 extern void     readmesh();
119 extern void     writemesh();
120
121 #else
122
121   extern MESH     *getmesh(char *mname, int flags);
122   extern MESHINST *getmeshinst(OBJREC *o, int flags);
123 < extern int      getmeshtrivid(int4 tvid[3], MESH *mp, OBJECT ti);
123 > extern int      getmeshtrivid(int4 tvid[3], OBJECT *mo,
124 >                                MESH *mp, OBJECT ti);
125   extern int      getmeshvert(MESHVERT *vp, MESH *mp, int4 vid, int what);
126 < extern int      getmeshtri(MESHVERT tv[3], MESH *mp, OBJECT ti, int what);
126 > extern int      getmeshtri(MESHVERT tv[3], OBJECT *mo,
127 >                                MESH *mp, OBJECT ti, int what);
128 > extern OBJREC   *getmeshpseudo(MESH *mp, OBJECT mo);
129   extern int4     addmeshvert(MESH *mp, MESHVERT *vp);
130 < extern OBJECT   addmeshtri(MESH *mp, MESHVERT tv[3]);
130 > extern OBJECT   addmeshtri(MESH *mp, MESHVERT tv[3], OBJECT mo);
131 > extern char     *checkmesh(MESH *mp);
132   extern void     printmeshstats(MESH *ms, FILE *fp);
133   extern void     freemesh(MESH *ms);
134   extern void     freemeshinst(OBJREC *o);
135   extern void     readmesh(MESH *mp, char *path, int flags);
136   extern void     writemesh(MESH *mp, FILE *fp);
137  
138 < #endif /* NOPROTO */
138 >
139 > #ifdef __cplusplus
140 > }
141 > #endif
142 > #endif /* _RAD_MESH_H_ */
143 >

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines