1 |
82eb152a
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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 |
3ee1d662
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.ObjectFaceShape;
|
27 |
82eb152a
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.ObjectShape;
|
28 |
1d581993
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.ObjectSignature;
|
29 |
82eb152a
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.ObjectSticker;
|
30 |
10b7e306
|
Leszek Koltunski
|
import org.distorted.objectlib.scrambling.ScrambleState;
|
31 |
82eb152a
|
Leszek Koltunski
|
import org.distorted.objectlib.json.JsonReader;
|
32 |
|
|
|
33 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
34 |
|
|
|
35 |
|
|
public class TwistyJson extends TwistyObject
|
36 |
|
|
{
|
37 |
|
|
private JsonReader mReader;
|
38 |
|
|
|
39 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
40 |
|
|
|
41 |
3bf19410
|
Leszek Koltunski
|
public TwistyJson(InputStream jsonStream, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream meshStream)
|
42 |
82eb152a
|
Leszek Koltunski
|
{
|
43 |
3bf19410
|
Leszek Koltunski
|
super(jsonStream, meshState, iconMode, quat, move, scale, meshStream);
|
44 |
82eb152a
|
Leszek Koltunski
|
}
|
45 |
|
|
|
46 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
47 |
|
|
|
48 |
ed0988c0
|
Leszek Koltunski
|
@Override
|
49 |
|
|
public int[][] getSolvedQuats()
|
50 |
82eb152a
|
Leszek Koltunski
|
{
|
51 |
ed0988c0
|
Leszek Koltunski
|
return mReader.getSolvedQuats();
|
52 |
82eb152a
|
Leszek Koltunski
|
}
|
53 |
|
|
|
54 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
55 |
|
|
|
56 |
ed0988c0
|
Leszek Koltunski
|
@Override
|
57 |
|
|
public Static4D[] getQuats()
|
58 |
82eb152a
|
Leszek Koltunski
|
{
|
59 |
ed0988c0
|
Leszek Koltunski
|
return mReader.getQuats();
|
60 |
82eb152a
|
Leszek Koltunski
|
}
|
61 |
|
|
|
62 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
63 |
|
|
|
64 |
ed0988c0
|
Leszek Koltunski
|
@Override
|
65 |
|
|
public int getSolvedFunctionIndex()
|
66 |
82eb152a
|
Leszek Koltunski
|
{
|
67 |
ed0988c0
|
Leszek Koltunski
|
return mReader.getSolvedFunctionIndex();
|
68 |
82eb152a
|
Leszek Koltunski
|
}
|
69 |
|
|
|
70 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
71 |
|
|
|
72 |
ed0988c0
|
Leszek Koltunski
|
@Override
|
73 |
|
|
public int getNumCubitFaces()
|
74 |
82eb152a
|
Leszek Koltunski
|
{
|
75 |
ed0988c0
|
Leszek Koltunski
|
return mReader.getNumCubitFaces();
|
76 |
82eb152a
|
Leszek Koltunski
|
}
|
77 |
|
|
|
78 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
79 |
|
|
|
80 |
ed0988c0
|
Leszek Koltunski
|
@Override
|
81 |
|
|
public int getVariantFaceColor(int variant, int face)
|
82 |
82eb152a
|
Leszek Koltunski
|
{
|
83 |
ed0988c0
|
Leszek Koltunski
|
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 |
253e440f
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
127 |
|
|
|
128 |
|
|
@Override
|
129 |
|
|
public int getInternalColor()
|
130 |
|
|
{
|
131 |
|
|
return mReader.getInternalColor();
|
132 |
|
|
}
|
133 |
|
|
|
134 |
ed0988c0
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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 |
82eb152a
|
Leszek Koltunski
|
}
|
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 |
11fa413d
|
Leszek Koltunski
|
public int getTouchControlType()
|
165 |
82eb152a
|
Leszek Koltunski
|
{
|
166 |
|
|
return mReader.getMovementType();
|
167 |
|
|
}
|
168 |
|
|
|
169 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
170 |
|
|
|
171 |
11fa413d
|
Leszek Koltunski
|
public int getTouchControlSplit()
|
172 |
82eb152a
|
Leszek Koltunski
|
{
|
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 |
4c9ca251
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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 |
82eb152a
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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 |
3ee1d662
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
213 |
|
|
|
214 |
|
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
215 |
|
|
{
|
216 |
|
|
return mReader.getObjectFaceShape(variant);
|
217 |
|
|
}
|
218 |
|
|
|
219 |
82eb152a
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
220 |
|
|
|
221 |
d0e6cf7f
|
Leszek Koltunski
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
222 |
82eb152a
|
Leszek Koltunski
|
{
|
223 |
d0e6cf7f
|
Leszek Koltunski
|
return mReader.getCubitQuats(cubit);
|
224 |
82eb152a
|
Leszek Koltunski
|
}
|
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 |
d53fb890
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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 |
82eb152a
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
265 |
|
|
// PUBLIC API
|
266 |
|
|
|
267 |
|
|
public Static3D[] getRotationAxis()
|
268 |
|
|
{
|
269 |
|
|
return mReader.getRotationAxis();
|
270 |
|
|
}
|
271 |
|
|
|
272 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
273 |
|
|
|
274 |
beee90ab
|
Leszek Koltunski
|
public int[][] getBasicAngles()
|
275 |
82eb152a
|
Leszek Koltunski
|
{
|
276 |
|
|
return mReader.getBasicAngle();
|
277 |
|
|
}
|
278 |
|
|
|
279 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
280 |
|
|
|
281 |
5f54927b
|
Leszek Koltunski
|
public int getNumScramble()
|
282 |
82eb152a
|
Leszek Koltunski
|
{
|
283 |
5f54927b
|
Leszek Koltunski
|
return mReader.getNumScrambles();
|
284 |
|
|
}
|
285 |
|
|
|
286 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
287 |
|
|
|
288 |
1d581993
|
Leszek Koltunski
|
public ObjectSignature getSignature()
|
289 |
5f54927b
|
Leszek Koltunski
|
{
|
290 |
|
|
return mReader.getSignature();
|
291 |
82eb152a
|
Leszek Koltunski
|
}
|
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 |
e1a86bf2
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
343 |
|
|
|
344 |
|
|
public String getShortName()
|
345 |
|
|
{
|
346 |
|
|
return mReader.getShortName();
|
347 |
|
|
}
|
348 |
|
|
|
349 |
052e0362
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
350 |
|
|
|
351 |
|
|
public String[][] getTutorials()
|
352 |
|
|
{
|
353 |
|
|
return mReader.getTutorials();
|
354 |
|
|
}
|
355 |
|
|
|
356 |
82eb152a
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
357 |
|
|
|
358 |
|
|
public int getFOV()
|
359 |
|
|
{
|
360 |
|
|
switch( mReader.getNumFaces() )
|
361 |
|
|
{
|
362 |
386af988
|
Leszek Koltunski
|
case 4: return ShapeTetrahedron.FOV;
|
363 |
|
|
case 6: return ShapeHexahedron.FOV;
|
364 |
|
|
case 8: return ShapeOctahedron.FOV;
|
365 |
|
|
case 12: return ShapeDodecahedron.FOV;
|
366 |
82eb152a
|
Leszek Koltunski
|
}
|
367 |
|
|
|
368 |
|
|
return 0;
|
369 |
|
|
}
|
370 |
|
|
|
371 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
372 |
|
|
|
373 |
|
|
public float getScreenRatio()
|
374 |
|
|
{
|
375 |
|
|
switch( mReader.getNumFaces() )
|
376 |
|
|
{
|
377 |
386af988
|
Leszek Koltunski
|
case 4: return ShapeTetrahedron.RATIO;
|
378 |
|
|
case 6: return ShapeHexahedron.RATIO;
|
379 |
|
|
case 8: return ShapeOctahedron.RATIO;
|
380 |
|
|
case 12: return ShapeDodecahedron.RATIO;
|
381 |
82eb152a
|
Leszek Koltunski
|
}
|
382 |
|
|
|
383 |
|
|
return 0.0f;
|
384 |
|
|
}
|
385 |
|
|
}
|