Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyCuboid.java @ 43a4ccff

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.cube2 : R.raw.cu_232;
187
      case 3: switch(y)
188
                {
189
                case 2: return R.raw.cu_323;
190
                case 3: return R.raw.cube3;
191
                case 4: return R.raw.cu_343;
192
                }
193
      case 4: return R.raw.cube4;
194
      case 5: return R.raw.cube5;
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
  protected int getFaceColor(int cubit, int cubitface, int[] numLayers)
479
    {
480
    int centerNum = getCenterNum(cubit,numLayers);
481

    
482
    if( centerNum<0 )
483
      {
484
      int axis = cubitface/2;
485
      return CUBITS[cubit].getRotRow(axis) == (cubitface%2==0 ? (1<<(numLayers[axis]-1)):1) ? cubitface : NUM_TEXTURES;
486
      }
487
    else
488
      {
489
      return cubitface == 4 ? centerNum : NUM_TEXTURES;
490
      }
491
    }
492

    
493
///////////////////////////////////////////////////////////////////////////////////////////////////
494

    
495
  public ObjectSticker retSticker(int sticker)
496
    {
497
    if( mStickers==null )
498
      {
499
      final float[][] STICKERS = new float[][]  { { -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f } };
500
      final float radius = 0.10f;
501
      final float[] radii = {radius,radius,radius,radius};
502
      mStickers = new ObjectSticker[STICKERS.length];
503
      float stroke = 0.08f;
504

    
505
      if( ObjectControl.isInIconMode() )
506
        {
507
        int[] numLayers = getNumLayers();
508

    
509
        switch(numLayers[0])
510
          {
511
          case 2: stroke*=1.8f; break;
512
          case 3: stroke*=2.0f; break;
513
          case 4: stroke*=2.1f; break;
514
          default:stroke*=2.2f; break;
515
          }
516
        }
517

    
518
      mStickers[0] = new ObjectSticker(STICKERS[0],null,radii,stroke );
519
      }
520

    
521
    return mStickers[sticker];
522
    }
523

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

    
526
  public Static4D[] getQuats()
527
    {
528
    if( mQuats ==null ) initializeQuats();
529
    return mQuats;
530
    }
531

    
532
///////////////////////////////////////////////////////////////////////////////////////////////////
533

    
534
  public float[][] getCuts(int[] numLayers)
535
    {
536
    if( mCuts==null )
537
      {
538
      mCuts = new float[3][];
539

    
540
      for(int axis=0; axis<3; axis++)
541
        {
542
        int len = numLayers[axis];
543
        float start = (2-len)*0.5f;
544

    
545
        if( len>=2 )
546
          {
547
          mCuts[axis] = new float[len-1];
548
          for(int i=0; i<len-1; i++) mCuts[axis][i] = start+i;
549
          }
550
        }
551
      }
552

    
553
    return mCuts;
554
    }
555

    
556
///////////////////////////////////////////////////////////////////////////////////////////////////
557

    
558
  public boolean[][] getLayerRotatable(int[] numLayers)
559
    {
560
    int numAxis = ROT_AXIS.length;
561
    boolean[][] layerRotatable = new boolean[numAxis][];
562

    
563
    for(int i=0; i<numAxis; i++)
564
      {
565
      layerRotatable[i] = new boolean[numLayers[i]];
566
      for(int j=0; j<numLayers[i]; j++) layerRotatable[i][j] = true;
567
      }
568

    
569
    return layerRotatable;
570
    }
571

    
572
///////////////////////////////////////////////////////////////////////////////////////////////////
573

    
574
  public int getMovementType()
575
    {
576
    return MOVEMENT_SHAPECHANGE;
577
    }
578

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

    
581
  public int getMovementSplit()
582
    {
583
    return TYPE_NOT_SPLIT;
584
    }
585

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

    
588
  public int[][][] getEnabled()
589
    {
590
    return new int[][][]
591
      {
592
          {{1,2}},{{1,2}},{{0,2}},{{0,2}},{{0,1}},{{0,1}},
593
      };
594
    }
595

    
596
///////////////////////////////////////////////////////////////////////////////////////////////////
597

    
598
  public float[] getDist3D(int[] numLayers)
599
    {
600
    float avg = (numLayers[0]+numLayers[1]+numLayers[2])/3.0f;
601

    
602
    return new float[]
603
        {
604
        0.5f*numLayers[0]/avg,
605
        0.5f*numLayers[0]/avg,
606
        0.5f*numLayers[1]/avg,
607
        0.5f*numLayers[1]/avg,
608
        0.5f*numLayers[2]/avg,
609
        0.5f*numLayers[2]/avg,
610
        };
611
    }
612

    
613
///////////////////////////////////////////////////////////////////////////////////////////////////
614

    
615
  public int getSolvedFunctionIndex()
616
    {
617
    return 0;
618
    }
619

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

    
622
  public int getNumStickerTypes(int[] numLayers)
623
    {
624
    return 1;
625
    }
626

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

    
629
  protected int getNumCubitFaces()
630
    {
631
    return 6;
632
    }
633

    
634
///////////////////////////////////////////////////////////////////////////////////////////////////
635
// PUBLIC API
636

    
637
  public Static3D[] getRotationAxis()
638
    {
639
    return ROT_AXIS;
640
    }
641

    
642
///////////////////////////////////////////////////////////////////////////////////////////////////
643

    
644
  public int[] getBasicAngle()
645
    {
646
    if( mBasicAngle==null )
647
      {
648
      int[] num = getNumLayers();
649
      int x = num[1]==num[2] ? 4 : 2;
650
      int y = num[0]==num[2] ? 4 : 2;
651
      int z = num[0]==num[1] ? 4 : 2;
652

    
653
      mBasicAngle = new int[] { x,y,z };
654
      }
655
    return mBasicAngle;
656
    }
657

    
658
///////////////////////////////////////////////////////////////////////////////////////////////////
659

    
660
  public ObjectType intGetObjectType(int[] numLayers)
661
    {
662
    int x = numLayers[0];
663
    int y = numLayers[1];
664

    
665
    switch(x)
666
      {
667
      case 2: switch(y)
668
                {
669
                case 2: return ObjectType.CUBE_2;
670
                case 3: return ObjectType.CU_232;
671
                }
672
      case 3: switch(y)
673
                {
674
                case 2: return ObjectType.CU_323;
675
                case 3: return ObjectType.CUBE_3;
676
                case 4: return ObjectType.CU_343;
677
                }
678
      case 4: return ObjectType.CUBE_4;
679
      case 5: return ObjectType.CUBE_5;
680
      }
681

    
682
    return ObjectType.CUBE_3;
683
    }
684

    
685
///////////////////////////////////////////////////////////////////////////////////////////////////
686

    
687
  public int getObjectName(int[] numLayers)
688
    {
689
    switch(numLayers[0])
690
      {
691
      case 2: return R.string.cube2;
692
      case 3: return R.string.cube3;
693
      case 4: return R.string.cube4;
694
      case 5: return R.string.cube5;
695
      }
696
    return R.string.cube3;
697
    }
698

    
699
///////////////////////////////////////////////////////////////////////////////////////////////////
700

    
701
  public int getInventor(int[] numLayers)
702
    {
703
    switch(numLayers[0])
704
      {
705
      case 2: return R.string.cube2_inventor;
706
      case 3: return R.string.cube3_inventor;
707
      case 4: return R.string.cube4_inventor;
708
      case 5: return R.string.cube5_inventor;
709
      }
710
    return R.string.cube3_inventor;
711
    }
712

    
713
///////////////////////////////////////////////////////////////////////////////////////////////////
714

    
715
  public int getYearOfInvention(int[] numLayers)
716
    {
717
    switch(numLayers[0])
718
      {
719
      case 2: return 1970;
720
      case 3: return 1974;
721
      case 4: return 1981;
722
      case 5: return 1981;
723
      }
724
    return 1974;
725
    }
726

    
727
///////////////////////////////////////////////////////////////////////////////////////////////////
728

    
729
  public int getComplexity(int[] numLayers)
730
    {
731
    switch(numLayers[0])
732
      {
733
      case 2: return 4;
734
      case 3: return 6;
735
      case 4: return 8;
736
      case 5: return 10;
737
      }
738
    return 6;
739
    }
740
}
(6-6/25)