-
Notifications
You must be signed in to change notification settings - Fork 2
/
dialog.h
388 lines (326 loc) · 10 KB
/
dialog.h
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
#ifndef DIALOG_H
#define DIALOG_H
#include <QDialog>
#include <QtCore/QVariant>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QComboBox>
#include <QtWidgets/QDialog>
#include <QtWidgets/QGroupBox>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QLabel>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QRadioButton>
#include <QtWidgets/QSpinBox>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QWidget>
#include <QFileDialog>
#include <QMessageBox>
#include <QMatrix4x4>
#include <vector>
#include <map>
#include "renderer/mainwidget.h"
//remove me later
#include <QDebug>
/*
namespace Ui {
class Dialog;
}
*/
class Dialog : public QDialog
{
Q_OBJECT
public:
explicit Dialog(QWidget *parent = 0);
~Dialog();
QByteArray Readbyte(char* buffer, int &offset);
QByteArray Readlong(char* buffer, int &offset);
QByteArray ReadBElong(char* buffer, int &offset);
QByteArray Readshort(char* buffer, int &offset);
QByteArray ReadBEshort(char* buffer, int &offset);
QByteArray ReadBEpointer(char* buffer, int &offset, bool x64);
QByteArray Readpointer(char* buffer, int &offset, bool x64);
QByteArray ReadBEfloat (char* buffer, int &offset, bool x64);
QByteArray Readfloat(char* buffer, int &offset, bool x64);
void ReadMatrix44(char* buffer, int &offset,std::vector<QByteArray> &dest);
void ReadBEMatrix44(char* buffer, int &offset,std::vector<QByteArray> &dest);
QByteArray ReadMaterial(char* buffer, int &offset);
void WriteMaterial(FILE *f, QByteArray & bytes);
void WriteMatrix44(FILE *f,int offset, std::vector<QByteArray> &dest);
void WriteBEMatrix44(FILE *f,int offset, std::vector<QByteArray> &dest);
void Writebyte(FILE *f, QByteArray & bytes);
void Writelong(FILE *f, QByteArray & bytes);
void WriteBElong(FILE *f,QByteArray & bytes);
void Writeshort(FILE *f, QByteArray & bytes);
void WriteBEshort(FILE *f, QByteArray & bytes);
private slots:
void on_btnListen_clicked();
void on_addr_changed(QString fileName);
void on_btnClose_clicked();
private:
// Ui::Dialog *ui;
long int goffset ; // global write offset
std::map<QByteArray,long int> blocktype;
std::map<QByteArray,long int> unknownblocktypes;
std::map<QByteArray,long int> unknownbyte3;
std::map<QByteArray,QByteArray> byte3map;
int unktypesfound;
int unkbyte3found;
std::vector< std::vector<QByteArray> > faces;
QGroupBox *groupBox;
QWidget *layoutWidget;
QVBoxLayout *verticalLayout;
QVBoxLayout *outerLayout;
QVBoxLayout *insideboxLayout;
QRadioButton *rdoSingle;
QRadioButton *rdoPooled;
QRadioButton *rdoTheaded;
QLabel *label_2;
QLineEdit *spinBoxMax;
QLineEdit *spinBox;
QLabel *label;
QLabel *label_3;
QLabel *difflabel;
QLabel *speclabel;
QLabel *normlabel;
QLabel *litelabel;
QComboBox *cmbAddress;
QLineEdit *spinboxIdle;
QLabel *label_meshcount;
QLineEdit *meshcount;
QLabel *label_materialcount;
QLineEdit *materialcount;
QLabel *label_vertexcount;
QLineEdit *vertexcount;
QLabel *label_facecount;
QLineEdit *facecount;
QLabel *label_vertexids;
QLineEdit *vertexids;
QLabel *label_vertexbuffersize;
QLineEdit *vertexbuffersize;
QLabel *label_scondbuffersize;
QLineEdit *scondbuffersize;
QLabel *label_groupcount;
QLineEdit *groupcount;
QLabel *label_bonesoffset;
QLineEdit *bonesoffset;
QLabel *label_groupoffset;
QLineEdit *groupoffset;
QLabel *label_textureoffset;
QLineEdit *textureoffset;
QLabel *label_meshoffset;
QLineEdit *meshoffset;
QLabel *label_vertexoffset;
QLineEdit *vertexoffset;
QLabel *label_facesoffset;
QLineEdit *facesoffset;
QLabel *label_unkoffset;
QLineEdit *unkoffset;
QLabel *label_4;
QWidget *layoutWidget1;
QHBoxLayout *horizontalLayout_0;
QHBoxLayout *horizontalLayout_1;
QHBoxLayout *horizontalLayout_2;
QHBoxLayout *horizontalLayout_3;
QHBoxLayout *horizontalLayout_4;
QHBoxLayout *horizontalLayout_5;
QHBoxLayout *horizontalLayout_6;
QHBoxLayout *horizontalLayout_7;
QPushButton *btnListen;
QPushButton *btnClose;
//3d renderer for later
struct MODHeader
{
QByteArray id;
QByteArray version2; //byte
QByteArray version;
bool BEndian;
QByteArray bonecount; //short
QByteArray meshcount;
QByteArray materialcount;
QByteArray vertexcount;
QByteArray facecount;
QByteArray vertexids;
QByteArray vertexbuffersize;
QByteArray scondbuffersize;
QByteArray texturecount;
QByteArray groupcount; //x64 pointer
QByteArray bonemapcount; //x64 pointer
QByteArray bonesoffset; //x64 pointer
QByteArray groupoffset; //x64 pointer
QByteArray textureoffset; //x64 pointer
QByteArray meshoffset; //x64 pointer
QByteArray vertexoffset; //x64 pointer
QByteArray vertex2offset;
QByteArray facesoffset; //x64 pointer
QByteArray unkoffset; //x64 pointer
QByteArray unkoffset2;
// bbsphereposition vec3
QByteArray bbsphereradius;
// bbmin vec3 long
// bbmax vec3 long
} Mheader;
struct MOD_unk1_header
{
QByteArray un1;
QByteArray un2;
QByteArray un3;
QByteArray un4;
QByteArray un5;
QByteArray un6;
QByteArray un7;
QByteArray un8;
QByteArray un9;
QByteArray un10;
QByteArray un11;
QByteArray un12;
QByteArray un13;
QByteArray un14;
QByteArray un15;
QByteArray un16; // on pc dd;da it is "0000CDCD" on ps3 it's all 0's
QByteArray un17;
} Mhunk1;
struct MOD_Bone_info
{
QByteArray id;
QByteArray parentid;
QByteArray child;
QByteArray unk;
QByteArray lmatref;
QByteArray amatref;
QByteArray unk1;
QByteArray unk2;
QByteArray unk3;
QByteArray unk4;
QByteArray unk5;
};
struct MOD_bones
{
std::vector<MOD_Bone_info> boneinfo;
std::vector<QByteArray> lmatrices;
std::vector<QByteArray> amatrices;
int remaptablesize;
std::vector<QByteArray> remaptable;
QMatrix4x4 mtx; //unused till rendering
} Mbones;
struct MOD_Group_info
{
//header
QByteArray h0; //ddon pc has the only value
QByteArray h1; // dd;da pc has cdcdcdcd ps3 has 000000
QByteArray h2;
QByteArray h3;
//body?
QByteArray b0;
QByteArray b1;
QByteArray b2;
QByteArray b3;
};
struct MOD_Groups
{
std::vector<MOD_Group_info> groupinfo;
} Mgroups;
struct MOD_Materials
{
std::vector<QByteArray> name;
} Mmats;
struct MOD_Mesh_Data
{
std::vector<QByteArray> verticies;
std::vector<QByteArray> texturemap;
std::vector<QByteArray> normals;
std::vector<QByteArray> weights;
std::vector< std::vector<QByteArray> > faces; //array of triangle strips as qbytearray per int val
std::vector<QByteArray> bns;
std::vector<QByteArray> unkbyte1;
std::vector<QByteArray> unklong2;
std::vector<QByteArray> unksh1;
std::vector<QByteArray> unksh2;
std::vector<QByteArray> unksh3;
std::vector<QByteArray> unksh4;
std::vector<QByteArray> unklong1;
std::vector<QByteArray> unklong3;
std::vector<QByteArray> unklong4;
std::vector<QByteArray> unklong5;
};
struct MOD_Mesh_Part2
{
QByteArray unksh1;
QByteArray vertexcount;
QByteArray id;
QByteArray material;
QByteArray LOD;
QByteArray unkbyte20;
QByteArray unkbyte21;
QByteArray blocksize;
QByteArray unkbtye3;
QByteArray vertexsub;
QByteArray vertexoffset;
QByteArray blocktype;
QByteArray faceoffset;
QByteArray facecount;
QByteArray unklong4;
QByteArray unkbyte5;
QByteArray boneremapid;
QByteArray unksh6;
QByteArray unksh7;
QByteArray unksh8;
QByteArray unklong; /// pc E0,00,??,1D ps3.... gibberish?
std::vector<MOD_Mesh_Data> meshdata; // why is this a vector? it only ever does this once
};
struct MOD_unk2_chunk
{
QByteArray un1;
QByteArray un2; // on pc dd;da it is "CDCDCDCD" on ps3 it's all 0's
QByteArray un3; // on pc dd;da it is "CDCDCDCD" on ps3 it's all 0's
QByteArray un4; // on pc dd;da it is "CDCDCDCD" on ps3 it's all 0's
QByteArray un5;
QByteArray un6;
QByteArray un7; //body begin
QByteArray un8;
QByteArray un9;
QByteArray un10;
QByteArray un11;
QByteArray un12;
QByteArray un13;
QByteArray un14;
QByteArray un15;
QByteArray un16;
QByteArray un17;
QByteArray un18;
QByteArray un19;
QByteArray un20;
QByteArray un21;
QByteArray un22;
QByteArray un23;
QByteArray un24;
QByteArray un25;
QByteArray un26;
QByteArray un27;
QByteArray un28;
QByteArray un29;
QByteArray un30;
QByteArray un31;
QByteArray un32;
QByteArray un33;
QByteArray un34;
QByteArray un35;
QByteArray un36;
} ;
struct MOD_Mesh_Parts
{
// QByteArray mtxcount;
// std::vector<QByteArray> matrices;
std::vector<MOD_Mesh_Part2> parts;
std::vector<MOD_unk2_chunk> chunks;
} Mparts;
void open_file(QString fileName);
signals:
void newTextures(QString fileName);
void newMesh(MOD_Mesh_Parts &mesh, std::vector<QByteArray> &lmatrices, std::vector<QByteArray> &amatrices);
void newDAPCMesh(MOD_Mesh_Parts &mesh);
};
#endif // DIALOG_H