mirror of
https://notabug.org/scuti/lib3ddevil1
synced 2025-05-31 14:11:42 +05:30
Merge branch 'a/geometry'
Geometry internals complete, interfaces likely to change
This commit is contained in:
27
test/main.c
27
test/main.c
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "devil1pld.h"
|
||||
#include "devil1tex.h"
|
||||
#include "devil1geo.h"
|
||||
|
||||
|
||||
#define TYPE_ID_LENGTH 4
|
||||
@@ -116,13 +117,37 @@ void exporttextures(const char *filedata,
|
||||
return;
|
||||
}
|
||||
|
||||
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++) {
|
||||
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
|
||||
}
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
char *f = argv[1];
|
||||
unsigned int bufsize = 0;
|
||||
char *buffer = loadfile(f, &bufsize);
|
||||
unpackpld(buffer, bufsize, f);
|
||||
// unpackpld(buffer, bufsize, f);
|
||||
// exporttextures(buffer, bufsize, f);
|
||||
extractmeshes(buffer, bufsize, f);
|
||||
free(buffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user