mirror of
https://notabug.org/scuti/lib3ddevil1
synced 2024-11-22 05:42:59 +05:30
Moved out for loop & fixed getting mesh headers
This commit is contained in:
parent
0e5c96b83b
commit
8016deae86
@ -71,7 +71,9 @@ struct Mesh {
|
||||
|
||||
void printgheader(struct Header*);
|
||||
|
||||
bool getmeshheaders(struct MeshHeader **, const char *, unsigned int);
|
||||
void printmeshheader(struct MeshHeader*);
|
||||
|
||||
bool getmeshheader(struct MeshHeader**, unsigned int i, const char * const);
|
||||
|
||||
#endif
|
||||
|
||||
|
42
src/devil1geo.c
Normal file
42
src/devil1geo.c
Normal file
@ -0,0 +1,42 @@
|
||||
#include "devil1geo.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void printgheader(struct Header *gh) {
|
||||
if (gh != NULL) {
|
||||
printf("pointer %x\n", gh);
|
||||
printf("number of meshes %x\n", gh -> numMesh);
|
||||
printf("unknown number B %x\n", gh -> unknownNumberB);
|
||||
printf("unknown number C %x\n", gh -> unknownNumberC);
|
||||
printf("unknown number D %x\n", gh -> unknownNumberD);
|
||||
printf("padding %x\n", gh -> padding);
|
||||
printf("unknown offset %x\n", gh -> unknownOffset);
|
||||
}
|
||||
}
|
||||
|
||||
void printmeshheader(struct MeshHeader *mh) {
|
||||
if (mh == NULL) {
|
||||
return;
|
||||
}
|
||||
printf("number of batches %x\n", mh -> numBatch);
|
||||
printf("number of vertices %x\n", mh -> numVertex);
|
||||
printf("unknown %x\n", mh -> u);
|
||||
printf("batch offset %x\n", mh -> offsetBatches);
|
||||
printf("flags %x\n\n", mh -> flags);
|
||||
}
|
||||
|
||||
bool getmeshheader(struct MeshHeader **hs,
|
||||
unsigned int i,
|
||||
const char * const filedata) {
|
||||
bool done = false;
|
||||
if (hs == NULL || filedata == NULL) {
|
||||
return done;
|
||||
}
|
||||
struct Header *h = (struct Header*)filedata;
|
||||
if (h -> numMesh < i) {
|
||||
return done;
|
||||
}
|
||||
unsigned int pos = sizeof(struct MeshHeader) * i + sizeof(struct Header);
|
||||
(*hs) = (struct MeshHeader*)(filedata + pos);
|
||||
done = true;
|
||||
return done;
|
||||
}
|
16
test/main.c
16
test/main.c
@ -111,17 +111,15 @@ void extractmeshes(const char* filedata,
|
||||
if (filedata == NULL || filesize <= 0) {
|
||||
return;
|
||||
}
|
||||
struct Header *h = NULL;
|
||||
h = (struct Header*)filedata;
|
||||
printf("pointer %x\n", h);
|
||||
printgheader(h);
|
||||
struct MeshHeader **mh = NULL;
|
||||
mh = (struct MeshHeader**)
|
||||
malloc(sizeof(struct MeshHeader*) * h -> numMesh);
|
||||
getmeshheaders(mh, filedata, filesize);
|
||||
struct Header *h = (struct Header*)filedata;
|
||||
struct MeshHeader *mh = NULL;
|
||||
unsigned int i;
|
||||
bool ok;
|
||||
for (i = 0; i < h -> numMesh; i++) {
|
||||
printf("returning %x \n", mh[i]);
|
||||
ok = getmeshheader(&mh, i, filedata);
|
||||
if (ok) {
|
||||
printmeshheader(mh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user