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
|
#include "animation.h"
#include "lyt/binaryfile.h"
LYTAnimation::~LYTAnimation() {
}
LYTAnimation::LYTAnimation(QByteArray data) {
LYTBinaryFile file(data);
foreach (const LYTBinaryFileSection §ion, file.sections) {
switch (section.magic.value) {
case 'pat1': {
// Info
QDataStream in(section.data);
InitDataStream(in);
quint16 groupCount;
quint32 nameOffset, groupOffset;
quint8 flag;
in >> sourceTagNumber;
in >> groupCount;
in >> nameOffset;
in >> groupOffset;
in >> sourceStartFrame;
in >> sourceEndFrame;
in >> flag;
qDebug() << "Source: Tag:" << sourceTagNumber << "- Frames:" << sourceStartFrame << "to" << sourceEndFrame;
qDebug() << "Groups: Offset" << groupOffset << ", count" << groupCount << "- Name offset:" << nameOffset;
recursiveBind = ((flag & 1) != 0);
qDebug() << "Flag:" << flag << "; Recursive bind:" << recursiveBind;
in.device()->seek(nameOffset - 8);
// a royal hack
name = ReadFixedLengthASCII(in, groupOffset-nameOffset);
qDebug() << "Rlan name:" << name;
groups.reserve(groupCount);
in.device()->seek(groupOffset - 8);
for (int i = 0; i < groupCount; i++) {
LYTAnimGroupInfo info;
info.name = ReadFixedLengthASCII(in, 17);
in >> info.unusedFlag;
in.skipRawData(2);
groups.append(info);
qDebug() << "Group name:" << info.name;
}
break;
}
case 'pai1': {
// Bits
QDataStream in(section.data);
InitDataStream(in);
quint8 loop;
quint16 fileCount, blockCount;
quint32 offsetOffset;
in >> frameSize;
in >> loop;
in.skipRawData(1);
in >> fileCount;
in >> blockCount;
in >> offsetOffset;
qDebug() << "Loop:" << loop << "- File count:" << fileCount << ", Block count:" << blockCount;
qDebug() << "Offset Offset:" << offsetOffset;
this->loop = (loop & 1);
importedFiles.reserve(fileCount);
qint64 strTabBegin = in.device()->pos();
for (int i = 0; i < fileCount; i++) {
quint32 offs;
in >> offs;
qint64 saveMe = in.device()->pos();
in.device()->seek(strTabBegin + offs);
importedFiles.append(ReadVariableLengthASCII(in));
in.device()->seek(saveMe);
qDebug() << "Imported file:" << importedFiles.last();
}
// Now, each block
in.device()->seek(offsetOffset-8);
blocks.reserve(blockCount);
for (int i = 0; i < blockCount; i++) {
quint32 blockOffs;
in >> blockOffs;
qint64 saveInList = in.device()->pos();
in.device()->seek(blockOffs - 8);
// Block.
LYTAnimBlock block;
block.name = ReadFixedLengthASCII(in, 20);
quint8 pieceCount, type;
in >> pieceCount;
in >> type;
in.skipRawData(2);
block.isMaterial = (type == 1);
qDebug() << "Block @ " << QString::number(blockOffs,16) << ":" << block.name << "- Piece Count:" << pieceCount << "- Type:" << type << "IsMaterial:" << block.isMaterial;
// Now, the piece list
block.pieces.reserve(pieceCount);
for (int j = 0; j < pieceCount; j++) {
quint32 pieceOffs;
in >> pieceOffs;
qint64 saveInList2 = in.device()->pos();
in.device()->seek(blockOffs + pieceOffs - 8);
// Piece
LYTAnimPiece piece;
Magic pieceMagic(0);
in >> pieceMagic.value;
switch (pieceMagic.value) {
case 'RLPA': piece.type = piece.PaneAnim; break;
case 'RLTS': piece.type = piece.TexSRTAnim; break;
case 'RLVI': piece.type = piece.VisAnim; break;
case 'RLVC': piece.type = piece.VtxClrAnim; break;
case 'RLMC': piece.type = piece.MatClrAnim; break;
case 'RLTP': piece.type = piece.TexPatAnim; break;
case 'RLIM': piece.type = piece.IndTexSRTAnim; break;
}
quint8 entryCount;
in >> entryCount;
in.skipRawData(3);
qDebug("Piece: %c%c%c%c, Entry Count: %d", pieceMagic.str[3], pieceMagic.str[2], pieceMagic.str[1], pieceMagic.str[0], entryCount);
piece.entries.reserve(entryCount);
// ANOTHER LIST ARGHHHH
for (int k = 0; k < entryCount; k++) {
quint32 entryOffs;
in >> entryOffs;
qint64 saveInList3 = in.device()->pos();
in.device()->seek(blockOffs + pieceOffs + entryOffs - 8);
// Entry
LYTAnimEntry entry;
in >> entry.id;
in >> entry.target;
in >> entry.curveType;
in.skipRawData(1);
quint16 keyCount;
quint32 keyOffset;
in >> keyCount;
in.skipRawData(2);
in >> keyOffset;
qDebug() << "Entry ID:" << entry.id << "Target:" << entry.target << "CurveType:" << entry.curveType << "KeyCount:" << keyCount << "KeyOffset:" << keyOffset;
in.device()->seek(blockOffs + pieceOffs + entryOffs + keyOffset - 8);
if (piece.type == piece.TexPatAnim || piece.type == piece.VisAnim) {
entry.stepKeys.reserve(keyCount);
for (int l = 0; l < keyCount; l++) {
// Step Key
LYTAnimStepKey key;
in >> key.frame;
in >> key.value;
in.skipRawData(2);
qDebug() << "Step Key:" << key.frame << key.value;
entry.stepKeys.append(key);
}
} else {
entry.keys.reserve(keyCount);
for (int l = 0; l < keyCount; l++) {
// Key
LYTAnimHermiteKey key;
in >> key.frame;
in >> key.value;
in >> key.slope;
qDebug() << "Key:" << key.frame << key.value << key.slope;
entry.keys.append(key);
}
}
piece.entries.append(entry);
in.device()->seek(saveInList3);
}
block.pieces.append(piece);
in.device()->seek(saveInList2);
}
blocks.append(block);
in.device()->seek(saveInList);
}
break;
}
case 'pah1':
// Share
qFatal("AnimShare unsupported");
break;
}
}
}
|