Project

General

Profile

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

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

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, mNumFaceColors;
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

    
97
///////////////////////////////////////////////////////////////////////////////////////////////////
98

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

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

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

    
142
    return new ObjectSignature(signature);
143
    }
144

    
145
///////////////////////////////////////////////////////////////////////////////////////////////////
146

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

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

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

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

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

    
189
///////////////////////////////////////////////////////////////////////////////////////////////////
190

    
191
  private void parseCubits(JSONArray object) throws JSONException
192
    {
193
    int numCubits = object.length();
194

    
195
    mCubitQuats     = new Static4D[numCubits];
196
    mCubitVariant   = new int[numCubits];
197
    mPositions      = new float[numCubits][];
198
    mCubitFaceColor = new int[numCubits][];
199
    mCubitType      = new int[numCubits];
200
    mCubitRowOffset = new float[numCubits][];
201

    
202
    for(int i=0; i<numCubits; i++)
203
      {
204
      JSONObject jsonCubit = object.getJSONObject(i);
205

    
206
      float qx = (float)jsonCubit.getDouble("qx");
207
      float qy = (float)jsonCubit.getDouble("qy");
208
      float qz = (float)jsonCubit.getDouble("qz");
209
      float qw = (float)jsonCubit.getDouble("qw");
210

    
211
      mCubitQuats[i] = new Static4D(qx,qy,qz,qw);
212
      mCubitVariant[i] = jsonCubit.getInt("variant");
213

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

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

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

    
232
///////////////////////////////////////////////////////////////////////////////////////////////////
233

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

    
244
    for(int i=0; i<mNumCubitVariants; i++)
245
      {
246
      JSONObject jsonShape = object.getJSONObject(i);
247

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

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

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

    
267
      if( !multigon )
268
        {
269
        int[][] vertIndices = new int[numFaces][];
270

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

    
280
        mShapes[i] = new ObjectShape(verts,vertIndices);
281
        }
282
      else
283
        {
284
        int[][][] vertIndices = new int[numFaces][][];
285

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

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

    
302
        mShapes[i] = new ObjectShape(verts,vertIndices);
303
        }
304

    
305
      /////////////////////////////////////////////////////////////////////////
306
      ////// StickerShape & Outer /////////////////////////////////////////////
307
      mVariantStickerShape[i]= new int[numFaces];
308
      mVariantFaceIsOuter[i] = new int[numFaces];
309
      int[] bandIndices = new int[numFaces];
310

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

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

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

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

    
339
      JSONObject jsonConvexity = jsonShape.optJSONObject("convexity");
340
      float[] convexity = null;
341

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

    
350
      mFaceShapes[i] = new ObjectFaceShape(bands,bandIndices,convexity);
351

    
352
      /////////////////////////////////////////////////////////////////////////
353
      ////// ObjectVertexEffects //////////////////////////////////////////////
354
      JSONArray jsonEffects = jsonShape.optJSONArray("effects");
355

    
356
      if( jsonEffects!=null )
357
        {
358
        int numEffects = jsonEffects.length();
359

    
360
        String[] name    = new String[numEffects];
361
        float[][] vars   = new float[numEffects][5];
362
        float[][] center = new float[numEffects][3];
363
        float[][] region = new float[numEffects][4];
364
        boolean[] use    = new boolean[numEffects];
365

    
366
        for(int j=0; j<numEffects; j++)
367
          {
368
          JSONObject jsonEffect = jsonEffects.getJSONObject(j);
369

    
370
          name[j] = jsonEffect.getString("name");
371

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

    
378
          center[j][0] = (float)jsonEffect.getDouble("center0");
379
          center[j][1] = (float)jsonEffect.getDouble("center1");
380
          center[j][2] = (float)jsonEffect.getDouble("center2");
381

    
382
          region[j][0] = (float)jsonEffect.getDouble("region0");
383
          region[j][1] = (float)jsonEffect.getDouble("region1");
384
          region[j][2] = (float)jsonEffect.getDouble("region2");
385
          region[j][3] = (float)jsonEffect.getDouble("region3");
386

    
387
          use[j] = jsonEffect.getBoolean("use");
388
          }
389

    
390
        mVertexEffects[i] = new ObjectVertexEffects(name,vars,center,region,use);
391
        }
392
      }
393
    }
394

    
395
///////////////////////////////////////////////////////////////////////////////////////////////////
396

    
397
  private void parseStickers11(JSONArray object) throws JSONException
398
    {
399
    mNumStickerTypes = object.length();
400
    mObjectSticker = new ObjectSticker[mNumStickerTypes];
401

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

    
409
      float[][][] coords   = new float[1][numVertices][2];
410
      float[][] curvatures = new float[1][numVertices];
411
      float[][] radii      = new float[1][numVertices];
412
      float[][] strokes    = new float[1][numVertices];
413

    
414
      for(int j=0; j<numVertices; j++)
415
        {
416
        JSONObject vertex = vertices.getJSONObject(j);
417

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

    
425
      mObjectSticker[i] = new ObjectSticker(coords,curvatures,radii,strokes);
426
      }
427
    }
428

    
429
///////////////////////////////////////////////////////////////////////////////////////////////////
430

    
431
  private void parseStickers12to14(JSONArray object) throws JSONException
432
    {
433
    mNumStickerTypes = object.length();
434
    mObjectSticker = new ObjectSticker[mNumStickerTypes];
435

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

    
443
      float[][][] coords   = new float[numLoops][][];
444
      float[][] curvatures = new float[numLoops][];
445
      float[][] radii      = new float[numLoops][];
446
      float[][] strokes    = new float[numLoops][];
447

    
448
      for(int l=0; l<numLoops; l++)
449
        {
450
        JSONArray loop = loops.getJSONArray(l);
451
        int numVertices= loop.length();
452

    
453
        coords[l]     = new float[numVertices][2];
454
        curvatures[l] = new float[numVertices];
455
        radii[l]      = new float[numVertices];
456
        strokes[l]    = new float[numVertices];
457

    
458
        for(int v=0; v<numVertices; v++)
459
          {
460
          JSONObject vertex= loop.getJSONObject(v);
461

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

    
470
      mObjectSticker[i] = new ObjectSticker(coords,curvatures,radii,strokes);
471
      }
472
    }
473

    
474
///////////////////////////////////////////////////////////////////////////////////////////////////
475

    
476
  private void parseStickers15up(JSONArray object) throws JSONException
477
    {
478
    mNumStickerTypes = object.length();
479
    mObjectSticker = new ObjectSticker[mNumStickerTypes];
480

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

    
487
      float[][][] coords   = new float[numLoops][][];
488
      float[][] curvatures = new float[numLoops][];
489
      float[][] radii      = new float[numLoops][];
490
      float[][] strokes    = new float[numLoops][];
491

    
492
      for(int l=0; l<numLoops; l++)
493
        {
494
        JSONArray loop = loops.getJSONArray(l);
495
        int numVertices= loop.length();
496

    
497
        coords[l]     = new float[numVertices][2];
498
        curvatures[l] = new float[numVertices];
499
        radii[l]      = new float[numVertices];
500
        strokes[l]    = new float[numVertices];
501

    
502
        for(int v=0; v<numVertices; v++)
503
          {
504
          JSONObject vertex= loop.getJSONObject(v);
505

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

    
514
      mObjectSticker[i] = new ObjectSticker(coords,curvatures,radii,strokes);
515
      }
516
    }
517

    
518
///////////////////////////////////////////////////////////////////////////////////////////////////
519

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

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

    
544
///////////////////////////////////////////////////////////////////////////////////////////////////
545

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

    
557
    JSONArray overrides= object.optJSONArray("overrides");
558
    parseOverrides(overrides);
559

    
560
    mPillowCoeff = (float)object.optDouble("pillow",1.0);
561
    }
562

    
563
///////////////////////////////////////////////////////////////////////////////////////////////////
564

    
565
  private void parseAxis(JSONArray object) throws JSONException
566
    {
567
    int numAxis = object.length();
568

    
569
    mBasicAngle     = new int[numAxis][];
570
    mAxis           = new Static3D[numAxis];
571
    mCuts           = new float[numAxis][];
572
    mLayerRotatable = new boolean[numAxis][];
573
    mRotationFactor = new float[numAxis][];
574
    mNumLayers      = new int[numAxis];
575

    
576
    for(int i=0; i<numAxis; i++)
577
      {
578
      JSONObject jsonAx = object.getJSONObject(i);
579

    
580
      float x = (float)jsonAx.getDouble("x");
581
      float y = (float)jsonAx.getDouble("y");
582
      float z = (float)jsonAx.getDouble("z");
583

    
584
      mAxis[i] = new Static3D(x,y,z);
585

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

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

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

    
601
      JSONArray jsonFactor = jsonAx.optJSONArray("factor");
602

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

    
615
      JSONArray jsonMinimal = jsonAx.optJSONArray("minimal");
616

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

    
625
      mNumLayers[i] = numRota;
626
      }
627
    }
628

    
629
///////////////////////////////////////////////////////////////////////////////////////////////////
630

    
631
  private void parseQuats(JSONArray object) throws JSONException
632
    {
633
    int numQuats = object.length();
634
    mQuats = new Static4D[numQuats];
635

    
636
    for(int i=0; i<numQuats; i++)
637
      {
638
      JSONObject jsonQuat = object.getJSONObject(i);
639

    
640
      float x = (float)jsonQuat.getDouble("x");
641
      float y = (float)jsonQuat.getDouble("y");
642
      float z = (float)jsonQuat.getDouble("z");
643
      float w = (float)jsonQuat.getDouble("w");
644

    
645
      mQuats[i] = new Static4D(x,y,z,w);
646
      }
647
    }
648

    
649
///////////////////////////////////////////////////////////////////////////////////////////////////
650

    
651
  private int getAlgorithmIndex(int ax, int layer, int angle)
652
    {
653
    int numAlgs = mAlgorithms.length;
654

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

    
661
    return -1;
662
    }
663

    
664
///////////////////////////////////////////////////////////////////////////////////////////////////
665

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

    
672
    int[] ret = new int[2*length/3];
673

    
674
    for(int ax=0; ax<numAxis; ax++)
675
      {
676
      int[] data = scramblingData[ax];
677
      int num = data.length/3;
678

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

    
685
        ret[2*index  ] = getAlgorithmIndex(ax,layer,angle);
686
        ret[2*index+1] = state;
687
        index++;
688
        }
689
      }
690

    
691
    return ret;
692
    }
693

    
694
///////////////////////////////////////////////////////////////////////////////////////////////////
695

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

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

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

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

    
722
///////////////////////////////////////////////////////////////////////////////////////////////////
723

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

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

    
742
    JSONArray jsonEdges = object.getJSONArray("edges");
743
    int numEdges = jsonEdges.length();
744
    mEdges = new int[numEdges][];
745

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

    
755
///////////////////////////////////////////////////////////////////////////////////////////////////
756

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

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

    
771
    JSONArray jsonEdges = object.getJSONArray("edges");
772
    int numEdges = jsonEdges.length();
773
    mEdges = new int[numEdges][];
774

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

    
784
///////////////////////////////////////////////////////////////////////////////////////////////////
785

    
786
  private void parseScrambling(JSONObject object, int major) throws JSONException
787
    {
788
    mScrambleType = object.getInt("scrambleType");
789

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

    
798
///////////////////////////////////////////////////////////////////////////////////////////////////
799

    
800
  private void parseTouchcontrol(JSONObject object) throws JSONException
801
    {
802
    mMovementType = object.getInt("movementType");
803
    mMovementSplit= object.getInt("movementSplit");
804

    
805
    try
806
      {
807
      JSONArray jsonEnabled = object.getJSONArray("enabledAxis");
808
      int numFace = jsonEnabled.length();
809

    
810
      mEnabled = new int[numFace][][];
811

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

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

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

    
845
///////////////////////////////////////////////////////////////////////////////////////////////////
846

    
847
  private void parseColors(JSONArray object) throws JSONException
848
    {
849
    mNumFaceColors = object.length()-1;
850

    
851
    mColorTable = new int[mNumFaceColors];
852
    for(int i=0; i<mNumFaceColors; i++) mColorTable[i] = object.getInt(i);
853

    
854
    mInternalColor = object.getInt(mNumFaceColors);
855
    }
856

    
857
///////////////////////////////////////////////////////////////////////////////////////////////////
858

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

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

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

    
883
///////////////////////////////////////////////////////////////////////////////////////////////////
884

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

    
905
///////////////////////////////////////////////////////////////////////////////////////////////////
906

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

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

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

    
925
///////////////////////////////////////////////////////////////////////////////////////////////////
926
// PUBLIC
927
///////////////////////////////////////////////////////////////////////////////////////////////////
928

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

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

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

    
952
///////////////////////////////////////////////////////////////////////////////////////////////////
953

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

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

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

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

    
978
///////////////////////////////////////////////////////////////////////////////////////////////////
979

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

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

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

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

    
1003
///////////////////////////////////////////////////////////////////////////////////////////////////
1004

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

    
1010
///////////////////////////////////////////////////////////////////////////////////////////////////
1011

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

    
1017
///////////////////////////////////////////////////////////////////////////////////////////////////
1018

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

    
1024
///////////////////////////////////////////////////////////////////////////////////////////////////
1025

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

    
1031
///////////////////////////////////////////////////////////////////////////////////////////////////
1032

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

    
1038
///////////////////////////////////////////////////////////////////////////////////////////////////
1039

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

    
1045
///////////////////////////////////////////////////////////////////////////////////////////////////
1046

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

    
1052
///////////////////////////////////////////////////////////////////////////////////////////////////
1053

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

    
1059
///////////////////////////////////////////////////////////////////////////////////////////////////
1060

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

    
1066
///////////////////////////////////////////////////////////////////////////////////////////////////
1067

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

    
1073
///////////////////////////////////////////////////////////////////////////////////////////////////
1074

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

    
1080
///////////////////////////////////////////////////////////////////////////////////////////////////
1081

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

    
1087
///////////////////////////////////////////////////////////////////////////////////////////////////
1088

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

    
1094
///////////////////////////////////////////////////////////////////////////////////////////////////
1095

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

    
1101
///////////////////////////////////////////////////////////////////////////////////////////////////
1102

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

    
1108
///////////////////////////////////////////////////////////////////////////////////////////////////
1109

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

    
1115
///////////////////////////////////////////////////////////////////////////////////////////////////
1116

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

    
1122
///////////////////////////////////////////////////////////////////////////////////////////////////
1123

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

    
1129
///////////////////////////////////////////////////////////////////////////////////////////////////
1130

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

    
1136
///////////////////////////////////////////////////////////////////////////////////////////////////
1137

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

    
1143
///////////////////////////////////////////////////////////////////////////////////////////////////
1144

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

    
1150
///////////////////////////////////////////////////////////////////////////////////////////////////
1151

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

    
1157
///////////////////////////////////////////////////////////////////////////////////////////////////
1158

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

    
1165
///////////////////////////////////////////////////////////////////////////////////////////////////
1166

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

    
1172
///////////////////////////////////////////////////////////////////////////////////////////////////
1173

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

    
1179
///////////////////////////////////////////////////////////////////////////////////////////////////
1180

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

    
1186
///////////////////////////////////////////////////////////////////////////////////////////////////
1187

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

    
1193
///////////////////////////////////////////////////////////////////////////////////////////////////
1194

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

    
1200
///////////////////////////////////////////////////////////////////////////////////////////////////
1201

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

    
1207
///////////////////////////////////////////////////////////////////////////////////////////////////
1208

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

    
1214
///////////////////////////////////////////////////////////////////////////////////////////////////
1215

    
1216
  public ObjectSticker retSticker(int sticker)
1217
    {
1218
    return mObjectSticker[sticker];
1219
    }
1220

    
1221
///////////////////////////////////////////////////////////////////////////////////////////////////
1222

    
1223
  public ObjectStickerOverride[] getStickerOverrides()
1224
    {
1225
    return mStickerOverrides;
1226
    }
1227

    
1228
///////////////////////////////////////////////////////////////////////////////////////////////////
1229

    
1230
  public float getPillowCoeff()
1231
    {
1232
    return mPillowCoeff;
1233
    }
1234

    
1235
///////////////////////////////////////////////////////////////////////////////////////////////////
1236

    
1237
  public Static3D[] getRotationAxis()
1238
    {
1239
    return mAxis;
1240
    }
1241

    
1242
///////////////////////////////////////////////////////////////////////////////////////////////////
1243

    
1244
  public int[][] getBasicAngle()
1245
    {
1246
    return mBasicAngle;
1247
    }
1248

    
1249
///////////////////////////////////////////////////////////////////////////////////////////////////
1250

    
1251
  public ObjectSignature getSignature()
1252
    {
1253
    return mSignature;
1254
    }
1255

    
1256
///////////////////////////////////////////////////////////////////////////////////////////////////
1257

    
1258
  public String getObjectName()
1259
    {
1260
    return mLongName;
1261
    }
1262

    
1263
///////////////////////////////////////////////////////////////////////////////////////////////////
1264

    
1265
  public String getShortName()
1266
    {
1267
    return mShortName;
1268
    }
1269

    
1270
///////////////////////////////////////////////////////////////////////////////////////////////////
1271

    
1272
  public String getAuthor()
1273
    {
1274
    return mAuthor;
1275
    }
1276

    
1277
///////////////////////////////////////////////////////////////////////////////////////////////////
1278

    
1279
  public int getYearOfInvention()
1280
    {
1281
    return mYearOfInvention;
1282
    }
1283

    
1284
///////////////////////////////////////////////////////////////////////////////////////////////////
1285

    
1286
  public float getDifficulty()
1287
    {
1288
    return mDifficulty;
1289
    }
1290

    
1291
///////////////////////////////////////////////////////////////////////////////////////////////////
1292

    
1293
  public int getCategory()
1294
    {
1295
    return mCategory;
1296
    }
1297

    
1298
///////////////////////////////////////////////////////////////////////////////////////////////////
1299

    
1300
  public int getNumFaces()
1301
    {
1302
    return mNumFaces;
1303
    }
1304

    
1305
///////////////////////////////////////////////////////////////////////////////////////////////////
1306

    
1307
  public int[] getNumLayers()
1308
    {
1309
    return mNumLayers;
1310
    }
1311

    
1312
///////////////////////////////////////////////////////////////////////////////////////////////////
1313

    
1314
  public float getSize()
1315
    {
1316
    return mSize;
1317
    }
1318

    
1319
///////////////////////////////////////////////////////////////////////////////////////////////////
1320

    
1321
  public int[] getColorTable()
1322
    {
1323
    return mColorTable;
1324
    }
1325

    
1326
///////////////////////////////////////////////////////////////////////////////////////////////////
1327

    
1328
  public int getInternalColor()
1329
    {
1330
    return mInternalColor;
1331
    }
1332

    
1333
///////////////////////////////////////////////////////////////////////////////////////////////////
1334

    
1335
  public boolean shouldResetTextureMaps()
1336
    {
1337
    return mResetMaps;
1338
    }
1339

    
1340
///////////////////////////////////////////////////////////////////////////////////////////////////
1341

    
1342
  public String getTutorialObject()
1343
    {
1344
    return mTutorialObject;
1345
    }
1346

    
1347
///////////////////////////////////////////////////////////////////////////////////////////////////
1348

    
1349
  public String[][] getTutorials()
1350
    {
1351
    return mTutorials;
1352
    }
1353
}
(1-1/2)