Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyCuboid.java @ 55fa6993

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 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.objectlib.objects;
21

    
22
import static org.distorted.objectlib.main.Movement.MOVEMENT_SHAPECHANGE;
23
import static org.distorted.objectlib.main.Movement.TYPE_NOT_SPLIT;
24

    
25
import android.content.res.Resources;
26

    
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

    
33
import org.distorted.objectlib.R;
34
import org.distorted.objectlib.main.MovementC;
35
import org.distorted.objectlib.main.ObjectControl;
36
import org.distorted.objectlib.main.ObjectType;
37
import org.distorted.objectlib.helpers.ObjectShape;
38
import org.distorted.objectlib.helpers.ObjectSticker;
39
import org.distorted.objectlib.helpers.ScrambleState;
40
import org.distorted.objectlib.main.Twisty6;
41

    
42
///////////////////////////////////////////////////////////////////////////////////////////////////
43

    
44
public class TwistyCuboid extends Twisty6
45
{
46
  static final Static3D[] ROT_AXIS = new Static3D[]
47
         {
48
           new Static3D(1,0,0),
49
           new Static3D(0,1,0),
50
           new Static3D(0,0,1)
51
         };
52

    
53
  private ScrambleState[] mStates;
54
  private Static4D[] mQuats;
55
  private float[][] mCuts;
56
  private int[] mBasicAngle;
57
  private ObjectSticker[] mStickers;
58

    
59
///////////////////////////////////////////////////////////////////////////////////////////////////
60

    
61
  public TwistyCuboid(int[] numL, Static4D quat, Static3D move, DistortedTexture texture,
62
                      MeshSquare mesh, DistortedEffects effects, Resources res, int surfaceW, int surfaceH)
63
    {
64
    super(numL, (numL[0]+numL[1]+numL[2])/3.0f, quat, move, texture, mesh, effects, res, surfaceW, surfaceH);
65
    }
66

    
67
///////////////////////////////////////////////////////////////////////////////////////////////////
68

    
69
  private int[] createEdges(int size, boolean full, int vertex)
70
    {
71
    if( size==1 ) return null;
72

    
73
    if( full )
74
      {
75
      int[] ret = new int[9*size];
76

    
77
      for(int l=0; l<size; l++)
78
        {
79
        ret[9*l  ] = l;
80
        ret[9*l+1] =-1;
81
        ret[9*l+2] = vertex;
82
        ret[9*l+3] = l;
83
        ret[9*l+4] = 1;
84
        ret[9*l+5] = vertex;
85
        ret[9*l+6] = l;
86
        ret[9*l+7] = 2;
87
        ret[9*l+8] = vertex;
88
        }
89

    
90
      return ret;
91
      }
92
    else
93
      {
94
      int[] ret = new int[6*size];
95

    
96
      for(int l=0; l<size; l++)
97
        {
98
        ret[6*l  ] = l;
99
        ret[6*l+1] = 1;
100
        ret[6*l+2] = vertex;
101
        ret[6*l+3] = l;
102
        ret[6*l+4] =-1;
103
        ret[6*l+5] = vertex;
104
        }
105

    
106
      return ret;
107
      }
108
    }
109

    
110
///////////////////////////////////////////////////////////////////////////////////////////////////
111

    
112
  public ScrambleState[] getScrambleStates()
113
    {
114
    if( mStates==null )
115
      {
116
      int[] numLayers = getNumLayers();
117

    
118
      int X = numLayers[0];
119
      int Y = numLayers[1];
120
      int Z = numLayers[2];
121

    
122
      int[][] mX = new int[16][];
123
      int[][] mY = new int[16][];
124
      int[][] mZ = new int[16][];
125

    
126
      for(int i=0; i<16; i++)
127
        {
128
        mX[i] = createEdges(X,Y==Z,i);
129
        mY[i] = createEdges(Y,X==Z,i);
130
        mZ[i] = createEdges(Z,X==Y,i);
131
        }
132

    
133
      if( X>1 && Y>1 && Z>1 )
134
        {
135
        mStates = new ScrambleState[]
136
          {
137
          new ScrambleState( new int[][] { mX[ 1], mY[ 2], mZ[ 3] } ),  //  0 0
138
          new ScrambleState( new int[][] {   null, mY[ 4], mZ[ 5] } ),  //  1 x
139
          new ScrambleState( new int[][] { mX[ 6],   null, mZ[ 7] } ),  //  2 y
140
          new ScrambleState( new int[][] { mX[ 8], mY[ 9],   null } ),  //  3 z
141
          new ScrambleState( new int[][] { mX[10],   null, mZ[ 7] } ),  //  4 xy
142
          new ScrambleState( new int[][] { mX[11], mY[ 9],   null } ),  //  5 xz
143
          new ScrambleState( new int[][] {   null, mY[12], mZ[ 5] } ),  //  6 yx
144
          new ScrambleState( new int[][] { mX[ 8], mY[13],   null } ),  //  7 yz
145
          new ScrambleState( new int[][] {   null, mY[ 4], mZ[14] } ),  //  8 zx
146
          new ScrambleState( new int[][] { mX[ 6],   null, mZ[15] } ),  //  9 zy
147
          new ScrambleState( new int[][] {   null,   null, mZ[ 5] } ),  // 10 xyx
148
          new ScrambleState( new int[][] {   null, mY[ 4],   null } ),  // 11 xzx
149
          new ScrambleState( new int[][] {   null,   null, mZ[ 7] } ),  // 12 yxy
150
          new ScrambleState( new int[][] { mX[ 6],   null,   null } ),  // 13 yzy
151
          new ScrambleState( new int[][] {   null, mY[ 9],   null } ),  // 14 zxz
152
          new ScrambleState( new int[][] { mX[ 8],   null,   null } ),  // 15 zyz
153
          };
154
        }
155
      else if( X==1 && Y==1 && Z==1 )
156
        {
157
        int[] state = new int[] {0,-1,0,0,1,0,0,2,0};
158

    
159
        mStates = new ScrambleState[]
160
          {
161
          new ScrambleState( new int[][] { state, state, state } )
162
          };
163
        }
164
      else
165
        {
166
        mStates = new ScrambleState[]
167
          {
168
          new ScrambleState( new int[][] { mX[ 0], mY[ 0], mZ[ 0] } )
169
          };
170
        }
171

    
172
      }
173

    
174
    return mStates;
175
    }
176

    
177
///////////////////////////////////////////////////////////////////////////////////////////////////
178

    
179
  protected int getResource(int[] numLayers)
180
    {
181
    int x = numLayers[0];
182
    int y = numLayers[1];
183

    
184
    switch(x)
185
      {
186
      case 2: return y==2 ? R.raw.cube_2 : R.raw.cu_232;
187
      case 3: switch(y)
188
                {
189
                case 2: return R.raw.cu_323;
190
                case 3: return R.raw.cube_3;
191
                case 4: return R.raw.cu_343;
192
                }
193
      case 4: return R.raw.cube_4;
194
      case 5: return R.raw.cube_5;
195
      }
196

    
197
    return 0;
198
    }
199

    
200
///////////////////////////////////////////////////////////////////////////////////////////////////
201

    
202
  private void initializeQuats()
203
    {
204
    mQuats = new Static4D[]
205
         {
206
         new Static4D(  0.0f,   0.0f,   0.0f,   1.0f),
207
         new Static4D(  1.0f,   0.0f,   0.0f,   0.0f),
208
         new Static4D(  0.0f,   1.0f,   0.0f,   0.0f),
209
         new Static4D(  0.0f,   0.0f,   1.0f,   0.0f),
210

    
211
         new Static4D( SQ2/2,  SQ2/2,  0.0f ,   0.0f),
212
         new Static4D( SQ2/2, -SQ2/2,  0.0f ,   0.0f),
213
         new Static4D( SQ2/2,   0.0f,  SQ2/2,   0.0f),
214
         new Static4D(-SQ2/2,   0.0f,  SQ2/2,   0.0f),
215
         new Static4D( SQ2/2,   0.0f,   0.0f,  SQ2/2),
216
         new Static4D( SQ2/2,   0.0f,   0.0f, -SQ2/2),
217
         new Static4D(  0.0f,  SQ2/2,  SQ2/2,   0.0f),
218
         new Static4D(  0.0f,  SQ2/2, -SQ2/2,   0.0f),
219
         new Static4D(  0.0f,  SQ2/2,   0.0f,  SQ2/2),
220
         new Static4D(  0.0f,  SQ2/2,   0.0f, -SQ2/2),
221
         new Static4D(  0.0f,   0.0f,  SQ2/2,  SQ2/2),
222
         new Static4D(  0.0f,   0.0f,  SQ2/2, -SQ2/2),
223

    
224
         new Static4D(  0.5f,   0.5f,   0.5f,   0.5f),
225
         new Static4D(  0.5f,   0.5f,  -0.5f,   0.5f),
226
         new Static4D(  0.5f,   0.5f,  -0.5f,  -0.5f),
227
         new Static4D(  0.5f,  -0.5f,   0.5f,  -0.5f),
228
         new Static4D( -0.5f,  -0.5f,  -0.5f,   0.5f),
229
         new Static4D( -0.5f,   0.5f,  -0.5f,  -0.5f),
230
         new Static4D( -0.5f,   0.5f,   0.5f,  -0.5f),
231
         new Static4D( -0.5f,   0.5f,   0.5f,   0.5f)
232
         };
233
    }
234

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

    
237
  public int[] getSolvedQuats(int cubit, int[] numLayers)
238
    {
239
    if( mQuats ==null ) initializeQuats();
240
    int status = retCubitSolvedStatus(cubit,numLayers);
241
    return status<0 ? null : buildSolvedQuats(MovementC.FACE_AXIS[status], mQuats);
242
    }
243

    
244
///////////////////////////////////////////////////////////////////////////////////////////////////
245

    
246
  public ObjectShape getObjectShape(int variant)
247
    {
248
    int extraI, extraV, num, numL = getNumLayers()[0];
249
    float height;
250

    
251
    switch(numL)
252
        {
253
        case 2 : num = 6; extraI = 2; extraV = 2; height = 0.045f; break;
254
        case 3 : num = 5; extraI = 2; extraV = 2; height = 0.045f; break;
255
        case 4 : num = 5; extraI = 1; extraV = 1; height = 0.045f; break;
256
        default: num = 5; extraI = 0; extraV = 0; height = 0.045f; break;
257
        }
258

    
259
    double[][] vertices = new double[][]
260
          {
261
              { 0.5, 0.5, 0.5 },
262
              { 0.5, 0.5,-0.5 },
263
              { 0.5,-0.5, 0.5 },
264
              { 0.5,-0.5,-0.5 },
265
              {-0.5, 0.5, 0.5 },
266
              {-0.5, 0.5,-0.5 },
267
              {-0.5,-0.5, 0.5 },
268
              {-0.5,-0.5,-0.5 },
269
          };
270

    
271
    int[][] vert_indices = new int[][]
272
          {
273
              {2,3,1,0},
274
              {7,6,4,5},
275
              {4,0,1,5},
276
              {7,3,2,6},
277
              {6,2,0,4},
278
              {3,7,5,1}
279
          };
280

    
281
    float[][] corners   = new float[][] { {0.036f,0.12f} };
282
    int[] cornerIndices = new int[] { 0,0,0,0,0,0,0,0 };
283
    float[][] centers   = new float[][] { {0.0f, 0.0f, 0.0f} };
284
    int[] centerIndices = new int[] { 0,0,0,0,0,0,0,0 };
285

    
286
    if( variant==0 )
287
      {
288
      float[][] bands   = new float[][] { {height,35,0.5f,0.7f,num,extraI,extraV} };
289
      int[] bandIndices = new int[] { 0,0,0,0,0,0};
290
      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
291
      }
292
    else
293
      {
294
      int extraI2, extraV2, num2;
295

    
296
      switch(numL)
297
        {
298
        case 2 : num2 = 6; extraI2 = 2; extraV2 = 2; break;
299
        case 3 : num2 = 5; extraI2 = 1; extraV2 = 0; break;
300
        case 4 : num2 = 4; extraI2 = 0; extraV2 = 0; break;
301
        default: num2 = 3; extraI2 = 0; extraV2 = 0; break;
302
        }
303

    
304
      float[][] bands   = new float[][]
305
        {
306
          {height,35,0.5f,0.7f,num ,extraI ,extraV },
307
          {height,35,0.5f,0.7f,num2,extraI2,extraV2},
308
          {height,35,0.5f,0.7f,   2,      0,      0},
309
        };
310
      int[] bandIndices = new int[] { 1,1,1,1,0,2};
311
      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
312
      }
313
    }
314

    
315
///////////////////////////////////////////////////////////////////////////////////////////////////
316

    
317
  private int getCenterNum(int cubit, int[] numLayers)
318
    {
319
    int num = cubit - getNumCornersAndEdges(numLayers);
320

    
321
    if( num>=0 )
322
      {
323
      int numLR = (numLayers[1]-2)*(numLayers[2]-2);
324
      if( num<  numLR ) return 0;
325
      if( num<2*numLR ) return 1;
326
      num -= 2*numLR;
327

    
328
      int numTD = (numLayers[0]-2)*(numLayers[2]-2);
329
      if( num<  numTD ) return 2;
330
      if( num<2*numTD ) return 3;
331
      num -= 2*numTD;
332

    
333
      int numFB = (numLayers[0]-2)*(numLayers[1]-2);
334
      if( num<  numFB ) return 4;
335
      if( num<2*numFB ) return 5;
336
      }
337

    
338
    return -1;
339
    }
340

    
341
///////////////////////////////////////////////////////////////////////////////////////////////////
342

    
343
  private int getNumCornersAndEdges(int[] numLayers)
344
    {
345
    int x = numLayers[0];
346
    int y = numLayers[1];
347
    int z = numLayers[2];
348

    
349
    return ( x==1 || y==1 || z==1 ) ? x*y*z : 4*( (x-2)+(y-2)+(z-2) ) + 8;
350
    }
351

    
352
///////////////////////////////////////////////////////////////////////////////////////////////////
353

    
354
  public float[][] getCubitPositions(int[] numLayers)
355
    {
356
    final int X = numLayers[0];
357
    final int Y = numLayers[1];
358
    final int Z = numLayers[2];
359

    
360
    final float lenX = 0.5f*(X-1);
361
    final float lenY = 0.5f*(Y-1);
362
    final float lenZ = 0.5f*(Z-1);
363

    
364
    int curPos = 0;
365

    
366
    if( X==1 )
367
      {
368
      float[][] pos = new float[X*Y*Z][];
369

    
370
      for(int y=0; y<Y; y++)
371
        for(int z=0; z<Z; z++) pos[curPos++] = new float[] {+lenX,y-lenY,z-lenZ};
372

    
373
      return pos;
374
      }
375

    
376
    if( Y==1 )
377
      {
378
      float[][] pos = new float[X*Y*Z][];
379

    
380
      for(int x=0; x<X; x++)
381
        for(int z=0; z<Z; z++) pos[curPos++] = new float[] {x-lenX,+lenY,z-lenZ};
382

    
383
      return pos;
384
      }
385

    
386
    if( Z==1 )
387
      {
388
      float[][] pos = new float[X*Y*Z][];
389

    
390
      for(int x=0; x<X; x++)
391
        for(int y=0; y<Y; y++) pos[curPos++] = new float[] {x-lenX,y-lenY,+lenZ};
392

    
393
      return pos;
394
      }
395

    
396
    int numCubits = X*Y*Z - (X-2)*(Y-2)*(Z-2);
397
    float[][] pos = new float[numCubits][];
398

    
399
    pos[curPos++] = new float[] {-lenX,-lenY,-lenZ};
400
    pos[curPos++] = new float[] {-lenX,-lenY,+lenZ};
401
    pos[curPos++] = new float[] {-lenX,+lenY,-lenZ};
402
    pos[curPos++] = new float[] {-lenX,+lenY,+lenZ};
403
    pos[curPos++] = new float[] {+lenX,-lenY,-lenZ};
404
    pos[curPos++] = new float[] {+lenX,-lenY,+lenZ};
405
    pos[curPos++] = new float[] {+lenX,+lenY,-lenZ};
406
    pos[curPos++] = new float[] {+lenX,+lenY,+lenZ};
407

    
408
    for(int i=1; i<X-1; i++) pos[curPos++] = new float[] { i-lenX,  -lenY,  -lenZ };
409
    for(int i=1; i<X-1; i++) pos[curPos++] = new float[] { i-lenX,  -lenY,  +lenZ };
410
    for(int i=1; i<X-1; i++) pos[curPos++] = new float[] { i-lenX,  +lenY,  -lenZ };
411
    for(int i=1; i<X-1; i++) pos[curPos++] = new float[] { i-lenX,  +lenY,  +lenZ };
412
    for(int i=1; i<Y-1; i++) pos[curPos++] = new float[] {  -lenX, i-lenY,  -lenZ };
413
    for(int i=1; i<Y-1; i++) pos[curPos++] = new float[] {  -lenX, i-lenY,  +lenZ };
414
    for(int i=1; i<Y-1; i++) pos[curPos++] = new float[] {  +lenX, i-lenY,  -lenZ };
415
    for(int i=1; i<Y-1; i++) pos[curPos++] = new float[] {  +lenX, i-lenY,  +lenZ };
416
    for(int i=1; i<Z-1; i++) pos[curPos++] = new float[] {  -lenX,  -lenY, i-lenZ };
417
    for(int i=1; i<Z-1; i++) pos[curPos++] = new float[] {  -lenX,  +lenY, i-lenZ };
418
    for(int i=1; i<Z-1; i++) pos[curPos++] = new float[] {  +lenX,  -lenY, i-lenZ };
419
    for(int i=1; i<Z-1; i++) pos[curPos++] = new float[] {  +lenX,  +lenY, i-lenZ };
420

    
421
    for(int y=1; y<Y-1; y++)
422
      for(int z=1; z<Z-1; z++) pos[curPos++] = new float[] {+lenX,y-lenY,z-lenZ};
423

    
424
    for(int y=1; y<Y-1; y++)
425
      for(int z=1; z<Z-1; z++) pos[curPos++] = new float[] {-lenX,y-lenY,z-lenZ};
426

    
427
    for(int x=1; x<X-1; x++)
428
      for(int z=1; z<Z-1; z++) pos[curPos++] = new float[] {x-lenX,+lenY,z-lenZ};
429

    
430
    for(int x=1; x<X-1; x++)
431
      for(int z=1; z<Z-1; z++) pos[curPos++] = new float[] {x-lenX,-lenY,z-lenZ};
432

    
433
    for(int x=1; x<X-1; x++)
434
      for(int y=1; y<Y-1; y++) pos[curPos++] = new float[] {x-lenX,y-lenY,+lenZ};
435

    
436
    for(int x=1; x<X-1; x++)
437
      for(int y=1; y<Y-1; y++) pos[curPos++] = new float[] {x-lenX,y-lenY,-lenZ};
438

    
439
    return pos;
440
    }
441

    
442
///////////////////////////////////////////////////////////////////////////////////////////////////
443

    
444
  public Static4D getQuat(int cubit, int[] numLayers)
445
    {
446
    if( mQuats ==null ) initializeQuats();
447

    
448
    int centerNum = getCenterNum(cubit,numLayers);
449

    
450
    switch(centerNum)
451
      {
452
      case 0 : return mQuats[13];
453
      case 1 : return mQuats[12];
454
      case 2 : return mQuats[ 8];
455
      case 3 : return mQuats[ 9];
456
      case 4 : return mQuats[ 0];
457
      case 5 : return mQuats[ 1];
458
      default: return mQuats[ 0];
459
      }
460
    }
461

    
462
///////////////////////////////////////////////////////////////////////////////////////////////////
463

    
464
  public int getNumCubitVariants(int[] numLayers)
465
    {
466
    return numLayers[0]>2 ? 2:1;
467
    }
468

    
469
///////////////////////////////////////////////////////////////////////////////////////////////////
470

    
471
  public int getCubitVariant(int cubit, int[] numLayers)
472
    {
473
    return cubit < getNumCornersAndEdges(numLayers) ? 0 : 1;
474
    }
475

    
476
///////////////////////////////////////////////////////////////////////////////////////////////////
477

    
478
  public int getVariantFaceColor(int variant, int face, int[] numLayers)
479
    {
480
    return 0;
481
    }
482

    
483
///////////////////////////////////////////////////////////////////////////////////////////////////
484

    
485
  public int getCubitFaceColor(int cubit, int face, int[] numLayers)
486
    {
487
    int centerNum = getCenterNum(cubit,numLayers);
488

    
489
    if( centerNum<0 )
490
      {
491
      int axis = face/2;
492
      return CUBITS[cubit].getRotRow(axis) == (face%2==0 ? (1<<(numLayers[axis]-1)):1) ? face : -1;
493
      }
494
    else
495
      {
496
      return face==4 ? centerNum : -1;
497
      }
498
    }
499

    
500
///////////////////////////////////////////////////////////////////////////////////////////////////
501

    
502
  public ObjectSticker retSticker(int sticker)
503
    {
504
    if( mStickers==null )
505
      {
506
      final float[][] STICKERS = new float[][]  { { -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f } };
507
      final float radius = 0.10f;
508
      final float[] radii = {radius,radius,radius,radius};
509
      mStickers = new ObjectSticker[STICKERS.length];
510
      float stroke = 0.08f;
511

    
512
      if( ObjectControl.isInIconMode() )
513
        {
514
        int[] numLayers = getNumLayers();
515

    
516
        switch(numLayers[0])
517
          {
518
          case 2: stroke*=1.8f; break;
519
          case 3: stroke*=2.0f; break;
520
          case 4: stroke*=2.1f; break;
521
          default:stroke*=2.2f; break;
522
          }
523
        }
524

    
525
      mStickers[0] = new ObjectSticker(STICKERS[0],null,radii,stroke );
526
      }
527

    
528
    return mStickers[sticker];
529
    }
530

    
531
///////////////////////////////////////////////////////////////////////////////////////////////////
532

    
533
  public Static4D[] getQuats()
534
    {
535
    if( mQuats ==null ) initializeQuats();
536
    return mQuats;
537
    }
538

    
539
///////////////////////////////////////////////////////////////////////////////////////////////////
540

    
541
  public float[][] getCuts(int[] numLayers)
542
    {
543
    if( mCuts==null )
544
      {
545
      mCuts = new float[3][];
546

    
547
      for(int axis=0; axis<3; axis++)
548
        {
549
        int len = numLayers[axis];
550
        float start = (2-len)*0.5f;
551

    
552
        if( len>=2 )
553
          {
554
          mCuts[axis] = new float[len-1];
555
          for(int i=0; i<len-1; i++) mCuts[axis][i] = start+i;
556
          }
557
        }
558
      }
559

    
560
    return mCuts;
561
    }
562

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

    
565
  public boolean[][] getLayerRotatable(int[] numLayers)
566
    {
567
    int numAxis = ROT_AXIS.length;
568
    boolean[][] layerRotatable = new boolean[numAxis][];
569

    
570
    for(int i=0; i<numAxis; i++)
571
      {
572
      layerRotatable[i] = new boolean[numLayers[i]];
573
      for(int j=0; j<numLayers[i]; j++) layerRotatable[i][j] = true;
574
      }
575

    
576
    return layerRotatable;
577
    }
578

    
579
///////////////////////////////////////////////////////////////////////////////////////////////////
580

    
581
  public int getMovementType()
582
    {
583
    return MOVEMENT_SHAPECHANGE;
584
    }
585

    
586
///////////////////////////////////////////////////////////////////////////////////////////////////
587

    
588
  public int getMovementSplit()
589
    {
590
    return TYPE_NOT_SPLIT;
591
    }
592

    
593
///////////////////////////////////////////////////////////////////////////////////////////////////
594

    
595
  public int[][][] getEnabled()
596
    {
597
    return new int[][][]
598
      {
599
          {{1,2}},{{1,2}},{{0,2}},{{0,2}},{{0,1}},{{0,1}},
600
      };
601
    }
602

    
603
///////////////////////////////////////////////////////////////////////////////////////////////////
604

    
605
  public float[] getDist3D(int[] numLayers)
606
    {
607
    float avg = (numLayers[0]+numLayers[1]+numLayers[2])/3.0f;
608

    
609
    return new float[]
610
        {
611
        0.5f*numLayers[0]/avg,
612
        0.5f*numLayers[0]/avg,
613
        0.5f*numLayers[1]/avg,
614
        0.5f*numLayers[1]/avg,
615
        0.5f*numLayers[2]/avg,
616
        0.5f*numLayers[2]/avg,
617
        };
618
    }
619

    
620
///////////////////////////////////////////////////////////////////////////////////////////////////
621

    
622
  public int getSolvedFunctionIndex()
623
    {
624
    return 0;
625
    }
626

    
627
///////////////////////////////////////////////////////////////////////////////////////////////////
628

    
629
  public int getNumStickerTypes(int[] numLayers)
630
    {
631
    return 1;
632
    }
633

    
634
///////////////////////////////////////////////////////////////////////////////////////////////////
635

    
636
  public int getNumCubitFaces()
637
    {
638
    return 6;
639
    }
640

    
641
///////////////////////////////////////////////////////////////////////////////////////////////////
642
// PUBLIC API
643

    
644
  public Static3D[] getRotationAxis()
645
    {
646
    return ROT_AXIS;
647
    }
648

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

    
651
  public int[] getBasicAngle()
652
    {
653
    if( mBasicAngle==null )
654
      {
655
      int[] num = getNumLayers();
656
      int x = num[1]==num[2] ? 4 : 2;
657
      int y = num[0]==num[2] ? 4 : 2;
658
      int z = num[0]==num[1] ? 4 : 2;
659

    
660
      mBasicAngle = new int[] { x,y,z };
661
      }
662
    return mBasicAngle;
663
    }
664

    
665
///////////////////////////////////////////////////////////////////////////////////////////////////
666

    
667
  public ObjectType intGetObjectType(int[] numLayers)
668
    {
669
    int x = numLayers[0];
670
    int y = numLayers[1];
671

    
672
    switch(x)
673
      {
674
      case 2: switch(y)
675
                {
676
                case 2: return ObjectType.CUBE_2;
677
                case 3: return ObjectType.CU_232;
678
                }
679
      case 3: switch(y)
680
                {
681
                case 2: return ObjectType.CU_323;
682
                case 3: return ObjectType.CUBE_3;
683
                case 4: return ObjectType.CU_343;
684
                }
685
      case 4: return ObjectType.CUBE_4;
686
      case 5: return ObjectType.CUBE_5;
687
      }
688

    
689
    return ObjectType.CUBE_3;
690
    }
691

    
692
///////////////////////////////////////////////////////////////////////////////////////////////////
693

    
694
  public int getObjectName(int[] numLayers)
695
    {
696
    switch(numLayers[0])
697
      {
698
      case 2: return R.string.cube2;
699
      case 3: return R.string.cube3;
700
      case 4: return R.string.cube4;
701
      case 5: return R.string.cube5;
702
      }
703
    return R.string.cube3;
704
    }
705

    
706
///////////////////////////////////////////////////////////////////////////////////////////////////
707

    
708
  public int getInventor(int[] numLayers)
709
    {
710
    switch(numLayers[0])
711
      {
712
      case 2: return R.string.cube2_inventor;
713
      case 3: return R.string.cube3_inventor;
714
      case 4: return R.string.cube4_inventor;
715
      case 5: return R.string.cube5_inventor;
716
      }
717
    return R.string.cube3_inventor;
718
    }
719

    
720
///////////////////////////////////////////////////////////////////////////////////////////////////
721

    
722
  public int getYearOfInvention(int[] numLayers)
723
    {
724
    switch(numLayers[0])
725
      {
726
      case 2: return 1970;
727
      case 3: return 1974;
728
      case 4: return 1981;
729
      case 5: return 1981;
730
      }
731
    return 1974;
732
    }
733

    
734
///////////////////////////////////////////////////////////////////////////////////////////////////
735

    
736
  public int getComplexity(int[] numLayers)
737
    {
738
    switch(numLayers[0])
739
      {
740
      case 2: return 4;
741
      case 3: return 6;
742
      case 4: return 8;
743
      case 5: return 10;
744
      }
745
    return 6;
746
    }
747
}
(6-6/25)