2018-04-01 12:43:30 +05:30
|
|
|
|
2018-04-02 02:51:12 +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 {
|
2018-04-02 02:51:12 +05:30
|
|
|
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>
|
2018-04-02 02:51:12 +05:30
|
|
|
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]
|
|
|
|
|
2018-04-14 03:26:14 +05:30
|
|
|
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>
|
|
|
|
};
|
2018-04-10 09:21:37 +05:30
|
|
|
|
2018-04-14 03:26:14 +05:30
|
|
|
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>
|
2018-04-14 03:26:14 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
struct VertexData {
|
2018-04-18 07:02:23 +05:30
|
|
|
// following structs should in an array of size 'numVertex'
|
2018-04-14 03:26:14 +05:30
|
|
|
struct Coordinate *positions;
|
|
|
|
struct Coordinate *normals;
|
2018-04-01 12:43:30 +05:30
|
|
|
struct UVs *u;
|
|
|
|
struct BoneIndexes *bi;
|
|
|
|
struct BoneWeights *bw;
|
|
|
|
};
|
|
|
|
|
2018-04-14 03:26:14 +05:30
|
|
|
struct Batch {
|
2018-04-18 07:02:23 +05:30
|
|
|
struct BatchData *bd; // pointer to region in file data
|
|
|
|
struct VertexData vd; // collection of pointers to regions in file data
|
2018-04-14 03:26:14 +05:30
|
|
|
};
|
|
|
|
|
2018-04-01 12:43:30 +05:30
|
|
|
struct Mesh {
|
2018-04-18 07:02:23 +05:30
|
|
|
// array of batches
|
2018-04-14 03:26:14 +05:30
|
|
|
struct Batch *b;
|
2018-04-01 12:43:30 +05:30
|
|
|
};
|
|
|
|
|
2018-04-10 09:21:37 +05:30
|
|
|
#pragma pack(pop)
|
|
|
|
|
2018-04-18 08:44:45 +05:30
|
|
|
typedef struct {
|
|
|
|
void (* const printheader) (struct Header*);
|
|
|
|
void (* const printmeshheader)(struct MeshHeader*);
|
|
|
|
void (* const printbatch) (struct Batch*);
|
|
|
|
void (* const printcoordinate)(struct Coordinate*, unsigned int);
|
2018-04-07 15:54:07 +05:30
|
|
|
|
2018-04-18 08:44:45 +05:30
|
|
|
bool (* const getmeshheader) (struct MeshHeader**,
|
|
|
|
unsigned int i,
|
|
|
|
const char * const);
|
2018-04-07 17:09:16 +05:30
|
|
|
|
2018-04-18 08:44:45 +05:30
|
|
|
bool (* const getbatch) (struct Batch*,
|
|
|
|
unsigned int offset,
|
|
|
|
const char * const);
|
2018-04-08 08:07:43 +05:30
|
|
|
|
2018-04-18 08:44:45 +05:30
|
|
|
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);
|
2018-04-08 10:39:29 +05:30
|
|
|
|
2018-04-08 08:07:43 +05:30
|
|
|
// ** = 'pass by reference' of a pointer to struct
|
2018-04-18 08:44:45 +05:30
|
|
|
static bool getmeshheader(struct MeshHeader**, unsigned int i, const char * const);
|
2018-04-07 15:54:07 +05:30
|
|
|
|
2018-04-18 08:44:45 +05:30
|
|
|
static bool getmeshbatch(struct Batch*, unsigned int offset, const char * const);
|
2018-04-18 07:02:23 +05:30
|
|
|
|
2018-04-18 08:44:45 +05:30
|
|
|
static bool getmesh(struct Mesh*, unsigned int i, const char* filename);
|
2018-04-08 08:07:43 +05:30
|
|
|
|
2018-04-02 02:51:12 +05:30
|
|
|
#endif
|
2018-04-01 12:43:30 +05:30
|
|
|
|