-
Notifications
You must be signed in to change notification settings - Fork 0
/
MOD.hpp
141 lines (118 loc) · 3.02 KB
/
MOD.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#ifndef MOD_HPP
#define MOD_HPP
#include <array>
#include <common.hpp>
#include <optional>
#include <string_view>
#include <util/fstream_reader.hpp>
#include <util/fstream_writer.hpp>
#include <vector>
/**
* @brief Enumeration representing the flags for the MOD.
*/
enum class MODFlags : u8 {
None = 0x00,
UseNBT = 0x01,
};
/**
* @brief Struct representing the header of the MOD.
*/
struct MODHeader {
struct {
u16 mYear = 2024;
u8 mMonth = 03;
u8 mDay = 07;
} mDateTime;
u32 mFlags = static_cast<u32>(MODFlags::None);
};
/**
* @brief Struct representing the MOD.
*/
struct MOD {
/**
* @brief Enumeration representing the chunk types in the MOD.
*/
enum class EChunkType {
Header = 0x00,
Vertex = 0x10,
VertexNormal = 0x11,
VertexNBT = 0x12,
VertexColour = 0x13,
TexCoord0 = 0x18,
TexCoord1 = 0x19,
TexCoord2 = 0x1A,
TexCoord3 = 0x1B,
TexCoord4 = 0x1C,
TexCoord5 = 0x1D,
TexCoord6 = 0x1E,
TexCoord7 = 0x1F,
Texture = 0x20,
TextureAttribute = 0x22,
Material = 0x30,
VertexMatrix = 0x40,
MatrixEnvelope = 0x41,
Mesh = 0x50,
Joint = 0x60,
JointName = 0x61,
CollisionPrism = 0x100,
CollisionGrid = 0x110,
EndOfFile = 0xFFFF
};
/**
* @brief Default constructor for MOD.
*/
MOD() = default;
/**
* @brief Constructor for MOD that reads data from the given reader.
* @param reader The fstream_reader to read data from.
*/
MOD(util::fstream_reader& reader) { read(reader); }
/**
* @brief Default destructor for MOD.
*/
~MOD() = default;
/**
* @brief Reads the MOD data from the given reader.
* @param reader The fstream_reader to read data from.
*/
void read(util::fstream_reader& reader);
/**
* @brief Writes the MOD data to the given writer.
* @param writer The fstream_writer to write data to.
*/
void write(util::fstream_writer& writer);
/**
* @brief Resets the MOD data to its default state.
*/
void reset();
/**
* @brief Gets the name of the chunk with the given opcode.
* @param opcode The opcode of the chunk.
* @return The name of the chunk as an optional string_view.
*/
static const std::optional<std::string_view> getChunkName(u32 opcode);
/**
* @brief Gets the name of the chunk with the given chunk type.
* @param chunkType The chunk type.
* @return The name of the chunk as an optional string_view.
*/
static const std::optional<std::string_view> getChunkName(EChunkType chunkType);
MODHeader mHeader;
std::vector<Vector3f> mVertices;
std::vector<Vector3f> mVertexNormals;
std::vector<NBT> mVertexNbt;
std::vector<ColourU8> mVertexColours;
std::array<std::vector<Vector2f>, 8> mTextureCoords;
std::vector<Texture> mTextures;
std::vector<TextureAttributes> mTextureAttributes;
MaterialContainer mMaterials;
std::vector<VtxMatrix> mVertexMatrices;
std::vector<Envelope> mVertexEnvelopes;
std::vector<Mesh> mMeshes;
std::vector<Joint> mJoints;
std::vector<std::string> mJointNames;
CollTriInfo mCollisionTriangles;
CollGrid mCollisionGridInfo;
std::vector<u8> mEndOfFileData;
};
#endif