-
Notifications
You must be signed in to change notification settings - Fork 0
/
DAG.bt
458 lines (404 loc) · 9.23 KB
/
DAG.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
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
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
//------------------------------------------------
//--- 010 Editor v8.0.1 Binary Template
//
// File:
// Authors:
// Version:
// Purpose:
// Category:
// File Mask:
// ID Bytes:
// History:
//------------------------------------------------
local uint n, k, n0, io, childNumber, isObjStarted, sectionType, pos;
local float Size, Sz, cnt;
typedef struct {
FLOAT X;
FLOAT Y;
FLOAT Z;
} VECTOR_3F;
typedef struct {
FLOAT X;
FLOAT Y;
} VECTOR_2F;
typedef struct {
UINT16 X;
UINT16 Y;
UINT16 Z;
} VECTOR_3UI;
uint getType()
{
local uint type;
FSkip(4);
type = ReadInt(FTell());
FSkip(-4);
return type;
}
uint getSize()
{
local uint size;
size = ReadInt(FTell());
return size;
}
struct {
UCHAR Magic[4]; // signature
UINT DataSize;
UCHAR DAG[4];
} HEADER <name="File Header">;
typedef struct {
UINT DataSize;
UINT Type;
BYTE Length;
UCHAR MaterialName[Length];
struct {
INT Unknown;
INT Unknown;
INT Unknown;
FLOAT Unknown;
INT Unknown;
INT16 TextureIndex;
INT16 Unknown;
INT Unknown;
INT Unknown;
INT Unknown;
FLOAT Unknown;
FLOAT Unknown;
INT Unknown;
INT Unknown;
INT Unknown;
INT Unknown;
INT Unknown;
INT Unknown;
BYTE Length;
UCHAR LightMapName[Length];
} PROPERTIES;
UBYTE UNKNOWN_DATA[DataSize - (Length + PROPERTIES.Length + 74)];
} MATERIAL <name=GetMatName>;
typedef enum <uint> {
END = 0,
BEGIN = 1,
HEADER = 2,
DATA1 = 3,
MESH_OBJECTS_CONTAINER = 4,
DATA2 = 5,
DATA3 = 6,
OBJECTS_CONTAINER = 7,
DATA5 = 8,
} OBJECT_SECTION_TYPE;
uint readMeshObject(uint datasize)
{
local uint dsize = datasize - 4;
local uint faceNum;
while (dsize > 0)
{
UINT DataSize1;
UINT Type;
if (Type == 1) {
struct {
UINT16 VertexCount;
VECTOR_3F VertexCoordinates[VertexCount];
UINT16 FaceCount;
struct {
uint i1;
uint i2;
uint i3;
} Facent[FaceCount];
UBYTE Count8;
struct {
UINT16 Count0;
UINT16 Count;
VECTOR_2F TexCoordinates[Count0];
VECTOR_3UI Indexes[FaceCount];
} YU[Count8];
} S1;
}
if (Type == 3) {
struct {
FLOAT TY[5];
UINT16 KK;
FLOAT TY2[3];
} S3;
}
if (Type == 4) {
struct {
uint16 num0;
struct {
uint16 index;
float x;
float y;
float z;
float x;
float y;
float z;
float x;
float y;
float z;
float x;
float y;
float z;
} Un[num0];
uint num;
struct {
float fg[num0];
} un[num];
} S4;
}
if (Type == 6) {
struct {
if (exists(S1))
byte data1[S1.FaceCount];
else
byte data1[DataSize1 - 4];
} S6;
}
if (Type == 2)
{
struct {
UINT16 FaceCount;
UINT16 Un;
struct {
UINT16 Index1;
UINT16 Un;
UINT16 Index2;
UINT16 Un;
UINT16 Index3;
UINT16 Un;
UINT16 Un;
UINT16 Un;
UINT16 Un;
} Facent[FaceCount];
BYTE Count00;
struct {
UINT Count3;
BYTE Count001;
BYTE Count002;
struct {
FLOAT XYZ[Count001];
} TY[Count3];
struct {
UINT Indexes[3];
} TY2[FaceCount];
} wqr[Count00] <optimize=false>;
UINT Count;
BYTE R[Count];
} S2;
}
dsize -= (DataSize1 + 4);
};
return 0;
}
// objects tree
uint readObject() {
struct {
UINT DataSize;
UINT Type;
local uint faceCount, datasize, childNum;
datasize = DataSize - 4;
while (datasize > 0)
{
UINT DataSize1;
UINT Type;
if (Type == 1) {
struct {
if (DataSize1 == 52)
struct {
FLOAT X;
FLOAT Y;
FLOAT Z;
FLOAT X;
FLOAT Y;
FLOAT Z;
FLOAT X;
FLOAT Y;
FLOAT Z;
FLOAT PosX;
FLOAT PosY;
FLOAT PosZ;
} MATRIX;
} MATRIX;
}
if (Type == 2) {
struct {
INT16 Index <name="Object index">;
INT16 ChildCount <name="Number of child objects">;
childNum = ChildCount;
UINT type;
if (DataSize1 > 12)
UCHAR ObjectName[DataSize1 - 12];
} HEADER;
}
if (Type == 3) {
struct {
CHAR Str[DataSize1 - 4];
} NAME;
}
if (Type == 4) {
struct {
readMeshObject(DataSize1);
} MESH;
};
if (Type == 5) {
struct {
BYTE DAta[DataSize1 - 4];
} U_5;
};
if (Type == 6) {
struct {
if (faceCount == 0)
{
INT16 A;
INT16 num;
if (num > 1)
struct {
uint unk;
FLOAT tt0;
FLOAT tt1;
FLOAT tt2;
FLOAT tt0;
FLOAT tt1;
FLOAT tt2;
FLOAT tt0;
FLOAT tt1;
FLOAT tt2;
} tqi[num];
else uint tiuyo[3];
INT16 num;
struct {
FLOAT tt0;
FLOAT tt1;
FLOAT tt0;
FLOAT tt1;
FLOAT tt2;
FLOAT tt0;
FLOAT tt1;
FLOAT tt2;
FLOAT tt0;
FLOAT tt1;
FLOAT tt2;
FLOAT tt1;
FLOAT tt2;
} tqi2[num];
INT16 num;
if (num > 1)
struct {
uint unk;
FLOAT tt0;
FLOAT tt1;
FLOAT tt2;
FLOAT tt0;
FLOAT tt1;
FLOAT tt2;
FLOAT tt0;
FLOAT tt1;
FLOAT tt2;
} tqi3[num];
else struct {
uint unk;
FLOAT tt0;
FLOAT tt1;
} e;
}
else {
UBYTE Indexes1[faceCount];
}
} U_6;
};
if (Type == 7) {
if (HEADER.ChildCount > 0)
{
struct {
local uint i;
for (i = 0; i < childNum; i++)
{
struct {
readObject();
} ONE_HELL_OF_AN_OBJECT;
}
} CHILD_OBJECTS;
}
};
if (Type == 8) {
byte data034[DataSize1 - 4];
}
datasize -= (DataSize1 + 4);
};
} OBJECT;
return 0;
};
local uint frameNum;
while (!FEof())
{
FSkip(4);
n = ReadInt(FTell());
FSkip(-4);
if (n == 5) {
struct {
UINT DataSize;
UINT Type;
struct {
UINT16 AnimationIndex;
UINT frameIndex;
} A[frameNum];
} ANIMATION_FRAME <name="Frames data">;
}
if (n == 4)
struct {
UINT DataSize;
UINT Type;
UINT16 Count;
frameNum = Count;
typedef struct {
BYTE Length;
UCHAR Name[Length];
} STATE_NAME <name=GetStateName>;
typedef struct (uint arraysize) {
STATE_NAME Array[arraysize] <optimize=false>;
} STATE_NAMES;
STATE_NAMES FileNames(Count) <name="State Names">;
} ANIMATIONS <name="Animations">;
if (n == 3)
struct {
UINT DataSize;
UINT Type;
UINT16 TextureCount;
typedef struct {
BYTE Length;
UCHAR FileName[Length];
} FILE_NAME <optimize=false, name=GetTexName>;
typedef struct (uint arraysize) {
FILE_NAME Array[arraysize];
} FILE_NAME_ARRAY <optimize=false>;
FILE_NAME_ARRAY FileNames(TextureCount) <name="Texture List">;
} TEXTURE <name="Textures">;
if (n == 2)
MATERIAL Material;
if (n == 1) {
struct {
readObject();
} GEOMETRY;
};
if (n == 0)
struct {
UINT DataSize;
UINT Type;
} end;
}
//string GetObjName(OBJECT &obj)
//{
// return "Object: " + obj.ObjectName;
//}
string GetStateName(STATE_NAME &st)
{
return "State: " + st.Name;
}
string GetTexName(FILE_NAME &fn)
{
return "Texture: " + fn.FileName;
}
string GetMatName(MATERIAL &mt)
{
if (exists(mt.MaterialName))
return "Material: " + mt.MaterialName;
else
return "Material";
}