Project

General

Profile

Download (35.9 KB) Statistics
| Branch: | Revision:

distorted-objectlib / src / main / java / org / distorted / objectlib / json / JsonReader.java @ aacf5e27

1 82eb152a Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2021 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Distorted.                                                               //
5
//                                                                                               //
6 4c87f159 Leszek Koltunski
// 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 82eb152a Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
9
10
package org.distorted.objectlib.json;
11
12 8f44228f Leszek Koltunski
import static org.distorted.objectlib.objects.TwistyBandagedCuboid.OBJECT_NAME;
13
import static org.distorted.objectlib.scrambling.ScrambleStateBandagedCuboid.MAX_SUPPORTED_SIZE;
14
15 82eb152a Leszek Koltunski
import java.io.BufferedReader;
16
import java.io.IOException;
17
import java.io.InputStream;
18
import java.io.InputStreamReader;
19
import java.nio.charset.StandardCharsets;
20
21 3ee1d662 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectFaceShape;
22 1d581993 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectSignature;
23 3a0a23bf Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectStickerOverride;
24 84a17011 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectVertexEffects;
25 5618c5a9 Leszek Koltunski
import org.distorted.objectlib.main.TwistyObjectCubit;
26 731280f7 Leszek Koltunski
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator;
27 82eb152a Leszek Koltunski
import org.json.JSONArray;
28
import org.json.JSONException;
29
import org.json.JSONObject;
30
31
import org.distorted.library.type.Static3D;
32
import org.distorted.library.type.Static4D;
33
34
import org.distorted.objectlib.helpers.ObjectShape;
35
import org.distorted.objectlib.helpers.ObjectSticker;
36
import org.distorted.objectlib.main.ObjectType;
37
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39
40
public class JsonReader
41
{
42 9ba7f3f6 Leszek Koltunski
  private int[][] mAlgorithms;
43
  private int[][] mEdges;
44 82eb152a Leszek Koltunski
  private int[][] mSolvedQuats;
45
  private Static4D[] mQuats;
46
  private int mSolvedFuncIndex;
47
  private int mNumStickerTypes;
48
  private float[][] mCuts;
49
  private boolean[][] mLayerRotatable;
50
  private int mMovementType, mMovementSplit;
51
  private int[][][] mEnabled;
52
  private float[] mDist3D;
53 d66e98d7 Leszek Koltunski
  private int mNumCubitFaces, mNumFaces, mNumFaceColors;
54 82eb152a Leszek Koltunski
  private float[][] mPositions;
55
  private ObjectShape[] mShapes;
56 3ee1d662 Leszek Koltunski
  private ObjectFaceShape[] mFaceShapes;
57 84a17011 Leszek Koltunski
  private ObjectVertexEffects[] mVertexEffects;
58 82eb152a Leszek Koltunski
  private Static4D[] mCubitQuats;
59
  private int mNumCubitVariants;
60
  private int[] mCubitVariant;
61 51262d81 Leszek Koltunski
  private int[][] mVariantStickerShape, mVariantFaceIsOuter, mCubitFaceColor;
62 82eb152a Leszek Koltunski
  private ObjectSticker[] mObjectSticker;
63
  private Static3D[] mAxis;
64 beee90ab Leszek Koltunski
  private int[][] mBasicAngle;
65 e1a86bf2 Leszek Koltunski
  private String mLongName, mShortName, mInventor;
66 82eb152a Leszek Koltunski
  private int mYearOfInvention, mComplexity;
67
  private int[] mNumLayers;
68
  private float mSize;
69 e1a86bf2 Leszek Koltunski
  private int mScrambleType, mNumScrambles;
70 8b3b1d85 Leszek Koltunski
  private int mPrice;
71 82eb152a Leszek Koltunski
  private int[] mColor;
72 253e440f Leszek Koltunski
  private int mInternalColor;
73 0f72365b Leszek Koltunski
  private boolean mResetMaps;
74 052e0362 Leszek Koltunski
  private String mTutorialObject;
75
  private String[][] mTutorials;
76 1d581993 Leszek Koltunski
  private ObjectSignature mSignature;
77 7aae846c Leszek Koltunski
  private int[] mCubitType;
78
  private float[][] mCubitRowOffset;
79 3a0a23bf Leszek Koltunski
  private ObjectStickerOverride[] mStickerOverrides;
80 6db8fe2e Leszek Koltunski
  private float mPillowCoeff;
81 82eb152a Leszek Koltunski
82 8f44228f Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
83
84
  public static ObjectSignature produceSignature(String shortName, String longName, long[] signature)
85
    {
86
    // 'BAN*_*' ( or future possible 'BA**_*' ) objects
87
    if( shortName.charAt(0)=='B' && shortName.charAt(1)=='A' && shortName.charAt(4)=='_' )
88
      {
89
      char second = shortName.charAt(2);
90
      char third  = shortName.charAt(3);
91
92
      if( (second=='N' || (second>='0' && second<='9')) && (third>='0' && third<='9') )
93
        {
94
        int size = shortName.charAt(5) - '0';
95
        if( size>=2 && size<=MAX_SUPPORTED_SIZE ) return new ObjectSignature(size,signature);
96
        }
97
      }
98
99
    if( longName.equals(OBJECT_NAME) ) new ObjectSignature(shortName,signature);
100
101
    return new ObjectSignature(signature);
102
    }
103
104 82eb152a Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
105
106 f8a992a9 Leszek Koltunski
  private void parseMetadata(JSONObject metadata) throws JSONException
107 82eb152a Leszek Koltunski
    {
108 84a17011 Leszek Koltunski
    mLongName        = metadata.getString("longname");
109
    mShortName       = metadata.getString("shortname");
110
    mInventor        = metadata.getString("inventor");
111
    mYearOfInvention = metadata.getInt("year");
112
    mComplexity      = metadata.getInt("complexity");
113
    mSize            = (float)metadata.getDouble("size");
114
    mNumScrambles    = metadata.getInt("scrambles");
115
    mResetMaps       = metadata.getBoolean("resetmaps");
116
    mNumFaces        = metadata.getInt("num_faces");
117 882a8142 Leszek Koltunski
118
    try
119
      {
120 84a17011 Leszek Koltunski
      JSONArray sigArray = metadata.getJSONArray("signature");
121 882a8142 Leszek Koltunski
      int size = sigArray.length();
122
      long[] signature = new long[size];
123
      for(int i=0; i<size; i++) signature[i] = sigArray.getLong(i);
124 8f44228f Leszek Koltunski
      mSignature = produceSignature(mShortName,mLongName,signature);
125 1d581993 Leszek Koltunski
      }
126
    catch(JSONException ex)
127
      {
128 84a17011 Leszek Koltunski
      long signature = metadata.getLong("signature");
129 1d581993 Leszek Koltunski
      mSignature = new ObjectSignature(signature);
130 5f54927b Leszek Koltunski
      }
131 84224c99 Leszek Koltunski
132 84a17011 Leszek Koltunski
    boolean free = metadata.optBoolean("free", true);
133 8b3b1d85 Leszek Koltunski
134
    if( free ) mPrice = 0;
135 84a17011 Leszek Koltunski
    else mPrice = metadata.optInt("price", ObjectType.DEFAULT_PRICE_OF_OLD_OBJECTS );
136 82eb152a Leszek Koltunski
    }
137
138
///////////////////////////////////////////////////////////////////////////////////////////////////
139
140
  private void parseCubits(JSONArray object) throws JSONException
141
    {
142
    int numCubits = object.length();
143
144
    mCubitQuats     = new Static4D[numCubits];
145
    mCubitVariant   = new int[numCubits];
146
    mPositions      = new float[numCubits][];
147
    mCubitFaceColor = new int[numCubits][];
148 7aae846c Leszek Koltunski
    mCubitType      = new int[numCubits];
149
    mCubitRowOffset = new float[numCubits][];
150 82eb152a Leszek Koltunski
151
    for(int i=0; i<numCubits; i++)
152
      {
153
      JSONObject jsonCubit = object.getJSONObject(i);
154
155
      float qx = (float)jsonCubit.getDouble("qx");
156
      float qy = (float)jsonCubit.getDouble("qy");
157
      float qz = (float)jsonCubit.getDouble("qz");
158
      float qw = (float)jsonCubit.getDouble("qw");
159
160
      mCubitQuats[i] = new Static4D(qx,qy,qz,qw);
161
      mCubitVariant[i] = jsonCubit.getInt("variant");
162
163
      JSONArray jsonCenter = jsonCubit.getJSONArray("centers");
164
      int numCenter = jsonCenter.length();
165
      mPositions[i] = new float[numCenter];
166
      for(int j=0; j<numCenter; j++) mPositions[i][j] = (float)jsonCenter.getDouble(j);
167
168
      JSONArray jsonColor  = jsonCubit.getJSONArray("colors");
169
      int numColor = jsonColor.length();
170
      mCubitFaceColor[i] = new int[numColor];
171
      for(int j=0; j<numColor; j++) mCubitFaceColor[i][j] = jsonColor.getInt(j);
172 7aae846c Leszek Koltunski
173 5618c5a9 Leszek Koltunski
      mCubitType[i] = jsonCubit.optInt("type", TwistyObjectCubit.TYPE_NORMAL);
174 7aae846c Leszek Koltunski
      float xoff = (float)jsonCubit.optDouble("offsetX", 0 );
175
      float yoff = (float)jsonCubit.optDouble("offsetY", 0 );
176
      float zoff = (float)jsonCubit.optDouble("offsetZ", 0 );
177
      mCubitRowOffset[i] = new float[] {xoff,yoff,zoff};
178 82eb152a Leszek Koltunski
      }
179
    }
180
181
///////////////////////////////////////////////////////////////////////////////////////////////////
182
183
  private void parseShapes(JSONArray object) throws JSONException
184
    {
185 40e77224 Leszek Koltunski
    mNumCubitVariants     = object.length();
186 51262d81 Leszek Koltunski
    mVariantStickerShape  = new int[mNumCubitVariants][];
187 40e77224 Leszek Koltunski
    mVariantFaceIsOuter   = new int[mNumCubitVariants][];
188
    mShapes               = new ObjectShape[mNumCubitVariants];
189
    mFaceShapes           = new ObjectFaceShape[mNumCubitVariants];
190 84a17011 Leszek Koltunski
    mVertexEffects        = new ObjectVertexEffects[mNumCubitVariants];
191 57ef6378 Leszek Koltunski
    float[][][] verts     = new float[mNumCubitVariants][][];
192
    float[][][] bands     = new float[mNumCubitVariants][][];
193
    float[][] convexity   = new float[mNumCubitVariants][];
194
    int[][] bandIndices   = new int[mNumCubitVariants][];
195 82eb152a Leszek Koltunski
    int[][][] vertIndices = new int[mNumCubitVariants][][];
196
197 d66e98d7 Leszek Koltunski
    mNumCubitFaces = -1;
198
199 82eb152a Leszek Koltunski
    for(int i=0; i<mNumCubitVariants; i++)
200
      {
201
      JSONObject jsonShape = object.getJSONObject(i);
202
203
      ////// vertices /////////////////////////////////////////////////
204
      JSONArray jsonVertices= jsonShape.getJSONArray("vertices");
205
      int numVertices = jsonVertices.length();
206 57ef6378 Leszek Koltunski
      verts[i] = new float[numVertices][3];
207 82eb152a Leszek Koltunski
208
      for(int j=0; j<numVertices; j++)
209
        {
210
        JSONObject vert = jsonVertices.getJSONObject(j);
211 57ef6378 Leszek Koltunski
        verts[i][j][0] = (float)vert.getDouble("x");
212
        verts[i][j][1] = (float)vert.getDouble("y");
213
        verts[i][j][2] = (float)vert.getDouble("z");
214 82eb152a Leszek Koltunski
        }
215
216
      ////// faces ////////////////////////////////////////////////////
217
      JSONArray jsonFaces= jsonShape.getJSONArray("faces");
218
      int numFaces = jsonFaces.length();
219 51262d81 Leszek Koltunski
      mVariantStickerShape[i]= new int[numFaces];
220 40e77224 Leszek Koltunski
      mVariantFaceIsOuter[i] = new int[numFaces];
221 82eb152a Leszek Koltunski
      bandIndices[i] = new int[numFaces];
222
      vertIndices[i] = new int[numFaces][];
223
224 d66e98d7 Leszek Koltunski
      if( mNumCubitFaces<numFaces ) mNumCubitFaces=numFaces;
225
226 82eb152a Leszek Koltunski
      for(int j=0; j<numFaces; j++)
227
        {
228
        JSONObject jsonFace = jsonFaces.getJSONObject(j);
229 51262d81 Leszek Koltunski
        mVariantStickerShape[i][j]= jsonFace.getInt("sticker");
230 40e77224 Leszek Koltunski
        mVariantFaceIsOuter[i][j] = jsonFace.optInt("isOuter",0);
231 82eb152a Leszek Koltunski
        bandIndices[i][j] = jsonFace.getInt("bandIndex");
232
        JSONArray vertices = jsonFace.getJSONArray("vertexIndices");
233
        int numV = vertices.length();
234
        vertIndices[i][j] = new int[numV];
235
        for(int k=0; k<numV; k++) vertIndices[i][j][k] = vertices.getInt(k);
236
        }
237
238
      ////// bands ////////////////////////////////////////////////////
239
      JSONArray jsonBands= jsonShape.getJSONArray("bands");
240
      int numBands = jsonBands.length();
241
      bands[i] = new float[numBands][7];
242
243
      for(int j=0; j<numBands; j++)
244
        {
245
        JSONObject jsonBand = jsonBands.getJSONObject(j);
246
247
        bands[i][j][0] = (float)jsonBand.getDouble("height");
248
        bands[i][j][1] = (float)jsonBand.getDouble("angle");
249
        bands[i][j][2] = (float)jsonBand.getDouble("distanceToCenter");
250
        bands[i][j][3] = (float)jsonBand.getDouble("distanceToFlat");
251
        bands[i][j][4] = (float)jsonBand.getDouble("numOfBands");
252
        bands[i][j][5] = (float)jsonBand.getDouble("extraI");
253
        bands[i][j][6] = (float)jsonBand.getDouble("extraJ");
254
        }
255
256 84a17011 Leszek Koltunski
      ////// convexity ///////////////////////////////////////////////
257
      JSONObject jsonConvexity = jsonShape.optJSONObject("convexity");
258 82eb152a Leszek Koltunski
259 84a17011 Leszek Koltunski
      if( jsonConvexity!=null )
260 82eb152a Leszek Koltunski
        {
261 84a17011 Leszek Koltunski
        convexity[i] = new float[3];
262
        convexity[i][0] = (float)jsonConvexity.getDouble("x");
263
        convexity[i][1] = (float)jsonConvexity.getDouble("y");
264
        convexity[i][2] = (float)jsonConvexity.getDouble("z");
265 82eb152a Leszek Koltunski
        }
266
267 84a17011 Leszek Koltunski
      ////// effects /////////////////////////////////////////////////
268
      JSONArray jsonEffects = jsonShape.optJSONArray("effects");
269 82eb152a Leszek Koltunski
270 84a17011 Leszek Koltunski
      if( jsonEffects!=null )
271 82eb152a Leszek Koltunski
        {
272 84a17011 Leszek Koltunski
        int numEffects = jsonEffects.length();
273 9e8eb9e4 Leszek Koltunski
274 84a17011 Leszek Koltunski
        String[] name    = new String[numEffects];
275
        float[][] vars   = new float[numEffects][5];
276
        float[][] center = new float[numEffects][3];
277
        float[][] region = new float[numEffects][4];
278
        boolean[] use    = new boolean[numEffects];
279
280
        for(int j=0; j<numEffects; j++)
281 9e8eb9e4 Leszek Koltunski
          {
282 84a17011 Leszek Koltunski
          JSONObject jsonEffect = jsonEffects.getJSONObject(j);
283 82eb152a Leszek Koltunski
284 84a17011 Leszek Koltunski
          name[j] = jsonEffect.getString("name");
285 9e8eb9e4 Leszek Koltunski
286 84a17011 Leszek Koltunski
          vars[j][0] = (float)jsonEffect.getDouble("var0");
287
          vars[j][1] = (float)jsonEffect.getDouble("var1");
288
          vars[j][2] = (float)jsonEffect.getDouble("var2");
289
          vars[j][3] = (float)jsonEffect.getDouble("var3");
290
          vars[j][4] = (float)jsonEffect.getDouble("var4");
291
292
          center[j][0] = (float)jsonEffect.getDouble("center0");
293
          center[j][1] = (float)jsonEffect.getDouble("center1");
294
          center[j][2] = (float)jsonEffect.getDouble("center2");
295
296
          region[j][0] = (float)jsonEffect.getDouble("region0");
297
          region[j][1] = (float)jsonEffect.getDouble("region1");
298
          region[j][2] = (float)jsonEffect.getDouble("region2");
299
          region[j][3] = (float)jsonEffect.getDouble("region3");
300
301
          use[j] = jsonEffect.getBoolean("use");
302
          }
303
304
        mVertexEffects[i] = new ObjectVertexEffects(name,vars,center,region,use);
305 82eb152a Leszek Koltunski
        }
306
      }
307
308
    for(int i=0; i<mNumCubitVariants; i++)
309
      {
310 59a971c1 Leszek Koltunski
      mShapes[i] = new ObjectShape(verts[i],vertIndices[i]);
311 84a17011 Leszek Koltunski
      mFaceShapes[i] = new ObjectFaceShape(bands[i],bandIndices[i],convexity[i]);
312 82eb152a Leszek Koltunski
      }
313
    }
314
315
///////////////////////////////////////////////////////////////////////////////////////////////////
316
317
  private void parseStickers(JSONArray object) throws JSONException
318
    {
319
    mNumStickerTypes = object.length();
320
    mObjectSticker = new ObjectSticker[mNumStickerTypes];
321
322
    for(int i=0; i<mNumStickerTypes; i++)
323
      {
324
      JSONObject sticker = object.getJSONObject(i);
325
      float stroke = (float)sticker.getDouble("stroke");
326
      JSONArray vertices = sticker.getJSONArray("vertices");
327
      int numVertices = vertices.length();
328
329
      float[] coords     = new float[2*numVertices];
330
      float[] curvatures = new float[numVertices];
331
      float[] radii      = new float[numVertices];
332
333
      for(int j=0; j<numVertices; j++)
334
        {
335
        JSONObject vertex = vertices.getJSONObject(j);
336
337
        coords[2*j  ] = (float)vertex.getDouble("x");
338
        coords[2*j+1] = (float)vertex.getDouble("y");
339
        curvatures[j] = (float)vertex.getDouble("angle");
340
        radii[j]      = (float)vertex.getDouble("radius");
341
        }
342
343
      mObjectSticker[i] = new ObjectSticker(coords,curvatures,radii,stroke);
344
      }
345
    }
346
347 3a0a23bf Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
348
349
  private void parseOverrides(JSONArray object) throws JSONException
350
    {
351 fd9d4a2c Leszek Koltunski
    if( object!=null )
352
      {
353
      int numOverrides = object.length();
354
      mStickerOverrides= new ObjectStickerOverride[numOverrides];
355 3a0a23bf Leszek Koltunski
356 fd9d4a2c Leszek Koltunski
      for(int i=0; i<numOverrides; i++)
357
        {
358
        JSONObject override  = object.getJSONObject(i);
359
        JSONArray cubitArray = override.getJSONArray("cubitfaces");
360
        int color = override.getInt("color");
361
        int numCubits = cubitArray.length();
362
        int[] cubitface = new int[numCubits];
363
        for(int j=0; j<numCubits; j++) cubitface[j] = cubitArray.getInt(j);
364
        mStickerOverrides[i] = new ObjectStickerOverride(cubitface,color);
365
        }
366
      }
367
    else
368 3a0a23bf Leszek Koltunski
      {
369 fd9d4a2c Leszek Koltunski
      mStickerOverrides = null;
370 3a0a23bf Leszek Koltunski
      }
371
    }
372
373 82eb152a Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
374
375
  private void parseMesh(JSONObject object) throws JSONException
376
    {
377
    JSONArray cubits   = object.getJSONArray("cubits");
378
    parseCubits(cubits);
379
    JSONArray shapes   = object.getJSONArray("shapes");
380
    parseShapes(shapes);
381
    JSONArray stickers = object.getJSONArray("stickers");
382
    parseStickers(stickers);
383 3a0a23bf Leszek Koltunski
384
    JSONArray overrides= object.optJSONArray("overrides");
385 fd9d4a2c Leszek Koltunski
    parseOverrides(overrides);
386 6db8fe2e Leszek Koltunski
387
    mPillowCoeff = (float)object.optDouble("pillow",1.0);
388 82eb152a Leszek Koltunski
    }
389
390
///////////////////////////////////////////////////////////////////////////////////////////////////
391
392 84a17011 Leszek Koltunski
  private void parseAxis(JSONArray object) throws JSONException
393 beee90ab Leszek Koltunski
    {
394
    int numAxis = object.length();
395
396
    mBasicAngle     = new int[numAxis][];
397
    mAxis           = new Static3D[numAxis];
398
    mCuts           = new float[numAxis][];
399
    mLayerRotatable = new boolean[numAxis][];
400
    mNumLayers      = new int[numAxis];
401
402
    for(int i=0; i<numAxis; i++)
403
      {
404
      JSONObject jsonAx = object.getJSONObject(i);
405 82eb152a Leszek Koltunski
406
      float x = (float)jsonAx.getDouble("x");
407
      float y = (float)jsonAx.getDouble("y");
408
      float z = (float)jsonAx.getDouble("z");
409
410
      mAxis[i] = new Static3D(x,y,z);
411
412 beee90ab Leszek Koltunski
      JSONArray jsonAngles = jsonAx.getJSONArray("basicAngles");
413
      int numAngles = jsonAngles.length();
414
      mBasicAngle[i] = new int[numAngles];
415
      for(int j=0; j<numAngles; j++) mBasicAngle[i][j] = jsonAngles.getInt(j);
416
417 82eb152a Leszek Koltunski
      JSONArray jsonCuts = jsonAx.getJSONArray("cuts");
418
      int numCuts = jsonCuts.length();
419
      mCuts[i] = new float[numCuts];
420
      for(int j=0; j<numCuts; j++) mCuts[i][j] = (float)jsonCuts.getDouble(j);
421
422
      JSONArray jsonRota = jsonAx.getJSONArray("rotatable");
423
      int numRota = jsonRota.length();
424
      mLayerRotatable[i] = new boolean[numRota];
425
      for(int j=0; j<numRota; j++) mLayerRotatable[i][j] = jsonRota.getBoolean(j);
426
427
      mNumLayers[i] = numRota;
428
      }
429
    }
430
431
///////////////////////////////////////////////////////////////////////////////////////////////////
432
433
  private void parseQuats(JSONArray object) throws JSONException
434
    {
435
    int numQuats = object.length();
436
    mQuats = new Static4D[numQuats];
437
438
    for(int i=0; i<numQuats; i++)
439
      {
440
      JSONObject jsonQuat = object.getJSONObject(i);
441
442
      float x = (float)jsonQuat.getDouble("x");
443
      float y = (float)jsonQuat.getDouble("y");
444
      float z = (float)jsonQuat.getDouble("z");
445
      float w = (float)jsonQuat.getDouble("w");
446
447
      mQuats[i] = new Static4D(x,y,z,w);
448
      }
449
    }
450
451
///////////////////////////////////////////////////////////////////////////////////////////////////
452
453 28bfa000 Leszek Koltunski
  private int getAlgorithmIndex(int ax, int layer, int angle)
454 82eb152a Leszek Koltunski
    {
455 28bfa000 Leszek Koltunski
    int numAlgs = mAlgorithms.length;
456 82eb152a Leszek Koltunski
457 28bfa000 Leszek Koltunski
    for(int alg=0; alg<numAlgs; alg++)
458
      {
459 731280f7 Leszek Koltunski
      int[] a = mAlgorithms[alg];
460
      if( a.length>=3 && a[0]==ax && a[1]==layer && a[2]==angle ) return alg;
461 28bfa000 Leszek Koltunski
      }
462
463
    return -1;
464
    }
465
466
///////////////////////////////////////////////////////////////////////////////////////////////////
467
468
  private int[] produceEdge(int[][] scramblingData)
469
    {
470
    int index=0, length=0;
471
    int numAxis = scramblingData.length;
472
    for (int[] scramblingDatum : scramblingData) length += scramblingDatum.length;
473
474
    int[] ret = new int[2*length/3];
475
476
    for(int ax=0; ax<numAxis; ax++)
477 82eb152a Leszek Koltunski
      {
478 28bfa000 Leszek Koltunski
      int[] data = scramblingData[ax];
479
      int num = data.length/3;
480 82eb152a Leszek Koltunski
481 28bfa000 Leszek Koltunski
      for(int j=0; j<num; j++)
482 82eb152a Leszek Koltunski
        {
483 28bfa000 Leszek Koltunski
        int layer = data[3*j];
484
        int angle = data[3*j+1];
485
        int state = data[3*j+2];
486
487
        ret[2*index  ] = getAlgorithmIndex(ax,layer,angle);
488
        ret[2*index+1] = state;
489
        index++;
490 9ba7f3f6 Leszek Koltunski
        }
491 28bfa000 Leszek Koltunski
      }
492 82eb152a Leszek Koltunski
493 28bfa000 Leszek Koltunski
    return ret;
494
    }
495
496
///////////////////////////////////////////////////////////////////////////////////////////////////
497 82eb152a Leszek Koltunski
498 28bfa000 Leszek Koltunski
  private void parseScrambling6(JSONObject object) throws JSONException
499
    {
500
    JSONArray jsonStates = object.getJSONArray("scrambleStates");
501
    int numStates = jsonStates.length();
502
    int[][][] scramblingData = new int[numStates][][];
503
504
    for(int i=0; i<numStates; i++)
505
      {
506
      JSONArray jsonState = jsonStates.getJSONArray(i);
507
      int numAxis = jsonState.length();
508
      scramblingData[i] = new int[numAxis][];
509
510
      for(int j=0; j<numAxis; j++)
511 9ba7f3f6 Leszek Koltunski
        {
512 28bfa000 Leszek Koltunski
        JSONArray jsonData = jsonState.getJSONArray(j);
513
        int numData = jsonData.length();
514
        scramblingData[i][j] = new int[numData];
515
        for(int k=0; k<numData; k++) scramblingData[i][j][k] = jsonData.getInt(k);
516 82eb152a Leszek Koltunski
        }
517
      }
518 28bfa000 Leszek Koltunski
519 731280f7 Leszek Koltunski
    mAlgorithms = ScrambleEdgeGenerator.getScramblingAlgorithms(mBasicAngle);
520 28bfa000 Leszek Koltunski
    mEdges = new int[numStates][];
521
    for(int i=0; i<numStates; i++) mEdges[i] = produceEdge(scramblingData[i]);
522
    }
523
524
///////////////////////////////////////////////////////////////////////////////////////////////////
525
526
  private void parseScrambling7orMore(JSONObject object) throws JSONException
527
    {
528
    JSONArray jsonAlgorithms = object.getJSONArray("algorithms");
529
    int numAlgs = jsonAlgorithms.length();
530
    mAlgorithms = new int[numAlgs][];
531
532
    for(int i=0; i<numAlgs; i++)
533
      {
534
      JSONArray jsonAlg = jsonAlgorithms.getJSONArray(i);
535
      int numEntries = jsonAlg.length();
536
      mAlgorithms[i] = new int[numEntries];
537
      for(int j=0; j<numEntries; j++) mAlgorithms[i][j] = jsonAlg.getInt(j);
538
      }
539
540
    JSONArray jsonEdges = object.getJSONArray("edges");
541
    int numEdges = jsonEdges.length();
542
    mEdges = new int[numEdges][];
543
544
    for(int i=0; i<numEdges; i++)
545
      {
546
      JSONArray jsonEdge = jsonEdges.getJSONArray(i);
547
      int numEntries = jsonEdge.length();
548
      mEdges[i] = new int[numEntries];
549
      for(int j=0; j<numEntries; j++) mEdges[i][j] = jsonEdge.getInt(j);
550
      }
551
    }
552
553
///////////////////////////////////////////////////////////////////////////////////////////////////
554
555
  private void parseScrambling(JSONObject object, int major) throws JSONException
556
    {
557
    mScrambleType = object.getInt("scrambleType");
558
559
    if( mScrambleType==0 )
560
      {
561
      if( major==6 ) parseScrambling6(object);
562
      else           parseScrambling7orMore(object);
563
      }
564 82eb152a Leszek Koltunski
    }
565
566
///////////////////////////////////////////////////////////////////////////////////////////////////
567
568
  private void parseTouchcontrol(JSONObject object) throws JSONException
569
    {
570
    mMovementType = object.getInt("movementType");
571
    mMovementSplit= object.getInt("movementSplit");
572
573 82904e62 Leszek Koltunski
    try
574 82eb152a Leszek Koltunski
      {
575 82904e62 Leszek Koltunski
      JSONArray jsonEnabled = object.getJSONArray("enabledAxis");
576
      int numFace = jsonEnabled.length();
577 82eb152a Leszek Koltunski
578 82904e62 Leszek Koltunski
      mEnabled = new int[numFace][][];
579
580
      for(int i=0; i<numFace; i++)
581 82eb152a Leszek Koltunski
        {
582 82904e62 Leszek Koltunski
        JSONArray jsonSection = jsonEnabled.getJSONArray(i);
583
        int numSection = jsonSection.length();
584
        mEnabled[i] = new int[numSection][];
585
586
        for(int j=0; j<numSection; j++)
587
          {
588
          JSONArray jsonAx = jsonSection.getJSONArray(j);
589
          int numAxis = jsonAx.length();
590
          mEnabled[i][j] = new int[numAxis];
591
          for(int k=0; k<numAxis; k++) mEnabled[i][j][k] = jsonAx.getInt(k);
592
          }
593 82eb152a Leszek Koltunski
        }
594
      }
595 82904e62 Leszek Koltunski
    catch( JSONException ex )
596
      {
597
      // ignore, the object does not have to have 'enabledAxis' defined at all.
598
      }
599 82eb152a Leszek Koltunski
600
    try
601
      {
602
      JSONArray jsonDist = object.getJSONArray("dist3D");
603 a72cd106 Leszek Koltunski
      int num = jsonDist.length();
604
      mDist3D = new float[num];
605
      for(int j=0; j<num; j++) mDist3D[j] = (float)jsonDist.getDouble(j);
606 82eb152a Leszek Koltunski
      }
607
    catch( JSONException ex )
608
      {
609 a72cd106 Leszek Koltunski
      // ignore, the object does not have a 'dist3D' which is possible.
610 82eb152a Leszek Koltunski
      }
611
    }
612
613
///////////////////////////////////////////////////////////////////////////////////////////////////
614
615
  private void parseColors(JSONArray object) throws JSONException
616
    {
617 253e440f Leszek Koltunski
    mNumFaceColors = object.length()-1;
618
619 82eb152a Leszek Koltunski
    mColor = new int[mNumFaceColors];
620
    for(int i=0; i<mNumFaceColors; i++) mColor[i] = object.getInt(i);
621 253e440f Leszek Koltunski
622
    mInternalColor = object.getInt(mNumFaceColors);
623 82eb152a Leszek Koltunski
    }
624
625 3c48fab9 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
626
627
  private void parseSolved(JSONObject solved) throws JSONException
628
    {
629
    mSolvedFuncIndex = solved.getInt("functionIndex");
630
631
    try
632
      {
633
      JSONArray groupArray= solved.getJSONArray("groups");
634
      int numGroups = groupArray.length();
635
      mSolvedQuats  = new int[numGroups][];
636
637
      for(int i=0; i<numGroups; i++)
638
        {
639
        JSONArray groupElements = groupArray.getJSONArray(i);
640
        int groupSize = groupElements.length();
641
        mSolvedQuats[i] = new int[groupSize];
642
        for(int j=0; j<groupSize; j++) mSolvedQuats[i][j] = groupElements.getInt(j);
643
        }
644
      }
645
    catch( JSONException ex )
646
      {
647
      // ignore, the object does not have to have an array of solved groups.
648
      }
649
    }
650
651 82eb152a Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
652
653 28bfa000 Leszek Koltunski
  private void parseFile(JSONObject object, int major) throws JSONException
654 beee90ab Leszek Koltunski
    {
655
    JSONObject metadata    = object.getJSONObject("metadata");
656 84a17011 Leszek Koltunski
    parseMetadata(metadata);
657 beee90ab Leszek Koltunski
    JSONObject mesh        = object.getJSONObject("mesh");
658
    parseMesh(mesh);
659
    JSONArray axis         = object.getJSONArray("axis");
660 84a17011 Leszek Koltunski
    parseAxis(axis);
661 882a8142 Leszek Koltunski
    JSONArray quats        = object.getJSONArray("quats");
662
    parseQuats(quats);
663
    JSONObject scrambling  = object.getJSONObject("scrambling");
664 28bfa000 Leszek Koltunski
    parseScrambling(scrambling,major);
665 882a8142 Leszek Koltunski
    JSONObject touchcontrol= object.getJSONObject("touchcontrol");
666
    parseTouchcontrol(touchcontrol);
667
    JSONArray colors       = object.getJSONArray("colors");
668
    parseColors(colors);
669
    JSONObject solved      = object.getJSONObject("solved");
670
    parseSolved(solved);
671
    }
672
673
///////////////////////////////////////////////////////////////////////////////////////////////////
674
675 84a17011 Leszek Koltunski
  private void parseTutorial(JSONObject object) throws JSONException
676 052e0362 Leszek Koltunski
    {
677
    mTutorialObject = object.getString("object");
678
    JSONArray tuts= object.getJSONArray("tutorials");
679
680
    int len = tuts.length();
681
    mTutorials = new String[len][4];
682
683
    for(int i=0; i<len; i++)
684
      {
685
      JSONObject tut = tuts.getJSONObject(i);
686
      mTutorials[i][0] = tut.getString("language");
687
      mTutorials[i][1] = tut.getString("link");
688
      mTutorials[i][2] = tut.getString("title");
689
      mTutorials[i][3] = tut.getString("author");
690
      }
691
    }
692
693 b39f8e39 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
694 84a17011 Leszek Koltunski
// PUBLIC
695 82eb152a Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
696
697 3ce95490 Leszek Koltunski
  public void parseJsonFile(InputStream jsonStream) throws JSONException, IOException
698 82eb152a Leszek Koltunski
    {
699
    BufferedReader br = new BufferedReader(new InputStreamReader(jsonStream, StandardCharsets.UTF_8));
700 3ce95490 Leszek Koltunski
    StringBuilder contents = new StringBuilder();
701 f8a992a9 Leszek Koltunski
    String line;
702 82eb152a Leszek Koltunski
703 f8a992a9 Leszek Koltunski
    while( (line = br.readLine()) != null) contents.append(line);
704 3ce95490 Leszek Koltunski
    br.close();
705
    jsonStream.close();
706 f8a992a9 Leszek Koltunski
    String contentsString = contents.toString();
707
    JSONObject object = new JSONObject(contentsString);
708 3ce95490 Leszek Koltunski
    int major = object.getInt("major");
709 82eb152a Leszek Koltunski
710 27a44b5e Leszek Koltunski
    if( major>=6 )
711 882a8142 Leszek Koltunski
      {
712 28bfa000 Leszek Koltunski
      parseFile(object,major);
713 882a8142 Leszek Koltunski
      }
714 3ce95490 Leszek Koltunski
    else
715 82eb152a Leszek Koltunski
      {
716 3ce95490 Leszek Koltunski
      android.util.Log.e("readJsonFile", "Unknown version "+major);
717 82eb152a Leszek Koltunski
      }
718
    }
719
720 b39f8e39 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
721
722 3ce95490 Leszek Koltunski
  public void parseJsonFileMetadata(InputStream jsonStream) throws JSONException, IOException
723 b39f8e39 Leszek Koltunski
    {
724
    BufferedReader br = new BufferedReader(new InputStreamReader(jsonStream, StandardCharsets.UTF_8));
725 3ce95490 Leszek Koltunski
    StringBuilder contents = new StringBuilder();
726
    String tmp;
727 b39f8e39 Leszek Koltunski
728 3ce95490 Leszek Koltunski
    while( (tmp = br.readLine()) != null) contents.append(tmp);
729
    br.close();
730
    jsonStream.close();
731 b39f8e39 Leszek Koltunski
732 3ce95490 Leszek Koltunski
    JSONObject object = new JSONObject(contents.toString());
733
    int major = object.getInt("major");
734 b39f8e39 Leszek Koltunski
735 27a44b5e Leszek Koltunski
    if( major>=6 )
736 882a8142 Leszek Koltunski
      {
737 80fd07aa Leszek Koltunski
      JSONObject metadata = object.getJSONObject("metadata");
738
      parseMetadata(metadata);
739 882a8142 Leszek Koltunski
      }
740 3ce95490 Leszek Koltunski
    else
741 b39f8e39 Leszek Koltunski
      {
742 3ce95490 Leszek Koltunski
      android.util.Log.e("readJsonFileQuick", "Unknown version "+major);
743 b39f8e39 Leszek Koltunski
      }
744
    }
745
746 bf52deb2 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
747
748 440f8e33 Leszek Koltunski
  public void readNumScramblesAndPrice(InputStream stream) throws IOException, JSONException
749 bf52deb2 Leszek Koltunski
    {
750 3ce95490 Leszek Koltunski
    BufferedReader br = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8));
751 bf52deb2 Leszek Koltunski
752 3ce95490 Leszek Koltunski
    StringBuilder contents = new StringBuilder();
753
    String tmp;
754
    while( (tmp = br.readLine()) != null) contents.append(tmp);
755
    br.close();
756
    stream.close();
757 ef021035 Leszek Koltunski
758 3ce95490 Leszek Koltunski
    JSONObject object = new JSONObject(contents.toString());
759
    JSONObject metadata = object.getJSONObject("metadata");
760 84224c99 Leszek Koltunski
    mNumScrambles = metadata.getInt("scrambles");
761 8b3b1d85 Leszek Koltunski
762
    boolean free = metadata.optBoolean("free",true);
763
    if( free ) mPrice = 0;
764
    else mPrice = metadata.optInt("price", ObjectType.DEFAULT_PRICE_OF_OLD_OBJECTS );
765 bf52deb2 Leszek Koltunski
    }
766
767 052e0362 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
768
769 3ce95490 Leszek Koltunski
  public void parseJsonTutorial(InputStream jsonStream) throws IOException, JSONException
770 052e0362 Leszek Koltunski
    {
771
    BufferedReader br = new BufferedReader(new InputStreamReader(jsonStream, StandardCharsets.UTF_8));
772 3ce95490 Leszek Koltunski
    StringBuilder contents = new StringBuilder();
773
    String tmp;
774 052e0362 Leszek Koltunski
775 3ce95490 Leszek Koltunski
    while( (tmp = br.readLine()) != null) contents.append(tmp);
776
    br.close();
777
    jsonStream.close();
778 052e0362 Leszek Koltunski
779 3ce95490 Leszek Koltunski
    JSONObject object = new JSONObject(contents.toString());
780
    int major = object.getInt("major");
781 052e0362 Leszek Koltunski
782 27a44b5e Leszek Koltunski
    if( major==1 )
783 052e0362 Leszek Koltunski
      {
784 84a17011 Leszek Koltunski
      parseTutorial(object);
785 052e0362 Leszek Koltunski
      }
786 3ce95490 Leszek Koltunski
    else
787 052e0362 Leszek Koltunski
      {
788 3ce95490 Leszek Koltunski
      android.util.Log.e("readJsonFile", "Unknown tutorial version "+major);
789 052e0362 Leszek Koltunski
      }
790
    }
791
792 82eb152a Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
793
794 9ba7f3f6 Leszek Koltunski
  public int getScrambleType()
795
    {
796
    return mScrambleType;
797
    }
798
799
///////////////////////////////////////////////////////////////////////////////////////////////////
800
801
  public int[][] getScrambleEdges()
802 82eb152a Leszek Koltunski
    {
803 9ba7f3f6 Leszek Koltunski
    return mEdges;
804
    }
805
806
///////////////////////////////////////////////////////////////////////////////////////////////////
807
808
  public int[][] getScrambleAlgorithms()
809
    {
810
    return mAlgorithms;
811 82eb152a Leszek Koltunski
    }
812
813
///////////////////////////////////////////////////////////////////////////////////////////////////
814
815 19595510 Leszek Koltunski
  public int[][] getSolvedQuats()
816 82eb152a Leszek Koltunski
    {
817 19595510 Leszek Koltunski
    return mSolvedQuats;
818 82eb152a Leszek Koltunski
    }
819
820
///////////////////////////////////////////////////////////////////////////////////////////////////
821
822
  public Static4D[] getQuats()
823
    {
824
    return mQuats;
825
    }
826
827
///////////////////////////////////////////////////////////////////////////////////////////////////
828
829
  public int getSolvedFunctionIndex()
830
    {
831
    return mSolvedFuncIndex;
832
    }
833
834
///////////////////////////////////////////////////////////////////////////////////////////////////
835
836
  public int getNumStickerTypes()
837
    {
838
    return mNumStickerTypes;
839
    }
840
841
///////////////////////////////////////////////////////////////////////////////////////////////////
842
843
  public float[][] getCuts()
844
    {
845
    return mCuts;
846
    }
847
848
///////////////////////////////////////////////////////////////////////////////////////////////////
849
850
  public boolean[][] getLayerRotatable()
851
    {
852
    return mLayerRotatable;
853
    }
854
855
///////////////////////////////////////////////////////////////////////////////////////////////////
856
857
  public int getMovementType()
858
    {
859
    return mMovementType;
860
    }
861
862
///////////////////////////////////////////////////////////////////////////////////////////////////
863
864
  public int getMovementSplit()
865
    {
866
    return mMovementSplit;
867
    }
868
869
///////////////////////////////////////////////////////////////////////////////////////////////////
870
871
  public int[][][] getEnabled()
872
    {
873
    return mEnabled;
874
    }
875
876
///////////////////////////////////////////////////////////////////////////////////////////////////
877
878
  public float[] getDist3D()
879
    {
880
    return mDist3D;
881
    }
882
883 d66e98d7 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
884
885
  public int getNumCubitFaces()
886
    {
887
    return mNumCubitFaces;
888
    }
889
890 82eb152a Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
891
892
  public float[][] getCubitPositions()
893
    {
894
    return mPositions;
895
    }
896
897
///////////////////////////////////////////////////////////////////////////////////////////////////
898
899
  public ObjectShape getObjectShape(int variant)
900
    {
901
    return mShapes[variant];
902
    }
903
904 3ee1d662 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
905
906
  public ObjectFaceShape getObjectFaceShape(int variant)
907
    {
908
    return mFaceShapes[variant];
909
    }
910
911 84a17011 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
912
913
  public ObjectVertexEffects getVertexEffects(int variant)
914
    {
915
    return mVertexEffects[variant];
916
    }
917
918 82eb152a Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
919
920 d0e6cf7f Leszek Koltunski
  public Static4D getCubitQuats(int cubit)
921 82eb152a Leszek Koltunski
    {
922
    return mCubitQuats[cubit];
923
    }
924
925
///////////////////////////////////////////////////////////////////////////////////////////////////
926
927
  public int getNumCubitVariants()
928
    {
929
    return mNumCubitVariants;
930
    }
931
932
///////////////////////////////////////////////////////////////////////////////////////////////////
933
934
  public int getCubitVariant(int cubit)
935
    {
936
    return mCubitVariant[cubit];
937
    }
938
939
///////////////////////////////////////////////////////////////////////////////////////////////////
940
941 51262d81 Leszek Koltunski
  public int getVariantStickerShape(int variant, int face)
942 82eb152a Leszek Koltunski
    {
943 51262d81 Leszek Koltunski
    int[] shapes = mVariantStickerShape[variant];
944
    return shapes.length>face ? shapes[face] : -1;
945 82eb152a Leszek Koltunski
    }
946
947 7aae846c Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
948
949
  public int[] getCubitTypes()
950
    {
951
    return mCubitType;
952
    }
953
954
///////////////////////////////////////////////////////////////////////////////////////////////////
955
956
  public float[][] getCubitOffsets()
957
    {
958
    return mCubitRowOffset;
959
    }
960
961 40e77224 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
962
963
  public int[][] getVariantFaceIsOuter()
964
    {
965
    return mVariantFaceIsOuter;
966
    }
967
968 82eb152a Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
969
970 ed0988c0 Leszek Koltunski
  public int getCubitFaceFace(int cubit, int face)
971 82eb152a Leszek Koltunski
    {
972
    return mCubitFaceColor[cubit][face];
973
    }
974
975 e1a86bf2 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
976
977
  public int getNumScrambles()
978
    {
979
    return mNumScrambles;
980
    }
981
982 84224c99 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
983
984 8b3b1d85 Leszek Koltunski
  public int getPrice()
985 84224c99 Leszek Koltunski
    {
986 8b3b1d85 Leszek Koltunski
    return mPrice;
987 84224c99 Leszek Koltunski
    }
988
989 82eb152a Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
990
991
  public ObjectSticker retSticker(int sticker)
992
    {
993
    return mObjectSticker[sticker];
994
    }
995 3a0a23bf Leszek Koltunski
996
///////////////////////////////////////////////////////////////////////////////////////////////////
997
998
  public ObjectStickerOverride[] getStickerOverrides()
999
    {
1000
    return mStickerOverrides;
1001
    }
1002 82eb152a Leszek Koltunski
1003 6db8fe2e Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
1004
1005
  public float getPillowCoeff()
1006
    {
1007
    return mPillowCoeff;
1008
    }
1009
1010 82eb152a Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
1011
1012
  public Static3D[] getRotationAxis()
1013
    {
1014
    return mAxis;
1015
    }
1016
1017
///////////////////////////////////////////////////////////////////////////////////////////////////
1018
1019 beee90ab Leszek Koltunski
  public int[][] getBasicAngle()
1020 82eb152a Leszek Koltunski
    {
1021
    return mBasicAngle;
1022
    }
1023
1024
///////////////////////////////////////////////////////////////////////////////////////////////////
1025
1026 1d581993 Leszek Koltunski
  public ObjectSignature getSignature()
1027 82eb152a Leszek Koltunski
    {
1028 5f54927b Leszek Koltunski
    return mSignature;
1029 82eb152a Leszek Koltunski
    }
1030
1031
///////////////////////////////////////////////////////////////////////////////////////////////////
1032
1033
  public String getObjectName()
1034
    {
1035
    return mLongName;
1036
    }
1037
1038 e1a86bf2 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
1039
1040
  public String getShortName()
1041
    {
1042
    return mShortName;
1043
    }
1044
1045 82eb152a Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
1046
1047
  public String getInventor()
1048
    {
1049
    return mInventor;
1050
    }
1051
1052
///////////////////////////////////////////////////////////////////////////////////////////////////
1053
1054
  public int getYearOfInvention()
1055
    {
1056
    return mYearOfInvention;
1057
    }
1058
1059
///////////////////////////////////////////////////////////////////////////////////////////////////
1060
1061
  public int getComplexity()
1062
    {
1063
    return mComplexity;
1064
    }
1065
1066
///////////////////////////////////////////////////////////////////////////////////////////////////
1067
1068
  public int getNumFaces()
1069
    {
1070
    return mNumFaces;
1071
    }
1072
1073
///////////////////////////////////////////////////////////////////////////////////////////////////
1074
1075
  public int getNumFaceColors()
1076
    {
1077
    return mNumFaceColors;
1078
    }
1079
1080
///////////////////////////////////////////////////////////////////////////////////////////////////
1081
1082
  public int[] getNumLayers()
1083
    {
1084
    return mNumLayers;
1085
    }
1086
1087
///////////////////////////////////////////////////////////////////////////////////////////////////
1088
1089
  public float getSize()
1090
    {
1091
    return mSize;
1092
    }
1093
1094
///////////////////////////////////////////////////////////////////////////////////////////////////
1095
1096
  public int getColor(int face)
1097
    {
1098
    return mColor[face];
1099
    }
1100 0f72365b Leszek Koltunski
1101 253e440f Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
1102
1103
  public int getInternalColor()
1104
    {
1105
    return mInternalColor;
1106
    }
1107
1108 0f72365b Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
1109
1110
  public boolean shouldResetTextureMaps()
1111
    {
1112
    return mResetMaps;
1113
    }
1114 052e0362 Leszek Koltunski
1115
///////////////////////////////////////////////////////////////////////////////////////////////////
1116
1117
  public String getTutorialObject()
1118
    {
1119
    return mTutorialObject;
1120
    }
1121
1122
///////////////////////////////////////////////////////////////////////////////////////////////////
1123
1124
  public String[][] getTutorials()
1125
    {
1126
    return mTutorials;
1127
    }
1128 82eb152a Leszek Koltunski
}