forked from paulhoad/gp2trackeditor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInternalObject.h
More file actions
executable file
·335 lines (274 loc) · 6.35 KB
/
Copy pathInternalObject.h
File metadata and controls
executable file
·335 lines (274 loc) · 6.35 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
#ifndef _INCLUDED_INTERNAL_OBJECT_H
#define _INCLUDED_INTERNAL_OBJECT_H
#define GP_OBJECT_BYTE 1
#define GP_OBJECT_WORD 2
#define GP_OBJECT_DWORD 4
#include "Observer.h"
#include "Vector.h"
#include "GPTrack.h"
#include "Vertex.h"
#include <fstream>
class ObjectData : public CObject
, public DataValue
, public Observer
{
public:
ObjectData(int type = GP_OBJECT_DWORD, int val = 0)
: DataValue(val), Observer(NULL, t_ObjectData, NULL), objtype(type)
{}
// virtual int getValue(){return 0;}
// virtual void setValue(int val){}
int getType()
{
return objtype;
}
int getSize()
{
return objtype;
}
void
exportHex(FILE *fp, LPCSTR msg);
void exportFile(FILE *fp, LPCSTR msg);
void
Open(CTrackTree *tree);
int objtype;
};
class ObjectWord : public ObjectData
{
public:
ObjectWord(int val) : ObjectData(GP_OBJECT_WORD, val)
// value(val)
{}
/*
int getValue()
{
return value;
}
void setValue(int val)
{
value = val;
}
int value;
*/
};
class ObjectDWord : public ObjectData
{
public:
ObjectDWord(int val) : ObjectData(GP_OBJECT_DWORD, val)
// value(val)
{}
/*
int getValue()
{
return value;
}
void setValue(int val)
{
value = val;
}
int value;
*/
};
class InternalObject : public Observer
, public CObject
{
private:
LPSTR objectName;
public:
int Verticies;
int XYZData;
int VertexData;
Vector *objectData;
Vector *treeItemData;
Vector *subObjects;
int DataSize;
CDocument *pDoc;
HTREEITEM SubTree;
CString *objectLowerName;
InternalObject(GPTrack *mytrack, CDocument *Doc, int offset, int endoffset)
: Offset(offset),
pDoc(Doc),
Observer(mytrack, t_InternalObject, NULL),
treeItemData(NULL)
{
objectData = new Vector("Internal Objects", __LINE__);
DataSize = endoffset - offset;
MagicNumber = -1;
SubTree = NULL;
polygonPoints = NULL;
objectName = NULL;
objectLowerName = NULL;
created = FALSE;
VerticiesArray = NULL;
ptArray = NULL;
subObjects = NULL;
}
char *
getIntObjectName()
{
return objectName;
}
void
setObjectName(char *str)
{
objectName = str;
}
void
Expand(CTrackTree *tracktree, HTREEITEM node);
void
LoadTree(CTrackTree *tree, HTREEITEM node);
void
LoadTreeTop(CTrackTree *tree, HTREEITEM node);
void
LoadJamTexture(GPTrack *mytrack, CBitmap &output, int idx, int hres, int vres);
void
TextureMap(CDC *pDC, CBitmap &cbmp);
void
Parse();
Vector *polygonPoints;
int getXYZOffset();
int getVertexOffset();
int getNumVertexConnections();
int getScaleOffset();
int getScaleEndOffset();
int getTextureOffset();
int getTextureEndOffset();
int getDefaultRotation();
int getEndVertexOffset();
int getEndOffset();
int getListOffset(int pos);
CDocument *
GetDocument()
{
return pDoc;
}
virtual ~InternalObject();
int getOffset()
{
return Offset;
}
void
setOffset(int off)
{
Offset = off;
}
int getSize()
{
return DataSize;
}
int getNumPoints()
{
return Verticies;
}
void
Delete();
void
ReadObject(GPTrack *track);
void
WriteObject(int offset);
BOOL
ImportFromFile(LPCSTR filename);
void
exportFile();
int write(GPTrack *track, int offset)
{
// using original offset until we need more objects
offset = Offset;
// TRACE("%x %d\n",offset,objectData->size());
// int listsize = objectData->size();
ObjectData *last = (ObjectData *)objectData->lastElement();
ObjectData *first = (ObjectData *)objectData->elementAt(0);
ObjectData *dat;
int size = objectData->size();
int count = 0;
for (dat = first; count < size;
dat = (ObjectData *)objectData->next(dat), count++) {
switch (dat->getType()) {
case GP_OBJECT_WORD:
track->WritePCWord(offset, dat->GetValue());
offset += 2;
break;
case GP_OBJECT_DWORD:
track->WritePCDWord(offset, dat->GetValue());
offset += 4;
break;
case GP_OBJECT_BYTE:
track->WritePCByte(offset, dat->GetValue());
offset += 1;
break;
}
}
/*
for(int i=0;i<listsize;i++)
{
ObjectData *dat = (ObjectData*)objectData->elementAt(i);
switch(dat->getType())
{
case GP_OBJECT_WORD:
track->WritePCWord(offset,dat->GetValue());offset+=2;
break;
case GP_OBJECT_DWORD:
track->WritePCDWord(offset,dat->GetValue());offset+=4;
break;
case GP_OBJECT_BYTE:
track->WritePCByte(offset,dat->GetValue());offset+=1;
break;
}
}
*/
return offset;
}
int Open();
int Offset;
int itemId;
int PossibleId;
int MagicNumber;
void
ExportObject(CString filename);
BOOL
ImportObject(CString filename);
void
ReplaceObject(CString filename);
void
AdjustPointers();
LPCSTR
getName();
CString *
getLowerName();
int CalculateDigitalSignature();
void
AddSumValue(int da)
{
// where unsigned shorts
int d1, d2, d3;
d2 = secondCheckSum;
// was short int
d1 = (int)da;
firstCheckSum += d1;
d1 = d1 & 0x000000FF;
d3 = d2 & 0x0000E000;
d3 = d3 >> 13;
d2 = d2 << 3;
d2 = d2 | d3;
d2 = d2 + d1;
secondCheckSum = d2;
}
short firstCheckSum;
short secondCheckSum;
void
DrawVML(std::ofstream &file, double x, double y, double z, double angle, BOOL drawAxis);
void
DrawGL(CDC *pDC, double x, double y, double z, double angle, BOOL drawAxis);
void
Draw2D(Display *g, double x, double y, double z, double angle, BOOL drawAxis);
static void
Draw2DExternal(Display *g, double x, double y, double z, double angle, BOOL drawAxis);
void
CreateObject();
BOOL created;
t_SingleVertex *VerticiesArray;
Point3D **ptArray;
void
UpdateStructure();
};
#endif