| 7 |
|
|
| 8 |
|
#include "copyright.h" |
| 9 |
|
|
| 10 |
+ |
#include "lookup.h" |
| 11 |
+ |
|
| 12 |
|
#ifndef uint4 |
| 13 |
|
#define uint4 unsigned int4 |
| 14 |
|
#endif |
| 42 |
|
* a lot of effort, but it can reduce mesh storage by a factor of 3 |
| 43 |
|
* or more. This is important, as the whole point is to model very |
| 44 |
|
* complicated geometry with this structure, and memory is the main |
| 45 |
< |
* limitation. (We also optimize intersection tests for triangles.) |
| 45 |
> |
* limitation. |
| 46 |
|
*/ |
| 47 |
|
|
| 48 |
|
/* A triangle mesh patch */ |
| 53 |
|
struct PTri { |
| 54 |
|
BYTE v1, v2, v3; /* local vertices */ |
| 55 |
|
} *tri; /* local triangles */ |
| 56 |
+ |
short solemat; /* sole material */ |
| 57 |
+ |
int2 *trimat; /* or local material indices */ |
| 58 |
|
struct PJoin1 { |
| 59 |
|
int4 v1j; /* non-local vertex */ |
| 60 |
+ |
int2 mat; /* material index */ |
| 61 |
|
BYTE v2, v3; /* local vertices */ |
| 62 |
|
} *j1tri; /* joiner triangles */ |
| 63 |
|
struct PJoin2 { |
| 64 |
|
int4 v1j, v2j; /* non-local vertices */ |
| 65 |
+ |
int2 mat; /* material index */ |
| 66 |
|
BYTE v3; /* local vertex */ |
| 67 |
|
} *j2tri; /* double joiner triangles */ |
| 68 |
|
short nverts; /* vertex count */ |
| 78 |
|
int ldflags; /* what we've loaded */ |
| 79 |
|
CUBE mcube; /* bounds and octree */ |
| 80 |
|
FLOAT uvlim[2][2]; /* local coordinate extrema */ |
| 81 |
+ |
OBJECT mat0; /* base material index */ |
| 82 |
+ |
OBJECT nmats; /* number of materials */ |
| 83 |
|
MESHPATCH *patch; /* mesh patch list */ |
| 84 |
|
int npatches; /* number of mesh patches */ |
| 85 |
< |
char *cdata; /* opaque client data pointer */ |
| 85 |
> |
OBJREC *pseudo; /* mesh pseudo objects */ |
| 86 |
> |
LUTAB lut; /* vertex lookup table */ |
| 87 |
|
struct mesh *next; /* next mesh in list */ |
| 88 |
|
} MESH; |
| 89 |
|
|
| 110 |
|
/* mesh format identifier */ |
| 111 |
|
#define MESHFMT "Radiance_tmesh" |
| 112 |
|
/* magic number for mesh files */ |
| 113 |
< |
#define MESHMAGIC ( 0 *MAXOBJSIZ+311) /* increment first value */ |
| 113 |
> |
#define MESHMAGIC ( 1 *MAXOBJSIZ+311) /* increment first value */ |
| 114 |
|
|
| 115 |
|
#ifdef NOPROTO |
| 116 |
|
|
| 119 |
|
extern int getmeshtrivid(); |
| 120 |
|
extern int getmeshvert(); |
| 121 |
|
extern int getmeshtri(); |
| 122 |
+ |
extern OBJREC *getmeshpseudo(); |
| 123 |
|
extern int4 addmeshvert(); |
| 124 |
|
extern OBJECT addmeshtri(); |
| 125 |
+ |
extern char *checkmesh(); |
| 126 |
|
extern void printmeshstats(); |
| 127 |
|
extern void freemesh(); |
| 128 |
|
extern void freemeshinst(); |
| 133 |
|
|
| 134 |
|
extern MESH *getmesh(char *mname, int flags); |
| 135 |
|
extern MESHINST *getmeshinst(OBJREC *o, int flags); |
| 136 |
< |
extern int getmeshtrivid(int4 tvid[3], MESH *mp, OBJECT ti); |
| 136 |
> |
extern int getmeshtrivid(int4 tvid[3], OBJECT *mo, |
| 137 |
> |
MESH *mp, OBJECT ti); |
| 138 |
|
extern int getmeshvert(MESHVERT *vp, MESH *mp, int4 vid, int what); |
| 139 |
< |
extern int getmeshtri(MESHVERT tv[3], MESH *mp, OBJECT ti, int what); |
| 139 |
> |
extern int getmeshtri(MESHVERT tv[3], OBJECT *mo, |
| 140 |
> |
MESH *mp, OBJECT ti, int what); |
| 141 |
> |
extern OBJREC *getmeshpseudo(MESH *mp, OBJECT mo); |
| 142 |
|
extern int4 addmeshvert(MESH *mp, MESHVERT *vp); |
| 143 |
< |
extern OBJECT addmeshtri(MESH *mp, MESHVERT tv[3]); |
| 143 |
> |
extern OBJECT addmeshtri(MESH *mp, MESHVERT tv[3], OBJECT mo); |
| 144 |
> |
extern char *checkmesh(MESH *mp); |
| 145 |
|
extern void printmeshstats(MESH *ms, FILE *fp); |
| 146 |
|
extern void freemesh(MESH *ms); |
| 147 |
|
extern void freemeshinst(OBJREC *o); |