mirror of
https://notabug.org/scuti/lib3ddevil1
synced 2024-11-25 16:28:57 +05:30
Initial with structs for model format
This commit is contained in:
commit
1ba3b35dc1
75
devil3model.c
Normal file
75
devil3model.c
Normal file
@ -0,0 +1,75 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
struct Header {
|
||||
char numMesh;
|
||||
char unknownNumberB;
|
||||
char unknownNumberC;
|
||||
char unknownNumberD;
|
||||
uint32_t padding; // <format=hex>
|
||||
uint64_t unknowOffset;
|
||||
};
|
||||
|
||||
struct MeshHeaders {
|
||||
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 Positions {
|
||||
float x, y, z;
|
||||
};
|
||||
|
||||
struct Normals {
|
||||
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>
|
||||
};
|
||||
|
||||
// This is where most of the parsing will be.
|
||||
// this struct is in-order of what the file format wil have.
|
||||
struct Batch {
|
||||
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>
|
||||
int64_t pos; // set while parsing batch from ftell();
|
||||
// following structs should in an array of size numVertex
|
||||
struct Positions *p;
|
||||
struct Normals *n;
|
||||
struct UVs *u;
|
||||
struct BoneIndexes *bi;
|
||||
struct BoneWeights *bw;
|
||||
};
|
||||
|
||||
struct Mesh {
|
||||
struct Batch b;
|
||||
};
|
||||
|
||||
// just for now
|
||||
// need to separate file operation from the lib later
|
||||
bool readin(const char *fname) {
|
||||
;
|
||||
}
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
;
|
||||
}
|
Loading…
Reference in New Issue
Block a user