devil1geo.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #ifndef DEVIL1GEO_H
  2. #define DEVIL1GEO_H
  3. #include <stdint.h>
  4. #include <stdbool.h>
  5. #pragma pack(push, 1)
  6. struct Header {
  7. unsigned char numMesh;
  8. unsigned char unknownNumberB;
  9. unsigned char unknownNumberC;
  10. unsigned char unknownNumberD;
  11. uint32_t padding; // <format=hex>
  12. uint64_t unknownOffset;
  13. };
  14. struct MeshHeader {
  15. int16_t numBatch;
  16. int16_t numVertex;
  17. uint32_t u; // <format=hex>
  18. uint64_t offsetBatches;
  19. uint64_t flags;
  20. }; // put these in an array of size: [header.numMesh]
  21. struct Coordinate {
  22. float x, y, z;
  23. };
  24. struct UVs {
  25. int16_t u, v;
  26. };
  27. struct BoneIndexes {
  28. unsigned char indexes[4]; // from ubyte
  29. };
  30. struct BoneWeights {
  31. uint16_t weights; // <format=hex>
  32. };
  33. struct BatchData {
  34. int16_t numVertex;
  35. int16_t uB;
  36. uint32_t padding; // <format=hex>
  37. uint64_t offsetPositions; // <format=hex>
  38. uint64_t offsetNormals; // <format=hex>
  39. uint64_t offsetUVs; // <format=hex>
  40. uint64_t offsetBoneIndexes; // <format=hex>
  41. uint64_t offsetBoneWeights; // <format=hex>
  42. uint64_t offsets[1]; // <format=hex>
  43. };
  44. struct VertexData {
  45. // following structs should in an array of size 'numVertex'
  46. struct Coordinate *positions;
  47. struct Coordinate *normals;
  48. struct UVs *u;
  49. struct BoneIndexes *bi;
  50. struct BoneWeights *bw;
  51. };
  52. struct Batch {
  53. struct BatchData *bd; // pointer to region in file data
  54. struct VertexData vd; // collection of pointers to regions in file data
  55. };
  56. struct Mesh {
  57. // array of batches
  58. struct Batch *b;
  59. };
  60. #pragma pack(pop)
  61. typedef struct {
  62. // input: pointer to struct
  63. void (* const printheader) (struct Header*);
  64. // input: pointer to struct
  65. void (* const printmeshheader)(struct MeshHeader*);
  66. // input: pointer to struct
  67. void (* const printbatch) (struct Batch*);
  68. // input: pointer to struct
  69. void (* const printcoordinate)(struct Coordinate*, unsigned int);
  70. // input: pointer to struct, file data
  71. bool (* const getheader) (struct Header**, const char*);
  72. // input: pointer of pointer to struct, order, file data
  73. // ** = 'pass by reference' of a pointer to struct
  74. bool (* const getmeshheader) (struct MeshHeader**,
  75. unsigned int i,
  76. const char * const);
  77. // input: pointer to struct, offset of file data batch is at, file data
  78. bool (* const getbatch) (struct Batch*,
  79. unsigned int offset,
  80. const char * const);
  81. // input: pointer to struct, order, file data, file size
  82. bool (* const getmesh) (struct Mesh*,
  83. unsigned int i,
  84. const char*,
  85. unsigned int);
  86. } fn_devil1geo;
  87. extern fn_devil1geo const DEVIL1GEO;
  88. #endif