1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2020 Leszek Koltunski //
|
3
|
// //
|
4
|
// This file is part of Magic Cube. //
|
5
|
// //
|
6
|
// Magic Cube is proprietary software licensed under an EULA which you should have received //
|
7
|
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html //
|
8
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
9
|
|
10
|
package org.distorted.objectlib.main;
|
11
|
|
12
|
import org.distorted.library.type.Static3D;
|
13
|
import org.distorted.library.type.Static4D;
|
14
|
import org.distorted.objectlib.helpers.ObjectFaceShape;
|
15
|
import org.distorted.objectlib.helpers.ObjectShape;
|
16
|
import org.distorted.objectlib.signature.ObjectSignature;
|
17
|
import org.distorted.objectlib.helpers.ObjectSticker;
|
18
|
import org.distorted.objectlib.helpers.ObjectStickerOverride;
|
19
|
import org.distorted.objectlib.helpers.ObjectVertexEffects;
|
20
|
import org.distorted.objectlib.json.JsonReader;
|
21
|
import org.distorted.objectlib.shape.ShapeDiamond;
|
22
|
import org.distorted.objectlib.shape.ShapeDodecahedron;
|
23
|
import org.distorted.objectlib.shape.ShapeHexahedron;
|
24
|
import org.distorted.objectlib.shape.ShapeIcosahedron;
|
25
|
import org.distorted.objectlib.shape.ShapeOctahedron;
|
26
|
import org.distorted.objectlib.shape.ShapeTetrahedron;
|
27
|
import org.distorted.objectlib.touchcontrol.TouchControlBall;
|
28
|
import org.distorted.objectlib.touchcontrol.TouchControlDodecahedron;
|
29
|
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
|
30
|
import org.distorted.objectlib.touchcontrol.TouchControlIcosahedron;
|
31
|
import org.distorted.objectlib.touchcontrol.TouchControlOctahedron;
|
32
|
import org.distorted.objectlib.touchcontrol.TouchControlTetrahedron;
|
33
|
|
34
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
35
|
|
36
|
public class TwistyJson extends TwistyObject
|
37
|
{
|
38
|
private JsonReader mReader;
|
39
|
|
40
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
41
|
|
42
|
public TwistyJson(int iconMode, Static4D quat, Static3D move, float scale, InitAssets assets)
|
43
|
{
|
44
|
super(iconMode, quat, move, scale, assets);
|
45
|
}
|
46
|
|
47
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
48
|
|
49
|
@Override
|
50
|
public int[][] getMinimalCubiesInRow()
|
51
|
{
|
52
|
return mReader.getMinimalCubiesInRow();
|
53
|
}
|
54
|
|
55
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
56
|
|
57
|
@Override
|
58
|
public int getCubitRotationType(int cubitIndex)
|
59
|
{
|
60
|
return mReader.getCubitTypes()[cubitIndex];
|
61
|
}
|
62
|
|
63
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
64
|
|
65
|
@Override
|
66
|
public float[] getCubitRowOffset(int cubitIndex)
|
67
|
{
|
68
|
return mReader.getCubitOffsets()[cubitIndex];
|
69
|
}
|
70
|
|
71
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
72
|
|
73
|
@Override
|
74
|
public int[][] getVariantFaceIsOuter()
|
75
|
{
|
76
|
return mReader.getVariantFaceIsOuter();
|
77
|
}
|
78
|
|
79
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
80
|
|
81
|
@Override
|
82
|
public int[][] getSolvedQuats()
|
83
|
{
|
84
|
return mReader.getSolvedQuats();
|
85
|
}
|
86
|
|
87
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
88
|
|
89
|
@Override
|
90
|
public Static4D[] getQuats()
|
91
|
{
|
92
|
return mReader.getQuats();
|
93
|
}
|
94
|
|
95
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
96
|
|
97
|
@Override
|
98
|
public int getSolvedFunctionIndex()
|
99
|
{
|
100
|
return mReader.getSolvedFunctionIndex();
|
101
|
}
|
102
|
|
103
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
104
|
|
105
|
@Override
|
106
|
public int getNumCubitFaces()
|
107
|
{
|
108
|
return mReader.getNumCubitFaces();
|
109
|
}
|
110
|
|
111
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
112
|
|
113
|
@Override
|
114
|
public int getVariantStickerShape(int variant, int face)
|
115
|
{
|
116
|
return mReader.getVariantStickerShape(variant,face);
|
117
|
}
|
118
|
|
119
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
120
|
|
121
|
@Override
|
122
|
public int getCubitFaceMap(int cubit, int face)
|
123
|
{
|
124
|
return mReader.getCubitFaceFace(cubit,face);
|
125
|
}
|
126
|
|
127
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
128
|
|
129
|
@Override
|
130
|
public float getPillowCoeff()
|
131
|
{
|
132
|
return mReader.getPillowCoeff();
|
133
|
}
|
134
|
|
135
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
136
|
|
137
|
@Override
|
138
|
public int getNumStickerTypes()
|
139
|
{
|
140
|
return mReader.getNumStickerTypes();
|
141
|
}
|
142
|
|
143
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
144
|
|
145
|
@Override
|
146
|
public ObjectSticker retSticker(int sticker)
|
147
|
{
|
148
|
return mReader.retSticker(sticker);
|
149
|
}
|
150
|
|
151
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
152
|
|
153
|
@Override
|
154
|
public ObjectStickerOverride[] getStickerOverrides()
|
155
|
{
|
156
|
return mReader.getStickerOverrides();
|
157
|
}
|
158
|
|
159
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
160
|
|
161
|
@Override
|
162
|
public int getScrambleType()
|
163
|
{
|
164
|
return mReader.getScrambleType();
|
165
|
}
|
166
|
|
167
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
168
|
|
169
|
@Override
|
170
|
public int[][] getScrambleAlgorithms()
|
171
|
{
|
172
|
return mReader.getScrambleAlgorithms();
|
173
|
}
|
174
|
|
175
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
176
|
|
177
|
@Override
|
178
|
public boolean shouldResetTextureMaps()
|
179
|
{
|
180
|
return mReader.shouldResetTextureMaps();
|
181
|
}
|
182
|
|
183
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
184
|
|
185
|
@Override
|
186
|
public int getInternalColor()
|
187
|
{
|
188
|
return mReader.getInternalColor();
|
189
|
}
|
190
|
|
191
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
192
|
|
193
|
@Override
|
194
|
public float[][] returnRotationFactor()
|
195
|
{
|
196
|
return mReader.returnRotationFactor();
|
197
|
}
|
198
|
|
199
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
200
|
|
201
|
public void setReader(JsonReader reader)
|
202
|
{
|
203
|
mReader = reader;
|
204
|
}
|
205
|
|
206
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
207
|
|
208
|
public int[][] getScrambleEdges()
|
209
|
{
|
210
|
return mReader.getScrambleEdges();
|
211
|
}
|
212
|
|
213
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
214
|
|
215
|
public float[][] getCuts(int[] numLayers)
|
216
|
{
|
217
|
return mReader.getCuts();
|
218
|
}
|
219
|
|
220
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
221
|
|
222
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
223
|
{
|
224
|
return mReader.getLayerRotatable();
|
225
|
}
|
226
|
|
227
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
228
|
|
229
|
public int getTouchControlType()
|
230
|
{
|
231
|
return mReader.getMovementType();
|
232
|
}
|
233
|
|
234
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
235
|
|
236
|
public int getTouchControlSplit()
|
237
|
{
|
238
|
return mReader.getMovementSplit();
|
239
|
}
|
240
|
|
241
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
242
|
|
243
|
public int[][][] getEnabled()
|
244
|
{
|
245
|
return mReader.getEnabled();
|
246
|
}
|
247
|
|
248
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
249
|
|
250
|
public float[] getDist3D(int[] numLayers)
|
251
|
{
|
252
|
return mReader.getDist3D();
|
253
|
}
|
254
|
|
255
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
256
|
|
257
|
public Static3D[] getFaceAxis()
|
258
|
{
|
259
|
int numFaces = mReader.getNumFaces();
|
260
|
|
261
|
switch(numFaces)
|
262
|
{
|
263
|
case 4: return TouchControlTetrahedron.FACE_AXIS;
|
264
|
case 6: return TouchControlHexahedron.FACE_AXIS;
|
265
|
case 8: return TouchControlOctahedron.FACE_AXIS;
|
266
|
case 12: return TouchControlDodecahedron.FACE_AXIS;
|
267
|
case 16: return TouchControlBall.FACE_AXIS;
|
268
|
case 20: return TouchControlIcosahedron.FACE_AXIS;
|
269
|
}
|
270
|
|
271
|
android.util.Log.e("D", "Unsupported number of faces in JSON file: "+numFaces);
|
272
|
return null;
|
273
|
}
|
274
|
|
275
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
276
|
|
277
|
public float[][] getCubitPositions(int[] numLayers)
|
278
|
{
|
279
|
return mReader.getCubitPositions();
|
280
|
}
|
281
|
|
282
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
283
|
|
284
|
public ObjectShape getObjectShape(int variant)
|
285
|
{
|
286
|
return mReader.getObjectShape(variant);
|
287
|
}
|
288
|
|
289
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
290
|
|
291
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
292
|
{
|
293
|
return mReader.getObjectFaceShape(variant);
|
294
|
}
|
295
|
|
296
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
297
|
|
298
|
public ObjectVertexEffects getVertexEffects(int variant)
|
299
|
{
|
300
|
return mReader.getVertexEffects(variant);
|
301
|
}
|
302
|
|
303
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
304
|
|
305
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
306
|
{
|
307
|
return mReader.getCubitQuats(cubit);
|
308
|
}
|
309
|
|
310
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
311
|
|
312
|
public int getNumCubitVariants(int[] numLayers)
|
313
|
{
|
314
|
return mReader.getNumCubitVariants();
|
315
|
}
|
316
|
|
317
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
318
|
|
319
|
public int getCubitVariant(int cubit, int[] numLayers)
|
320
|
{
|
321
|
return mReader.getCubitVariant(cubit);
|
322
|
}
|
323
|
|
324
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
325
|
// fake, this will never be called
|
326
|
|
327
|
public float getStickerStroke()
|
328
|
{
|
329
|
return 0.0f;
|
330
|
}
|
331
|
|
332
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
333
|
// fake, this will never be called
|
334
|
|
335
|
public float getStickerRadius()
|
336
|
{
|
337
|
return 0.0f;
|
338
|
}
|
339
|
|
340
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
341
|
// fake, this will never be called
|
342
|
|
343
|
public float[][][] getStickerAngles()
|
344
|
{
|
345
|
return null;
|
346
|
}
|
347
|
|
348
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
349
|
// PUBLIC API
|
350
|
|
351
|
public Static3D[] getRotationAxis()
|
352
|
{
|
353
|
return mReader.getRotationAxis();
|
354
|
}
|
355
|
|
356
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
357
|
|
358
|
public int[][] getBasicAngles()
|
359
|
{
|
360
|
return mReader.getBasicAngle();
|
361
|
}
|
362
|
|
363
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
364
|
|
365
|
public int getNumScramble()
|
366
|
{
|
367
|
return mReader.getNumScrambles();
|
368
|
}
|
369
|
|
370
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
371
|
|
372
|
public ObjectSignature getSignature()
|
373
|
{
|
374
|
return mReader.getSignature();
|
375
|
}
|
376
|
|
377
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
378
|
|
379
|
public String getObjectName()
|
380
|
{
|
381
|
return mReader.getObjectName();
|
382
|
}
|
383
|
|
384
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
385
|
|
386
|
public String getInventor()
|
387
|
{
|
388
|
return mReader.getAuthor();
|
389
|
}
|
390
|
|
391
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
392
|
|
393
|
public int getYearOfInvention()
|
394
|
{
|
395
|
return mReader.getYearOfInvention();
|
396
|
}
|
397
|
|
398
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
399
|
|
400
|
public float getComplexity()
|
401
|
{
|
402
|
return mReader.getDifficulty();
|
403
|
}
|
404
|
|
405
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
406
|
|
407
|
public int getNumPuzzleFaces()
|
408
|
{
|
409
|
return mReader.getNumFaces();
|
410
|
}
|
411
|
|
412
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
413
|
|
414
|
public int[] getColorTable()
|
415
|
{
|
416
|
return mReader.getColorTable();
|
417
|
}
|
418
|
|
419
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
420
|
|
421
|
public String getShortName()
|
422
|
{
|
423
|
return mReader.getShortName();
|
424
|
}
|
425
|
|
426
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
427
|
|
428
|
public String[][] getTutorials()
|
429
|
{
|
430
|
return mReader.getTutorials();
|
431
|
}
|
432
|
|
433
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
434
|
|
435
|
public int getFOV()
|
436
|
{
|
437
|
switch( mReader.getNumFaces() )
|
438
|
{
|
439
|
case 4: return ShapeTetrahedron.FOV;
|
440
|
case 6: return ShapeHexahedron.FOV;
|
441
|
case 8: return ShapeOctahedron.FOV;
|
442
|
case 12: return ShapeDodecahedron.FOV;
|
443
|
case 16: return ShapeDiamond.FOV;
|
444
|
case 20: return ShapeIcosahedron.FOV;
|
445
|
}
|
446
|
|
447
|
return 0;
|
448
|
}
|
449
|
|
450
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
451
|
|
452
|
public float getScreenRatio()
|
453
|
{
|
454
|
switch( mReader.getNumFaces() )
|
455
|
{
|
456
|
case 4: return ShapeTetrahedron.RATIO;
|
457
|
case 6: return ShapeHexahedron.RATIO;
|
458
|
case 8: return ShapeOctahedron.RATIO;
|
459
|
case 12: return ShapeDodecahedron.RATIO;
|
460
|
case 16: return ShapeDiamond.RATIO;
|
461
|
case 20: return ShapeIcosahedron.RATIO;
|
462
|
}
|
463
|
|
464
|
return 0.0f;
|
465
|
}
|
466
|
}
|