-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathMHS2 MOD.bt
272 lines (248 loc) · 5.95 KB
/
MHS2 MOD.bt
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
//------------------------------------------------
//--- 010 Editor v9.0.2 Binary Template
//
// File:
// Authors:
// Version:
// Purpose:
// Category:
// File Mask:
// ID Bytes:
// History:
//------------------------------------------------
local int i;
local int j;
local int faceCount;
local int faceIncrement;
const float WEIGHT_MULTIPLIER = 1.0/1023;
const float WEIGHT_MULTIPLIER2 = 1.0/255.0;
const float C8S = 0.0078125;
typedef struct{
float x;
float y;
float z;
}Vector3;
struct Header{
long id<format=hex>;
ubyte version;
ubyte version2;
short boneCount;
short meshCount;
short materialCount;
long vertexCount;
long faceCount;
long vertexIds;
long vertexBufferSize;
long secondBufferSize;
if(version<190){
long unknCount;
}
uint64 groupCount;
if((version<190)||(version>220)){
uint64 boneMapCount;
}
uint64 boneOffset<format=hex>;
uint64 groupOffset<format=hex>;
uint64 materialNamesOffset<format=hex>;
uint64 meshOffset<format=hex>;
uint64 VertexOffset<format=hex>;
if(version<190){
long vertex2Offset<format=hex>;
}
uint64 FacesOffset<format=hex>;
uint64 unknOffset<format=hex>;
if(version<190){
long unkOffset2<format=hex>;
Vector3 bbsphereposition;
float bspereradius;
Vector3 bbmin;
long unkn;
Vector3 bbmax;
long unkn;
}
float unkn1[11];
byte unkn2[24];
};
typedef struct{
short unkn1;
ubyte parentId;
ubyte child;
float unkn2;
float length;
float x;
float y;
float z;
}Bone;
typedef struct{
struct C{
float r1;
float r2;
float r3;
float r4;
}c[4];
}LMatrix;
typedef struct{
struct D{
float r1;
float r2;
float r3;
float r4;
}c[4];
}AMatrix;
typedef struct{
char name[128];
}materials;
typedef struct{
hfloat x;
hfloat y;
hfloat z;
}Position;
typedef struct{
byte normalX;
byte normalY;
byte normalZ;
byte normalW;
}Normal;
typedef struct{
byte tangentX;
byte tangentY;
byte tangentZ;
byte tangentW;
}Tangent;
typedef struct{
hfloat uvX;
hfloat uvY;
}Uv;
typedef struct{
long weight;
local hfloat weight1 = (weight & 0x3ff)*WEIGHT_MULTIPLIER;
local hfloat weight2 = ((weight>>10) & 0x3ff)*WEIGHT_MULTIPLIER;
local hfloat weight3 = ((weight>>20) & 0x3ff)*WEIGHT_MULTIPLIER;
local hfloat weight4 = 1-weight3-weight2-weight1;
}BaseWeight;
typedef struct{
byte weight2_0;
byte weight2_1;
byte weight2_2;
byte weight2_3;
local float weight5 = ((float)weight2_0)*WEIGHT_MULTIPLIER2;
local float weight6 = ((float)weight2_1)*WEIGHT_MULTIPLIER2;
local float weight7 = ((float)weight2_2)*WEIGHT_MULTIPLIER2;
local float weight8 = ((float)weight2_3)*WEIGHT_MULTIPLIER2;
}ExtendedWeight;
typedef struct{
ubyte red;
ubyte green;
ubyte blue;
ubyte alpha;
}Colour;
typedef struct{
Position position;
Normal normal;
Tangent tangent;
Uv uv;
BaseWeight baseweight;
ExtendedWeight extendedweight;
ubyte bone[8];
}VertexBuffer;
typedef struct{
uint unkn;
float unknFloats[7];
}unknGroupStruct;
typedef struct {
SHORT Mesh_Type;
SHORT Vertex_Count;
BYTE Group_Index;
BYTE Unknown_1; // ? usually 0
BYTE Material_Index;
BYTE Level_of_Detail_Index; // 0x00 = Null | 0x01 = HightPoly | 0x02 = MidPoly | 0x03 = LowPoly | 0xFF = Shadow
BYTE class; // 0x09 = Hidden? | 0x11 = Hands | 0x21 = Visible
BYTE mesh_class; // either body mesh, or hand mesh
BYTE Vertex_Stride;
BYTE Render_Mode;
ULONG Vertex_Position;
ULONG Vertex_Offset;
ULONG Vertex_Format<format=hex>; //block type
ULONG Face_Position;
ULONG Face_Count;
ULONG Face_Offset;
BYTE bone_id_start;
BYTE unique_boneids;
SHORT Mesh_Index;
SHORT Min_Index;
SHORT Max_Index;
LONG Hash; // ?unique ID give to distinguish each mesh? ixion-saga leaves this data blank
INT64 Unkn;
}MESH;
typedef struct{
ushort unkn;
ushort VertexCount;
byte id; //0 is visible at all times; 1 is visible when drawn; 2 is visible when on the back; ...
ushort materialIdx;
ubyte lod;
float unkn2;
uint VertexSub;
uint VertexOffset <format=hex>;
uint blocktype <format=hex>;
ulong FaceOffset <format=hex>;
ulong FaceCount;
ulong bonremapid;
byte unkns[12];
}MeshPartV2;
typedef struct{
short face[3];
}Strip;
typedef struct{
while(ReadShort() != -1) {
Strip face<bgcolor=0xFF0000>;
faceIncrement = faceIncrement+1;
if (ReadShort()!=-1){
FSeek(FTell()-4);
};
};
short stripEnd<bgcolor=0x000000>;
}tristrip;
typedef struct{
faceIncrement = 0;
while(faceIncrement<meshPart[i].Face_Count){
Printf("%i %i\n",i, faceIncrement);
tristrip StripData<optimize=false>;
};
}FaceData;
typedef struct(uint length){
byte vertex[length];
}BlindVertex;
Header head<bgcolor=0x00ff00>;
FSeek(head.materialNamesOffset);
materials materialNames[head.materialCount]<bgcolor=0xcc00cc>;
if(head.boneCount>0){
FSeek(head.boneOffset);
Bone Bones[head.boneCount]<bgcolor=0x330066>;
LMatrix LMatrices[head.boneCount]<bgcolor=0x660033>;
AMatrix AMatrices[head.boneCount]<bgcolor=0x663333>;
};
FSeek(head.groupOffset);
unknGroupStruct unknGroupStuff[head.groupCount]<bgcolor=0xAAAA33>;
FSeek(head.meshOffset);
if(head.version==214){
MESH meshPart[head.meshCount]<bgcolor=0xff0000>;
};
FSeek(head.VertexOffset);
struct Vertices{
for(i=0;i<head.meshCount;i++){
struct Vertexes{
for(j=0;j<meshPart[i].Vertex_Count;j++){
BlindVertex vertexes(meshPart[i].Vertex_Stride);
};
}vertexes;
};
}vertices;
/*
for (i=0;i<head.meshCount;i++){
faceCount = faceCount + meshPart[i].Face_Count;
};
Printf("Face Count = %u", faceCount);
FSeek(head.FacesOffset);
for (i=0;i<head.meshCount;i++){
FaceData Faces;
};*/