82 |
|
putint((long)pp->tri[i].v2, 1, fp); |
83 |
|
putint((long)pp->tri[i].v3, 1, fp); |
84 |
|
} |
85 |
+ |
/* local triangle material(s) */ |
86 |
+ |
if (pp->trimat == NULL) { |
87 |
+ |
putint(1L, 2, fp); |
88 |
+ |
putint((long)pp->solemat, 2, fp); |
89 |
+ |
} else { |
90 |
+ |
putint((long)pp->ntris, 2, fp); |
91 |
+ |
for (i = 0; i < pp->ntris; i++) |
92 |
+ |
putint((long)pp->trimat[i], 2, fp); |
93 |
+ |
} |
94 |
|
/* joiner triangles */ |
95 |
|
putint((long)pp->nj1tris, 2, fp); |
96 |
|
for (i = 0; i < pp->nj1tris; i++) { |
97 |
|
putint((long)pp->j1tri[i].v1j, 4, fp); |
98 |
|
putint((long)pp->j1tri[i].v2, 1, fp); |
99 |
|
putint((long)pp->j1tri[i].v3, 1, fp); |
100 |
+ |
putint((long)pp->j1tri[i].mat, 2, fp); |
101 |
|
} |
102 |
|
/* double joiner triangles */ |
103 |
|
putint((long)pp->nj2tris, 2, fp); |
105 |
|
putint((long)pp->j2tri[i].v1j, 4, fp); |
106 |
|
putint((long)pp->j2tri[i].v2j, 4, fp); |
107 |
|
putint((long)pp->j2tri[i].v3, 1, fp); |
108 |
+ |
putint((long)pp->j2tri[i].mat, 2, fp); |
109 |
|
} |
110 |
|
} |
111 |
|
|
115 |
|
MESH *mp; |
116 |
|
FILE *fp; |
117 |
|
{ |
118 |
+ |
char *err; |
119 |
|
char sbuf[64]; |
120 |
|
int i; |
121 |
< |
/* check that we have everything */ |
121 |
> |
/* do we have everything? */ |
122 |
|
if ((mp->ldflags & (IO_SCENE|IO_TREE|IO_BOUNDS)) != |
123 |
|
(IO_SCENE|IO_TREE|IO_BOUNDS)) |
124 |
|
error(INTERNAL, "missing data in writemesh"); |
125 |
+ |
/* validate mesh data */ |
126 |
+ |
if ((err = checkmesh(mp)) != NULL) |
127 |
+ |
error(USER, err); |
128 |
|
/* write format number */ |
129 |
|
putint((long)(MESHMAGIC+sizeof(OBJECT)), 2, fp); |
130 |
|
/* write boundaries */ |
140 |
|
} |
141 |
|
/* write the octree */ |
142 |
|
puttree(mp->mcube.cutree, fp); |
143 |
+ |
/* write the materials */ |
144 |
+ |
writescene(mp->mat0, mp->nmats, fp); |
145 |
|
/* write the patches */ |
146 |
|
putint((long)mp->npatches, 4, fp); |
147 |
|
for (i = 0; i < mp->npatches; i++) |