@@ -11,43 +11,43 @@ namespace MDL {
1111
1212 #pragma pack(push, 1)
1313 struct MDLHeader {
14- uint32_t Magic;
15- uint16_t FaceCount;
16- uint16_t Padding;
17- uint16_t SceneGraphNodeCount;
18- uint16_t PacketCount;
19- uint16_t WeightCount;
20- uint16_t JointCount;
21- uint16_t PositionCount;
22- uint16_t NormalCount;
23- uint16_t ColorCount;
24- uint16_t TexCoordCount;
25- uint8_t Padding2[8 ];
26- uint16_t TextureCount;
27- uint16_t Padding3;
28- uint16_t SamplerCount;
29- uint16_t DrawElementCount;
30- uint16_t MaterialCount;
31- uint16_t ShapeCount;
32- uint32_t Padding4;
33- uint32_t SceneGraphOffset;
34- uint32_t PacketOffset;
35- uint32_t InverseMatrixOffset;
36- uint32_t WeightOffset;
37- uint32_t JointIndexOffset;
38- uint32_t WeightCountTableOffset;
39- uint32_t PositionOffset;
40- uint32_t NormalsOffset;
41- uint32_t ColorsOffset;
42- uint32_t TexCoordsOffset;
43- uint8_t Padding5[8 ];
44- uint32_t TextureOffsetArray;
45- uint32_t Padding6;
46- uint32_t MaterialOffset;
47- uint32_t SamplerOffset;
48- uint32_t ShapeOffset;
49- uint32_t DrawElementOffset;
50- uint8_t Padding7[8 ];
14+ uint32_t Magic { 0 } ;
15+ uint16_t FaceCount { 0 } ;
16+ uint16_t Padding { 0 } ;
17+ uint16_t SceneGraphNodeCount { 0 } ;
18+ uint16_t PacketCount { 0 } ;
19+ uint16_t WeightCount { 0 } ;
20+ uint16_t JointCount { 0 } ;
21+ uint16_t PositionCount { 0 } ;
22+ uint16_t NormalCount { 0 } ;
23+ uint16_t ColorCount { 0 } ;
24+ uint16_t TexCoordCount { 0 } ;
25+ uint8_t Padding2 { 0 } [8 ];
26+ uint16_t TextureCount { 0 } ;
27+ uint16_t Padding3 { 0 } ;
28+ uint16_t SamplerCount { 0 } ;
29+ uint16_t DrawElementCount { 0 } ;
30+ uint16_t MaterialCount { 0 } ;
31+ uint16_t ShapeCount { 0 } ;
32+ uint32_t Padding4 { 0 } ;
33+ uint32_t SceneGraphOffset { 0 } ;
34+ uint32_t PacketOffset { 0 } ;
35+ uint32_t InverseMatrixOffset { 0 } ;
36+ uint32_t WeightOffset { 0 } ;
37+ uint32_t JointIndexOffset { 0 } ;
38+ uint32_t WeightCountTableOffset { 0 } ;
39+ uint32_t PositionOffset { 0 } ;
40+ uint32_t NormalsOffset { 0 } ;
41+ uint32_t ColorsOffset { 0 } ;
42+ uint32_t TexCoordsOffset { 0 } ;
43+ uint8_t Padding5 { 0 } [8 ];
44+ uint32_t TextureOffsetArray { 0 } ;
45+ uint32_t Padding6 { 0 } ;
46+ uint32_t MaterialOffset { 0 } ;
47+ uint32_t SamplerOffset { 0 } ;
48+ uint32_t ShapeOffset { 0 } ;
49+ uint32_t DrawElementOffset { 0 } ;
50+ uint8_t Padding7 { 0 } [8 ];
5151 };
5252 #pragma pack(pop)
5353
@@ -66,13 +66,15 @@ namespace MDL {
6666 uint32_t PaddingSecond;
6767
6868 void Read (bStream::CStream* stream) override ;
69+ void Save (bStream::CStream* stream);
6970 };
7071
7172 struct DrawElement : Readable {
7273 uint16_t MaterialIndex;
7374 uint16_t ShapeIndex;
7475
7576 void Read (bStream::CStream* stream) override ;
77+ void Save (bStream::CStream* stream);
7678 };
7779
7880 struct Shape : Readable {
@@ -86,6 +88,7 @@ namespace MDL {
8688 uint32_t Vao, Vbo, VertexCount; // Bind these for rendering
8789
8890 void Read (bStream::CStream* stream) override ;
91+ void Save (bStream::CStream* stream);
8992 void Destroy ();
9093 };
9194
@@ -96,8 +99,10 @@ namespace MDL {
9699 uint16_t MatrixCount;
97100 uint16_t MatrixIndices[10 ];
98101
102+ std::vector<Primitive> Primitives;
99103
100104 void Read (bStream::CStream* stream) override ;
105+ void Save (bStream::CStream* stream);
101106 void Destroy (); // Delete arrays
102107 };
103108
@@ -117,6 +122,7 @@ namespace MDL {
117122 std::vector<TevStage> TevStages;
118123
119124 void Read (bStream::CStream* stream) override ;
125+ void Save (bStream::CStream* stream);
120126 };
121127
122128 struct Sampler : Readable {
@@ -128,6 +134,7 @@ namespace MDL {
128134 uint8_t Unknown2;
129135
130136 void Read (bStream::CStream* stream) override ;
137+ void Save (bStream::CStream* stream);
131138 };
132139
133140 struct TextureHeader : Readable {
@@ -137,9 +144,11 @@ namespace MDL {
137144 uint16_t Height;
138145 uint8_t Padding2[26 ];
139146
147+ uint8_t * ImageData { nullptr };
140148 uint32_t TextureID { UINT32_MAX }; // Bind this for rendering
141149
142150 void Read (bStream::CStream* stream) override ;
151+ void Save (bStream::CStream* stream);
143152
144153 void Destroy ();
145154 };
@@ -236,15 +245,15 @@ namespace MDL {
236245
237246 MDLHeader mHeader ;
238247
239- std::vector< TextureHeader> mTextureHeaders ;
248+ std::map< int , TextureHeader> mTextureHeaders ;
240249
241- std::vector< Sampler> mSamplers ;
242- std::vector< Shape> mShapes ;
243- std::vector< Packet> mPackets ;
244- std::vector< DrawElement> mDrawElements ;
250+ std::map< int , Sampler> mSamplers ;
251+ std::map< int , Shape> mShapes ;
252+ std::map< int , Packet> mPackets ;
253+ std::map< int , DrawElement> mDrawElements ;
245254
246- std::vector< Material> mMaterials ;
247- std::vector< SceneGraphNode> mGraphNodes ;
255+ std::map< int , Material> mMaterials ;
256+ std::map< int , SceneGraphNode> mGraphNodes ;
248257
249258 std::vector<glm::vec3> mPositions ;
250259 std::vector<glm::vec3> mNormals ;
@@ -264,6 +273,7 @@ namespace MDL {
264273 CPathRenderer mSkeletonRenderer ;
265274 void Draw (glm::mat4* transform, int32_t id, bool selected, TXP::Animation* materialAnimtion = nullptr , Animation* skeletalAnimation = nullptr );
266275 void Load (bStream::CStream* stream);
276+ void Save (bStream::CStream* stream);
267277
268278 Model (){}
269279 ~Model ();
0 commit comments