forked from relaxok/wow010
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMDXTemplate.bt
More file actions
executable file
·437 lines (338 loc) · 9.6 KB
/
MDXTemplate.bt
File metadata and controls
executable file
·437 lines (338 loc) · 9.6 KB
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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
/*
MDX Template for WoW Alpha mdx
--Tigurius
*/
// colors for special puposes
local int cOffset = cLtYellow;
local int cFileName = cLtAqua;
local int cVector = cLtPurple;
/*******************************************************
* 1. BASIC TYPES
*******************************************************/
typedef union {
UBYTE byteValues[4];
UINT32 intValue;
} unkown;
// basic chunk structure
//--------------------------------------------------
typedef struct {
// always important to know!
local uint32 myOffset = FTell();
local uint32 myDataStart = myOffset + 8;
// color
SetColor( cWhite, cDkRed );
// magic value
char magic[4];
// color #2
SetColor( cBlack, 0x99CCFF );
// data size
uint32 byte_size;
// normal color plz
SetStdColor();
} _chunk <read=chunkGetMagic>;
// displays the magic and the size of this chunk
string chunkGetMagic(_chunk &c) {
string s;
SPrintf( s,
"%c%c%c%c: %i Byte",
//in mdx we have the cunk names in correct order!
c.magic[0], c.magic[1], c.magic[2], c.magic[3], c.byte_size
);
return s;
};
// unknown chunk - yes! Whenever we dont know anything!
//--------------------------------------------------
typedef struct {
local int i=0;
_chunk hdr;
while( FTell() < (hdr.byte_size + hdr.myDataStart) ) {
unkown value;
i++;
}
} unk_chunk<read=uChunkGetMagic>;
string uChunkGetMagic(unk_chunk &c) {
string s;
SPrintf( s,
"%c%c%c%c: %i Byte",
c.hdr.magic[0], c.hdr.magic[1], c.hdr.magic[2],
c.hdr.magic[3], c.hdr.byte_size
);
return s;
};
// offset including features
//--------------------------------------------------
typedef struct {
// we store this value for calculations
local uint32 upperChunkOffset = 0;
SetColor( cBlack, cOffset );
UINT32 adress <format=hex>;
SetStdColor();
}offset <read=offsetGetADR>;
// displays where this pointer is pointing to
string offsetGetADR(offset &o) {
string s;
// just an offset ?
if(o.upperChunkOffset==0) {
SPrintf( s, "+ %i Byte", o.adress);
}
// global offset
else {
// zero?
if(o.adress==0) return "- unused - ";
SPrintf( s, "-> 0x%02X", o.adress+o.upperChunkOffset);
}
return s;
}
// filename - ... because 010 want it so
//--------------------------------------------------
typedef struct {
SetColor( cBlack, cFileName );
string value;
SetStdColor();
} filename <read=filenameRead>;
string filenameRead(filename &f) {
return f.value;
};
// Vector3D
//--------------------------------------------------
typedef struct {
SetColor( cBlack, cVector );
float x, y, z;
SetStdColor();
} Vector3D;
typedef struct{
SetColor( cBlack, cVector );
float w,x, y, z;
SetStdColor();
}Quaternion;
typedef struct {
SetColor( cBlack, cVector );
Vector3D min,max;
SetStdColor();
} Vector6D;
typedef struct {
SetColor( cBlack, cVector );
float u,v;
SetStdColor();
} Vector2D;
typedef struct {
SetColor( cBlack, cVector );
short x,y,z;
SetStdColor();
} Triangle;
// RGB
//--------------------------------------------------
typedef struct {
ubyte r;
ubyte g;
ubyte b;
} rgb<read=rgbRead>;
// display the color a bit more nice
string rgbRead(rgb &f) {
local string s;
SPrintf( s, "#%02X%02X%02X", f.r, f.g, f.b);
return s;
};
/*******************************************************
* 2. Chunk Def.
*******************************************************/
// MVER - Versions Header
//--------------------------------------------------
typedef struct {
_chunk hdr;
unsigned byte version[4] <format=hex>;
} VERS;
typedef struct {
_chunk hdr;
char Name[80];
char AnimationFileName[260];
float BoundsRadius;
Vector3D MinimumExtent;
Vector3D MaximumExtent;
int BlendTime;
char unk;//oO
} MODL;
typedef struct //NrOfSequences = ChunkSize / 132
{
char Name[80];
int IntervalStart;
int IntervalEnd;
float MoveSpeed;
int Flags; //0 - Looping
//1 - NonLooping
Vector3D MinimumExtent;
Vector3D MaximumExtent;
float Rarity;
int SyncPoint;
float BoundsRadius;
int null;
int PlaybackSpeed;//?
}SequEntry;
typedef struct {
local int i=0;
_chunk hdr;
int nSequences;
while( FTell() < (hdr.byte_size + hdr.myDataStart) ) {
SequEntry entry;
i++;
}
} SEQS;
typedef struct
{
local int i=0;
_chunk hdr;
while( FTell() < (hdr.byte_size + hdr.myDataStart) ) {
int GlobalSequence;
i++;
}
} GLBS;
typedef struct{
int InclusiveSize;
int PriorityPlane;
int Flags; //#1 - ConstantColor
//#2 - ???
//#4 - ???
//#8 - SortPrimitivesNearZ
//#16 - SortPrimitivesFarZ
//#32 - FullResolution
int InclusiveSize2;
int FilterMode; //0 - None
//1 - Transparent
//2 - Blend
//3 - Additive
//4 - AddAlpha
//5 - Modulate
//6 - Modulate2x
int ShadingFlags; //#1 - Unshaded
//#2 - SphereEnvironmentMap
//#4 - ???
//#8 - ???
//#16 - TwoSided
//#32 - Unfogged
//#64 - NoDepthTest
//#128 - NoDepthSet
int TextureId;
int TextureAnimationId;
int CoordId;
float Alpha;
}MatEntry;
typedef struct
{
local int i=0;
_chunk hdr;
int nMaterials;
int unk;
while( FTell() < (hdr.byte_size + hdr.myDataStart) ) {
MatEntry Material;
i++;
}
} MTLS;
typedef struct{
int ReplaceableId;
char FileName[260] ;
int Flags; //#1 - WrapWidth
//#2 - WrapHeight
}TexEntry;
typedef struct
{
local int i=0;
_chunk hdr;
while( FTell() < (hdr.byte_size + hdr.myDataStart) ) {
TexEntry Texture;
i++;
}
} TEXS;
typedef struct{
char vert[4];
int NrOfVertexPositions;
Vector3D vpos[NrOfVertexPositions];
char norm[4];
int NrOfVertexNormals;
Vector3D vnorm[NrOfVertexNormals];
char uvas[4];
int NrOfTextureVertexGroups;
Vector2D unk[NrOfVertexNormals];
char ptyp[4];
int NrOfFaceTypeGroups;
char FaceType[NrOfFaceTypeGroups];
//4 - Triangles
//??? - Triangle fan
//??? - Triangle strip
//??? - Quads
//??? - Quad strip
char pcnt[4];
int NrOfFaceGroups;
int NrOfIndexes[NrOfFaceGroups];
char pvtx[4];
int TotalNrOfIndexes;
local int TotalNrOfFaces = TotalNrOfIndexes / 3;
Triangle Face[TotalNrOfFaces] ;
//TotalNrOfFaces = TotalNrOfIndexes / 3
char gndx[4];
int NrOfVertexGroups;
byte MatrixGroup[NrOfVertexGroups];
char mtgc[4];
int NrOfMatrixGroups;
int MatrixGroupSize[NrOfMatrixGroups];
char mats[4];
int NrOfMatrixIndexes;
int MatrixIndex[NrOfMatrixIndexes];
char bidx[4];
int nBidx;
int Bidx[nBidx];
char bwgt[4];
int nBwgt;
float Bwgt[nBwgt];
int MaterialId;
int SelectionGroup;
int SelectionFlags; //0 - None
//#1 - ???
//#2 - ???
//#4 - Unselectable
float BoundsRadius;
Vector3D MinimumExtent;
Vector3D MaximumExtent;
int NrOfExtents;
Vector6D Extent[NrOfExtents];
float unk_[15];
//int NrOfVertexTexturePositions;
// Vector2D VertexTexturePosition[NrOfVertexTexturePositions];
}GeosetEntry;
typedef struct
{
local int i=0;
_chunk hdr;
int nGeos;
int unk;
while( FTell() < (hdr.byte_size + hdr.myDataStart) ) {
GeosetEntry Geoset;
i++;
}
} GEOS;
/*******************************************************
* 3. MDX File
*******************************************************/
struct {
// magic value == MDLX
char magic[4];
VERS vers;
MODL modl;
SEQS seqs;
GLBS glbs;
MTLS mtls;
TEXS texs;
GEOS geos;
}mdx_file;
/*******************************************************
* 4. Helpers
*******************************************************/
// im soo lazy
void SetStdColor() {
SetColor( cBlack, cWhite );
}
// whats comming next?
char nextChar() {
return ReadByte(FTell());
}
int checkHeader(string magic){
}