lib3ddevil1/include/devil1geo.h

95 lines
2.1 KiB
C
Raw Normal View History

2018-04-01 12:43:30 +05:30
#ifndef DEVIL1GEO_H
#define DEVIL1GEO_H
#include <stdint.h>
2018-04-07 15:54:07 +05:30
#include <stdbool.h>
#pragma pack(push, 1)
2018-04-01 12:43:30 +05:30
struct Header {
unsigned char numMesh;
unsigned char unknownNumberB;
unsigned char unknownNumberC;
unsigned char unknownNumberD;
2018-04-01 12:43:30 +05:30
uint32_t padding; // <format=hex>
uint64_t unknownOffset;
2018-04-01 12:43:30 +05:30
};
2018-04-07 15:54:07 +05:30
struct MeshHeader {
2018-04-01 12:43:30 +05:30
int16_t numBatch;
int16_t numVertex;
uint32_t u; // <format=hex>
uint64_t offsetBatches;
uint64_t flags;
}; // put these in an array of size: [header.numMesh]
struct Coordinate {
2018-04-01 12:43:30 +05:30
float x, y, z;
};
struct UVs {
int16_t u, v;
};
struct BoneIndexes {
unsigned char indexes[4]; // from ubyte
};
struct BoneWeights {
uint16_t weights; // <format=hex>
};
struct BatchData {
2018-04-01 12:43:30 +05:30
int16_t numVertex;
int16_t uB;
uint32_t padding; // <format=hex>
uint64_t offsetPositions; // <format=hex>
uint64_t offsetNormals; // <format=hex>
uint64_t offsetUVs; // <format=hex>
uint64_t offsetBoneIndexes; // <format=hex>
uint64_t offsetBoneWeights; // <format=hex>
uint64_t offsets[1]; // <format=hex>
};
struct VertexData {
2018-04-01 12:43:30 +05:30
// following structs should in an array of size numVertex
struct Coordinate *positions;
struct Coordinate *normals;
2018-04-01 12:43:30 +05:30
struct UVs *u;
struct BoneIndexes *bi;
struct BoneWeights *bw;
};
// This is where most of the parsing will be.
// this struct is in-order of what the file format will have.
struct Batch {
struct BatchData *bd;
struct VertexData vd;
};
2018-04-01 12:43:30 +05:30
struct Mesh {
// may contain multiple batches
struct Batch *b;
2018-04-01 12:43:30 +05:30
};
#pragma pack(pop)
2018-04-07 15:54:07 +05:30
void printgheader(struct Header*);
void printmeshheader(struct MeshHeader*);
void printmeshbatch(struct Batch*);
void printcoordinate(struct Coordinate*, unsigned int);
// ** = 'pass by reference' of a pointer to struct
bool getmeshheader(struct MeshHeader**, unsigned int i, const char * const);
2018-04-07 15:54:07 +05:30
// ** = 'pass by reference' of a pointer to struct
bool getmeshbatch(struct Batch*,
2018-04-14 05:52:07 +05:30
unsigned int offset,
const char * const);
#endif
2018-04-01 12:43:30 +05:30