Project

General

Profile

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

magiccube / src / main / java / org / distorted / objects / TwistySkewb.java @ 8c3148e2

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.res.Resources;
23

    
24
import org.distorted.helpers.ObjectShape;
25
import org.distorted.helpers.ObjectSticker;
26
import org.distorted.helpers.ScrambleState;
27
import org.distorted.library.main.DistortedEffects;
28
import org.distorted.library.main.DistortedTexture;
29
import org.distorted.library.mesh.MeshSquare;
30
import org.distorted.library.type.Static3D;
31
import org.distorted.library.type.Static4D;
32
import org.distorted.main.R;
33

    
34
import java.util.Random;
35

    
36
///////////////////////////////////////////////////////////////////////////////////////////////////
37

    
38
public class TwistySkewb extends TwistyObject
39
{
40
  // the four rotation axis of a RubikSkewb. Must be normalized.
41
  static final Static3D[] ROT_AXIS = new Static3D[]
42
         {
43
           new Static3D(+SQ3/3,+SQ3/3,+SQ3/3),
44
           new Static3D(+SQ3/3,+SQ3/3,-SQ3/3),
45
           new Static3D(+SQ3/3,-SQ3/3,+SQ3/3),
46
           new Static3D(+SQ3/3,-SQ3/3,-SQ3/3)
47
         };
48

    
49
  private static final int[] FACE_COLORS = new int[]
50
         {
51
           COLOR_YELLOW, COLOR_WHITE,
52
           COLOR_BLUE  , COLOR_GREEN,
53
           COLOR_RED   , COLOR_ORANGE
54
         };
55

    
56
  private int mCurrState;
57
  private int mIndexExcluded;
58
  private final ScrambleState[] mStates;
59
  private int[][] mScrambleTable;
60
  private int[] mNumOccurences;
61
  private int[] mBasicAngle;
62
  private Static4D[] mQuats;
63
  private int[][] mCornerMap,mEdgeMap,mCenterMap;
64
  private ObjectSticker[] mStickers;
65

    
66
///////////////////////////////////////////////////////////////////////////////////////////////////
67

    
68
  TwistySkewb(int size, Static4D quat, DistortedTexture texture,
69
              MeshSquare mesh, DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
70
    {
71
    super(size, 2*size-2, quat, texture, mesh, effects, moves, ObjectList.SKEW, res, scrWidth);
72

    
73
    int[] tmp = {0,-1,0, 0,1,0, size-1,-1,0, size-1,1,0 };
74

    
75
    mStates = new ScrambleState[]
76
      {
77
      new ScrambleState( new int[][] {tmp,tmp,tmp,tmp} )
78
      };
79
    }
80

    
81
///////////////////////////////////////////////////////////////////////////////////////////////////
82

    
83
  private void initializeQuats()
84
    {
85
    mQuats = new Static4D[]
86
         {
87
         new Static4D(  0.0f,  0.0f,  0.0f,  1.0f ),
88
         new Static4D(  1.0f,  0.0f,  0.0f,  0.0f ),
89
         new Static4D(  0.0f,  1.0f,  0.0f,  0.0f ),
90
         new Static4D(  0.0f,  0.0f,  1.0f,  0.0f ),
91

    
92
         new Static4D(  0.5f,  0.5f,  0.5f,  0.5f ),
93
         new Static4D(  0.5f,  0.5f,  0.5f, -0.5f ),
94
         new Static4D(  0.5f,  0.5f, -0.5f,  0.5f ),
95
         new Static4D(  0.5f,  0.5f, -0.5f, -0.5f ),
96
         new Static4D(  0.5f, -0.5f,  0.5f,  0.5f ),
97
         new Static4D(  0.5f, -0.5f,  0.5f, -0.5f ),
98
         new Static4D(  0.5f, -0.5f, -0.5f,  0.5f ),
99
         new Static4D(  0.5f, -0.5f, -0.5f, -0.5f )
100
         };
101
    }
102

    
103
///////////////////////////////////////////////////////////////////////////////////////////////////
104

    
105
  int[] getSolvedQuats(int cubit, int numLayers)
106
    {
107
    if( mQuats==null ) initializeQuats();
108
    int status = retCubitSolvedStatus(cubit,numLayers);
109
    return status<0 ? null : buildSolvedQuats(MovementSkewb.FACE_AXIS[status],mQuats);
110
    }
111

    
112
///////////////////////////////////////////////////////////////////////////////////////////////////
113

    
114
  private int getNumCorners()
115
    {
116
    return 8;
117
    }
118

    
119
///////////////////////////////////////////////////////////////////////////////////////////////////
120

    
121
  private int getNumEdges(int layers)
122
    {
123
    return (layers-2)*12;
124
    }
125

    
126
///////////////////////////////////////////////////////////////////////////////////////////////////
127

    
128
  private int getNumCentersPerFace(int layers)
129
    {
130
    return ((layers-2)*(layers-2) + (layers-1)*(layers-1));
131
    }
132

    
133
///////////////////////////////////////////////////////////////////////////////////////////////////
134

    
135
  float getScreenRatio()
136
    {
137
    return 1.0f;
138
    }
139

    
140
///////////////////////////////////////////////////////////////////////////////////////////////////
141

    
142
  Static4D[] getQuats()
143
    {
144
    if( mQuats==null ) initializeQuats();
145
    return mQuats;
146
    }
147

    
148
///////////////////////////////////////////////////////////////////////////////////////////////////
149

    
150
  int getNumFaces()
151
    {
152
    return FACE_COLORS.length;
153
    }
154

    
155
///////////////////////////////////////////////////////////////////////////////////////////////////
156

    
157
  int getSolvedFunctionIndex()
158
    {
159
    return 0;
160
    }
161

    
162
///////////////////////////////////////////////////////////////////////////////////////////////////
163

    
164
  boolean shouldResetTextureMaps()
165
    {
166
    return false;
167
    }
168

    
169
///////////////////////////////////////////////////////////////////////////////////////////////////
170

    
171
  int getNumStickerTypes(int numLayers)
172
    {
173
    return 3;
174
    }
175

    
176
///////////////////////////////////////////////////////////////////////////////////////////////////
177

    
178
  float[][] getCuts(int numLayers)
179
    {
180
    switch(numLayers)
181
      {
182
      case 2: float[] c2 = new float[] {0.0f};
183
              return new float[][] { c2,c2,c2,c2 };
184
      case 3: float[] c3 = new float[] {-SQ3/12,+SQ3/12};
185
              return new float[][] { c3,c3,c3,c3 };
186
      }
187
    return null;
188
    }
189

    
190
///////////////////////////////////////////////////////////////////////////////////////////////////
191

    
192
  int getNumCubitFaces()
193
    {
194
    return 6;
195
    }
196

    
197
///////////////////////////////////////////////////////////////////////////////////////////////////
198

    
199
  float[][] getCubitPositions(int numLayers)
200
    {
201
    final float DIST_CORNER = (numLayers-1)*0.50f;
202
    final float DIST_EDGE   = (numLayers-1)*0.50f;
203
    final float DIST_CENTER = (numLayers-1)*0.50f;
204

    
205
    final int numCorners = getNumCorners();
206
    final int numEdges   = getNumEdges(numLayers);
207
    final int numCenters = 6*getNumCentersPerFace(numLayers);
208

    
209
    final float[][] CENTERS = new float[numCorners+numEdges+numCenters][];
210

    
211
    /// CORNERS //////////////////////////////////////////////
212

    
213
    CENTERS[0] = new float[] { DIST_CORNER, DIST_CORNER, DIST_CORNER };
214
    CENTERS[1] = new float[] { DIST_CORNER, DIST_CORNER,-DIST_CORNER };
215
    CENTERS[2] = new float[] { DIST_CORNER,-DIST_CORNER, DIST_CORNER };
216
    CENTERS[3] = new float[] { DIST_CORNER,-DIST_CORNER,-DIST_CORNER };
217
    CENTERS[4] = new float[] {-DIST_CORNER, DIST_CORNER, DIST_CORNER };
218
    CENTERS[5] = new float[] {-DIST_CORNER, DIST_CORNER,-DIST_CORNER };
219
    CENTERS[6] = new float[] {-DIST_CORNER,-DIST_CORNER, DIST_CORNER };
220
    CENTERS[7] = new float[] {-DIST_CORNER,-DIST_CORNER,-DIST_CORNER };
221

    
222
    /// EDGES ///////////////////////////////////////////////
223

    
224
    final float[][]  edgeTable =
225
        {
226
            {0,+DIST_EDGE,+DIST_EDGE},
227
            {+DIST_EDGE,0,+DIST_EDGE},
228
            {0,-DIST_EDGE,+DIST_EDGE},
229
            {-DIST_EDGE,0,+DIST_EDGE},
230
            {+DIST_EDGE,+DIST_EDGE,0},
231
            {+DIST_EDGE,-DIST_EDGE,0},
232
            {-DIST_EDGE,-DIST_EDGE,0},
233
            {-DIST_EDGE,+DIST_EDGE,0},
234
            {0,+DIST_EDGE,-DIST_EDGE},
235
            {+DIST_EDGE,0,-DIST_EDGE},
236
            {0,-DIST_EDGE,-DIST_EDGE},
237
            {-DIST_EDGE,0,-DIST_EDGE}
238
        };
239

    
240
    int index=8;
241

    
242
    for (float[] edges : edgeTable)
243
      {
244
      float c = (3-numLayers)*0.5f;
245

    
246
      for (int j=0; j<numLayers-2; j++, c+=1.0f, index++)
247
        {
248
        CENTERS[index] = new float[] { edges[0]==0 ? c : edges[0] ,
249
                                       edges[1]==0 ? c : edges[1] ,
250
                                       edges[2]==0 ? c : edges[2] };
251
        }
252
      }
253

    
254
    /// CENTERS //////////////////////////////////////////////
255

    
256
    final float X= -1000.0f;
257
    final float Y= -1001.0f;
258

    
259
    final float[][]  centerTable =
260
        {
261
            {+DIST_CENTER,X,Y},
262
            {-DIST_CENTER,X,Y},
263
            {X,+DIST_CENTER,Y},
264
            {X,-DIST_CENTER,Y},
265
            {X,Y,+DIST_CENTER},
266
            {X,Y,-DIST_CENTER}
267
        };
268

    
269
    float x,y, cen0, cen1, cen2;
270

    
271
    for( float[] centers : centerTable )
272
      {
273
      x = (2-numLayers)*0.5f;
274

    
275
      for(int i=0; i<numLayers-1; i++, x+=1.0f)
276
        {
277
        y = (2-numLayers)*0.5f;
278

    
279
        for(int j=0; j<numLayers-1; j++, y+=1.0f, index++)
280
          {
281
               if( centers[0]==Y ) cen0 = y;
282
          else if( centers[0]==X ) cen0 = x;
283
          else                     cen0 = centers[0];
284

    
285
               if( centers[1]==Y ) cen1 = y;
286
          else if( centers[1]==X ) cen1 = x;
287
          else                     cen1 = centers[1];
288

    
289
               if( centers[2]==Y ) cen2 = y;
290
          else if( centers[2]==X ) cen2 = x;
291
          else                     cen2 = centers[2];
292

    
293
          CENTERS[index] = new float[] {cen0,cen1,cen2};
294
          }
295
        }
296

    
297
      x = (3-numLayers)*0.5f;
298

    
299
      for(int i=0; i<numLayers-2; i++, x+=1.0f)
300
        {
301
        y = (3-numLayers)*0.5f;
302

    
303
        for(int j=0; j<numLayers-2; j++, y+=1.0f, index++)
304
          {
305
               if( centers[0]==Y ) cen0 = y;
306
          else if( centers[0]==X ) cen0 = x;
307
          else                     cen0 = centers[0];
308

    
309
               if( centers[1]==Y ) cen1 = y;
310
          else if( centers[1]==X ) cen1 = x;
311
          else                     cen1 = centers[1];
312

    
313
               if( centers[2]==Y ) cen2 = y;
314
          else if( centers[2]==X ) cen2 = x;
315
          else                     cen2 = centers[2];
316

    
317
          CENTERS[index] = new float[] {cen0,cen1,cen2};
318
          }
319
        }
320
      }
321

    
322
    return CENTERS;
323
    }
324

    
325
///////////////////////////////////////////////////////////////////////////////////////////////////
326

    
327
  Static4D getQuat(int cubit, int numLayers)
328
    {
329
    if( mQuats==null ) initializeQuats();
330
    int numCorners = getNumCorners();
331
    int numEdges   = getNumEdges(numLayers);
332

    
333
    if( cubit<numCorners )
334
      {
335
      switch(cubit)
336
        {
337
        case  0: return mQuats[0];                         //  unit quat
338
        case  1: return new Static4D( SQ2/2,0,0,SQ2/2);    //  90 along X
339
        case  2: return new Static4D(-SQ2/2,0,0,SQ2/2);    // -90 along X
340
        case  3: return mQuats[1];                         // 180 along X
341
        case  4: return new Static4D(0, SQ2/2,0,SQ2/2);    //  90 along Y
342
        case  5: return mQuats[2];                         // 180 along Y
343
        case  6: return mQuats[3];                         // 180 along Z
344
        case  7: return new Static4D(SQ2/2,0,-SQ2/2,0);    // 180 along (SQ2/2,0,-SQ2/2)
345
        }
346
      }
347
    else if( cubit<numCorners+numEdges )
348
      {
349
      int edge = (cubit-numCorners)/(numLayers-2);
350

    
351
      switch(edge)
352
        {
353
        case  0: return mQuats[ 0];
354
        case  1: return mQuats[ 5];
355
        case  2: return mQuats[ 3];
356
        case  3: return mQuats[11];
357
        case  4: return mQuats[ 4];
358
        case  5: return mQuats[ 7];
359
        case  6: return mQuats[ 9];
360
        case  7: return mQuats[10];
361
        case  8: return mQuats[ 2];
362
        case  9: return mQuats[ 8];
363
        case 10: return mQuats[ 1];
364
        case 11: return mQuats[ 6];
365
        }
366
      }
367
    else
368
      {
369
      int center = (cubit-numCorners-numEdges)/getNumCentersPerFace(numLayers);
370

    
371
      switch(center)
372
        {
373
        case 0: return new Static4D(0,-SQ2/2,0,SQ2/2);    // -90 along Y
374
        case 1: return new Static4D(0, SQ2/2,0,SQ2/2);    //  90 along Y
375
        case 2: return new Static4D( SQ2/2,0,0,SQ2/2);    //  90 along X
376
        case 3: return new Static4D(-SQ2/2,0,0,SQ2/2);    // -90 along X
377
        case 4: return mQuats[0];                         //  unit quaternion
378
        case 5: return mQuats[1];                         // 180 along X
379
        }
380
      }
381

    
382
    return null;
383
    }
384

    
385
///////////////////////////////////////////////////////////////////////////////////////////////////
386

    
387
  ObjectShape getObjectShape(int cubit, int numLayers)
388
    {
389
    int variant = getCubitVariant(cubit,numLayers);
390

    
391
    if( variant==0 )
392
      {
393
      double[][] vertices = new double[][] { {-0.5f, 0.0f, 0.0f},{ 0.0f,-0.5f, 0.0f},{ 0.0f, 0.0f,-0.5f},{-0.5f,-0.5f,-0.5f},{ 0.0f, 0.0f, 0.0f} };
394
      int[][] vert_indices = new int[][] { {0,1,4},{2,0,4},{1,2,4},{3,1,0},{3,2,1},{3,0,2} };
395
      int N = numLayers==2 ? 7:5;
396
      int E1= numLayers==2 ? 3:2;
397
      int E2= numLayers==2 ? 5:3;
398
      float[][] bands     = new float[][] { {0.028f,35,0.16f,0.7f,N,E1,E1}, {0.000f, 0,1.00f,0.0f,3,1,E2} };
399
      int[] bandIndices   = new int[] { 0,0,0,1,1,1 };
400
      float[][] corners   = new float[][] { {0.08f,0.15f}, {0.08f,0.20f} };
401
      int[] cornerIndices = new int[] { 1,1,1,0,0 };
402
      float[][] centers   = new float[][] { {-0.25f, -0.25f, -0.25f} };
403
      int[] centerIndices = new int[] { 0,0,0,-1,0 };
404
      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
405
      }
406
    else if( variant==1 )
407
      {
408
      double[][] vertices = new double[][] { {-0.5, 0.0, 0.0},{ 0.5, 0.0, 0.0},{ 0.0,-0.5, 0.0},{ 0.0, 0.0,-0.5} };
409
      int[][] vert_indices = new int[][] { {2,1,0},{3,0,1},{2,3,1},{3,2,0} };
410
      int N = numLayers==2 ? 7:5;
411
      int E = numLayers==2 ? 5:2;
412
      float[][] bands     = new float[][] { {0.035f,30,0.16f,0.8f,N,2,E}, {0.020f,45,0.16f,0.2f,3,1,2} };
413
      int[] bandIndices   = new int[] { 0,0,1,1 };
414
      float[][] corners   = new float[][] { {0.07f,0.20f}, {0.02f,0.30f} };
415
      int[] cornerIndices = new int[] { 0,0,1,1 };
416
      float[][] centers   = new float[][] { {0.0f, -0.25f, -0.25f} };
417
      int[] centerIndices = new int[] { 0,0,0,0 };
418
      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
419
      }
420
    else
421
      {
422
      double[][] vertices = new double[][] { {-0.5f, 0.0f, 0.0f },{ 0.0f,-0.5f, 0.0f },{ 0.5f, 0.0f, 0.0f },{ 0.0f, 0.5f, 0.0f },{ 0.0f, 0.0f,-0.5f } };
423
      int[][] vert_indices = new int[][] { {0,1,2,3},{4,1,0},{4,2,1},{4,3,2},{4,0,3} };
424
      int N = numLayers==2 ? 7:6;
425
      int E = numLayers==2 ? 3:1;
426
      float[][] bands     = new float[][] { {0.051f,35,SQ2/8,0.9f,N,E,E}, {0.000f,0,1,0.0f,3,0,0} };
427
      int[] bandIndices   = new int[] { 0,1,1,1,1 };
428
      float[][] corners   = new float[][] { {0.06f,0.10f} };
429
      int[] cornerIndices = new int[] { 0,0,0,0,0 };
430
      float[][] centers   = new float[][] { {0,0,-0.2f} };
431
      int[] centerIndices = new int[] { 0,0,0,0,-1 };
432
      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
433
      }
434
    }
435

    
436
///////////////////////////////////////////////////////////////////////////////////////////////////
437

    
438
  int getNumCubitVariants(int numLayers)
439
    {
440
    return 3;
441
    }
442

    
443
///////////////////////////////////////////////////////////////////////////////////////////////////
444

    
445
  int getCubitVariant(int cubit, int numLayers)
446
    {
447
    int numCorners = getNumCorners();
448
    if( cubit<numCorners ) return 0;
449
    int numEdges = getNumEdges(numLayers);
450
    return cubit<numCorners+numEdges ? 1:2;
451
    }
452

    
453
///////////////////////////////////////////////////////////////////////////////////////////////////
454

    
455
  int getFaceColor(int cubit, int cubitface, int numLayers)
456
    {
457
    if( mCornerMap==null || mEdgeMap==null || mCenterMap==null )
458
      {
459
      mCornerMap = new int[][]
460
         {
461
           {  4, 2, 0, 18,18,18 },
462
           {  2, 5, 0, 18,18,18 },
463
           {  3, 4, 0, 18,18,18 },
464
           {  5, 3, 0, 18,18,18 },
465
           {  1, 2, 4, 18,18,18 },
466
           {  5, 2, 1, 18,18,18 },
467
           {  4, 3, 1, 18,18,18 },
468
           {  1, 3, 5, 18,18,18 },
469
         };
470

    
471
      mEdgeMap = new int[][]
472
         {
473
           { 10, 8, 18,18,18,18 },
474
           {  6,10, 18,18,18,18 },
475
           { 10, 9, 18,18,18,18 },
476
           {  7,10, 18,18,18,18 },
477
           {  8, 6, 18,18,18,18 },
478
           {  9, 6, 18,18,18,18 },
479
           {  9, 7, 18,18,18,18 },
480
           {  8, 7, 18,18,18,18 },
481
           { 11, 8, 18,18,18,18 },
482
           {  6,11, 18,18,18,18 },
483
           { 11, 9, 18,18,18,18 },
484
           {  7,11, 18,18,18,18 }
485
         };
486

    
487
      mCenterMap = new int[][]
488
         {
489
           { 12, 18,18,18,18,18 },
490
           { 13, 18,18,18,18,18 },
491
           { 14, 18,18,18,18,18 },
492
           { 15, 18,18,18,18,18 },
493
           { 16, 18,18,18,18,18 },
494
           { 17, 18,18,18,18,18 },
495
         };
496
      }
497

    
498
    int numCorners = getNumCorners();
499
    int numEdges   = getNumEdges(numLayers);
500

    
501
    if( cubit<numCorners )
502
      {
503
      return mCornerMap[cubit][cubitface];
504
      }
505
    else if( cubit<numCorners+numEdges )
506
      {
507
      int edge = (cubit-numCorners)/(numLayers-2);
508
      return mEdgeMap[edge][cubitface];
509
      }
510
    else
511
      {
512
      int center = (cubit-numCorners-numEdges)/getNumCentersPerFace(numLayers);
513
      return mCenterMap[center][cubitface];
514
      }
515
    }
516

    
517
///////////////////////////////////////////////////////////////////////////////////////////////////
518

    
519
  int getColor(int face)
520
    {
521
    return FACE_COLORS[face];
522
    }
523

    
524
///////////////////////////////////////////////////////////////////////////////////////////////////
525

    
526
  ObjectSticker retSticker(int face)
527
    {
528
    if( mStickers==null )
529
      {
530
      float[][] STICKERS = new float[][]
531
          {
532
             { -0.5f, 0.25f, 0.25f,  -0.5f, 0.25f, 0.25f  },
533
             { -0.5f, 0.00f, 0.00f,  -0.5f, 0.50f, 0.0f, 0.0f, 0.5f }
534
          };
535

    
536
      final float R1 = 0.025f;
537
      final float R2 = 0.025f;
538
      final float R3 = 0.055f;
539
      final float[][] radii  = { { R1,R1,R1 },{ R2,R2,R2 },{ R3,R3,R3,R3 } };
540
      final float[] strokes = { 0.045f, 0.035f, 0.035f };
541

    
542
      mStickers = new ObjectSticker[STICKERS.length+1];
543

    
544
      for(int s=0; s<STICKERS.length+1; s++)
545
        {
546
        int index = s<2 ? 0:1;
547
        mStickers[s] = new ObjectSticker(STICKERS[index],null,radii[s],strokes[s]);
548
        }
549
      }
550

    
551
    return mStickers[face/NUM_FACES];
552
    }
553

    
554
///////////////////////////////////////////////////////////////////////////////////////////////////
555

    
556
  float returnMultiplier()
557
    {
558
    return 2.0f;
559
    }
560

    
561
///////////////////////////////////////////////////////////////////////////////////////////////////
562

    
563
  private void initializeScrambling()
564
    {
565
    int numLayers = getNumLayers();
566

    
567
    if( mScrambleTable ==null )
568
      {
569
      mScrambleTable = new int[NUM_AXIS][numLayers];
570
      }
571
    if( mNumOccurences ==null )
572
      {
573
      int max=0;
574

    
575
      for (ScrambleState mState : mStates)
576
        {
577
        int tmp = mState.getTotal(-1);
578
        if (max < tmp) max = tmp;
579
        }
580

    
581
      mNumOccurences = new int[max];
582
      }
583

    
584
    for(int i=0; i<NUM_AXIS; i++)
585
      for(int j=0; j<numLayers; j++) mScrambleTable[i][j] = 0;
586
    }
587

    
588
///////////////////////////////////////////////////////////////////////////////////////////////////
589
// PUBLIC API
590

    
591
  public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles)
592
    {
593
    if( curr==0 )
594
      {
595
      mCurrState     = 0;
596
      mIndexExcluded =-1;
597
      initializeScrambling();
598
      }
599

    
600
    int[] info= mStates[mCurrState].getRandom(rnd, mIndexExcluded, mScrambleTable, mNumOccurences);
601

    
602
    scramble[curr][0] = info[0];
603
    scramble[curr][1] = info[1];
604
    scramble[curr][2] = info[2];
605

    
606
    mCurrState     = info[3];
607
    mIndexExcluded = info[0];
608
    }
609

    
610
///////////////////////////////////////////////////////////////////////////////////////////////////
611

    
612
  public Static3D[] getRotationAxis()
613
    {
614
    return ROT_AXIS;
615
    }
616

    
617
///////////////////////////////////////////////////////////////////////////////////////////////////
618

    
619
  public int[] getBasicAngle()
620
    {
621
    if( mBasicAngle ==null ) mBasicAngle = new int[] { 3,3,3,3 };
622
    return mBasicAngle;
623
    }
624

    
625
///////////////////////////////////////////////////////////////////////////////////////////////////
626

    
627
  public int getObjectName(int numLayers)
628
    {
629
    switch(numLayers)
630
      {
631
      case 2: return R.string.skew2;
632
      case 3: return R.string.skew3;
633
      }
634
    return R.string.skew2;
635
    }
636

    
637
///////////////////////////////////////////////////////////////////////////////////////////////////
638

    
639
  public int getInventor(int numLayers)
640
    {
641
    switch(numLayers)
642
      {
643
      case 2: return R.string.skew2_inventor;
644
      case 3: return R.string.skew3_inventor;
645
      }
646
    return R.string.skew2_inventor;
647
    }
648

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

    
651
  public int getComplexity(int numLayers)
652
    {
653
    switch(numLayers)
654
      {
655
      case 2: return 4;
656
      case 3: return 8;
657
      }
658
    return 5;
659
    }
660
}
(37-37/41)