Project

General

Profile

Download (38.6 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / objects / TwistyObject.java @ 6cf89a3e

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
package org.distorted.objects;
21

    
22
import android.content.SharedPreferences;
23
import android.content.res.Resources;
24
import android.graphics.Bitmap;
25
import android.graphics.Canvas;
26
import android.graphics.Paint;
27

    
28
import com.google.firebase.crashlytics.FirebaseCrashlytics;
29

    
30
import org.distorted.helpers.FactoryCubit;
31
import org.distorted.helpers.FactorySticker;
32
import org.distorted.helpers.ObjectShape;
33
import org.distorted.helpers.ObjectSticker;
34
import org.distorted.helpers.QuatHelper;
35
import org.distorted.library.effect.Effect;
36
import org.distorted.library.effect.MatrixEffectMove;
37
import org.distorted.library.effect.MatrixEffectQuaternion;
38
import org.distorted.library.effect.MatrixEffectScale;
39
import org.distorted.library.effect.VertexEffectQuaternion;
40
import org.distorted.library.effect.VertexEffectRotate;
41
import org.distorted.library.main.DistortedEffects;
42
import org.distorted.library.main.DistortedLibrary;
43
import org.distorted.library.main.DistortedNode;
44
import org.distorted.library.main.DistortedTexture;
45
import org.distorted.library.mesh.MeshBase;
46
import org.distorted.library.mesh.MeshFile;
47
import org.distorted.library.mesh.MeshJoined;
48
import org.distorted.library.mesh.MeshSquare;
49
import org.distorted.library.message.EffectListener;
50
import org.distorted.library.type.Dynamic1D;
51
import org.distorted.library.type.Static1D;
52
import org.distorted.library.type.Static3D;
53
import org.distorted.library.type.Static4D;
54
import org.distorted.main.BuildConfig;
55

    
56
import java.io.DataInputStream;
57
import java.io.IOException;
58
import java.io.InputStream;
59
import java.util.Random;
60

    
61
///////////////////////////////////////////////////////////////////////////////////////////////////
62

    
63
public abstract class TwistyObject extends DistortedNode
64
  {
65
  public static final int COLOR_YELLOW = 0xffffff00;
66
  public static final int COLOR_WHITE  = 0xffffffff;
67
  public static final int COLOR_BLUE   = 0xff0000ff;
68
  public static final int COLOR_GREEN  = 0xff00bb00;
69
  public static final int COLOR_RED    = 0xff990000;
70
  public static final int COLOR_ORANGE = 0xffff6200;
71
  public static final int COLOR_GREY   = 0xff727c7b;
72
  public static final int COLOR_VIOLET = 0xff7700bb;
73
  public static final int COLOR_BLACK  = 0xff000000;
74

    
75
  public static final int TEXTURE_HEIGHT = 256;
76
  static final int NUM_STICKERS_IN_ROW = 4;
77

    
78
  static final float SQ2 = (float)Math.sqrt(2);
79
  static final float SQ3 = (float)Math.sqrt(3);
80
  static final float SQ5 = (float)Math.sqrt(5);
81
  static final float SQ6 = (float)Math.sqrt(6);
82

    
83
  private static final float NODE_RATIO = 1.40f;
84
  private static final float MAX_SIZE_CHANGE = 1.35f;
85
  private static final float MIN_SIZE_CHANGE = 0.75f;
86

    
87
  private static final Static3D CENTER = new Static3D(0,0,0);
88
  private static final int POST_ROTATION_MILLISEC = 500;
89

    
90
  MeshBase[] mMeshes;
91
  final Static4D[] QUATS;
92
  final Cubit[] CUBITS;
93
  final int NUM_FACES;
94
  final int NUM_TEXTURES;
95
  final int NUM_CUBITS;
96
  final int NUM_AXIS;
97

    
98
  private final int mNumCubitFaces;
99
  private final Static3D[] mAxis;
100
  private final float[][] mCuts;
101
  private final int[] mNumCuts;
102
  private final int mNodeSize;
103
  private final float[][] mOrigPos;
104
  private final Static3D mNodeScale;
105
  private final Static4D mQuat;
106
  private final int mNumLayers, mRealSize;
107
  private final ObjectList mList;
108
  private final DistortedEffects mEffects;
109
  private final VertexEffectRotate mRotateEffect;
110
  private final Dynamic1D mRotationAngle;
111
  private final Static3D mRotationAxis;
112
  private final Static3D mObjectScale;
113
  private final int[] mQuatDebug;
114
  private final float mCameraDist;
115
  private final Static1D mRotationAngleStatic, mRotationAngleMiddle, mRotationAngleFinal;
116
  private final DistortedTexture mTexture;
117
  private final float mInitScreenRatio;
118
  private final int mSolvedFunctionIndex;
119
  private final boolean mIsBandaged;
120
  private float mObjectScreenRatio;
121
  private int[][] mSolvedQuats;
122
  private int[][] mQuatMult;
123
  private int[] mTmpQuats;
124
  private int mNumTexRows, mNumTexCols;
125
  private int mRotRowBitmap;
126
  private int mRotAxis;
127
  private MeshBase mMesh;
128

    
129
  //////////////////// SOLVED1 ////////////////////////
130

    
131
  private static final int[] mFaceMap = { 4, 2, 2, 4, 0, 2, 1, 4, 0, 0, 1, 1 };
132
  private static int[][] mScramble;
133
  private int[] mColors;
134

    
135
///////////////////////////////////////////////////////////////////////////////////////////////////
136

    
137
  TwistyObject(int numLayers, int realSize, Static4D quat, DistortedTexture nodeTexture, MeshSquare nodeMesh,
138
               DistortedEffects nodeEffects, int[][] moves, ObjectList list, Resources res, int screenWidth)
139
    {
140
    super(nodeTexture,nodeEffects,nodeMesh);
141

    
142
    mNodeSize = screenWidth;
143

    
144
    resizeFBO(mNodeSize, (int)(NODE_RATIO*mNodeSize));
145

    
146
    mNumLayers = numLayers;
147
    mRealSize = realSize;
148
    mList = list;
149
    mOrigPos = getCubitPositions(mNumLayers);
150
    mAxis = getRotationAxis();
151
    mInitScreenRatio = getScreenRatio();
152
    mObjectScreenRatio = 1.0f;
153
    mNumCubitFaces = getNumCubitFaces();
154
    mSolvedFunctionIndex = getSolvedFunctionIndex();
155

    
156
    mCuts = getCuts(mNumLayers);
157
    mNumCuts = new int[mAxis.length];
158
    if( mCuts==null ) for(int i=0; i<mAxis.length; i++) mNumCuts[i] = 0;
159
    else              for(int i=0; i<mAxis.length; i++) mNumCuts[i] = mCuts[i].length;
160

    
161
    QUATS = getQuats();
162
    NUM_CUBITS  = mOrigPos.length;
163
    NUM_FACES = getNumFaces();
164
    NUM_TEXTURES = getNumStickerTypes(mNumLayers)*NUM_FACES;
165
    NUM_AXIS = mAxis.length;
166

    
167
    boolean bandaged=false;
168

    
169
    for(int c=0; c<NUM_CUBITS; c++)
170
      {
171
      if( mOrigPos[c].length>3 )
172
        {
173
        bandaged=true;
174
        break;
175
        }
176
      }
177

    
178
    mIsBandaged = bandaged;
179

    
180
    mQuatDebug = new int[NUM_CUBITS];
181

    
182
    if( mObjectScreenRatio>MAX_SIZE_CHANGE) mObjectScreenRatio = MAX_SIZE_CHANGE;
183
    if( mObjectScreenRatio<MIN_SIZE_CHANGE) mObjectScreenRatio = MIN_SIZE_CHANGE;
184

    
185
    mNodeScale= new Static3D(1,NODE_RATIO,1);
186
    mQuat = quat;
187

    
188
    mRotationAngle= new Dynamic1D();
189
    mRotationAxis = new Static3D(1,0,0);
190
    mRotateEffect = new VertexEffectRotate(mRotationAngle, mRotationAxis, CENTER);
191

    
192
    mRotationAngleStatic = new Static1D(0);
193
    mRotationAngleMiddle = new Static1D(0);
194
    mRotationAngleFinal  = new Static1D(0);
195

    
196
    float scale  = mObjectScreenRatio*mInitScreenRatio*mNodeSize/mRealSize;
197
    mObjectScale = new Static3D(scale,scale,scale);
198
    MatrixEffectScale scaleEffect = new MatrixEffectScale(mObjectScale);
199
    MatrixEffectQuaternion quatEffect  = new MatrixEffectQuaternion(quat, CENTER);
200

    
201
    MatrixEffectScale nodeScaleEffect = new MatrixEffectScale(mNodeScale);
202
    nodeEffects.apply(nodeScaleEffect);
203

    
204
    mNumTexCols = NUM_STICKERS_IN_ROW;
205
    mNumTexRows = (NUM_TEXTURES+1)/NUM_STICKERS_IN_ROW;
206

    
207
    if( mNumTexCols*mNumTexRows < NUM_TEXTURES+1 ) mNumTexRows++;
208

    
209
    CUBITS = new Cubit[NUM_CUBITS];
210
    createMeshAndCubits(list,res);
211
    createDataStructuresForSolved(numLayers);
212

    
213
    mTexture = new DistortedTexture();
214
    mEffects = new DistortedEffects();
215

    
216
    int num_quats = QUATS.length;
217
    for(int q=0; q<num_quats; q++)
218
      {
219
      VertexEffectQuaternion vq = new VertexEffectQuaternion(QUATS[q],CENTER);
220
      vq.setMeshAssociation(0,q);
221
      mEffects.apply(vq);
222
      }
223

    
224
    mEffects.apply(mRotateEffect);
225
    mEffects.apply(quatEffect);
226
    mEffects.apply(scaleEffect);
227

    
228
    // Now postprocessed effects (the glow when you solve an object) require component centers. In
229
    // order for the effect to be in front of the object, we need to set the center to be behind it.
230
    getMesh().setComponentCenter(0,0,0,-0.1f);
231

    
232
    attach( new DistortedNode(mTexture,mEffects,mMesh) );
233

    
234
    setupPosition(moves);
235

    
236
    float fov = list.getFOV();
237
    double halfFOV = fov * (Math.PI/360);
238
    mCameraDist = 0.5f*NODE_RATIO / (float)Math.tan(halfFOV);
239

    
240
    setProjection( fov, 0.1f);
241
    }
242

    
243
///////////////////////////////////////////////////////////////////////////////////////////////////
244

    
245
  private Static3D getPos(float[] origPos)
246
    {
247
    int len = origPos.length/3;
248
    float sumX = 0.0f;
249
    float sumY = 0.0f;
250
    float sumZ = 0.0f;
251

    
252
    for(int i=0; i<len; i++)
253
      {
254
      sumX += origPos[3*i  ];
255
      sumY += origPos[3*i+1];
256
      sumZ += origPos[3*i+2];
257
      }
258

    
259
    sumX /= len;
260
    sumY /= len;
261
    sumZ /= len;
262

    
263
    return new Static3D(sumX,sumY,sumZ);
264
    }
265

    
266
///////////////////////////////////////////////////////////////////////////////////////////////////
267

    
268
  private void createMeshAndCubits(ObjectList list, Resources res)
269
    {
270
    int sizeIndex = ObjectList.getSizeIndex(list.ordinal(),mNumLayers);
271
    int resourceID= list.getResourceIDs()[sizeIndex];
272

    
273
    if( resourceID!=0 )
274
      {
275
      InputStream is = res.openRawResource(resourceID);
276
      DataInputStream dos = new DataInputStream(is);
277
      mMesh = new MeshFile(dos);
278

    
279
      try
280
        {
281
        is.close();
282
        }
283
      catch(IOException e)
284
        {
285
        android.util.Log.e("meshFile", "Error closing InputStream: "+e.toString());
286
        }
287

    
288
      for(int i=0; i<NUM_CUBITS; i++)
289
        {
290
        CUBITS[i] = new Cubit(this,mOrigPos[i], NUM_AXIS);
291
        mMesh.setEffectAssociation(i, CUBITS[i].computeAssociation(), 0);
292
        }
293

    
294
      if( shouldResetTextureMaps() ) resetAllTextureMaps();
295
      }
296
    else
297
      {
298
      MeshBase[] cubitMesh = new MeshBase[NUM_CUBITS];
299

    
300
      for(int i=0; i<NUM_CUBITS; i++)
301
        {
302
        CUBITS[i] = new Cubit(this,mOrigPos[i], NUM_AXIS);
303
        cubitMesh[i] = createCubitMesh(i,mNumLayers);
304
        Static3D pos = getPos(mOrigPos[i]);
305
        cubitMesh[i].apply(new MatrixEffectMove(pos),1,0);
306
        cubitMesh[i].setEffectAssociation(0, CUBITS[i].computeAssociation(), 0);
307
        }
308

    
309
      mMesh = new MeshJoined(cubitMesh);
310
      resetAllTextureMaps();
311
      }
312
    }
313

    
314
///////////////////////////////////////////////////////////////////////////////////////////////////
315

    
316
  private MeshBase createCubitMesh(int cubit, int numLayers)
317
    {
318
    int variant = getCubitVariant(cubit,numLayers);
319

    
320
    if( mMeshes==null )
321
      {
322
      FactoryCubit factory = FactoryCubit.getInstance();
323
      factory.clear();
324
      mMeshes = new MeshBase[getNumCubitVariants(numLayers)];
325
      }
326

    
327
    if( mMeshes[variant]==null )
328
      {
329
      ObjectShape shape = getObjectShape(cubit,numLayers);
330
      FactoryCubit factory = FactoryCubit.getInstance();
331
      factory.createNewFaceTransform(shape);
332
      mMeshes[variant] = factory.createRoundedSolid(shape);
333
      }
334

    
335
    MeshBase mesh = mMeshes[variant].copy(true);
336
    MatrixEffectQuaternion quat = new MatrixEffectQuaternion( getQuat(cubit,numLayers), new Static3D(0,0,0) );
337
    mesh.apply(quat,0xffffffff,0);
338

    
339
    return mesh;
340
    }
341

    
342
///////////////////////////////////////////////////////////////////////////////////////////////////
343

    
344
  private void createDataStructuresForSolved(int numLayers)
345
    {
346
    mTmpQuats = new int[QUATS.length];
347
    mSolvedQuats = new int[NUM_CUBITS][];
348

    
349
    for(int c=0; c<NUM_CUBITS; c++)
350
      {
351
      mSolvedQuats[c] = getSolvedQuats(c,numLayers);
352
      }
353
    }
354

    
355
///////////////////////////////////////////////////////////////////////////////////////////////////
356
// This is used to build internal data structures for the generic 'isSolved()'
357
//
358
// if this is an internal cubit (all faces black): return -1
359
// if this is a face cubit (one non-black face): return the color index of the only non-black face.
360
// Color index, i.e. the index into the 'FACE_COLORS' table.
361
// else (edge or corner cubit, more than one non-black face): return -2.
362

    
363
  int retCubitSolvedStatus(int cubit, int numLayers)
364
    {
365
    int numNonBlack=0, nonBlackIndex=-1, color;
366

    
367
    for(int face=0; face<mNumCubitFaces; face++)
368
      {
369
      color = getFaceColor(cubit,face,numLayers);
370

    
371
      if( color<NUM_TEXTURES )
372
        {
373
        numNonBlack++;
374
        nonBlackIndex = color%NUM_FACES;
375
        }
376
      }
377

    
378
    if( numNonBlack==0 ) return -1;
379
    if( numNonBlack>=2 ) return -2;
380

    
381
    return nonBlackIndex;
382
    }
383

    
384
///////////////////////////////////////////////////////////////////////////////////////////////////
385

    
386
  int[] buildSolvedQuats(Static3D faceAx, Static4D[] quats)
387
    {
388
    final float MAXD = 0.0001f;
389
    float x = faceAx.get0();
390
    float y = faceAx.get1();
391
    float z = faceAx.get2();
392
    float a,dx,dy,dz,qx,qy,qz;
393
    Static4D quat;
394

    
395
    int len = quats.length;
396
    int place = 0;
397

    
398
    for(int q=1; q<len; q++)
399
      {
400
      quat = quats[q];
401
      qx = quat.get0();
402
      qy = quat.get1();
403
      qz = quat.get2();
404

    
405
           if( x!=0.0f ) { a = qx/x; }
406
      else if( y!=0.0f ) { a = qy/y; }
407
      else               { a = qz/z; }
408

    
409
      dx = a*x-qx;
410
      dy = a*y-qy;
411
      dz = a*z-qz;
412

    
413
      if( dx>-MAXD && dx<MAXD && dy>-MAXD && dy<MAXD && dz>-MAXD && dz<MAXD )
414
        {
415
        mTmpQuats[place++] = q;
416
        }
417
      }
418

    
419
    if( place!=0 )
420
      {
421
      int[] ret = new int[place];
422
      System.arraycopy(mTmpQuats,0,ret,0,place);
423
      return ret;
424
      }
425

    
426
    return null;
427
    }
428

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

    
431
  private int getMultQuat(int index1, int index2)
432
    {
433
    if( mQuatMult==null )
434
      {
435
      int len = QUATS.length;
436
      mQuatMult = new int[len][len];
437

    
438
      for(int i=0; i<len; i++)
439
        for(int j=0; j<len; j++) mQuatMult[i][j] = -1;
440
      }
441

    
442
    if( mQuatMult[index1][index2]==-1 )
443
      {
444
      mQuatMult[index1][index2] = mulQuat(index1,index2);
445
      }
446

    
447
    return mQuatMult[index1][index2];
448
    }
449

    
450
///////////////////////////////////////////////////////////////////////////////////////////////////
451

    
452
  public boolean isSolved()
453
    {
454
    if( mSolvedFunctionIndex==0 ) return isSolved0();
455
    if( mSolvedFunctionIndex==1 ) return isSolved1();
456
    if( mSolvedFunctionIndex==2 ) return isSolved2();
457

    
458
    return false;
459
    }
460

    
461
///////////////////////////////////////////////////////////////////////////////////////////////////
462

    
463
  public boolean isSolved0()
464
    {
465
    int len, q1,q = CUBITS[0].mQuatIndex;
466
    int[] solved;
467
    boolean skip;
468

    
469
    for(int c=1; c<NUM_CUBITS; c++)
470
      {
471
      q1 = CUBITS[c].mQuatIndex;
472

    
473
      if( q1==q ) continue;
474

    
475
      skip = false;
476
      solved = mSolvedQuats[c];
477
      len = solved==null ? 0:solved.length;
478

    
479
      for(int i=0; i<len; i++)
480
        {
481
        if( q1==getMultQuat(q,solved[i]) )
482
          {
483
          skip = true;
484
          break;
485
          }
486
        }
487

    
488
      if( !skip ) return false;
489
      }
490

    
491
    return true;
492
    }
493

    
494
///////////////////////////////////////////////////////////////////////////////////////////////////
495

    
496
  private int computeScramble(int quatNum, int centerNum)
497
    {
498
    float MAXDIFF = 0.01f;
499
    float[] center= mOrigPos[centerNum];
500
    Static4D sc = new Static4D(center[0], center[1], center[2], 1.0f);
501
    Static4D result = QuatHelper.rotateVectorByQuat(sc,QUATS[quatNum]);
502

    
503
    float x = result.get0();
504
    float y = result.get1();
505
    float z = result.get2();
506

    
507
    for(int c=0; c<NUM_CUBITS; c++)
508
      {
509
      float[] cent = mOrigPos[c];
510

    
511
      float qx = cent[0] - x;
512
      float qy = cent[1] - y;
513
      float qz = cent[2] - z;
514

    
515
      if( qx>-MAXDIFF && qx<MAXDIFF &&
516
          qy>-MAXDIFF && qy<MAXDIFF &&
517
          qz>-MAXDIFF && qz<MAXDIFF  ) return c;
518
      }
519

    
520
    return -1;
521
    }
522

    
523
///////////////////////////////////////////////////////////////////////////////////////////////////
524
// Dino4 uses this. It is solved if and only if groups of cubits
525
// (0,3,7), (1,2,5), (4,8,9), (6,10,11)
526
// or
527
// (0,1,4), (2,3,6), (5,9,10), (7,8,11)
528
// are all the same color.
529

    
530
  public boolean isSolved1()
531
    {
532
    if( mScramble==null )
533
      {
534
      int numQuats = QUATS.length;
535
      mScramble = new int[numQuats][NUM_CUBITS];
536
      mColors   = new int[NUM_CUBITS];
537

    
538
      for(int q=0; q<numQuats; q++)
539
        for(int c=0; c<NUM_CUBITS; c++) mScramble[q][c] = computeScramble(q,c);
540
      }
541

    
542
    for(int c=0; c<NUM_CUBITS; c++)
543
      {
544
      int index = mScramble[CUBITS[c].mQuatIndex][c];
545
      mColors[index] = mFaceMap[c];
546
      }
547

    
548
    if( mColors[0]==mColors[3] && mColors[0]==mColors[7] &&
549
        mColors[1]==mColors[2] && mColors[1]==mColors[5] &&
550
        mColors[4]==mColors[8] && mColors[4]==mColors[9]  ) return true;
551

    
552
    if( mColors[0]==mColors[1] && mColors[0]==mColors[4] &&
553
        mColors[2]==mColors[3] && mColors[2]==mColors[6] &&
554
        mColors[5]==mColors[9] && mColors[5]==mColors[10] ) return true;
555

    
556
    return false;
557
    }
558

    
559
///////////////////////////////////////////////////////////////////////////////////////////////////
560
// Dino6 uses this. It is solved if and only if:
561
//
562
// All four 'X' cubits (i.e. those whose longest edge goes along the X axis) are rotated
563
// by the same quaternion qX, similarly all four 'Y' cubits by the same qY and all four 'Z'
564
// by the same qZ, and then either:
565
//
566
// a) qX = qY = qZ
567
// b) qY = qX*Q2 and qZ = qX*Q8  (i.e. swap of WHITE and YELLOW faces)
568
// c) qX = qY*Q2 and qZ = qY*Q10 (i.e. swap of BLUE and GREEN faces)
569
// d) qX = qZ*Q8 and qY = qZ*Q10 (i.e. swap of RED and BROWN faces)
570
//
571
// BUT: cases b), c) and d) are really the same - it's all just a mirror image of the original.
572
//
573
// X cubits: 0, 2, 8, 10
574
// Y cubits: 1, 3, 9, 11
575
// Z cubits: 4, 5, 6, 7
576

    
577
  public boolean isSolved2()
578
    {
579
    int qX = CUBITS[0].mQuatIndex;
580
    int qY = CUBITS[1].mQuatIndex;
581
    int qZ = CUBITS[4].mQuatIndex;
582

    
583
    if( CUBITS[2].mQuatIndex != qX || CUBITS[8].mQuatIndex != qX || CUBITS[10].mQuatIndex != qX ||
584
        CUBITS[3].mQuatIndex != qY || CUBITS[9].mQuatIndex != qY || CUBITS[11].mQuatIndex != qY ||
585
        CUBITS[5].mQuatIndex != qZ || CUBITS[6].mQuatIndex != qZ || CUBITS[ 7].mQuatIndex != qZ  )
586
      {
587
      return false;
588
      }
589

    
590
    return ( qX==qY && qX==qZ ) || ( qY==mulQuat(qX,2) && qZ==mulQuat(qX,8) );
591

    
592
    }
593

    
594
///////////////////////////////////////////////////////////////////////////////////////////////////
595

    
596
  public void setObjectRatio(float sizeChange)
597
    {
598
    mObjectScreenRatio *= (1.0f+sizeChange)/2;
599

    
600
    if( mObjectScreenRatio>MAX_SIZE_CHANGE) mObjectScreenRatio = MAX_SIZE_CHANGE;
601
    if( mObjectScreenRatio<MIN_SIZE_CHANGE) mObjectScreenRatio = MIN_SIZE_CHANGE;
602

    
603
    float scale = mObjectScreenRatio*mInitScreenRatio*mNodeSize/mRealSize;
604
    mObjectScale.set(scale,scale,scale);
605
    }
606

    
607
///////////////////////////////////////////////////////////////////////////////////////////////////
608

    
609
  public float getObjectRatio()
610
    {
611
    return mObjectScreenRatio*mInitScreenRatio;
612
    }
613

    
614
///////////////////////////////////////////////////////////////////////////////////////////////////
615

    
616
  int computeRow(float[] pos, int axisIndex)
617
    {
618
    int ret=0;
619
    int len = pos.length / 3;
620
    Static3D axis = mAxis[axisIndex];
621
    float axisX = axis.get0();
622
    float axisY = axis.get1();
623
    float axisZ = axis.get2();
624
    float casted;
625

    
626
    for(int i=0; i<len; i++)
627
      {
628
      casted = pos[3*i]*axisX + pos[3*i+1]*axisY + pos[3*i+2]*axisZ;
629
      ret |= computeSingleRow(axisIndex,casted);
630
      }
631

    
632
    return ret;
633
    }
634

    
635
///////////////////////////////////////////////////////////////////////////////////////////////////
636

    
637
  private int computeSingleRow(int axisIndex,float casted)
638
    {
639
    int num = mNumCuts[axisIndex];
640

    
641
    for(int i=0; i<num; i++)
642
      {
643
      if( casted<mCuts[axisIndex][i] ) return (1<<i);
644
      }
645

    
646
    return (1<<num);
647
    }
648

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

    
651
  private boolean wasRotateApplied()
652
    {
653
    return mEffects.exists(mRotateEffect.getID());
654
    }
655

    
656
///////////////////////////////////////////////////////////////////////////////////////////////////
657

    
658
  private boolean belongsToRotation( int cubit, int axis, int rowBitmap)
659
    {
660
    return (CUBITS[cubit].mRotationRow[axis] & rowBitmap) != 0;
661
    }
662

    
663
///////////////////////////////////////////////////////////////////////////////////////////////////
664
// note the minus in front of the sin() - we rotate counterclockwise
665
// when looking towards the direction where the axis increases in values.
666

    
667
  private Static4D makeQuaternion(int axisIndex, int angleInDegrees)
668
    {
669
    Static3D axis = mAxis[axisIndex];
670

    
671
    while( angleInDegrees<0 ) angleInDegrees += 360;
672
    angleInDegrees %= 360;
673
    
674
    float cosA = (float)Math.cos(Math.PI*angleInDegrees/360);
675
    float sinA =-(float)Math.sqrt(1-cosA*cosA);
676

    
677
    return new Static4D(axis.get0()*sinA, axis.get1()*sinA, axis.get2()*sinA, cosA);
678
    }
679

    
680
///////////////////////////////////////////////////////////////////////////////////////////////////
681

    
682
  private synchronized void setupPosition(int[][] moves)
683
    {
684
    if( moves!=null )
685
      {
686
      Static4D quat;
687
      int index, axis, rowBitmap, angle;
688
      int[] basic = getBasicAngle();
689

    
690
      for(int[] move: moves)
691
        {
692
        axis     = move[0];
693
        rowBitmap= move[1];
694
        angle    = move[2]*(360/basic[axis]);
695
        quat     = makeQuaternion(axis,angle);
696

    
697
        for(int j=0; j<NUM_CUBITS; j++)
698
          if( belongsToRotation(j,axis,rowBitmap) )
699
            {
700
            index = CUBITS[j].removeRotationNow(quat);
701
            mMesh.setEffectAssociation(j, CUBITS[j].computeAssociation(),index);
702
            }
703
        }
704
      }
705
    }
706

    
707
///////////////////////////////////////////////////////////////////////////////////////////////////
708

    
709
  int computeBitmapFromRow(int rowBitmap, int axis)
710
    {
711
    if( mIsBandaged )
712
      {
713
      int bitmap, initBitmap=0;
714

    
715
      while( initBitmap!=rowBitmap )
716
        {
717
        initBitmap = rowBitmap;
718

    
719
        for(int cubit=0; cubit<NUM_CUBITS; cubit++)
720
          {
721
          bitmap = CUBITS[cubit].mRotationRow[axis];
722
          if( (rowBitmap & bitmap) != 0 ) rowBitmap |= bitmap;
723
          }
724
        }
725
      }
726

    
727
    return rowBitmap;
728
    }
729

    
730
///////////////////////////////////////////////////////////////////////////////////////////////////
731
// Clamp all rotated positions to one of those original ones to avoid accumulating errors.
732
// Do so only if minimal Error is appropriately low (shape-shifting puzzles - Square-1)
733

    
734
  void clampPos(float[] pos, int offset)
735
    {
736
    float currError, minError = Float.MAX_VALUE;
737
    int minErrorIndex1 = -1;
738
    int minErrorIndex2 = -1;
739

    
740
    float x = pos[offset  ];
741
    float y = pos[offset+1];
742
    float z = pos[offset+2];
743

    
744
    float xo,yo,zo;
745

    
746
    for(int i=0; i<NUM_CUBITS; i++)
747
      {
748
      int len = mOrigPos[i].length / 3;
749

    
750
      for(int j=0; j<len; j++)
751
        {
752
        xo = mOrigPos[i][3*j  ];
753
        yo = mOrigPos[i][3*j+1];
754
        zo = mOrigPos[i][3*j+2];
755

    
756
        currError = (xo-x)*(xo-x) + (yo-y)*(yo-y) + (zo-z)*(zo-z);
757

    
758
        if( currError<minError )
759
          {
760
          minError = currError;
761
          minErrorIndex1 = i;
762
          minErrorIndex2 = j;
763
          }
764
        }
765
      }
766

    
767
    if( minError< 0.1f ) // TODO: 0.1 ?
768
      {
769
      pos[offset  ] = mOrigPos[minErrorIndex1][3*minErrorIndex2  ];
770
      pos[offset+1] = mOrigPos[minErrorIndex1][3*minErrorIndex2+1];
771
      pos[offset+2] = mOrigPos[minErrorIndex1][3*minErrorIndex2+2];
772
      }
773
    }
774

    
775
///////////////////////////////////////////////////////////////////////////////////////////////////
776
// remember about the double cover or unit quaternions!
777

    
778
  int mulQuat(int q1, int q2)
779
    {
780
    Static4D result = QuatHelper.quatMultiply(QUATS[q1],QUATS[q2]);
781

    
782
    float rX = result.get0();
783
    float rY = result.get1();
784
    float rZ = result.get2();
785
    float rW = result.get3();
786

    
787
    final float MAX_ERROR = 0.1f;
788
    float dX,dY,dZ,dW;
789

    
790
    for(int i=0; i<QUATS.length; i++)
791
      {
792
      dX = QUATS[i].get0() - rX;
793
      dY = QUATS[i].get1() - rY;
794
      dZ = QUATS[i].get2() - rZ;
795
      dW = QUATS[i].get3() - rW;
796

    
797
      if( dX<MAX_ERROR && dX>-MAX_ERROR &&
798
          dY<MAX_ERROR && dY>-MAX_ERROR &&
799
          dZ<MAX_ERROR && dZ>-MAX_ERROR &&
800
          dW<MAX_ERROR && dW>-MAX_ERROR  ) return i;
801

    
802
      dX = QUATS[i].get0() + rX;
803
      dY = QUATS[i].get1() + rY;
804
      dZ = QUATS[i].get2() + rZ;
805
      dW = QUATS[i].get3() + rW;
806

    
807
      if( dX<MAX_ERROR && dX>-MAX_ERROR &&
808
          dY<MAX_ERROR && dY>-MAX_ERROR &&
809
          dZ<MAX_ERROR && dZ>-MAX_ERROR &&
810
          dW<MAX_ERROR && dW>-MAX_ERROR  ) return i;
811
      }
812

    
813
    return -1;
814
    }
815

    
816
///////////////////////////////////////////////////////////////////////////////////////////////////
817

    
818
  public int getCubitFaceColorIndex(int cubit, int face)
819
    {
820
    Static4D texMap = mMesh.getTextureMap(NUM_FACES*cubit + face);
821

    
822
    int x = (int)(texMap.get0()/texMap.get2());
823
    int y = (int)(texMap.get1()/texMap.get3());
824

    
825
    return (mNumTexRows-1-y)*NUM_STICKERS_IN_ROW + x;
826
    }
827

    
828
///////////////////////////////////////////////////////////////////////////////////////////////////
829
// the getFaceColors + final black in a grid (so that we do not exceed the maximum texture size)
830

    
831
  public void createTexture()
832
    {
833
    Bitmap bitmap;
834

    
835
    Paint paint = new Paint();
836
    bitmap = Bitmap.createBitmap( mNumTexCols*TEXTURE_HEIGHT, mNumTexRows*TEXTURE_HEIGHT, Bitmap.Config.ARGB_8888);
837
    Canvas canvas = new Canvas(bitmap);
838

    
839
    paint.setAntiAlias(true);
840
    paint.setTextAlign(Paint.Align.CENTER);
841
    paint.setStyle(Paint.Style.FILL);
842

    
843
    paint.setColor(COLOR_BLACK);
844
    canvas.drawRect(0, 0, mNumTexCols*TEXTURE_HEIGHT, mNumTexRows*TEXTURE_HEIGHT, paint);
845

    
846
    int face = 0;
847
    FactorySticker factory = FactorySticker.getInstance();
848

    
849
    for(int row=0; row<mNumTexRows; row++)
850
      for(int col=0; col<mNumTexCols; col++)
851
        {
852
        if( face>=NUM_TEXTURES ) break;
853
        ObjectSticker sticker = retSticker(face);
854
        factory.drawRoundedPolygon(canvas, paint, col*TEXTURE_HEIGHT, row*TEXTURE_HEIGHT, getColor(face%NUM_FACES), sticker);
855
        face++;
856
        }
857

    
858
    if( !mTexture.setTexture(bitmap) )
859
      {
860
      int max = DistortedLibrary.getMaxTextureSize();
861
      FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
862
      crashlytics.log("failed to set texture of size "+bitmap.getWidth()+"x"+bitmap.getHeight()+" max is "+max);
863
      }
864
    }
865

    
866
///////////////////////////////////////////////////////////////////////////////////////////////////
867

    
868
  public int getNumLayers()
869
    {
870
    return mNumLayers;
871
    }
872

    
873
///////////////////////////////////////////////////////////////////////////////////////////////////
874

    
875
  public void continueRotation(float angleInDegrees)
876
    {
877
    mRotationAngleStatic.set0(angleInDegrees);
878
    }
879

    
880
///////////////////////////////////////////////////////////////////////////////////////////////////
881

    
882
  public Static4D getRotationQuat()
883
      {
884
      return mQuat;
885
      }
886

    
887
///////////////////////////////////////////////////////////////////////////////////////////////////
888

    
889
  public void recomputeScaleFactor(int scrWidth)
890
    {
891
    mNodeScale.set(scrWidth,NODE_RATIO*scrWidth,scrWidth);
892
    }
893

    
894
///////////////////////////////////////////////////////////////////////////////////////////////////
895

    
896
  public void savePreferences(SharedPreferences.Editor editor)
897
    {
898
    for(int i=0; i<NUM_CUBITS; i++) CUBITS[i].savePreferences(editor);
899
    }
900

    
901
///////////////////////////////////////////////////////////////////////////////////////////////////
902

    
903
  public synchronized void restorePreferences(SharedPreferences preferences)
904
    {
905
    boolean error = false;
906

    
907
    for(int i=0; i<NUM_CUBITS; i++)
908
      {
909
      mQuatDebug[i] = CUBITS[i].restorePreferences(preferences);
910

    
911
      if( mQuatDebug[i]>=0 && mQuatDebug[i]<QUATS.length)
912
        {
913
        CUBITS[i].modifyCurrentPosition(QUATS[mQuatDebug[i]]);
914
        mMesh.setEffectAssociation(i, CUBITS[i].computeAssociation(),mQuatDebug[i]);
915
        }
916
      else
917
        {
918
        error = true;
919
        }
920
      }
921

    
922
    if( error )
923
      {
924
      for(int i=0; i<NUM_CUBITS; i++)
925
        {
926
        CUBITS[i].solve();
927
        mMesh.setEffectAssociation(i, CUBITS[i].computeAssociation(),0);
928
        }
929
      recordQuatsState("Failed to restorePreferences");
930
      }
931
    }
932

    
933
///////////////////////////////////////////////////////////////////////////////////////////////////
934

    
935
  public void recordQuatsState(String message)
936
    {
937
    StringBuilder quats = new StringBuilder();
938

    
939
    for(int j=0; j<NUM_CUBITS; j++)
940
      {
941
      quats.append(mQuatDebug[j]);
942
      quats.append(" ");
943
      }
944

    
945
    if( BuildConfig.DEBUG )
946
      {
947
      android.util.Log.e("quats" , quats.toString());
948
      android.util.Log.e("object", mList.name()+"_"+mNumLayers);
949
      }
950
    else
951
      {
952
      Exception ex = new Exception(message);
953
      FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
954
      crashlytics.setCustomKey("quats" , quats.toString());
955
      crashlytics.setCustomKey("object", mList.name()+"_"+mNumLayers );
956
      crashlytics.recordException(ex);
957
      }
958
    }
959

    
960
///////////////////////////////////////////////////////////////////////////////////////////////////
961

    
962
  public void releaseResources()
963
    {
964
    mTexture.markForDeletion();
965
    mMesh.markForDeletion();
966
    mEffects.markForDeletion();
967

    
968
    for(int j=0; j<NUM_CUBITS; j++)
969
      {
970
      CUBITS[j].releaseResources();
971
      }
972
    }
973

    
974
///////////////////////////////////////////////////////////////////////////////////////////////////
975

    
976
  public void apply(Effect effect, int position)
977
    {
978
    mEffects.apply(effect, position);
979
    }
980

    
981
///////////////////////////////////////////////////////////////////////////////////////////////////
982

    
983
  public void remove(long effectID)
984
    {
985
    mEffects.abortById(effectID);
986
    }
987

    
988
///////////////////////////////////////////////////////////////////////////////////////////////////
989

    
990
  public synchronized void solve()
991
    {
992
    for(int i=0; i<NUM_CUBITS; i++)
993
      {
994
      CUBITS[i].solve();
995
      mMesh.setEffectAssociation(i, CUBITS[i].computeAssociation(), 0);
996
      }
997
    }
998

    
999
///////////////////////////////////////////////////////////////////////////////////////////////////
1000

    
1001
  public void resetAllTextureMaps()
1002
    {
1003
    final float ratioW = 1.0f/mNumTexCols;
1004
    final float ratioH = 1.0f/mNumTexRows;
1005
    int color, row, col;
1006

    
1007
    for(int cubit=0; cubit<NUM_CUBITS; cubit++)
1008
      {
1009
      final Static4D[] maps = new Static4D[mNumCubitFaces];
1010

    
1011
      for(int cubitface=0; cubitface<mNumCubitFaces; cubitface++)
1012
        {
1013
        color = getFaceColor(cubit,cubitface,mNumLayers);
1014
        row = (mNumTexRows-1) - color/mNumTexCols;
1015
        col = color%mNumTexCols;
1016
        maps[cubitface] = new Static4D( col*ratioW, row*ratioH, ratioW, ratioH);
1017
        }
1018

    
1019
      mMesh.setTextureMap(maps,mNumCubitFaces*cubit);
1020
      }
1021
    }
1022

    
1023
///////////////////////////////////////////////////////////////////////////////////////////////////
1024

    
1025
  public void setTextureMap(int cubit, int face, int newColor)
1026
    {
1027
    final float ratioW = 1.0f/mNumTexCols;
1028
    final float ratioH = 1.0f/mNumTexRows;
1029
    final Static4D[] maps = new Static4D[mNumCubitFaces];
1030
    int row = (mNumTexRows-1) - newColor/mNumTexCols;
1031
    int col = newColor%mNumTexCols;
1032

    
1033
    maps[face] = new Static4D( col*ratioW, row*ratioH, ratioW, ratioH);
1034
    mMesh.setTextureMap(maps,mNumCubitFaces*cubit);
1035
    }
1036

    
1037
///////////////////////////////////////////////////////////////////////////////////////////////////
1038

    
1039
  public synchronized void beginNewRotation(int axis, int row )
1040
    {
1041
    if( axis<0 || axis>=NUM_AXIS )
1042
      {
1043
      android.util.Log.e("object", "invalid rotation axis: "+axis);
1044
      return;
1045
      }
1046
    if( row<0 || row>=mNumLayers )
1047
      {
1048
      android.util.Log.e("object", "invalid rotation row: "+row);
1049
      return;
1050
      }
1051

    
1052
    mRotAxis     = axis;
1053
    mRotRowBitmap= computeBitmapFromRow( (1<<row),axis );
1054
    mRotationAngleStatic.set0(0.0f);
1055
    mRotationAxis.set( mAxis[axis] );
1056
    mRotationAngle.add(mRotationAngleStatic);
1057
    mRotateEffect.setMeshAssociation( mRotRowBitmap<<(axis* ObjectList.MAX_OBJECT_SIZE) , -1);
1058
    }
1059

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

    
1062
  public synchronized long addNewRotation( int axis, int rowBitmap, int angle, long durationMillis, EffectListener listener )
1063
    {
1064
    if( wasRotateApplied() )
1065
      {
1066
      mRotAxis     = axis;
1067
      mRotRowBitmap= computeBitmapFromRow( rowBitmap,axis );
1068

    
1069
      mRotationAngleStatic.set0(0.0f);
1070
      mRotationAxis.set( mAxis[axis] );
1071
      mRotationAngle.setDuration(durationMillis);
1072
      mRotationAngle.resetToBeginning();
1073
      mRotationAngle.add(new Static1D(0));
1074
      mRotationAngle.add(new Static1D(angle));
1075
      mRotateEffect.setMeshAssociation( mRotRowBitmap<<(axis* ObjectList.MAX_OBJECT_SIZE) , -1);
1076
      mRotateEffect.notifyWhenFinished(listener);
1077

    
1078
      return mRotateEffect.getID();
1079
      }
1080

    
1081
    return 0;
1082
    }
1083

    
1084
///////////////////////////////////////////////////////////////////////////////////////////////////
1085

    
1086
  public long finishRotationNow(EffectListener listener, int nearestAngleInDegrees)
1087
    {
1088
    if( wasRotateApplied() )
1089
      {
1090
      float angle = getAngle();
1091
      mRotationAngleStatic.set0(angle);
1092
      mRotationAngleFinal.set0(nearestAngleInDegrees);
1093
      mRotationAngleMiddle.set0( nearestAngleInDegrees + (nearestAngleInDegrees-angle)*0.2f );
1094

    
1095
      mRotationAngle.setDuration(POST_ROTATION_MILLISEC);
1096
      mRotationAngle.resetToBeginning();
1097
      mRotationAngle.removeAll();
1098
      mRotationAngle.add(mRotationAngleStatic);
1099
      mRotationAngle.add(mRotationAngleMiddle);
1100
      mRotationAngle.add(mRotationAngleFinal);
1101
      mRotateEffect.notifyWhenFinished(listener);
1102

    
1103
      return mRotateEffect.getID();
1104
      }
1105

    
1106
    return 0;
1107
    }
1108

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

    
1111
  private float getAngle()
1112
    {
1113
    int pointNum = mRotationAngle.getNumPoints();
1114

    
1115
    if( pointNum>=1 )
1116
      {
1117
      return mRotationAngle.getPoint(pointNum-1).get0();
1118
      }
1119
    else
1120
      {
1121
      FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
1122
      crashlytics.log("points in RotationAngle: "+pointNum);
1123
      return 0;
1124
      }
1125
    }
1126

    
1127
///////////////////////////////////////////////////////////////////////////////////////////////////
1128

    
1129
  public synchronized void removeRotationNow()
1130
    {
1131
    float angle = getAngle();
1132
    double nearestAngleInRadians = angle*Math.PI/180;
1133
    float sinA =-(float)Math.sin(nearestAngleInRadians*0.5);
1134
    float cosA = (float)Math.cos(nearestAngleInRadians*0.5);
1135
    float axisX = mAxis[mRotAxis].get0();
1136
    float axisY = mAxis[mRotAxis].get1();
1137
    float axisZ = mAxis[mRotAxis].get2();
1138
    Static4D quat = new Static4D( axisX*sinA, axisY*sinA, axisZ*sinA, cosA);
1139

    
1140
    mRotationAngle.removeAll();
1141
    mRotationAngleStatic.set0(0);
1142

    
1143
    for(int i=0; i<NUM_CUBITS; i++)
1144
      if( belongsToRotation(i,mRotAxis,mRotRowBitmap) )
1145
        {
1146
        int index = CUBITS[i].removeRotationNow(quat);
1147
        mMesh.setEffectAssociation(i, CUBITS[i].computeAssociation(),index);
1148
        }
1149
    }
1150

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

    
1153
  public void initializeObject(int[][] moves)
1154
    {
1155
    solve();
1156
    setupPosition(moves);
1157
    }
1158

    
1159
///////////////////////////////////////////////////////////////////////////////////////////////////
1160

    
1161
  public int getCubit(float[] point3D)
1162
    {
1163
    float dist, minDist = Float.MAX_VALUE;
1164
    int currentBest=-1;
1165
    float multiplier = returnMultiplier();
1166

    
1167
    point3D[0] *= multiplier;
1168
    point3D[1] *= multiplier;
1169
    point3D[2] *= multiplier;
1170

    
1171
    for(int i=0; i<NUM_CUBITS; i++)
1172
      {
1173
      dist = CUBITS[i].getDistSquared(point3D);
1174
      if( dist<minDist )
1175
        {
1176
        minDist = dist;
1177
        currentBest = i;
1178
        }
1179
      }
1180

    
1181
    return currentBest;
1182
    }
1183

    
1184
///////////////////////////////////////////////////////////////////////////////////////////////////
1185

    
1186
  public int computeNearestAngle(int axis, float angle, float speed)
1187
    {
1188
    int[] basicArray = getBasicAngle();
1189
    int basicAngle   = basicArray[axis>=basicArray.length ? 0 : axis];
1190
    int nearestAngle = 360/basicAngle;
1191

    
1192
    int tmp = (int)((angle+nearestAngle/2)/nearestAngle);
1193
    if( angle< -(nearestAngle*0.5) ) tmp-=1;
1194

    
1195
    if( tmp!=0 ) return nearestAngle*tmp;
1196

    
1197
    return speed> 1.2f ? nearestAngle*(angle>0 ? 1:-1) : 0;
1198
    }
1199

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

    
1202
  public float getCameraDist()
1203
    {
1204
    return mCameraDist;
1205
    }
1206

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

    
1209
  public int getNodeSize()
1210
    {
1211
    return mNodeSize;
1212
    }
1213

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

    
1216
  public ObjectList getObjectList()
1217
    {
1218
    return mList;
1219
    }
1220

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

    
1223
  abstract float getScreenRatio();
1224
  abstract float[][] getCubitPositions(int numLayers);
1225
  abstract Static4D[] getQuats();
1226
  abstract int getNumFaces();
1227
  abstract int getNumStickerTypes(int numLayers);
1228
  abstract int getNumCubitFaces();
1229
  abstract ObjectSticker retSticker(int face);
1230
  abstract int getColor(int face);
1231
  abstract int getFaceColor(int cubit, int cubitface, int numLayers);
1232
  abstract float returnMultiplier();
1233
  abstract float[][] getCuts(int numLayers);
1234
  abstract boolean shouldResetTextureMaps();
1235
  abstract int getCubitVariant(int cubit, int numLayers);
1236
  abstract int getNumCubitVariants(int numLayers);
1237
  abstract Static4D getQuat(int cubit, int numLayers);
1238
  abstract ObjectShape getObjectShape(int cubit, int numLayers);
1239
  abstract int[] getSolvedQuats(int cubit, int numLayers);
1240
  abstract int getSolvedFunctionIndex();
1241

    
1242
  public abstract Static3D[] getRotationAxis();
1243
  public abstract int[] getBasicAngle();
1244
  public abstract void randomizeNewScramble(int[][] scramble, Random rnd, int curScramble, int totScrambles);
1245
  public abstract int getObjectName(int numLayers);
1246
  public abstract int getInventor(int numLayers);
1247
  public abstract int getComplexity(int numLayers);
1248
  }
(33-33/41)