-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHeaders.cs
162 lines (158 loc) · 6.16 KB
/
Headers.cs
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Reflection.PortableExecutable;
using System.Text;
using System.Threading.Tasks;
using static SC2_3DS.Helper;
namespace SC2_3DS
{
internal class Headers
{
public struct VMXHeader
{
public Byte4Array Magic;
public ConsoleVersion ConsoleVersion;
public byte Ukn01;
public byte Ukn02;
public byte Ukn03;
public byte Ukn04;
public ModelContent Contents;
public ushort MatrixCount;
public ushort Object0Count;
public ushort Object1Count;
public ushort Object2Count;
public ushort BoneCount;
public ushort MaterialCount;
public ushort MeshCount;
public uint TextureTableOffset;
public uint MaterialOffset;
public uint TextureMapOffset;
public uint MatrixTableOffset;
public uint MatrixUnkTableOffset;
public uint Object0Offset;
public uint Object1Offset;
public uint Object2Offset;
public uint WeightTableOffset;
public uint Ukn01_offset;
public uint BoneOffset;
public uint BoneNameOffset;
public uint Ukn02_offset;
}
//Xbox
public static VMXHeader ReadVMXHeader(BinaryReader reader)
{
VMXHeader value = new VMXHeader
{
Magic = ReadByte4Array(reader),
ConsoleVersion = (ConsoleVersion)reader.ReadByte(),
Ukn01 = reader.ReadByte(),
Ukn02 = reader.ReadByte(),
Ukn03 = reader.ReadByte(),
Ukn04 = reader.ReadByte(),
Contents = (ModelContent)reader.ReadByte(),
MatrixCount = ReadUInt16L(reader),
Object0Count = ReadUInt16L(reader),
Object1Count = ReadUInt16L(reader),
Object2Count = ReadUInt16L(reader),
BoneCount = ReadUInt16L(reader),
MaterialCount = ReadUInt16L(reader),
MeshCount = ReadUInt16L(reader),
TextureTableOffset = ReadUInt32L(reader),
MaterialOffset = ReadUInt32L(reader),
TextureMapOffset = ReadUInt32L(reader),
MatrixTableOffset = ReadUInt32L(reader),
MatrixUnkTableOffset = ReadUInt32L(reader),
Object0Offset = ReadUInt32L(reader),
Object1Offset = ReadUInt32L(reader),
Object2Offset = ReadUInt32L(reader),
WeightTableOffset = ReadUInt32L(reader),
Ukn01_offset = ReadUInt32L(reader),
BoneOffset = ReadUInt32L(reader),
BoneNameOffset = ReadUInt32L(reader),
Ukn02_offset = ReadUInt32L(reader)
};
return value;
}
//Gamecube
public static VMXHeader ReadVMGHeader(BinaryReader reader)
{
VMXHeader value = new VMXHeader
{
Magic = ReadByte4Array(reader),
ConsoleVersion = (ConsoleVersion)reader.ReadByte(),
Ukn01 = reader.ReadByte(),
Ukn02 = reader.ReadByte(),
Ukn03 = reader.ReadByte(),
Ukn04 = reader.ReadByte(),
Contents = (ModelContent)reader.ReadByte(),
MatrixCount = ReadUInt16B(reader),
Object0Count = ReadUInt16B(reader),
Object1Count = ReadUInt16B(reader),
Object2Count = ReadUInt16B(reader),
BoneCount = ReadUInt16B(reader),
MaterialCount = ReadUInt16B(reader),
MeshCount = ReadUInt16B(reader),
TextureTableOffset = ReadUInt32B(reader),
MaterialOffset = ReadUInt32B(reader),
TextureMapOffset = ReadUInt32B(reader),
MatrixTableOffset = ReadUInt32B(reader),
MatrixUnkTableOffset = ReadUInt32B(reader),
Object0Offset = ReadUInt32B(reader),
Object1Offset = ReadUInt32B(reader),
Object2Offset = ReadUInt32B(reader),
WeightTableOffset = ReadUInt32B(reader),
Ukn01_offset = ReadUInt32B(reader),
BoneOffset = ReadUInt32B(reader),
BoneNameOffset = ReadUInt32B(reader),
Ukn02_offset = ReadUInt32B(reader)
};
return value;
}
public struct VXTHeader
{
public Byte4Array Magic; // VXT, VGT
public byte Type; // Usually 0x01, 0x02 when clipping exists
public byte Unk01_flag; // Usually 4
public byte Unk02_flag; // Usually 2
public byte Pad;
public uint TextureCount;
public uint Pad2; //Gamecube pad?
public uint HeaderLength; // Usually 0014
public uint HeaderBlockSize;
}
public static VXTHeader ReadVXTHeader(BinaryReader reader)
{
VXTHeader value = new VXTHeader
{
Magic = ReadByte4Array(reader),
Type = reader.ReadByte(),
Unk01_flag = reader.ReadByte(),
Unk02_flag = reader.ReadByte(),
Pad = reader.ReadByte(),
TextureCount = ReadUInt32L(reader),
HeaderLength = ReadUInt32L(reader),
HeaderBlockSize = ReadUInt32L(reader),
};
return value;
}
public static VXTHeader ReadVGTHeader(BinaryReader reader)
{
VXTHeader value = new VXTHeader
{
Magic = ReadByte4Array(reader),
Type = reader.ReadByte(),
Unk01_flag = reader.ReadByte(),
Unk02_flag = reader.ReadByte(),
Pad = reader.ReadByte(),
TextureCount = ReadUInt32B(reader),
Pad2 = ReadUInt32B(reader),
HeaderLength = ReadUInt32B(reader),
HeaderBlockSize = ReadUInt32B(reader),
};
return value;
}
}
}