mirror of
https://notabug.org/scuti/lib3ddevil1
synced 2024-11-22 13:53:02 +05:30
39 lines
1023 B
C
39 lines
1023 B
C
#include "common.h"
|
|
#include "devil1geo.h"
|
|
|
|
void extractmeshes(const char *filedata,
|
|
unsigned int filesize,
|
|
const char *filename) {
|
|
if (filedata == NULL || filesize <= 0) {
|
|
return;
|
|
}
|
|
struct Header *h = (struct Header*)filedata;
|
|
struct MeshHeader *mh = NULL;
|
|
struct Mesh m;
|
|
m.b = NULL;
|
|
unsigned int i;
|
|
for (i = 0; i < h -> numMesh; i++) {
|
|
DEVIL1GEO.getmeshheader(&mh, i, filedata);
|
|
m.b = (struct Batch*)malloc(sizeof(struct Batch) * (mh -> numBatch));
|
|
if (m.b != NULL) {
|
|
DEVIL1GEO.getmesh(&m, i, filedata);
|
|
// do something with mesh e.g write to file.
|
|
free(m.b);
|
|
}
|
|
} // end for
|
|
}
|
|
|
|
|
|
int main(int argc, char ** argv) {
|
|
char *f = argv[1];
|
|
unsigned int bufsize = 0;
|
|
char *buffer = loadfile(f, &bufsize);
|
|
// unpackpld(buffer, bufsize, f);
|
|
// exporttextures(buffer, bufsize, f);
|
|
extractmeshes(buffer, bufsize, f);
|
|
free(buffer);
|
|
return 0;
|
|
}
|
|
|
|
|