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;
|
|
|
|
}
|
2018-04-14 03:26:14 +05:30
|
|
|
struct BatchData *bd = b -> bd;
|
|
|
|
printf("number of vertices %x\n", bd -> numVertex);
|
|
|
|
printf("unknown byte %x\n", bd -> uB);
|
|
|
|
printf("padding %x\n", bd -> padding);
|
|
|
|
printf("offsetPositions %x\n", bd -> offsetPositions);
|
|
|
|
printf("offsetNormals %x\n", bd -> offsetNormals);
|
|
|
|
printf("offsetUVs %x\n", bd -> offsetUVs);
|
|
|
|
printf("offsetBoneIndexes %x\n", bd -> offsetBoneIndexes);
|
|
|
|
printf("offsetBoneWeights %x\n", bd -> offsetBoneWeights);
|
|
|
|
printf("offsets %x\n\n", bd -> offsets[0]);
|
|
|
|
printcoordinate(b -> vd.positions, 3);
|
2018-04-08 08:07:43 +05:30
|
|
|
}
|
|
|
|
|
2018-04-14 03:26:14 +05:30
|
|
|
void printcoordinate(struct Coordinate *p, unsigned int count) {
|
2018-04-08 08:07:43 +05:30
|
|
|
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
|
|
|
|
2018-04-14 03:26:14 +05:30
|
|
|
bool getmeshbatch(struct Batch *b,
|
2018-04-08 08:07:43 +05:30
|
|
|
struct MeshHeader *h,
|
|
|
|
const char * const filedata) {
|
|
|
|
bool done = false;
|
|
|
|
if (b == NULL || h == NULL || filedata == NULL) {
|
|
|
|
return done;
|
|
|
|
}
|
|
|
|
unsigned int offset = h -> offsetBatches;
|
2018-04-14 03:26:14 +05:30
|
|
|
struct BatchData *d1 = NULL;
|
|
|
|
struct VertexData d2;
|
|
|
|
d1 = (struct BatchData*) (filedata + offset);
|
|
|
|
d2.positions = (struct Coordinate*) (filedata + (d1 -> offsetPositions));
|
|
|
|
d2.normals = (struct Coordinate*) (filedata + (d1 -> offsetNormals));
|
|
|
|
d2.u = (struct UVs*) (filedata + (d1 -> offsetUVs));
|
|
|
|
d2.bi = (struct BoneIndexes*)(filedata + (d1 -> offsetBoneIndexes));
|
|
|
|
d2.bw = (struct BoneWeights*)(filedata + (d1 -> offsetBoneWeights));
|
|
|
|
b -> bd = d1;
|
|
|
|
b -> vd = d2;
|
2018-04-08 08:07:43 +05:30
|
|
|
done = true;
|
|
|
|
return done;
|
|
|
|
}
|