Project

General

Profile

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

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

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2021 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Distorted.                                                               //
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.json;
11

    
12
import static org.distorted.objectlib.objects.TwistyBandagedCuboid.OBJECT_NAME_CUBOID;
13
import static org.distorted.objectlib.objects.TwistyBandagedDiamond.OBJECT_NAME_DIAMOND;
14
import static org.distorted.objectlib.objects.TwistyBandagedMegaminx.OBJECT_NAME_MEGAMINX;
15
import static org.distorted.objectlib.objects.TwistyBandagedPyraminx.OBJECT_NAME_PYRAMINX;
16
import static org.distorted.objectlib.objects.TwistyBandagedSkewb.OBJECT_NAME_SKEWB;
17
import static org.distorted.objectlib.scrambling.ObjectScrambler.SCRAMBLING_ALGORITHMS;
18
import static org.distorted.objectlib.scrambling.ObjectScrambler.SCRAMBLING_SHAPESHIFTER;
19
import static org.distorted.objectlib.scrambling.ScrambleStateLocallyBandaged.MAX_SUPPORTED_SIZE;
20

    
21
import java.io.BufferedReader;
22
import java.io.IOException;
23
import java.io.InputStream;
24
import java.io.InputStreamReader;
25
import java.nio.charset.StandardCharsets;
26

    
27
import org.distorted.objectlib.helpers.ObjectFaceShape;
28
import org.distorted.objectlib.signature.ObjectSignature;
29
import org.distorted.objectlib.helpers.ObjectStickerOverride;
30
import org.distorted.objectlib.helpers.ObjectVertexEffects;
31
import org.distorted.objectlib.main.TwistyObjectCubit;
32
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator;
33
import org.distorted.objectlib.signature.ObjectSignatureCuboid;
34
import org.distorted.objectlib.signature.ObjectSignatureDiamond;
35
import org.distorted.objectlib.signature.ObjectSignatureMegaminx;
36
import org.distorted.objectlib.signature.ObjectSignaturePyraminx;
37
import org.distorted.objectlib.signature.ObjectSignatureSkewb;
38
import org.json.JSONArray;
39
import org.json.JSONException;
40
import org.json.JSONObject;
41

    
42
import org.distorted.library.type.Static3D;
43
import org.distorted.library.type.Static4D;
44

    
45
import org.distorted.objectlib.helpers.ObjectShape;
46
import org.distorted.objectlib.helpers.ObjectSticker;
47
import org.distorted.objectlib.metadata.ListObjects;
48

    
49
///////////////////////////////////////////////////////////////////////////////////////////////////
50

    
51
public class JsonReader
52
{
53
  private int[][] mAlgorithms;
54
  private int[][] mEdges;
55
  private int[][] mSolvedQuats;
56
  private Static4D[] mQuats;
57
  private int mSolvedFuncIndex;
58
  private int mNumStickerTypes;
59
  private float[][] mCuts;
60
  private boolean[][] mLayerRotatable;
61
  private float[][] mRotationFactor;
62
  private int mMovementType, mMovementSplit;
63
  private int[][][] mEnabled;
64
  private float[] mDist3D;
65
  private int mNumCubitFaces, mNumFaces;
66
  private float[][] mPositions;
67
  private ObjectShape[] mShapes;
68
  private ObjectFaceShape[] mFaceShapes;
69
  private ObjectVertexEffects[] mVertexEffects;
70
  private Static4D[] mCubitQuats;
71
  private int mNumCubitVariants;
72
  private int[] mCubitVariant;
73
  private int[][] mVariantStickerShape, mVariantFaceIsOuter, mCubitFaceColor;
74
  private ObjectSticker[] mObjectSticker;
75
  private Static3D[] mAxis;
76
  private int[][] mBasicAngle;
77
  private String mLongName, mShortName, mAuthor;
78
  private int mYearOfInvention;
79
  private float mDifficulty;
80
  private int mCategory;
81
  private int[] mNumLayers;
82
  private float mSize;
83
  private int mScrambleType, mNumScrambles;
84
  private int mPrice;
85
  private int[] mColorTable;
86
  private int mInternalColor;
87
  private boolean mResetMaps;
88
  private String mTutorialObject;
89
  private String[][] mTutorials;
90
  private ObjectSignature mSignature;
91
  private int[] mCubitType;
92
  private float[][] mCubitRowOffset;
93
  private ObjectStickerOverride[] mStickerOverrides;
94
  private float mPillowCoeff;
95
  private int[][] mMinimalCubitsInRow;
96
  private boolean mSupportsAdjustableColors;
97

    
98
///////////////////////////////////////////////////////////////////////////////////////////////////
99

    
100
  public static ObjectSignature produceSignature(String shortName, String longName, long[] signature)
101
    {
102
    // 'BAN*_*' ( or future possible 'BA**_*' ) objects
103
    if( shortName.charAt(0)=='B' && shortName.charAt(1)=='A' && shortName.charAt(4)=='_' )
104
      {
105
      char second = shortName.charAt(2);
106
      char third  = shortName.charAt(3);
107

    
108
      if( (second=='N' || (second>='0' && second<='9')) && (third>='0' && third<='9') )
109
        {
110
        int s = shortName.charAt(5) - '0';
111
        if( s>=2 && s<=MAX_SUPPORTED_SIZE ) return new ObjectSignatureCuboid(s,s,s,signature);
112
        }
113
      }
114

    
115
    if( longName.equals(OBJECT_NAME_CUBOID) )
116
      {
117
      int x=shortName.charAt(0)-'0';
118
      int y=shortName.charAt(1)-'0';
119
      int z=shortName.charAt(2)-'0';
120
      return new ObjectSignatureCuboid(x,y,z,signature);
121
      }
122
    if( longName.equals(OBJECT_NAME_PYRAMINX) )
123
      {
124
      int x=shortName.charAt(1)-'0';
125
      return new ObjectSignaturePyraminx(x,signature);
126
      }
127
    if( longName.equals(OBJECT_NAME_MEGAMINX) )
128
      {
129
      int x=shortName.charAt(1)-'0';
130
      return new ObjectSignatureMegaminx(x,signature);
131
      }
132
    if( longName.equals(OBJECT_NAME_DIAMOND) )
133
      {
134
      int x=shortName.charAt(1)-'0';
135
      return new ObjectSignatureDiamond(x,signature);
136
      }
137
    if( longName.equals(OBJECT_NAME_SKEWB) )
138
      {
139
      int x=shortName.charAt(1)-'0';
140
      return new ObjectSignatureSkewb(x,signature);
141
      }
142

    
143
    return new ObjectSignature(signature);
144
    }
145

    
146
///////////////////////////////////////////////////////////////////////////////////////////////////
147

    
148
  private void parseMetadata(JSONObject metadata, int major) throws JSONException
149
    {
150
    mLongName        = metadata.getString("longname");
151
    mShortName       = metadata.getString("shortname");
152
    mAuthor          = metadata.getString("inventor");
153
    mYearOfInvention = metadata.getInt("year");
154
    mSize            = (float)metadata.getDouble("size");
155
    mNumScrambles    = metadata.getInt("scrambles");
156
    mResetMaps       = metadata.getBoolean("resetmaps");
157
    mNumFaces        = metadata.getInt("num_faces");
158

    
159
    if( major<=13 )
160
      {
161
      mDifficulty = metadata.getInt("complexity");
162
      mCategory   = 0;
163
      }
164
    else
165
      {
166
      mDifficulty = (float)metadata.getDouble("complexity");
167
      mCategory   = metadata.getInt("category");
168
      }
169

    
170
    try
171
      {
172
      JSONArray sigArray = metadata.getJSONArray("signature");
173
      int size = sigArray.length();
174
      long[] signature = new long[size];
175
      for(int i=0; i<size; i++) signature[i] = sigArray.getLong(i);
176
      mSignature = produceSignature(mShortName,mLongName,signature);
177
      }
178
    catch(JSONException ex)
179
      {
180
      long signature = metadata.getLong("signature");
181
      mSignature = new ObjectSignature(signature);
182
      }
183

    
184
    boolean free = metadata.optBoolean("free", true);
185

    
186
    if( free ) mPrice = 0;
187
    else mPrice = metadata.optInt("price", ListObjects.DEFAULT_PRICE_OF_OLD_OBJECTS );
188

    
189
    mSupportsAdjustableColors = metadata.optBoolean("adj_colors", true);
190
    }
191

    
192
///////////////////////////////////////////////////////////////////////////////////////////////////
193

    
194
  private void parseCubits(JSONArray object) throws JSONException
195
    {
196
    int numCubits = object.length();
197

    
198
    mCubitQuats     = new Static4D[numCubits];
199
    mCubitVariant   = new int[numCubits];
200
    mPositions      = new float[numCubits][];
201
    mCubitFaceColor = new int[numCubits][];
202
    mCubitType      = new int[numCubits];
203
    mCubitRowOffset = new float[numCubits][];
204

    
205
    for(int i=0; i<numCubits; i++)
206
      {
207
      JSONObject jsonCubit = object.getJSONObject(i);
208

    
209
      float qx = (float)jsonCubit.getDouble("qx");
210
      float qy = (float)jsonCubit.getDouble("qy");
211
      float qz = (float)jsonCubit.getDouble("qz");
212
      float qw = (float)jsonCubit.getDouble("qw");
213

    
214
      mCubitQuats[i] = new Static4D(qx,qy,qz,qw);
215
      mCubitVariant[i] = jsonCubit.getInt("variant");
216

    
217
      JSONArray jsonCenter = jsonCubit.getJSONArray("centers");
218
      int numCenter = jsonCenter.length();
219
      mPositions[i] = new float[numCenter];
220
      for(int j=0; j<numCenter; j++) mPositions[i][j] = (float)jsonCenter.getDouble(j);
221

    
222
      JSONArray jsonColor  = jsonCubit.getJSONArray("colors");
223
      int numColor = jsonColor.length();
224
      mCubitFaceColor[i] = new int[numColor];
225
      for(int j=0; j<numColor; j++) mCubitFaceColor[i][j] = jsonColor.getInt(j);
226

    
227
      mCubitType[i] = jsonCubit.optInt("type", TwistyObjectCubit.TYPE_NORMAL);
228
      float xoff = (float)jsonCubit.optDouble("offsetX", 0 );
229
      float yoff = (float)jsonCubit.optDouble("offsetY", 0 );
230
      float zoff = (float)jsonCubit.optDouble("offsetZ", 0 );
231
      mCubitRowOffset[i] = new float[] {xoff,yoff,zoff};
232
      }
233
    }
234

    
235
///////////////////////////////////////////////////////////////////////////////////////////////////
236

    
237
  private void parseShapes(JSONArray object) throws JSONException
238
    {
239
    mNumCubitVariants     = object.length();
240
    mVariantStickerShape  = new int[mNumCubitVariants][];
241
    mVariantFaceIsOuter   = new int[mNumCubitVariants][];
242
    mShapes               = new ObjectShape[mNumCubitVariants];
243
    mFaceShapes           = new ObjectFaceShape[mNumCubitVariants];
244
    mVertexEffects        = new ObjectVertexEffects[mNumCubitVariants];
245
    mNumCubitFaces = -1;
246

    
247
    for(int i=0; i<mNumCubitVariants; i++)
248
      {
249
      JSONObject jsonShape = object.getJSONObject(i);
250

    
251
      /////////////////////////////////////////////////////////////////////////
252
      ////// ObjectShape //////////////////////////////////////////////////////
253
      JSONArray jsonVertices= jsonShape.getJSONArray("vertices");
254
      int numVertices = jsonVertices.length();
255
      float[][] verts = new float[numVertices][3];
256

    
257
      for(int v=0; v<numVertices; v++)
258
        {
259
        JSONObject vert = jsonVertices.getJSONObject(v);
260
        verts[v][0] = (float)vert.getDouble("x");
261
        verts[v][1] = (float)vert.getDouble("y");
262
        verts[v][2] = (float)vert.getDouble("z");
263
        }
264

    
265
      JSONArray jsonFaces= jsonShape.getJSONArray("faces");
266
      int numFaces = jsonFaces.length();
267
      if( mNumCubitFaces<numFaces ) mNumCubitFaces=numFaces;
268
      boolean multigon = jsonShape.optBoolean("facesMultigon", false);
269

    
270
      if( !multigon )
271
        {
272
        int[][] vertIndices = new int[numFaces][];
273

    
274
        for(int f=0; f<numFaces; f++)
275
          {
276
          JSONObject jsonFace = jsonFaces.getJSONObject(f);
277
          JSONArray vertices = jsonFace.getJSONArray("vertexIndices");
278
          int numV = vertices.length();
279
          vertIndices[f] = new int[numV];
280
          for(int k=0; k<numV; k++) vertIndices[f][k] = vertices.getInt(k);
281
          }
282

    
283
        mShapes[i] = new ObjectShape(verts,vertIndices);
284
        }
285
      else
286
        {
287
        int[][][] vertIndices = new int[numFaces][][];
288

    
289
        for(int f=0; f<numFaces; f++)
290
          {
291
          JSONObject jsonFace = jsonFaces.getJSONObject(f);
292
          JSONArray vertices = jsonFace.getJSONArray("vertexIndices");
293
          int numC = vertices.length();
294
          vertIndices[f] = new int[numC][];
295

    
296
          for(int c=0; c<numC; c++)
297
            {
298
            JSONArray components = vertices.getJSONArray(c);
299
            int numV = components.length();
300
            vertIndices[f][c] = new int[numV];
301
            for(int k=0; k<numV; k++) vertIndices[f][c][k] = components.getInt(k);
302
            }
303
          }
304

    
305
        mShapes[i] = new ObjectShape(verts,vertIndices);
306
        }
307

    
308
      /////////////////////////////////////////////////////////////////////////
309
      ////// StickerShape & Outer /////////////////////////////////////////////
310
      mVariantStickerShape[i]= new int[numFaces];
311
      mVariantFaceIsOuter[i] = new int[numFaces];
312
      int[] bandIndices = new int[numFaces];
313

    
314
      for(int f=0; f<numFaces; f++)
315
        {
316
        JSONObject jsonFace = jsonFaces.getJSONObject(f);
317
        mVariantStickerShape[i][f]= jsonFace.getInt("sticker");
318
        mVariantFaceIsOuter[i][f] = jsonFace.optInt("isOuter",0);
319
        bandIndices[f] = jsonFace.getInt("bandIndex");
320
        }
321

    
322
      /////////////////////////////////////////////////////////////////////////
323
      ////// ObjectFaceShape //////////////////////////////////////////////////
324
      JSONArray jsonBands= jsonShape.getJSONArray("bands");
325
      int numBands = jsonBands.length();
326
      float[][] bands = new float[numBands][7];
327

    
328
      for(int b=0; b<numBands; b++)
329
        {
330
        JSONObject jsonBand = jsonBands.getJSONObject(b);
331
        float[] band = bands[b];
332

    
333
        band[0] = (float)jsonBand.getDouble("height");
334
        band[1] = (float)jsonBand.getDouble("angle");
335
        band[2] = (float)jsonBand.getDouble("distanceToCenter");
336
        band[3] = (float)jsonBand.getDouble("distanceToFlat");
337
        band[4] = (float)jsonBand.getDouble("numOfBands");
338
        band[5] = (float)jsonBand.getDouble("extraI");
339
        band[6] = (float)jsonBand.getDouble("extraJ");
340
        }
341

    
342
      JSONObject jsonConvexity = jsonShape.optJSONObject("convexity");
343
      float[] convexity = null;
344

    
345
      if( jsonConvexity!=null )
346
        {
347
        convexity = new float[3];
348
        convexity[0] = (float)jsonConvexity.getDouble("x");
349
        convexity[1] = (float)jsonConvexity.getDouble("y");
350
        convexity[2] = (float)jsonConvexity.getDouble("z");
351
        }
352

    
353
      mFaceShapes[i] = new ObjectFaceShape(bands,bandIndices,convexity);
354

    
355
      /////////////////////////////////////////////////////////////////////////
356
      ////// ObjectVertexEffects //////////////////////////////////////////////
357
      JSONArray jsonEffects = jsonShape.optJSONArray("effects");
358

    
359
      if( jsonEffects!=null )
360
        {
361
        int numEffects = jsonEffects.length();
362

    
363
        String[] name    = new String[numEffects];
364
        float[][] vars   = new float[numEffects][5];
365
        float[][] center = new float[numEffects][3];
366
        float[][] region = new float[numEffects][4];
367
        boolean[] use    = new boolean[numEffects];
368

    
369
        for(int j=0; j<numEffects; j++)
370
          {
371
          JSONObject jsonEffect = jsonEffects.getJSONObject(j);
372

    
373
          name[j] = jsonEffect.getString("name");
374

    
375
          vars[j][0] = (float)jsonEffect.getDouble("var0");
376
          vars[j][1] = (float)jsonEffect.getDouble("var1");
377
          vars[j][2] = (float)jsonEffect.getDouble("var2");
378
          vars[j][3] = (float)jsonEffect.getDouble("var3");
379
          vars[j][4] = (float)jsonEffect.getDouble("var4");
380

    
381
          center[j][0] = (float)jsonEffect.getDouble("center0");
382
          center[j][1] = (float)jsonEffect.getDouble("center1");
383
          center[j][2] = (float)jsonEffect.getDouble("center2");
384

    
385
          region[j][0] = (float)jsonEffect.getDouble("region0");
386
          region[j][1] = (float)jsonEffect.getDouble("region1");
387
          region[j][2] = (float)jsonEffect.getDouble("region2");
388
          region[j][3] = (float)jsonEffect.getDouble("region3");
389

    
390
          use[j] = jsonEffect.getBoolean("use");
391
          }
392

    
393
        mVertexEffects[i] = new ObjectVertexEffects(name,vars,center,region,use);
394
        }
395
      }
396
    }
397

    
398
///////////////////////////////////////////////////////////////////////////////////////////////////
399

    
400
  private void parseStickers11(JSONArray object) throws JSONException
401
    {
402
    mNumStickerTypes = object.length();
403
    mObjectSticker = new ObjectSticker[mNumStickerTypes];
404

    
405
    for(int i=0; i<mNumStickerTypes; i++)
406
      {
407
      JSONObject sticker = object.getJSONObject(i);
408
      float stroke = (float)sticker.getDouble("stroke");
409
      JSONArray vertices = sticker.getJSONArray("vertices");
410
      int numVertices = vertices.length();
411

    
412
      float[][][] coords   = new float[1][numVertices][2];
413
      float[][] curvatures = new float[1][numVertices];
414
      float[][] radii      = new float[1][numVertices];
415
      float[][] strokes    = new float[1][numVertices];
416

    
417
      for(int j=0; j<numVertices; j++)
418
        {
419
        JSONObject vertex = vertices.getJSONObject(j);
420

    
421
        coords[0][j][0]  = (float)vertex.getDouble("x");
422
        coords[0][j][1]  = (float)vertex.getDouble("y");
423
        curvatures[0][j] = (float)vertex.getDouble("angle");
424
        radii[0][j]      = (float)vertex.getDouble("radius");
425
        strokes[0][j]    = stroke;
426
        }
427

    
428
      mObjectSticker[i] = new ObjectSticker(coords,curvatures,radii,strokes);
429
      }
430
    }
431

    
432
///////////////////////////////////////////////////////////////////////////////////////////////////
433

    
434
  private void parseStickers12to14(JSONArray object) throws JSONException
435
    {
436
    mNumStickerTypes = object.length();
437
    mObjectSticker = new ObjectSticker[mNumStickerTypes];
438

    
439
    for(int i=0; i<mNumStickerTypes; i++)
440
      {
441
      JSONObject sticker = object.getJSONObject(i);
442
      float stroke = (float)sticker.getDouble("stroke");
443
      JSONArray loops = sticker.getJSONArray("loops");
444
      int numLoops = loops.length();
445

    
446
      float[][][] coords   = new float[numLoops][][];
447
      float[][] curvatures = new float[numLoops][];
448
      float[][] radii      = new float[numLoops][];
449
      float[][] strokes    = new float[numLoops][];
450

    
451
      for(int l=0; l<numLoops; l++)
452
        {
453
        JSONArray loop = loops.getJSONArray(l);
454
        int numVertices= loop.length();
455

    
456
        coords[l]     = new float[numVertices][2];
457
        curvatures[l] = new float[numVertices];
458
        radii[l]      = new float[numVertices];
459
        strokes[l]    = new float[numVertices];
460

    
461
        for(int v=0; v<numVertices; v++)
462
          {
463
          JSONObject vertex= loop.getJSONObject(v);
464

    
465
          coords[l][v][0]  = (float)vertex.getDouble("x");
466
          coords[l][v][1]  = (float)vertex.getDouble("y");
467
          curvatures[l][v] = (float)vertex.getDouble("angle");
468
          radii[l][v]      = (float)vertex.getDouble("radius");
469
          strokes[l][v]    = stroke;
470
          }
471
        }
472

    
473
      mObjectSticker[i] = new ObjectSticker(coords,curvatures,radii,strokes);
474
      }
475
    }
476

    
477
///////////////////////////////////////////////////////////////////////////////////////////////////
478

    
479
  private void parseStickers15up(JSONArray object) throws JSONException
480
    {
481
    mNumStickerTypes = object.length();
482
    mObjectSticker = new ObjectSticker[mNumStickerTypes];
483

    
484
    for(int i=0; i<mNumStickerTypes; i++)
485
      {
486
      JSONObject sticker = object.getJSONObject(i);
487
      JSONArray loops = sticker.getJSONArray("loops");
488
      int numLoops = loops.length();
489

    
490
      float[][][] coords   = new float[numLoops][][];
491
      float[][] curvatures = new float[numLoops][];
492
      float[][] radii      = new float[numLoops][];
493
      float[][] strokes    = new float[numLoops][];
494

    
495
      for(int l=0; l<numLoops; l++)
496
        {
497
        JSONArray loop = loops.getJSONArray(l);
498
        int numVertices= loop.length();
499

    
500
        coords[l]     = new float[numVertices][2];
501
        curvatures[l] = new float[numVertices];
502
        radii[l]      = new float[numVertices];
503
        strokes[l]    = new float[numVertices];
504

    
505
        for(int v=0; v<numVertices; v++)
506
          {
507
          JSONObject vertex= loop.getJSONObject(v);
508

    
509
          coords[l][v][0]  = (float)vertex.getDouble("x");
510
          coords[l][v][1]  = (float)vertex.getDouble("y");
511
          curvatures[l][v] = (float)vertex.getDouble("angle");
512
          radii[l][v]      = (float)vertex.getDouble("radius");
513
          strokes[l][v]    = (float)vertex.getDouble("stroke");
514
          }
515
        }
516

    
517
      mObjectSticker[i] = new ObjectSticker(coords,curvatures,radii,strokes);
518
      }
519
    }
520

    
521
///////////////////////////////////////////////////////////////////////////////////////////////////
522

    
523
  private void parseOverrides(JSONArray object) throws JSONException
524
    {
525
    if( object!=null )
526
      {
527
      int numOverrides = object.length();
528
      mStickerOverrides= new ObjectStickerOverride[numOverrides];
529

    
530
      for(int i=0; i<numOverrides; i++)
531
        {
532
        JSONObject override  = object.getJSONObject(i);
533
        JSONArray cubitArray = override.getJSONArray("cubitfaces");
534
        int color = override.getInt("color");
535
        int numCubits = cubitArray.length();
536
        int[] cubitface = new int[numCubits];
537
        for(int j=0; j<numCubits; j++) cubitface[j] = cubitArray.getInt(j);
538
        mStickerOverrides[i] = new ObjectStickerOverride(cubitface,color);
539
        }
540
      }
541
    else
542
      {
543
      mStickerOverrides = null;
544
      }
545
    }
546

    
547
///////////////////////////////////////////////////////////////////////////////////////////////////
548

    
549
  private void parseMesh(JSONObject object, int major) throws JSONException
550
    {
551
    JSONArray cubits   = object.getJSONArray("cubits");
552
    parseCubits(cubits);
553
    JSONArray shapes   = object.getJSONArray("shapes");
554
    parseShapes(shapes);
555
    JSONArray stickers = object.getJSONArray("stickers");
556
    if( major<=11 )      parseStickers11(stickers);
557
    else if( major<=14 ) parseStickers12to14(stickers);
558
    else                 parseStickers15up(stickers);
559

    
560
    JSONArray overrides= object.optJSONArray("overrides");
561
    parseOverrides(overrides);
562

    
563
    mPillowCoeff = (float)object.optDouble("pillow",1.0);
564
    }
565

    
566
///////////////////////////////////////////////////////////////////////////////////////////////////
567

    
568
  private void parseAxis(JSONArray object) throws JSONException
569
    {
570
    int numAxis = object.length();
571

    
572
    mBasicAngle     = new int[numAxis][];
573
    mAxis           = new Static3D[numAxis];
574
    mCuts           = new float[numAxis][];
575
    mLayerRotatable = new boolean[numAxis][];
576
    mRotationFactor = new float[numAxis][];
577
    mNumLayers      = new int[numAxis];
578

    
579
    for(int i=0; i<numAxis; i++)
580
      {
581
      JSONObject jsonAx = object.getJSONObject(i);
582

    
583
      float x = (float)jsonAx.getDouble("x");
584
      float y = (float)jsonAx.getDouble("y");
585
      float z = (float)jsonAx.getDouble("z");
586

    
587
      mAxis[i] = new Static3D(x,y,z);
588

    
589
      JSONArray jsonAngles = jsonAx.getJSONArray("basicAngles");
590
      int numAngles = jsonAngles.length();
591
      mBasicAngle[i] = new int[numAngles];
592
      for(int j=0; j<numAngles; j++) mBasicAngle[i][j] = jsonAngles.getInt(j);
593

    
594
      JSONArray jsonCuts = jsonAx.getJSONArray("cuts");
595
      int numCuts = jsonCuts.length();
596
      mCuts[i] = new float[numCuts];
597
      for(int j=0; j<numCuts; j++) mCuts[i][j] = (float)jsonCuts.getDouble(j);
598

    
599
      JSONArray jsonRota = jsonAx.getJSONArray("rotatable");
600
      int numRota = jsonRota.length();
601
      mLayerRotatable[i] = new boolean[numRota];
602
      for(int j=0; j<numRota; j++) mLayerRotatable[i][j] = jsonRota.getBoolean(j);
603

    
604
      JSONArray jsonFactor = jsonAx.optJSONArray("factor");
605

    
606
      if( jsonFactor!=null )
607
        {
608
        int numFactor = jsonFactor.length();
609
        mRotationFactor[i] = new float[numFactor];
610
        for(int j=0; j<numFactor; j++) mRotationFactor[i][j] = (float)jsonFactor.getDouble(j);
611
        }
612
      else
613
        {
614
        mRotationFactor[i] = new float[numRota];
615
        for(int j=0; j<numRota; j++) mRotationFactor[i][j] = 1.0f;
616
        }
617

    
618
      JSONArray jsonMinimal = jsonAx.optJSONArray("minimal");
619

    
620
      if( jsonMinimal!=null )
621
        {
622
        if( mMinimalCubitsInRow==null ) mMinimalCubitsInRow = new int[numAxis][];
623
        int numMinimal = jsonMinimal.length();
624
        mMinimalCubitsInRow[i] = new int[numMinimal];
625
        for(int j=0; j<numMinimal; j++) mMinimalCubitsInRow[i][j] = jsonMinimal.getInt(j);
626
        }
627

    
628
      mNumLayers[i] = numRota;
629
      }
630
    }
631

    
632
///////////////////////////////////////////////////////////////////////////////////////////////////
633

    
634
  private void parseQuats(JSONArray object) throws JSONException
635
    {
636
    int numQuats = object.length();
637
    mQuats = new Static4D[numQuats];
638

    
639
    for(int i=0; i<numQuats; i++)
640
      {
641
      JSONObject jsonQuat = object.getJSONObject(i);
642

    
643
      float x = (float)jsonQuat.getDouble("x");
644
      float y = (float)jsonQuat.getDouble("y");
645
      float z = (float)jsonQuat.getDouble("z");
646
      float w = (float)jsonQuat.getDouble("w");
647

    
648
      mQuats[i] = new Static4D(x,y,z,w);
649
      }
650
    }
651

    
652
///////////////////////////////////////////////////////////////////////////////////////////////////
653

    
654
  private int getAlgorithmIndex(int ax, int layer, int angle)
655
    {
656
    int numAlgs = mAlgorithms.length;
657

    
658
    for(int alg=0; alg<numAlgs; alg++)
659
      {
660
      int[] a = mAlgorithms[alg];
661
      if( a.length>=3 && a[0]==ax && a[1]==layer && a[2]==angle ) return alg;
662
      }
663

    
664
    return -1;
665
    }
666

    
667
///////////////////////////////////////////////////////////////////////////////////////////////////
668

    
669
  private int[] produceEdge(int[][] scramblingData)
670
    {
671
    int index=0, length=0;
672
    int numAxis = scramblingData.length;
673
    for (int[] scramblingDatum : scramblingData) length += scramblingDatum.length;
674

    
675
    int[] ret = new int[2*length/3];
676

    
677
    for(int ax=0; ax<numAxis; ax++)
678
      {
679
      int[] data = scramblingData[ax];
680
      int num = data.length/3;
681

    
682
      for(int j=0; j<num; j++)
683
        {
684
        int layer = data[3*j];
685
        int angle = data[3*j+1];
686
        int state = data[3*j+2];
687

    
688
        ret[2*index  ] = getAlgorithmIndex(ax,layer,angle);
689
        ret[2*index+1] = state;
690
        index++;
691
        }
692
      }
693

    
694
    return ret;
695
    }
696

    
697
///////////////////////////////////////////////////////////////////////////////////////////////////
698

    
699
  private void parseScrambling6(JSONObject object) throws JSONException
700
    {
701
    JSONArray jsonStates = object.getJSONArray("scrambleStates");
702
    int numStates = jsonStates.length();
703
    int[][][] scramblingData = new int[numStates][][];
704

    
705
    for(int i=0; i<numStates; i++)
706
      {
707
      JSONArray jsonState = jsonStates.getJSONArray(i);
708
      int numAxis = jsonState.length();
709
      scramblingData[i] = new int[numAxis][];
710

    
711
      for(int j=0; j<numAxis; j++)
712
        {
713
        JSONArray jsonData = jsonState.getJSONArray(j);
714
        int numData = jsonData.length();
715
        scramblingData[i][j] = new int[numData];
716
        for(int k=0; k<numData; k++) scramblingData[i][j][k] = jsonData.getInt(k);
717
        }
718
      }
719

    
720
    mAlgorithms = ScrambleEdgeGenerator.getScramblingAlgorithms(mBasicAngle);
721
    mEdges = new int[numStates][];
722
    for(int i=0; i<numStates; i++) mEdges[i] = produceEdge(scramblingData[i]);
723
    }
724

    
725
///////////////////////////////////////////////////////////////////////////////////////////////////
726

    
727
  private void parseScrambling7to10(JSONObject object) throws JSONException
728
    {
729
    JSONArray jsonAlgorithms = object.getJSONArray("algorithms");
730
    int numAlgs = jsonAlgorithms.length();
731
    mAlgorithms = new int[numAlgs][];
732

    
733
    for(int i=0; i<numAlgs; i++)
734
      {
735
      JSONArray jsonAlg = jsonAlgorithms.getJSONArray(i);
736
      int numEntries = jsonAlg.length();
737
      mAlgorithms[i] = new int[numEntries];
738
      for(int j=0; j<numEntries; j++)
739
        {
740
        int entry = jsonAlg.getInt(j);
741
        mAlgorithms[i][j] = ( (j%3)==1 ? (1<<entry) : entry );
742
        }
743
      }
744

    
745
    JSONArray jsonEdges = object.getJSONArray("edges");
746
    int numEdges = jsonEdges.length();
747
    mEdges = new int[numEdges][];
748

    
749
    for(int i=0; i<numEdges; i++)
750
      {
751
      JSONArray jsonEdge = jsonEdges.getJSONArray(i);
752
      int numEntries = jsonEdge.length();
753
      mEdges[i] = new int[numEntries];
754
      for(int j=0; j<numEntries; j++) mEdges[i][j] = jsonEdge.getInt(j);
755
      }
756
    }
757

    
758
///////////////////////////////////////////////////////////////////////////////////////////////////
759

    
760
  private void parseScrambling11orMore(JSONObject object) throws JSONException
761
    {
762
    JSONArray jsonAlgorithms = object.getJSONArray("algorithms");
763
    int numAlgs = jsonAlgorithms.length();
764
    mAlgorithms = new int[numAlgs][];
765

    
766
    for(int i=0; i<numAlgs; i++)
767
      {
768
      JSONArray jsonAlg = jsonAlgorithms.getJSONArray(i);
769
      int numEntries = jsonAlg.length();
770
      mAlgorithms[i] = new int[numEntries];
771
      for(int j=0; j<numEntries; j++) mAlgorithms[i][j] = jsonAlg.getInt(j);
772
      }
773

    
774
    JSONArray jsonEdges = object.getJSONArray("edges");
775
    int numEdges = jsonEdges.length();
776
    mEdges = new int[numEdges][];
777

    
778
    for(int i=0; i<numEdges; i++)
779
      {
780
      JSONArray jsonEdge = jsonEdges.getJSONArray(i);
781
      int numEntries = jsonEdge.length();
782
      mEdges[i] = new int[numEntries];
783
      for(int j=0; j<numEntries; j++) mEdges[i][j] = jsonEdge.getInt(j);
784
      }
785
    }
786

    
787
///////////////////////////////////////////////////////////////////////////////////////////////////
788

    
789
  private void parseScrambling(JSONObject object, int major) throws JSONException
790
    {
791
    mScrambleType = object.getInt("scrambleType");
792

    
793
    if( mScrambleType==SCRAMBLING_ALGORITHMS || mScrambleType==SCRAMBLING_SHAPESHIFTER )
794
      {
795
      if( major==6 )       parseScrambling6(object);
796
      else if( major<=10 ) parseScrambling7to10(object);
797
      else                 parseScrambling11orMore(object);
798
      }
799
    }
800

    
801
///////////////////////////////////////////////////////////////////////////////////////////////////
802

    
803
  private void parseTouchcontrol(JSONObject object) throws JSONException
804
    {
805
    mMovementType = object.getInt("movementType");
806
    mMovementSplit= object.getInt("movementSplit");
807

    
808
    try
809
      {
810
      JSONArray jsonEnabled = object.getJSONArray("enabledAxis");
811
      int numFace = jsonEnabled.length();
812

    
813
      mEnabled = new int[numFace][][];
814

    
815
      for(int i=0; i<numFace; i++)
816
        {
817
        JSONArray jsonSection = jsonEnabled.getJSONArray(i);
818
        int numSection = jsonSection.length();
819
        mEnabled[i] = new int[numSection][];
820

    
821
        for(int j=0; j<numSection; j++)
822
          {
823
          JSONArray jsonAx = jsonSection.getJSONArray(j);
824
          int numAxis = jsonAx.length();
825
          mEnabled[i][j] = new int[numAxis];
826
          for(int k=0; k<numAxis; k++) mEnabled[i][j][k] = jsonAx.getInt(k);
827
          }
828
        }
829
      }
830
    catch( JSONException ex )
831
      {
832
      // ignore, the object does not have to have 'enabledAxis' defined at all.
833
      }
834

    
835
    try
836
      {
837
      JSONArray jsonDist = object.getJSONArray("dist3D");
838
      int num = jsonDist.length();
839
      mDist3D = new float[num];
840
      for(int j=0; j<num; j++) mDist3D[j] = (float)jsonDist.getDouble(j);
841
      }
842
    catch( JSONException ex )
843
      {
844
      // ignore, the object does not have a 'dist3D' which is possible.
845
      }
846
    }
847

    
848
///////////////////////////////////////////////////////////////////////////////////////////////////
849

    
850
  private void parseColors(JSONArray object) throws JSONException
851
    {
852
    int num = object.length()-1;
853
    mColorTable = new int[num];
854
    for(int i=0; i<num; i++) mColorTable[i] = object.getInt(i);
855
    mInternalColor = object.getInt(num);
856
    }
857

    
858
///////////////////////////////////////////////////////////////////////////////////////////////////
859

    
860
  private void parseSolved(JSONObject solved) throws JSONException
861
    {
862
    mSolvedFuncIndex = solved.getInt("functionIndex");
863

    
864
    try
865
      {
866
      JSONArray groupArray= solved.getJSONArray("groups");
867
      int numGroups = groupArray.length();
868
      mSolvedQuats  = new int[numGroups][];
869

    
870
      for(int i=0; i<numGroups; i++)
871
        {
872
        JSONArray groupElements = groupArray.getJSONArray(i);
873
        int groupSize = groupElements.length();
874
        mSolvedQuats[i] = new int[groupSize];
875
        for(int j=0; j<groupSize; j++) mSolvedQuats[i][j] = groupElements.getInt(j);
876
        }
877
      }
878
    catch( JSONException ex )
879
      {
880
      // ignore, the object does not have to have an array of solved groups.
881
      }
882
    }
883

    
884
///////////////////////////////////////////////////////////////////////////////////////////////////
885

    
886
  private void parseFile(JSONObject object, int major) throws JSONException
887
    {
888
    JSONObject metadata    = object.getJSONObject("metadata");
889
    parseMetadata(metadata,major);
890
    JSONObject mesh        = object.getJSONObject("mesh");
891
    parseMesh(mesh,major);
892
    JSONArray axis         = object.getJSONArray("axis");
893
    parseAxis(axis);
894
    JSONArray quats        = object.getJSONArray("quats");
895
    parseQuats(quats);
896
    JSONObject scrambling  = object.getJSONObject("scrambling");
897
    parseScrambling(scrambling,major);
898
    JSONObject touchcontrol= object.getJSONObject("touchcontrol");
899
    parseTouchcontrol(touchcontrol);
900
    JSONArray colors       = object.getJSONArray("colors");
901
    parseColors(colors);
902
    JSONObject solved      = object.getJSONObject("solved");
903
    parseSolved(solved);
904
    }
905

    
906
///////////////////////////////////////////////////////////////////////////////////////////////////
907

    
908
  private void parseTutorial(JSONObject object) throws JSONException
909
    {
910
    mTutorialObject = object.getString("object");
911
    JSONArray tuts= object.getJSONArray("tutorials");
912

    
913
    int len = tuts.length();
914
    mTutorials = new String[len][4];
915

    
916
    for(int i=0; i<len; i++)
917
      {
918
      JSONObject tut = tuts.getJSONObject(i);
919
      mTutorials[i][0] = tut.getString("language");
920
      mTutorials[i][1] = tut.getString("link");
921
      mTutorials[i][2] = tut.getString("title");
922
      mTutorials[i][3] = tut.getString("author");
923
      }
924
    }
925

    
926
///////////////////////////////////////////////////////////////////////////////////////////////////
927
// PUBLIC
928
///////////////////////////////////////////////////////////////////////////////////////////////////
929

    
930
  public void parseJsonFile(InputStream jsonStream) throws JSONException, IOException
931
    {
932
    BufferedReader br = new BufferedReader(new InputStreamReader(jsonStream, StandardCharsets.UTF_8));
933
    StringBuilder contents = new StringBuilder();
934
    String line;
935

    
936
    while( (line = br.readLine()) != null) contents.append(line);
937
    br.close();
938
    jsonStream.close();
939
    String contentsString = contents.toString();
940
    JSONObject object = new JSONObject(contentsString);
941
    int major = object.getInt("major");
942

    
943
    if( major>=6 )
944
      {
945
      parseFile(object,major);
946
      }
947
    else
948
      {
949
      android.util.Log.e("readJsonFile", "Unknown version "+major);
950
      }
951
    }
952

    
953
///////////////////////////////////////////////////////////////////////////////////////////////////
954

    
955
  public void parseJsonFileMetadata(InputStream jsonStream) throws JSONException, IOException
956
    {
957
    BufferedReader br = new BufferedReader(new InputStreamReader(jsonStream, StandardCharsets.UTF_8));
958
    StringBuilder contents = new StringBuilder();
959
    String tmp;
960

    
961
    while( (tmp = br.readLine()) != null) contents.append(tmp);
962
    br.close();
963
    jsonStream.close();
964

    
965
    JSONObject object = new JSONObject(contents.toString());
966
    int major = object.getInt("major");
967

    
968
    if( major>=6 )
969
      {
970
      JSONObject metadata = object.getJSONObject("metadata");
971
      parseMetadata(metadata,major);
972
      }
973
    else
974
      {
975
      android.util.Log.e("readJsonFileQuick", "Unknown version "+major);
976
      }
977
    }
978

    
979
///////////////////////////////////////////////////////////////////////////////////////////////////
980

    
981
  public void parseJsonTutorial(InputStream jsonStream) throws IOException, JSONException
982
    {
983
    BufferedReader br = new BufferedReader(new InputStreamReader(jsonStream, StandardCharsets.UTF_8));
984
    StringBuilder contents = new StringBuilder();
985
    String tmp;
986

    
987
    while( (tmp = br.readLine()) != null) contents.append(tmp);
988
    br.close();
989
    jsonStream.close();
990

    
991
    JSONObject object = new JSONObject(contents.toString());
992
    int major = object.getInt("major");
993

    
994
    if( major==1 )
995
      {
996
      parseTutorial(object);
997
      }
998
    else
999
      {
1000
      android.util.Log.e("readJsonFile", "Unknown tutorial version "+major);
1001
      }
1002
    }
1003

    
1004
///////////////////////////////////////////////////////////////////////////////////////////////////
1005

    
1006
  public int[][] getMinimalCubiesInRow()
1007
    {
1008
    return mMinimalCubitsInRow;
1009
    }
1010

    
1011
///////////////////////////////////////////////////////////////////////////////////////////////////
1012

    
1013
  public int getScrambleType()
1014
    {
1015
    return mScrambleType;
1016
    }
1017

    
1018
///////////////////////////////////////////////////////////////////////////////////////////////////
1019

    
1020
  public int[][] getScrambleEdges()
1021
    {
1022
    return mEdges;
1023
    }
1024

    
1025
///////////////////////////////////////////////////////////////////////////////////////////////////
1026

    
1027
  public int[][] getScrambleAlgorithms()
1028
    {
1029
    return mAlgorithms;
1030
    }
1031

    
1032
///////////////////////////////////////////////////////////////////////////////////////////////////
1033

    
1034
  public int[][] getSolvedQuats()
1035
    {
1036
    return mSolvedQuats;
1037
    }
1038

    
1039
///////////////////////////////////////////////////////////////////////////////////////////////////
1040

    
1041
  public Static4D[] getQuats()
1042
    {
1043
    return mQuats;
1044
    }
1045

    
1046
///////////////////////////////////////////////////////////////////////////////////////////////////
1047

    
1048
  public int getSolvedFunctionIndex()
1049
    {
1050
    return mSolvedFuncIndex;
1051
    }
1052

    
1053
///////////////////////////////////////////////////////////////////////////////////////////////////
1054

    
1055
  public int getNumStickerTypes()
1056
    {
1057
    return mNumStickerTypes;
1058
    }
1059

    
1060
///////////////////////////////////////////////////////////////////////////////////////////////////
1061

    
1062
  public float[][] getCuts()
1063
    {
1064
    return mCuts;
1065
    }
1066

    
1067
///////////////////////////////////////////////////////////////////////////////////////////////////
1068

    
1069
  public boolean[][] getLayerRotatable()
1070
    {
1071
    return mLayerRotatable;
1072
    }
1073

    
1074
///////////////////////////////////////////////////////////////////////////////////////////////////
1075

    
1076
  public int getMovementType()
1077
    {
1078
    return mMovementType;
1079
    }
1080

    
1081
///////////////////////////////////////////////////////////////////////////////////////////////////
1082

    
1083
  public int getMovementSplit()
1084
    {
1085
    return mMovementSplit;
1086
    }
1087

    
1088
///////////////////////////////////////////////////////////////////////////////////////////////////
1089

    
1090
  public int[][][] getEnabled()
1091
    {
1092
    return mEnabled;
1093
    }
1094

    
1095
///////////////////////////////////////////////////////////////////////////////////////////////////
1096

    
1097
  public float[] getDist3D()
1098
    {
1099
    return mDist3D;
1100
    }
1101

    
1102
///////////////////////////////////////////////////////////////////////////////////////////////////
1103

    
1104
  public int getNumCubitFaces()
1105
    {
1106
    return mNumCubitFaces;
1107
    }
1108

    
1109
///////////////////////////////////////////////////////////////////////////////////////////////////
1110

    
1111
  public float[][] getCubitPositions()
1112
    {
1113
    return mPositions;
1114
    }
1115

    
1116
///////////////////////////////////////////////////////////////////////////////////////////////////
1117

    
1118
  public ObjectShape getObjectShape(int variant)
1119
    {
1120
    return mShapes[variant];
1121
    }
1122

    
1123
///////////////////////////////////////////////////////////////////////////////////////////////////
1124

    
1125
  public ObjectFaceShape getObjectFaceShape(int variant)
1126
    {
1127
    return mFaceShapes[variant];
1128
    }
1129

    
1130
///////////////////////////////////////////////////////////////////////////////////////////////////
1131

    
1132
  public ObjectVertexEffects getVertexEffects(int variant)
1133
    {
1134
    return mVertexEffects[variant];
1135
    }
1136

    
1137
///////////////////////////////////////////////////////////////////////////////////////////////////
1138

    
1139
  public Static4D getCubitQuats(int cubit)
1140
    {
1141
    return mCubitQuats[cubit];
1142
    }
1143

    
1144
///////////////////////////////////////////////////////////////////////////////////////////////////
1145

    
1146
  public int getNumCubitVariants()
1147
    {
1148
    return mNumCubitVariants;
1149
    }
1150

    
1151
///////////////////////////////////////////////////////////////////////////////////////////////////
1152

    
1153
  public int getCubitVariant(int cubit)
1154
    {
1155
    return mCubitVariant[cubit];
1156
    }
1157

    
1158
///////////////////////////////////////////////////////////////////////////////////////////////////
1159

    
1160
  public int getVariantStickerShape(int variant, int face)
1161
    {
1162
    int[] shapes = mVariantStickerShape[variant];
1163
    return shapes.length>face ? shapes[face] : -1;
1164
    }
1165

    
1166
///////////////////////////////////////////////////////////////////////////////////////////////////
1167

    
1168
  public float[][] returnRotationFactor()
1169
    {
1170
    return mRotationFactor;
1171
    }
1172

    
1173
///////////////////////////////////////////////////////////////////////////////////////////////////
1174

    
1175
  public int[] getCubitTypes()
1176
    {
1177
    return mCubitType;
1178
    }
1179

    
1180
///////////////////////////////////////////////////////////////////////////////////////////////////
1181

    
1182
  public float[][] getCubitOffsets()
1183
    {
1184
    return mCubitRowOffset;
1185
    }
1186

    
1187
///////////////////////////////////////////////////////////////////////////////////////////////////
1188

    
1189
  public int[][] getVariantFaceIsOuter()
1190
    {
1191
    return mVariantFaceIsOuter;
1192
    }
1193

    
1194
///////////////////////////////////////////////////////////////////////////////////////////////////
1195

    
1196
  public int getCubitFaceFace(int cubit, int face)
1197
    {
1198
    return mCubitFaceColor[cubit][face];
1199
    }
1200

    
1201
///////////////////////////////////////////////////////////////////////////////////////////////////
1202

    
1203
  public int getNumScrambles()
1204
    {
1205
    return mNumScrambles;
1206
    }
1207

    
1208
///////////////////////////////////////////////////////////////////////////////////////////////////
1209

    
1210
  public int getPrice()
1211
    {
1212
    return mPrice;
1213
    }
1214

    
1215
///////////////////////////////////////////////////////////////////////////////////////////////////
1216

    
1217
  public boolean getAdjustableColors()
1218
    {
1219
    return mSupportsAdjustableColors;
1220
    }
1221

    
1222
///////////////////////////////////////////////////////////////////////////////////////////////////
1223

    
1224
  public ObjectSticker retSticker(int sticker)
1225
    {
1226
    return mObjectSticker[sticker];
1227
    }
1228

    
1229
///////////////////////////////////////////////////////////////////////////////////////////////////
1230

    
1231
  public ObjectStickerOverride[] getStickerOverrides()
1232
    {
1233
    return mStickerOverrides;
1234
    }
1235

    
1236
///////////////////////////////////////////////////////////////////////////////////////////////////
1237

    
1238
  public float getPillowCoeff()
1239
    {
1240
    return mPillowCoeff;
1241
    }
1242

    
1243
///////////////////////////////////////////////////////////////////////////////////////////////////
1244

    
1245
  public Static3D[] getRotationAxis()
1246
    {
1247
    return mAxis;
1248
    }
1249

    
1250
///////////////////////////////////////////////////////////////////////////////////////////////////
1251

    
1252
  public int[][] getBasicAngle()
1253
    {
1254
    return mBasicAngle;
1255
    }
1256

    
1257
///////////////////////////////////////////////////////////////////////////////////////////////////
1258

    
1259
  public ObjectSignature getSignature()
1260
    {
1261
    return mSignature;
1262
    }
1263

    
1264
///////////////////////////////////////////////////////////////////////////////////////////////////
1265

    
1266
  public String getObjectName()
1267
    {
1268
    return mLongName;
1269
    }
1270

    
1271
///////////////////////////////////////////////////////////////////////////////////////////////////
1272

    
1273
  public String getShortName()
1274
    {
1275
    return mShortName;
1276
    }
1277

    
1278
///////////////////////////////////////////////////////////////////////////////////////////////////
1279

    
1280
  public String getAuthor()
1281
    {
1282
    return mAuthor;
1283
    }
1284

    
1285
///////////////////////////////////////////////////////////////////////////////////////////////////
1286

    
1287
  public int getYearOfInvention()
1288
    {
1289
    return mYearOfInvention;
1290
    }
1291

    
1292
///////////////////////////////////////////////////////////////////////////////////////////////////
1293

    
1294
  public float getDifficulty()
1295
    {
1296
    return mDifficulty;
1297
    }
1298

    
1299
///////////////////////////////////////////////////////////////////////////////////////////////////
1300

    
1301
  public int getCategory()
1302
    {
1303
    return mCategory;
1304
    }
1305

    
1306
///////////////////////////////////////////////////////////////////////////////////////////////////
1307

    
1308
  public int getNumFaces()
1309
    {
1310
    return mNumFaces;
1311
    }
1312

    
1313
///////////////////////////////////////////////////////////////////////////////////////////////////
1314

    
1315
  public int[] getNumLayers()
1316
    {
1317
    return mNumLayers;
1318
    }
1319

    
1320
///////////////////////////////////////////////////////////////////////////////////////////////////
1321

    
1322
  public float getSize()
1323
    {
1324
    return mSize;
1325
    }
1326

    
1327
///////////////////////////////////////////////////////////////////////////////////////////////////
1328

    
1329
  public int[] getColorTable()
1330
    {
1331
    return mColorTable;
1332
    }
1333

    
1334
///////////////////////////////////////////////////////////////////////////////////////////////////
1335

    
1336
  public int getInternalColor()
1337
    {
1338
    return mInternalColor;
1339
    }
1340

    
1341
///////////////////////////////////////////////////////////////////////////////////////////////////
1342

    
1343
  public boolean shouldResetTextureMaps()
1344
    {
1345
    return mResetMaps;
1346
    }
1347

    
1348
///////////////////////////////////////////////////////////////////////////////////////////////////
1349

    
1350
  public String getTutorialObject()
1351
    {
1352
    return mTutorialObject;
1353
    }
1354

    
1355
///////////////////////////////////////////////////////////////////////////////////////////////////
1356

    
1357
  public String[][] getTutorials()
1358
    {
1359
    return mTutorials;
1360
    }
1361
}
(1-1/2)