-
Notifications
You must be signed in to change notification settings - Fork 9
/
MHXR MOD.bt
225 lines (204 loc) · 4.7 KB
/
MHXR 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
//------------------------------------------------
//--- 010 Editor v9.0.2 Binary Template
//
// File:
// Authors:
// Version:
// Purpose:
// Category:
// File Mask:
// ID Bytes:
// History:
//------------------------------------------------
local int i;
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;
typedef struct{
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;
}
long groupCount;
if((version<190)||(version>220)){
long boneMapCount;
}
long boneOffset<format=hex>;
long groupOffset<format=hex>;
long materialNamesOffset<format=hex>;
long meshOffset<format=hex>;
long VertexOffset<format=hex>;
if(version<190){
long vertex2Offset<format=hex>;
}
long FacesOffset<format=hex>;
long EOFOffset<format=hex>;
if(version<190){
long unkOffset2<format=hex>;
Vector3 bbsphereposition;
float bspereradius;
Vector3 bbmin;
long unkn;
Vector3 bbmax;
long unkn;
}
float unkn2[12];
uint unkn3[5];
}Header;
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{
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;
short unkn2;
ubyte blockSize;
byte unkn3;
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{
while (faceIncrement < meshPart[i].FaceCount){
tristrip StripData<optimize=false>;
};
faceIncrement = 0;
}FaceData;
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==212){
MeshPartV2 meshPart[head.meshCount]<bgcolor=0xff0000>;
};
for (i=0;i<head.meshCount;i++){
FSeek(head.FacesOffset+meshPart[i].FaceOffset);
FaceData Faces;
};