2018-04-07 17:09:16 +05:30
|
|
|
#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);
|
|
|
|
}
|
|
|
|
|
2018-04-08 08:07:43 +05:30
|
|
|
void printmeshbatch(struct Batch *b) {
|
|
|
|
if (b == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
printf("number of vertices %x\n", b -> numVertex);
|
|
|
|
printf("unknown byte %x\n", b -> uB);
|
|
|
|
printf("padding %x\n", b -> padding);
|
|
|
|
printf("offsetPositions %x\n", b -> offsetPositions);
|
|
|
|
printf("offsetNormals %x\n", b -> offsetNormals);
|
|
|
|
printf("offsetUVs %x\n", b -> offsetUVs);
|
|
|
|
printf("offsetBoneIndexes %x\n", b -> offsetBoneIndexes);
|
|
|
|
printf("offsetBoneWeights %x\n", b -> offsetBoneWeights);
|
|
|
|
printf("offsets %x\n\n", b -> offsets[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void printpositions(struct Positions *p, unsigned int count) {
|
|
|
|
if (p == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
unsigned int i;
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
printf("(%f, %f, %f)\n", (p[i]).x, (p[i]).y, (p[i]).z);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-07 17:09:16 +05:30
|
|
|
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;
|
|
|
|
}
|
2018-04-08 08:07:43 +05:30
|
|
|
|
|
|
|
bool getmeshbatch(struct Batch **b,
|
|
|
|
struct MeshHeader *h,
|
|
|
|
const char * const filedata) {
|
|
|
|
bool done = false;
|
|
|
|
if (b == NULL || h == NULL || filedata == NULL) {
|
|
|
|
return done;
|
|
|
|
}
|
|
|
|
unsigned int offset = h -> offsetBatches;
|
|
|
|
*b = (struct Batch*)(filedata + offset);
|
|
|
|
(*b) -> p = (struct Positions*)(filedata + ((*b) -> offsetPositions));
|
|
|
|
printf("p = %x\n", (*b) -> offsetPositions);
|
|
|
|
printpositions((*b) -> p, 3);
|
|
|
|
(*b) -> n = NULL;
|
|
|
|
(*b) -> u = NULL;
|
|
|
|
(*b) -> bi = NULL;
|
|
|
|
(*b) -> bw = NULL;
|
|
|
|
done = true;
|
|
|
|
return done;
|
|
|
|
}
|