Added getmesh function

This commit is contained in:
_
2018-04-17 18:32:23 -07:00
parent 383abb1607
commit 9a75cd0940
3 changed files with 42 additions and 22 deletions

View File

@@ -113,20 +113,17 @@ void extractmeshes(const char *filedata,
}
struct Header *h = (struct Header*)filedata;
struct MeshHeader *mh = NULL;
struct Batch b;
struct Mesh m;
m.b = NULL;
unsigned int i;
unsigned int j;
bool ok;
//for (i = 0; i < 5; i++) {
for (i = 0; i < h -> numMesh; i++) {
ok = getmeshheader(&mh, i, filedata);
if (ok) {
for (j = 0; j < mh -> numBatch; j++) {
unsigned int offset = mh->offsetBatches + j * sizeof(struct BatchData);
getmeshbatch(&b, offset, filedata);
printmeshbatch(&b);
} // end for
} // end if
getmeshheader(&mh, i, filedata);
m.b = (struct Batch*)malloc(sizeof(struct Batch) * (mh -> numBatch));
if (m.b != NULL) {
getmesh(&m, i, filedata);
// do something with mesh e.g write to file.
free(m.b);
}
} // end for
}
@@ -141,3 +138,4 @@ int main(int argc, char ** argv) {
return 0;
}