174 |
|
} |
175 |
|
} else |
176 |
|
pp->tri = NULL; |
177 |
+ |
/* local triangle material(s) */ |
178 |
+ |
if (mgetint(2) > 1) { |
179 |
+ |
pp->trimat = (int2 *)malloc(pp->ntris*sizeof(int2)); |
180 |
+ |
if (pp->trimat == NULL) |
181 |
+ |
goto nomem; |
182 |
+ |
for (i = 0; i < pp->ntris; i++) |
183 |
+ |
pp->trimat[i] = mgetint(2); |
184 |
+ |
} else { |
185 |
+ |
pp->solemat = mgetint(2); |
186 |
+ |
pp->trimat = NULL; |
187 |
+ |
} |
188 |
|
/* joiner triangles */ |
189 |
|
pp->nj1tris = mgetint(2); |
190 |
|
if (pp->nj1tris < 0 || pp->nj1tris > 512) |
198 |
|
pp->j1tri[i].v1j = mgetint(4); |
199 |
|
pp->j1tri[i].v2 = mgetint(1); |
200 |
|
pp->j1tri[i].v3 = mgetint(1); |
201 |
+ |
pp->j1tri[i].mat = mgetint(2); |
202 |
|
} |
203 |
|
} else |
204 |
|
pp->j1tri = NULL; |
215 |
|
pp->j2tri[i].v1j = mgetint(4); |
216 |
|
pp->j2tri[i].v2j = mgetint(4); |
217 |
|
pp->j2tri[i].v3 = mgetint(1); |
218 |
+ |
pp->j2tri[i].mat = mgetint(2); |
219 |
|
} |
220 |
|
} else |
221 |
|
pp->j2tri = NULL; |
231 |
|
char *path; |
232 |
|
int flags; |
233 |
|
{ |
234 |
+ |
char *err; |
235 |
|
char sbuf[64]; |
236 |
|
int i; |
237 |
|
/* check what's loaded */ |
273 |
|
mp->mcube.cutree = gettree(); |
274 |
|
else if (flags & IO_SCENE) |
275 |
|
skiptree(); |
276 |
< |
/* read the patches */ |
276 |
> |
/* read materials and patches */ |
277 |
|
if (flags & IO_SCENE) { |
278 |
+ |
mp->mat0 = nobjects; |
279 |
+ |
readscene(meshfp, objsize); |
280 |
+ |
mp->nmats = nobjects - mp->mat0; |
281 |
|
mp->npatches = mgetint(4); |
282 |
|
mp->patch = (MESHPATCH *)calloc(mp->npatches, |
283 |
|
sizeof(MESHPATCH)); |
289 |
|
/* clean up */ |
290 |
|
fclose(meshfp); |
291 |
|
mp->ldflags |= flags; |
292 |
+ |
/* verify data */ |
293 |
+ |
if ((err = checkmesh(mp)) != NULL) |
294 |
+ |
mesherror(USER, err); |
295 |
|
} |