2018-04-01 00:13:30 -07:00
|
|
|
|
2018-04-01 14:21:12 -07:00
|
|
|
#ifndef DEVIL1GEO_H
|
|
|
|
#define DEVIL1GEO_H
|
|
|
|
#include <stdint.h>
|
2018-04-07 03:24:07 -07:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
|
|
|
|
#pragma pack(push, 1)
|
2018-04-01 00:13:30 -07:00
|
|
|
struct Header {
|
2018-04-01 14:21:12 -07:00
|
|
|
unsigned char numMesh;
|
|
|
|
unsigned char unknownNumberB;
|
|
|
|
unsigned char unknownNumberC;
|
|
|
|
unsigned char unknownNumberD;
|
2018-04-01 00:13:30 -07:00
|
|
|
uint32_t padding; // <format=hex>
|
2018-04-01 14:21:12 -07:00
|
|
|
uint64_t unknownOffset;
|
2018-04-01 00:13:30 -07:00
|
|
|
};
|
|
|
|
|
2018-04-07 03:24:07 -07:00
|
|
|
struct MeshHeader {
|
2018-04-01 00:13:30 -07:00
|
|
|
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]
|
|
|
|
|
2018-04-13 14:56:14 -07:00
|
|
|
struct Coordinate {
|
2018-04-01 00:13:30 -07:00
|
|
|
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>
|
|
|
|
};
|
2018-04-09 20:51:37 -07:00
|
|
|
|
2018-04-13 14:56:14 -07:00
|
|
|
struct BatchData {
|
2018-04-01 00:13:30 -07:00
|
|
|
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>
|
2018-04-13 14:56:14 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct VertexData {
|
2018-04-17 18:32:23 -07:00
|
|
|
// following structs should in an array of size 'numVertex'
|
2018-04-13 14:56:14 -07:00
|
|
|
struct Coordinate *positions;
|
|
|
|
struct Coordinate *normals;
|
2018-04-01 00:13:30 -07:00
|
|
|
struct UVs *u;
|
|
|
|
struct BoneIndexes *bi;
|
|
|
|
struct BoneWeights *bw;
|
|
|
|
};
|
|
|
|
|
2018-04-13 14:56:14 -07:00
|
|
|
struct Batch {
|
2018-04-17 18:32:23 -07:00
|
|
|
struct BatchData *bd; // pointer to region in file data
|
|
|
|
struct VertexData vd; // collection of pointers to regions in file data
|
2018-04-13 14:56:14 -07:00
|
|
|
};
|
|
|
|
|
2018-04-01 00:13:30 -07:00
|
|
|
struct Mesh {
|
2018-04-17 18:32:23 -07:00
|
|
|
// array of batches
|
2018-04-13 14:56:14 -07:00
|
|
|
struct Batch *b;
|
2018-04-01 00:13:30 -07:00
|
|
|
};
|
|
|
|
|
2018-04-09 20:51:37 -07:00
|
|
|
#pragma pack(pop)
|
|
|
|
|
2018-04-17 20:14:45 -07:00
|
|
|
typedef struct {
|
2018-04-19 05:42:44 -07:00
|
|
|
// input: pointer to struct
|
2018-04-17 20:14:45 -07:00
|
|
|
void (* const printheader) (struct Header*);
|
2018-04-19 05:42:44 -07:00
|
|
|
|
|
|
|
// input: pointer to struct
|
2018-04-17 20:14:45 -07:00
|
|
|
void (* const printmeshheader)(struct MeshHeader*);
|
2018-04-19 05:42:44 -07:00
|
|
|
|
|
|
|
// input: pointer to struct
|
2018-04-17 20:14:45 -07:00
|
|
|
void (* const printbatch) (struct Batch*);
|
2018-04-19 05:42:44 -07:00
|
|
|
|
|
|
|
// input: pointer to struct
|
2018-04-17 20:14:45 -07:00
|
|
|
void (* const printcoordinate)(struct Coordinate*, unsigned int);
|
2018-04-07 03:24:07 -07:00
|
|
|
|
2018-04-19 05:42:44 -07:00
|
|
|
// input: pointer of pointer to struct, order, file data
|
|
|
|
// ** = 'pass by reference' of a pointer to struct
|
2018-04-17 20:14:45 -07:00
|
|
|
bool (* const getmeshheader) (struct MeshHeader**,
|
|
|
|
unsigned int i,
|
|
|
|
const char * const);
|
2018-04-07 04:39:16 -07:00
|
|
|
|
2018-04-19 05:42:44 -07:00
|
|
|
// input: pointer to struct, offset of file data batch is at, file data
|
2018-04-17 20:14:45 -07:00
|
|
|
bool (* const getbatch) (struct Batch*,
|
|
|
|
unsigned int offset,
|
|
|
|
const char * const);
|
2018-04-07 19:37:43 -07:00
|
|
|
|
2018-04-19 05:42:44 -07:00
|
|
|
// input: pointer to struct, order, file data
|
2018-04-17 20:14:45 -07:00
|
|
|
bool (* const getmesh) (struct Mesh*,
|
|
|
|
unsigned int i,
|
2018-04-19 16:08:36 -07:00
|
|
|
const char*,
|
|
|
|
unsigned int filesize);
|
2018-04-17 20:14:45 -07:00
|
|
|
} fn_devil1geo;
|
|
|
|
extern fn_devil1geo const DEVIL1GEO;
|
|
|
|
|
2018-04-01 14:21:12 -07:00
|
|
|
#endif
|
2018-04-01 00:13:30 -07:00
|
|
|
|