#ifndef DEVIL1GEO_H #define DEVIL1GEO_H #include #include #pragma pack(push, 1) struct Header { unsigned char numMesh; unsigned char unknownNumberB; unsigned char unknownNumberC; unsigned char unknownNumberD; uint32_t padding; // uint64_t unknownOffset; }; struct MeshHeader { int16_t numBatch; int16_t numVertex; uint32_t u; // uint64_t offsetBatches; uint64_t flags; }; // put these in an array of size: [header.numMesh] struct Coordinate { float x, y, z; }; struct UVs { int16_t u, v; }; struct BoneIndexes { unsigned char indexes[4]; // from ubyte }; struct BoneWeights { uint16_t weights; // }; struct BatchData { int16_t numVertex; int16_t uB; uint32_t padding; // uint64_t offsetPositions; // uint64_t offsetNormals; // uint64_t offsetUVs; // uint64_t offsetBoneIndexes; // uint64_t offsetBoneWeights; // uint64_t offsets[1]; // }; struct VertexData { // following structs should in an array of size 'numVertex' struct Coordinate *positions; struct Coordinate *normals; struct UVs *u; struct BoneIndexes *bi; struct BoneWeights *bw; }; struct Batch { struct BatchData *bd; // pointer to region in file data struct VertexData vd; // collection of pointers to regions in file data }; struct Mesh { // array of batches struct Batch *b; }; #pragma pack(pop) typedef struct { void (* const printheader) (struct Header*); void (* const printmeshheader)(struct MeshHeader*); void (* const printbatch) (struct Batch*); void (* const printcoordinate)(struct Coordinate*, unsigned int); bool (* const getmeshheader) (struct MeshHeader**, unsigned int i, const char * const); bool (* const getbatch) (struct Batch*, unsigned int offset, const char * const); bool (* const getmesh) (struct Mesh*, unsigned int i, const char* filename); } fn_devil1geo; extern fn_devil1geo const DEVIL1GEO; static void printgheader(struct Header*); static void printmeshheader(struct MeshHeader*); static void printmeshbatch(struct Batch*); static void printcoordinate(struct Coordinate*, unsigned int); // ** = 'pass by reference' of a pointer to struct static bool getmeshheader(struct MeshHeader**, unsigned int i, const char * const); static bool getmeshbatch(struct Batch*, unsigned int offset, const char * const); static bool getmesh(struct Mesh*, unsigned int i, const char* filename); #endif