Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyCuboid.java @ 1bb09f88

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
  protected 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
  protected ObjectShape getObjectShape(int cubit, int[] numLayers)
247
    {
248
    int extraI, extraV, num;
249
    float height;
250
    int variant = getCubitVariant(cubit,numLayers);
251
    int numL = numLayers[0];
252

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

    
261
    double[][] vertices = new double[][]
262
          {
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
              {-0.5,-0.5, 0.5 },
270
              {-0.5,-0.5,-0.5 },
271
          };
272

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

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

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

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

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

    
317
///////////////////////////////////////////////////////////////////////////////////////////////////
318

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

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

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

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

    
340
    return -1;
341
    }
342

    
343
///////////////////////////////////////////////////////////////////////////////////////////////////
344

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

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

    
354
///////////////////////////////////////////////////////////////////////////////////////////////////
355

    
356
  protected float[][] getCubitPositions(int[] numLayers)
357
    {
358
    final int X = numLayers[0];
359
    final int Y = numLayers[1];
360
    final int Z = numLayers[2];
361

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

    
366
    int curPos = 0;
367

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

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

    
375
      return pos;
376
      }
377

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

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

    
385
      return pos;
386
      }
387

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

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

    
395
      return pos;
396
      }
397

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

    
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
    pos[curPos++] = new float[] {+lenX,+lenY,-lenZ};
408
    pos[curPos++] = new float[] {+lenX,+lenY,+lenZ};
409

    
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<X-1; i++) pos[curPos++] = new float[] { i-lenX,  +lenY,  -lenZ };
413
    for(int i=1; i<X-1; i++) pos[curPos++] = new float[] { i-lenX,  +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<Y-1; i++) pos[curPos++] = new float[] {  +lenX, i-lenY,  -lenZ };
417
    for(int i=1; i<Y-1; i++) pos[curPos++] = new float[] {  +lenX, i-lenY,  +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
    for(int i=1; i<Z-1; i++) pos[curPos++] = new float[] {  +lenX,  -lenY, i-lenZ };
421
    for(int i=1; i<Z-1; i++) pos[curPos++] = new float[] {  +lenX,  +lenY, i-lenZ };
422

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

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

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

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

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

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

    
441
    return pos;
442
    }
443

    
444
///////////////////////////////////////////////////////////////////////////////////////////////////
445

    
446
  protected Static4D getQuat(int cubit, int[] numLayers)
447
    {
448
    if( mQuats ==null ) initializeQuats();
449

    
450
    int centerNum = getCenterNum(cubit,numLayers);
451

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

    
464
///////////////////////////////////////////////////////////////////////////////////////////////////
465

    
466
  protected int getNumCubitVariants(int[] numLayers)
467
    {
468
    return numLayers[0]>2 ? 2:1;
469
    }
470

    
471
///////////////////////////////////////////////////////////////////////////////////////////////////
472

    
473
  protected int getCubitVariant(int cubit, int[] numLayers)
474
    {
475
    return cubit < getNumCornersAndEdges(numLayers) ? 0 : 1;
476
    }
477

    
478
///////////////////////////////////////////////////////////////////////////////////////////////////
479

    
480
  protected int getFaceColor(int cubit, int cubitface, int[] numLayers)
481
    {
482
    int centerNum = getCenterNum(cubit,numLayers);
483

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

    
495
///////////////////////////////////////////////////////////////////////////////////////////////////
496

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

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

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

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

    
523
    return mStickers[sticker];
524
    }
525

    
526
///////////////////////////////////////////////////////////////////////////////////////////////////
527

    
528
  protected int getStickerIndex(int face)
529
    {
530
    return face/NUM_FACE_COLORS;
531
    }
532

    
533
///////////////////////////////////////////////////////////////////////////////////////////////////
534

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

    
541
///////////////////////////////////////////////////////////////////////////////////////////////////
542

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

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

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

    
562
    return mCuts;
563
    }
564

    
565
///////////////////////////////////////////////////////////////////////////////////////////////////
566

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

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

    
578
    return layerRotatable;
579
    }
580

    
581
///////////////////////////////////////////////////////////////////////////////////////////////////
582

    
583
  public int getMovementType()
584
    {
585
    return MOVEMENT_SHAPECHANGE;
586
    }
587

    
588
///////////////////////////////////////////////////////////////////////////////////////////////////
589

    
590
  public int getMovementSplit()
591
    {
592
    return TYPE_NOT_SPLIT;
593
    }
594

    
595
///////////////////////////////////////////////////////////////////////////////////////////////////
596

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

    
605
///////////////////////////////////////////////////////////////////////////////////////////////////
606

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

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

    
622
///////////////////////////////////////////////////////////////////////////////////////////////////
623

    
624
  public int getSolvedFunctionIndex()
625
    {
626
    return 0;
627
    }
628

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

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

    
636
///////////////////////////////////////////////////////////////////////////////////////////////////
637

    
638
  protected int getNumCubitFaces()
639
    {
640
    return 6;
641
    }
642

    
643
///////////////////////////////////////////////////////////////////////////////////////////////////
644
// PUBLIC API
645

    
646
  public Static3D[] getRotationAxis()
647
    {
648
    return ROT_AXIS;
649
    }
650

    
651
///////////////////////////////////////////////////////////////////////////////////////////////////
652

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

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

    
667
///////////////////////////////////////////////////////////////////////////////////////////////////
668

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

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

    
691
    return ObjectType.CUBE_3;
692
    }
693

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

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

    
708
///////////////////////////////////////////////////////////////////////////////////////////////////
709

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

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

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

    
736
///////////////////////////////////////////////////////////////////////////////////////////////////
737

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