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 |
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 */ |
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 */ |
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 |
|
|
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 |
> |
|