1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2020 Leszek Koltunski //
|
3
|
// //
|
4
|
// This file is part of Magic Cube. //
|
5
|
// //
|
6
|
// Magic Cube is free software: you can redistribute it and/or modify //
|
7
|
// it under the terms of the GNU General Public License as published by //
|
8
|
// the Free Software Foundation, either version 2 of the License, or //
|
9
|
// (at your option) any later version. //
|
10
|
// //
|
11
|
// Magic Cube is distributed in the hope that it will be useful, //
|
12
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
13
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
14
|
// GNU General Public License for more details. //
|
15
|
// //
|
16
|
// You should have received a copy of the GNU General Public License //
|
17
|
// along with Magic Cube. If not, see <http://www.gnu.org/licenses/>. //
|
18
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19
|
|
20
|
package org.distorted.objectlib.main;
|
21
|
|
22
|
import java.io.InputStream;
|
23
|
|
24
|
import org.distorted.library.type.Static3D;
|
25
|
import org.distorted.library.type.Static4D;
|
26
|
import org.distorted.objectlib.helpers.ObjectFaceShape;
|
27
|
import org.distorted.objectlib.helpers.ObjectShape;
|
28
|
import org.distorted.objectlib.helpers.ObjectSignature;
|
29
|
import org.distorted.objectlib.helpers.ObjectSticker;
|
30
|
import org.distorted.objectlib.scrambling.ScrambleState;
|
31
|
import org.distorted.objectlib.json.JsonReader;
|
32
|
|
33
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
34
|
|
35
|
public class TwistyJson extends TwistyObject
|
36
|
{
|
37
|
private JsonReader mReader;
|
38
|
|
39
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
40
|
|
41
|
public TwistyJson(InputStream jsonStream, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream meshStream)
|
42
|
{
|
43
|
super(jsonStream, meshState, iconMode, quat, move, scale, meshStream);
|
44
|
}
|
45
|
|
46
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
47
|
|
48
|
@Override
|
49
|
public int[][] getSolvedQuats()
|
50
|
{
|
51
|
return mReader.getSolvedQuats();
|
52
|
}
|
53
|
|
54
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
55
|
|
56
|
@Override
|
57
|
public Static4D[] getQuats()
|
58
|
{
|
59
|
return mReader.getQuats();
|
60
|
}
|
61
|
|
62
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
63
|
|
64
|
@Override
|
65
|
public int getSolvedFunctionIndex()
|
66
|
{
|
67
|
return mReader.getSolvedFunctionIndex();
|
68
|
}
|
69
|
|
70
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
71
|
|
72
|
@Override
|
73
|
public int getNumCubitFaces()
|
74
|
{
|
75
|
return mReader.getNumCubitFaces();
|
76
|
}
|
77
|
|
78
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
79
|
|
80
|
@Override
|
81
|
public int getVariantFaceColor(int variant, int face)
|
82
|
{
|
83
|
return mReader.getVariantFaceColor(variant,face);
|
84
|
}
|
85
|
|
86
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
87
|
|
88
|
@Override
|
89
|
public int getCubitFaceMap(int cubit, int face)
|
90
|
{
|
91
|
return mReader.getCubitFaceFace(cubit,face);
|
92
|
}
|
93
|
|
94
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
95
|
|
96
|
@Override
|
97
|
public int getNumStickerTypes()
|
98
|
{
|
99
|
return mReader.getNumStickerTypes();
|
100
|
}
|
101
|
|
102
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
103
|
|
104
|
@Override
|
105
|
public ObjectSticker retSticker(int sticker)
|
106
|
{
|
107
|
return mReader.retSticker(sticker);
|
108
|
}
|
109
|
|
110
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
111
|
|
112
|
@Override
|
113
|
public int getScrambleType()
|
114
|
{
|
115
|
return mReader.getScrambleType();
|
116
|
}
|
117
|
|
118
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
119
|
|
120
|
@Override
|
121
|
public boolean shouldResetTextureMaps()
|
122
|
{
|
123
|
return mReader.shouldResetTextureMaps();
|
124
|
}
|
125
|
|
126
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
127
|
|
128
|
@Override
|
129
|
public int getInternalColor()
|
130
|
{
|
131
|
return mReader.getInternalColor();
|
132
|
}
|
133
|
|
134
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
135
|
|
136
|
public void setReader(JsonReader reader)
|
137
|
{
|
138
|
mReader = reader;
|
139
|
}
|
140
|
|
141
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
142
|
|
143
|
public ScrambleState[] getScrambleStates()
|
144
|
{
|
145
|
return mReader.getScrambleStates();
|
146
|
}
|
147
|
|
148
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
149
|
|
150
|
public float[][] getCuts(int[] numLayers)
|
151
|
{
|
152
|
return mReader.getCuts();
|
153
|
}
|
154
|
|
155
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
156
|
|
157
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
158
|
{
|
159
|
return mReader.getLayerRotatable();
|
160
|
}
|
161
|
|
162
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
163
|
|
164
|
public int getTouchControlType()
|
165
|
{
|
166
|
return mReader.getMovementType();
|
167
|
}
|
168
|
|
169
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
170
|
|
171
|
public int getTouchControlSplit()
|
172
|
{
|
173
|
return mReader.getMovementSplit();
|
174
|
}
|
175
|
|
176
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
177
|
|
178
|
public int[][][] getEnabled()
|
179
|
{
|
180
|
return mReader.getEnabled();
|
181
|
}
|
182
|
|
183
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
184
|
|
185
|
public float[] getDist3D(int[] numLayers)
|
186
|
{
|
187
|
return mReader.getDist3D();
|
188
|
}
|
189
|
|
190
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
191
|
// this is only needed when computing sticker colors which here we do via the retSticker() method.
|
192
|
|
193
|
public Static3D[] getFaceAxis()
|
194
|
{
|
195
|
return null;
|
196
|
}
|
197
|
|
198
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
199
|
|
200
|
public float[][] getCubitPositions(int[] numLayers)
|
201
|
{
|
202
|
return mReader.getCubitPositions();
|
203
|
}
|
204
|
|
205
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
206
|
|
207
|
public ObjectShape getObjectShape(int variant)
|
208
|
{
|
209
|
return mReader.getObjectShape(variant);
|
210
|
}
|
211
|
|
212
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
213
|
|
214
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
215
|
{
|
216
|
return mReader.getObjectFaceShape(variant);
|
217
|
}
|
218
|
|
219
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
220
|
|
221
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
222
|
{
|
223
|
return mReader.getCubitQuats(cubit);
|
224
|
}
|
225
|
|
226
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
227
|
|
228
|
public int getNumCubitVariants(int[] numLayers)
|
229
|
{
|
230
|
return mReader.getNumCubitVariants();
|
231
|
}
|
232
|
|
233
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
234
|
|
235
|
public int getCubitVariant(int cubit, int[] numLayers)
|
236
|
{
|
237
|
return mReader.getCubitVariant(cubit);
|
238
|
}
|
239
|
|
240
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
241
|
// fake, this will never be called
|
242
|
|
243
|
public float getStickerStroke()
|
244
|
{
|
245
|
return 0.0f;
|
246
|
}
|
247
|
|
248
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
249
|
// fake, this will never be called
|
250
|
|
251
|
public float getStickerRadius()
|
252
|
{
|
253
|
return 0.0f;
|
254
|
}
|
255
|
|
256
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
257
|
// fake, this will never be called
|
258
|
|
259
|
public float[][] getStickerAngles()
|
260
|
{
|
261
|
return null;
|
262
|
}
|
263
|
|
264
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
265
|
// PUBLIC API
|
266
|
|
267
|
public Static3D[] getRotationAxis()
|
268
|
{
|
269
|
return mReader.getRotationAxis();
|
270
|
}
|
271
|
|
272
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
273
|
|
274
|
public int[][] getBasicAngles()
|
275
|
{
|
276
|
return mReader.getBasicAngle();
|
277
|
}
|
278
|
|
279
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
280
|
|
281
|
public int getNumScramble()
|
282
|
{
|
283
|
return mReader.getNumScrambles();
|
284
|
}
|
285
|
|
286
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
287
|
|
288
|
public ObjectSignature getSignature()
|
289
|
{
|
290
|
return mReader.getSignature();
|
291
|
}
|
292
|
|
293
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
294
|
|
295
|
public String getObjectName()
|
296
|
{
|
297
|
return mReader.getObjectName();
|
298
|
}
|
299
|
|
300
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
301
|
|
302
|
public String getInventor()
|
303
|
{
|
304
|
return mReader.getInventor();
|
305
|
}
|
306
|
|
307
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
308
|
|
309
|
public int getYearOfInvention()
|
310
|
{
|
311
|
return mReader.getYearOfInvention();
|
312
|
}
|
313
|
|
314
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
315
|
|
316
|
public int getComplexity()
|
317
|
{
|
318
|
return mReader.getComplexity();
|
319
|
}
|
320
|
|
321
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
322
|
|
323
|
public int getNumFaces()
|
324
|
{
|
325
|
return mReader.getNumFaces();
|
326
|
}
|
327
|
|
328
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
329
|
|
330
|
public int getNumFaceColors()
|
331
|
{
|
332
|
return mReader.getNumFaceColors();
|
333
|
}
|
334
|
|
335
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
336
|
|
337
|
public int getColor(int face)
|
338
|
{
|
339
|
return mReader.getColor(face);
|
340
|
}
|
341
|
|
342
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
343
|
|
344
|
public String getShortName()
|
345
|
{
|
346
|
return mReader.getShortName();
|
347
|
}
|
348
|
|
349
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
350
|
|
351
|
public String[][] getTutorials()
|
352
|
{
|
353
|
return mReader.getTutorials();
|
354
|
}
|
355
|
|
356
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
357
|
|
358
|
public int getFOV()
|
359
|
{
|
360
|
switch( mReader.getNumFaces() )
|
361
|
{
|
362
|
case 4: return ShapeTetrahedron.FOV;
|
363
|
case 6: return ShapeHexahedron.FOV;
|
364
|
case 8: return ShapeOctahedron.FOV;
|
365
|
case 12: return ShapeDodecahedron.FOV;
|
366
|
}
|
367
|
|
368
|
return 0;
|
369
|
}
|
370
|
|
371
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
372
|
|
373
|
public float getScreenRatio()
|
374
|
{
|
375
|
switch( mReader.getNumFaces() )
|
376
|
{
|
377
|
case 4: return ShapeTetrahedron.RATIO;
|
378
|
case 6: return ShapeHexahedron.RATIO;
|
379
|
case 8: return ShapeOctahedron.RATIO;
|
380
|
case 12: return ShapeDodecahedron.RATIO;
|
381
|
}
|
382
|
|
383
|
return 0.0f;
|
384
|
}
|
385
|
}
|