/
Object.h
487 lines (354 loc) · 6.67 KB
/
Object.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
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
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
#ifndef _INCLUDED_CAR_H
#define _INCLUDED_CAR_H
#include "math.h"
#include <string>
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#include "Observer.h"
class CCarTree;
class JAM;
typedef struct
{
float r;
float g;
float b;
} t_Color;
static t_Color RandomColors[] = {
{1.0f,0.0f,0.0f},
{0.0f,1.0f,0.0f},
{0.0f,0.0f,1.0f},
{1.0f,1.0f,0.0f},
{1.0f,0.0f,1.0f},
{0.0f,1.0f,1.0f},
{0.5f,0.0f,0.0f},
{0.0f,0.5f,0.0f},
{0.0f,0.0f,0.5f},
{0.5f,0.5f,0.0f},
{0.5f,0.0f,0.5f},
{0.0f,0.5f,0.5f},
};
static int numRandomColors = sizeof(RandomColors)/sizeof(RandomColors[0]);
typedef struct
{
short Magic;
short id;
int scaleBegin;
int scaleEnd;
int textureBegin;
int pointsBegin;
int vertexBegin;
int textureEnd;
int vertexEnd;
int fileEnd;
int fileEnd2;
int always0;
int always1;
short unk;
short size;
short size8;
} t_objheader;
typedef struct
{
short X;
short Z;
short Y;
short ODirection;
short OPitch;
short ORoll;
short Detail1;
short Detail2;
} t_IntCamera;
class DatVal: public Observer
{
public:
DatVal():
Observer(t_DataVal)
{
data = 0;
}
int getVal()
{
return data;
}
void Open(CCarTree *tree);
void updateLabel(CCarTree *tree);
int data;
HTREEITEM node;
int idx;
};
class t_Arg : public Observer
{
public:
t_Arg():
Observer(t_TextureCmd)
{
val = 0;
desc = NULL;
}
void Open(CCarTree *tree);
void updateLabel(CCarTree *tree);
int val;
char *desc;
HTREEITEM node;
};
class TextureCmd : public Observer
{
public:
TextureCmd():
Observer(t_TextureCmd)
{
cmd.data=-1;
numArgs = 0;
numPts = 0;
textureid = NULL;
vres = NULL;
hres = NULL;
loadedTextureId = -1;
}
int numl;
int numh;
DatVal cmd;
t_Arg Args[20];
int numArgs;
CBitmap jamBitmap;
unsigned char * jamBits;
int loadedTextureId;
void parse();
void Select(CCarTree *tree);
void Draw(t_Color color);
void patch();
HTREEITEM LoadTree(CCarTree *tree,HTREEITEM node);
short PtsList[20];
int numPts;
HTREEITEM node;
int idx;
int offset;
int endoffset;
int *textureid;
int *vres;
int *hres;
double cx;
double cy;
double cz;
} ;
class Point3D : public Observer
{
public:
Point3D():x(0),y(0),z(0),Observer(t_Point)
{
desc.clear();
}
Point3D(int x,int y,int z):
x(x),y(y),z(z),Observer(t_Point)
{
desc.clear();
}
~Point3D()
{
}
void Open(CCarTree *tree);
void Select(CCarTree *tree);
int x;
int y;
int z;
//int oz;
int ox;
int oy;
void updateLabel(CCarTree *tree);
void patch();
double distance(Point3D *a)
{
return sqrt((double)(((a->x-x)*(a->x-x))+((a->y-y)*(a->y-y))+((a->z-z)*(a->z-z))));
}
HTREEITEM node;
int idx;
int offset;
std::string desc;
void setDesc(char *msg)
{
desc = msg;
}
std::string getDesc()
{
return desc;
}
};
class Vertex : public Observer
{
public:
Vertex():
from(0),to(0),Observer(t_Vertex)
{}
Vertex(int f,int t):
from(f),to(t),Observer(t_Vertex)
{
}
void Open(CCarTree *tree);
void Select(CCarTree *tree);
void updateLabel(CCarTree *tree);
void patch();
double Length();
double LengthCM();
int from;
int to;
HTREEITEM node;
int idx;
int offset;
double cx;
double cy;
double cz;
} ;
class Scale : public Observer
{
public:
Scale():val(0),offset(0),Observer(t_Scale)
{
//ptsDep = 0;
}
Scale(int v,int offset):
val(v),offset(offset),Observer(t_Scale)
{
//ptsDep = 0;
}
void Open(CCarTree *tree);
void patch();
int val;
int offset;
//int depend[255];
//int ptsDep;
HTREEITEM node;
int idx;
void updateLabel(CCarTree *tree);
} ;
class UnknownData : public Observer
{
public:
UnknownData():val(0),offset(0),Observer(t_Scale)
{
//ptsDep = 0;
}
UnknownData(int v,int offset):
val(v),offset(offset),Observer(t_Scale)
{
//ptsDep = 0;
}
void Open(CCarTree *tree);
void patch();
int val;
int offset;
//int depend[255];
//int ptsDep;
HTREEITEM node;
int idx;
void updateLabel(CCarTree *tree);
} ;
#define OFFSET_NOSE 31
#define OFFSET_PTS 194
#define DEF_CAR_LENGTH 54536
#define DEF_CAR_START 0x14C4A8
#define DEF_HELMET_START 0x1599B0
#define DEF_HELMET_LENGTH 4294
class Object3D: public CObject
{
public:
Object3D()
{
pDoc = NULL;
selectedPoint = NULL;
selectedVertex = NULL;
selectedTextureCmd = NULL;
scaleData = NULL;
vertexData = NULL;
pointData = NULL;
unkData = NULL;
}
virtual ~Object3D()
{
if (scaleData) delete[] scaleData;
if (pointData) delete[] pointData;
if (vertexData) delete[] vertexData;
if (textureData) delete[] textureData;
}
void clearSelections()
{
selectedPoint = NULL;
selectedVertex = NULL;
selectedTextureCmd = NULL;
}
int GetPCWord(int offset);
int GetPCByte(int offset);
long GetPCDWord(int offset);
Scale *scaleData;
DatVal *unkscaleData;
Vertex *vertexData;
Point3D *pointData;
TextureCmd *textureData;
DatVal *unkData;
void UpdatePoints();
void AddScaleValue();
void AddVertexValue();
void AddPointValue();
void AddTextureCmd(int vsize);
void AddNewJamFile();
int numVerticies;
int numScale;
int numPoints;
int textureSize;
int numUnks;
Point3D *selectedPoint;
Vertex *selectedVertex;
TextureCmd *selectedTextureCmd;
BOOL valid;
BOOL isValid()
{
return valid;
}
virtual void PatchData(){}
virtual void updateData(BOOL updateTexture,BOOL reread){}
CDocument *pDoc;
unsigned char data[65535];
t_objheader *header;
HTREEITEM carNode;
void addUniqueJamFile(char *file)
{
BOOL found=FALSE;
for(int i=0;i<numberOfJamNames;i++)
{
if (std::string(file) != jamFileNames[i])
{
found = TRUE;
break;
}
}
if (!found)
{
jamFileNames[numberOfJamNames] = file;
numberOfJamNames++;
}
}
std::string jamFileNames[200];
int numberOfJamNames;
};
class GPOObject: public Object3D
{
public:
int memoryOffset;
GPOObject()
{
numberOfJamNames = 0;
}
virtual ~GPOObject()
{
}
void parse(int begin);
//void write(CString filename);
void write(FILE *fp);
void LoadTree(CCarTree *tree);
void PatchData();
void updateData(BOOL updateTexture,BOOL reread);
void ParseAdditionalCommands(char *line);
void LoadJamTexture(CBitmap &output,int idx,int hres,int vres);
JAM *GetJAM(int id);
};
#endif