Project

General

Profile

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

magiccube / src / main / java / org / distorted / objects / TwistyMirror.java @ a76d9cb4

1 abf36986 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
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.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
///////////////////////////////////////////////////////////////////////////////////////////////////
35
36 efa81f0c Leszek Koltunski
class TwistyMirror extends Twisty6
37 abf36986 Leszek Koltunski
{
38
  static final Static3D[] ROT_AXIS = new Static3D[]
39
         {
40
           new Static3D(1,0,0),
41
           new Static3D(0,1,0),
42
           new Static3D(0,0,1)
43
         };
44
45
  private static final int[] FACE_COLORS = new int[] { COLOR_WHITE };
46
  private static final float DX = 0.10f;
47 62ec404d Leszek Koltunski
  private static final float DY = 0.25f;
48
  private static final float DZ = 0.40f;
49 abf36986 Leszek Koltunski
50
  private ScrambleState[] mStates;
51
  private Static4D[] mQuats;
52 ef018c1b Leszek Koltunski
  private float[][] mCuts;
53
  private boolean[][] mLayerRotatable;
54 abf36986 Leszek Koltunski
  private int[] mBasicAngle;
55
  private ObjectSticker[] mStickers;
56
  private float[][] mPositions;
57 e9a87113 Leszek Koltunski
  private Movement mMovement;
58 abf36986 Leszek Koltunski
59
///////////////////////////////////////////////////////////////////////////////////////////////////
60
61
  TwistyMirror(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
62
               DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
63
    {
64
    super(size, size, quat, texture, mesh, effects, moves, ObjectList.MIRR, res, scrWidth);
65
    }
66
67
///////////////////////////////////////////////////////////////////////////////////////////////////
68
69
  ScrambleState[] getScrambleStates()
70
    {
71
    if( mStates==null )
72
      {
73
      int size = getNumLayers();
74
      int[][] m = new int[16][];
75
      for(int i=1; i<16; i++) m[i] = createEdges(size,i);
76
77
      mStates = new ScrambleState[]
78
        {
79
        new ScrambleState( new int[][] { m[ 1], m[ 2], m[ 3] } ),  // 0
80
        new ScrambleState( new int[][] {  null, m[ 4], m[ 5] } ),  // x
81
        new ScrambleState( new int[][] { m[ 6],  null, m[ 7] } ),  // y
82
        new ScrambleState( new int[][] { m[ 8], m[ 8],  null } ),  // z
83
        new ScrambleState( new int[][] { m[10],  null, m[ 7] } ),  // xy
84
        new ScrambleState( new int[][] { m[11], m[ 9],  null } ),  // xz
85
        new ScrambleState( new int[][] {  null, m[12], m[ 5] } ),  // yx
86
        new ScrambleState( new int[][] { m[ 8], m[13],  null } ),  // yz
87
        new ScrambleState( new int[][] {  null, m[ 4], m[14] } ),  // zx
88
        new ScrambleState( new int[][] { m[ 6],  null, m[15] } ),  // zy
89
        new ScrambleState( new int[][] {  null,  null, m[ 5] } ),  // xyx
90
        new ScrambleState( new int[][] {  null, m[ 4],  null } ),  // xzx
91
        new ScrambleState( new int[][] {  null,  null, m[ 7] } ),  // yxy
92
        new ScrambleState( new int[][] { m[ 6],  null,  null } ),  // yzy
93
        new ScrambleState( new int[][] {  null, m[ 9],  null } ),  // zxz
94
        new ScrambleState( new int[][] { m[ 8],  null,  null } ),  // zyz
95
        };
96
      }
97
98
    return mStates;
99
    }
100
101
///////////////////////////////////////////////////////////////////////////////////////////////////
102
103
  private int[] createEdges(int size, int vertex)
104
    {
105
    int[] ret = new int[9*size];
106
107
    for(int l=0; l<size; l++)
108
      {
109
      ret[9*l  ] = l;
110
      ret[9*l+1] =-1;
111
      ret[9*l+2] = vertex;
112
      ret[9*l+3] = l;
113
      ret[9*l+4] = 1;
114
      ret[9*l+5] = vertex;
115
      ret[9*l+6] = l;
116
      ret[9*l+7] = 2;
117
      ret[9*l+8] = vertex;
118
      }
119
120
    return ret;
121
    }
122
123
///////////////////////////////////////////////////////////////////////////////////////////////////
124
125
  private void initializeQuats()
126
    {
127
    mQuats = new Static4D[]
128
         {
129
         new Static4D(  0.0f,   0.0f,   0.0f,   1.0f),
130
         new Static4D(  1.0f,   0.0f,   0.0f,   0.0f),
131
         new Static4D(  0.0f,   1.0f,   0.0f,   0.0f),
132
         new Static4D(  0.0f,   0.0f,   1.0f,   0.0f),
133
134
         new Static4D( SQ2/2,  SQ2/2,  0.0f ,   0.0f),
135
         new Static4D( SQ2/2, -SQ2/2,  0.0f ,   0.0f),
136
         new Static4D( SQ2/2,   0.0f,  SQ2/2,   0.0f),
137
         new Static4D(-SQ2/2,   0.0f,  SQ2/2,   0.0f),
138
         new Static4D( SQ2/2,   0.0f,   0.0f,  SQ2/2),
139
         new Static4D( SQ2/2,   0.0f,   0.0f, -SQ2/2),
140
         new Static4D(  0.0f,  SQ2/2,  SQ2/2,   0.0f),
141
         new Static4D(  0.0f,  SQ2/2, -SQ2/2,   0.0f),
142
         new Static4D(  0.0f,  SQ2/2,   0.0f,  SQ2/2),
143
         new Static4D(  0.0f,  SQ2/2,   0.0f, -SQ2/2),
144
         new Static4D(  0.0f,   0.0f,  SQ2/2,  SQ2/2),
145
         new Static4D(  0.0f,   0.0f,  SQ2/2, -SQ2/2),
146
147
         new Static4D(  0.5f,   0.5f,   0.5f,   0.5f),
148
         new Static4D(  0.5f,   0.5f,  -0.5f,   0.5f),
149
         new Static4D(  0.5f,   0.5f,  -0.5f,  -0.5f),
150
         new Static4D(  0.5f,  -0.5f,   0.5f,  -0.5f),
151
         new Static4D( -0.5f,  -0.5f,  -0.5f,   0.5f),
152
         new Static4D( -0.5f,   0.5f,  -0.5f,  -0.5f),
153
         new Static4D( -0.5f,   0.5f,   0.5f,  -0.5f),
154
         new Static4D( -0.5f,   0.5f,   0.5f,   0.5f)
155
         };
156
    }
157
158
///////////////////////////////////////////////////////////////////////////////////////////////////
159
// we cannot do this the standard, automatic way because there's only 1 color in the FACE_COLORS
160
// table and retCubitSolvedStatus() always returns -1,-1 or 0.
161
162
  int[] getSolvedQuats(int cubit, int numLayers)
163
    {
164
    if( numLayers==3 )
165
      {
166
      switch(cubit)
167
        {
168
        case  4:
169
        case 21: return new int[] {1,8,9};
170
        case 10:
171
        case 15: return new int[] {2,12,13};
172
        case 12:
173
        case 13: return new int[] {3,14,15};
174
        }
175
      }
176
177
    return null;
178
    }
179
180
///////////////////////////////////////////////////////////////////////////////////////////////////
181
182
  int getFaceColor(int cubit, int cubitface, int numLayers)
183
    {
184
    if( numLayers==2 )
185
      {
186
      switch(cubitface)
187
        {
188
        case 0: if( cubit==4 ) return 11;
189
                if( cubit==5 ) return 10;
190
                if( cubit==6 ) return  9;
191
                if( cubit==7 ) return  8;
192
                return NUM_TEXTURES;
193
        case 1: if( cubit==0 ) return 11;
194
                if( cubit==1 ) return 10;
195
                if( cubit==2 ) return  9;
196
                if( cubit==3 ) return  8;
197
                return NUM_TEXTURES;
198
        case 2: if( cubit==3 ) return  4;
199
                if( cubit==7 ) return  5;
200
                if( cubit==2 ) return  6;
201
                if( cubit==6 ) return  7;
202
                return NUM_TEXTURES;
203
        case 3: if( cubit==1 ) return  4;
204
                if( cubit==5 ) return  5;
205
                if( cubit==0 ) return  6;
206
                if( cubit==4 ) return  7;
207
                return NUM_TEXTURES;
208
        case 4: if( cubit==3 ) return  0;
209
                if( cubit==7 ) return  1;
210
                if( cubit==1 ) return  2;
211
                if( cubit==5 ) return  3;
212
                return NUM_TEXTURES;
213
        case 5: if( cubit==2 ) return  0;
214
                if( cubit==6 ) return  1;
215
                if( cubit==0 ) return  2;
216
                if( cubit==4 ) return  3;
217
                return NUM_TEXTURES;
218
        }
219
      }
220
    if( numLayers==3 )
221
      {
222
      switch(cubitface)
223
        {
224
        case 0: if( cubit==17 ) return 24;
225
                if( cubit==18 ) return 23;
226
                if( cubit==19 ) return 22;
227
                if( cubit==20 ) return 21;
228
                if( cubit==21 ) return  0;
229
                if( cubit==22 ) return 20;
230
                if( cubit==23 ) return 19;
231
                if( cubit==24 ) return 18;
232
                if( cubit==25 ) return 17;
233
                return NUM_TEXTURES;
234
        case 1: if( cubit== 0 ) return 24;
235
                if( cubit== 1 ) return 23;
236
                if( cubit== 2 ) return 22;
237
                if( cubit== 3 ) return 21;
238
                if( cubit== 4 ) return  0;
239
                if( cubit== 5 ) return 20;
240
                if( cubit== 6 ) return 19;
241
                if( cubit== 7 ) return 18;
242
                if( cubit== 8 ) return 17;
243
                return NUM_TEXTURES;
244
        case 2: if( cubit== 6 ) return 14;
245
                if( cubit==14 ) return  2; // theoretically should have been 15, but this must have gotten collapsed in the Factory
246
                if( cubit==23 ) return 16;
247
                if( cubit== 7 ) return 12;
248
                if( cubit==15 ) return  0;
249
                if( cubit==24 ) return 13;
250
                if( cubit== 8 ) return  9;
251 62ec404d Leszek Koltunski
                if( cubit==16 ) return 20; // ditto, theoretically 10
252 abf36986 Leszek Koltunski
                if( cubit==25 ) return 11;
253
                return NUM_TEXTURES;
254
        case 3: if( cubit== 0 ) return 14;
255
                if( cubit== 9 ) return  2; // ditto, theoretically 15
256
                if( cubit==17 ) return 16;
257
                if( cubit== 1 ) return 12;
258
                if( cubit==10 ) return  0;
259
                if( cubit==18 ) return 13;
260
                if( cubit== 2 ) return  9;
261 62ec404d Leszek Koltunski
                if( cubit==11 ) return 20; // ditto, theoretically 10
262 abf36986 Leszek Koltunski
                if( cubit==19 ) return 11;
263
                return NUM_TEXTURES;
264
        case 4: if( cubit== 8 ) return  1;
265
                if( cubit==16 ) return  2;
266
                if( cubit==25 ) return  3;
267
                if( cubit== 5 ) return  4;
268
                if( cubit==13 ) return  0;
269
                if( cubit==22 ) return  5;
270
                if( cubit== 2 ) return  6;
271
                if( cubit==11 ) return  7;
272
                if( cubit==19 ) return  8;
273
                return NUM_TEXTURES;
274
        case 5: if( cubit== 6 ) return  1;
275
                if( cubit==14 ) return  2;
276
                if( cubit==23 ) return  3;
277
                if( cubit== 3 ) return  4;
278
                if( cubit==12 ) return  0;
279
                if( cubit==20 ) return  5;
280
                if( cubit== 0 ) return  6;
281
                if( cubit== 9 ) return  7;
282
                if( cubit==17 ) return  8;
283
                return NUM_TEXTURES;
284
        }
285
      }
286
287
    return 0;
288
    }
289
290
///////////////////////////////////////////////////////////////////////////////////////////////////
291
292
  private float returnStroke(float x, float y)
293
    {
294
    return 0.08f/(Math.max(x,y));
295
    }
296
297
///////////////////////////////////////////////////////////////////////////////////////////////////
298
299
  private float[] generateStrokes()
300
    {
301
    int num = getNumLayers();
302
    final float A = 0.08f;
303
304
    if( num==2 )
305
      {
306
      return new float[] {
307
                           returnStroke(1-DX,1-DY),
308
                           returnStroke(1+DX,1-DY),
309
                           returnStroke(1-DX,1+DY),
310
                           returnStroke(1+DX,1+DY),
311
                           returnStroke(1-DX,1-DZ),
312
                           returnStroke(1+DX,1-DZ),
313
                           returnStroke(1-DX,1+DZ),
314
                           returnStroke(1+DX,1+DZ),
315
                           returnStroke(1-DZ,1-DY),
316
                           returnStroke(1+DZ,1-DY),
317
                           returnStroke(1-DZ,1+DY),
318
                           returnStroke(1+DZ,1+DY),
319
320
                           A/(1-DX), A/(1+DX), A/(1+DY), A/(1+DY),
321
                           A/(1-DX), A/(1+DX), A/(1+DZ), A/(1+DZ),
322
                           A/(1-DY), A/(1+DY), A/(1+DZ), A/(1+DZ),
323
                         };
324
      }
325
    else
326
      {
327
      return new float[] {
328
                           returnStroke(1   ,1   ),
329
330
                           returnStroke(1-DX,1-DY),
331
                           returnStroke(1   ,1-DY),
332
                           returnStroke(1+DX,1-DY),
333
                           returnStroke(1-DX,1   ),
334
                           returnStroke(1+DX,1   ),
335
                           returnStroke(1-DX,1+DY),
336
                           returnStroke(1   ,1+DY),
337
                           returnStroke(1+DX,1+DY),
338
339
                           returnStroke(1-DX,1-DZ),
340
                           returnStroke(1   ,1-DZ),
341
                           returnStroke(1+DX,1-DZ),
342
                           returnStroke(1-DX,1   ),
343
                           returnStroke(1+DX,1   ),
344
                           returnStroke(1-DX,1+DZ),
345
                           returnStroke(1   ,1+DZ),
346
                           returnStroke(1+DX,1+DZ),
347
348
                           returnStroke(1-DZ,1-DY),
349
                           returnStroke(1   ,1-DY),
350
                           returnStroke(1+DZ,1-DY),
351
                           returnStroke(1-DZ,1   ),
352
                           returnStroke(1+DZ,1   ),
353
                           returnStroke(1-DZ,1+DY),
354
                           returnStroke(1   ,1+DY),
355
                           returnStroke(1+DZ,1+DY),
356
                         };
357
      }
358
    }
359
360
///////////////////////////////////////////////////////////////////////////////////////////////////
361
362
  private float[] returnSticker(float x, float y)
363
    {
364
      float H = 0.5f;
365
366
      if( x<y ) { float D=H*x/y; return new float[] {-D,-H,+D,-H,+D,+H,-D,+H}; }
367
      else      { float D=H*y/x; return new float[] {-H,-D,+H,-D,+H,+D,-H,+D}; }
368
    }
369
370
///////////////////////////////////////////////////////////////////////////////////////////////////
371
372
  private float[][] generateStickers()
373
    {
374
    int num = getNumLayers();
375
376
    if( num==2 )
377
      {
378
      return new float[][]
379
          {
380
              returnSticker(1-DX,1-DY),
381
              returnSticker(1+DX,1-DY),
382
              returnSticker(1-DX,1+DY),
383
              returnSticker(1+DX,1+DY),
384
              returnSticker(1-DX,1-DZ),
385
              returnSticker(1+DX,1-DZ),
386
              returnSticker(1-DX,1+DZ),
387
              returnSticker(1+DX,1+DZ),
388
              returnSticker(1-DZ,1-DY),
389
              returnSticker(1+DZ,1-DY),
390
              returnSticker(1-DZ,1+DY),
391
              returnSticker(1+DZ,1+DY),
392
          };
393
      }
394
    else
395
      {
396
      return new float[][]
397
          {
398
              returnSticker(1   ,1   ),
399
400
              returnSticker(1-DX,1-DY),
401
              returnSticker(1   ,1-DY),
402
              returnSticker(1+DX,1-DY),
403
              returnSticker(1-DX,1   ),
404
              returnSticker(1+DX,1   ),
405
              returnSticker(1-DX,1+DY),
406
              returnSticker(1   ,1+DY),
407
              returnSticker(1+DX,1+DY),
408
409
              returnSticker(1-DX,1-DZ),
410
              returnSticker(1   ,1-DZ),
411
              returnSticker(1+DX,1-DZ),
412
              returnSticker(1-DX,1   ),
413
              returnSticker(1+DX,1   ),
414
              returnSticker(1-DX,1+DZ),
415
              returnSticker(1   ,1+DZ),
416
              returnSticker(1+DX,1+DZ),
417
418
              returnSticker(1-DZ,1-DY),
419
              returnSticker(1   ,1-DY),
420
              returnSticker(1+DZ,1-DY),
421
              returnSticker(1-DZ,1   ),
422
              returnSticker(1+DZ,1   ),
423
              returnSticker(1-DZ,1+DY),
424
              returnSticker(1   ,1+DY),
425
              returnSticker(1+DZ,1+DY),
426
          };
427
      }
428
    }
429
430
///////////////////////////////////////////////////////////////////////////////////////////////////
431
432
  ObjectSticker retSticker(int face)
433
    {
434
    if( mStickers==null )
435
      {
436
      final float[][] STICKERS = generateStickers();
437
      final float[] STROKES = generateStrokes();
438
      final int NUM_STICKERS = STICKERS.length;
439
      final float radius = 0.10f;
440
      final float[] radii = {radius,radius,radius,radius};
441
      mStickers = new ObjectSticker[NUM_STICKERS];
442
443
      for(int i=0; i<NUM_STICKERS; i++)
444
        {
445
        mStickers[i] = new ObjectSticker(STICKERS[i],null,radii,STROKES[i]);
446
        }
447
      }
448
449
    return mStickers[face/NUM_FACE_COLORS];
450
    }
451
452
///////////////////////////////////////////////////////////////////////////////////////////////////
453
454
  int getNumStickerTypes(int numLayers)
455
    {
456
    return numLayers==2 ? 12 : 25;
457
    }
458
459
///////////////////////////////////////////////////////////////////////////////////////////////////
460
461
  private int getRow(int cubit, int numLayers, int dim)
462
    {
463
    return (int)(mPositions[cubit][dim] + 0.5f*(numLayers-1));
464
    }
465
466
///////////////////////////////////////////////////////////////////////////////////////////////////
467
468
  ObjectShape getObjectShape(int cubit, int numLayers)
469
    {
470
    int extraI, extraV, num;
471
    float height;
472
473
    switch(numLayers)
474
      {
475
      case 2 : num = 6; extraI = 2; extraV = 2; height = 0.045f; break;
476
      case 3 : num = 5; extraI = 2; extraV = 2; height = 0.045f; break;
477
      case 4 : num = 5; extraI = 1; extraV = 1; height = 0.045f; break;
478
      default: num = 5; extraI = 0; extraV = 0; height = 0.045f; break;
479
      }
480
481
    int xrow = getRow(cubit,numLayers,0);
482
    int yrow = getRow(cubit,numLayers,1);
483
    int zrow = getRow(cubit,numLayers,2);
484
485
    float XL = -0.5f + (xrow==          0 ? DX : 0);
486
    float XR = +0.5f + (xrow==numLayers-1 ? DX : 0);
487
    float YL = -0.5f - (yrow==          0 ? DY : 0);
488
    float YR = +0.5f - (yrow==numLayers-1 ? DY : 0);
489
    float ZL = -0.5f - (zrow==          0 ? DZ : 0);
490
    float ZR = +0.5f - (zrow==numLayers-1 ? DZ : 0);
491
492
    double[][] vertices = new double[][]
493
          {
494
              { XR, YR, ZR },
495
              { XR, YR, ZL },
496
              { XR, YL, ZR },
497
              { XR, YL, ZL },
498
              { XL, YR, ZR },
499
              { XL, YR, ZL },
500
              { XL, YL, ZR },
501
              { XL, YL, ZL },
502
          };
503
504
    int[][] vert_indices = new int[][]
505
          {
506
              {2,3,1,0},
507
              {7,6,4,5},
508
              {4,0,1,5},
509
              {7,3,2,6},
510
              {6,2,0,4},
511
              {3,7,5,1}
512
          };
513
514
    float[][] bands     = new float[][] { {height,35,0.5f,0.7f,num,extraI,extraV} };
515
    int[] bandIndices   = new int[] { 0,0,0,0,0,0};
516
    float[][] corners   = new float[][] { {0.036f,0.12f} };
517
    int[] cornerIndices = new int[] { 0,0,0,0,0,0,0,0 };
518
    float[][] centers   = new float[][] { {0.0f, 0.0f, 0.0f} };
519
    int[] centerIndices = new int[] { 0,0,0,0,0,0,0,0 };
520
521
    return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
522
    }
523
524
///////////////////////////////////////////////////////////////////////////////////////////////////
525
526
  Static4D getQuat(int cubit, int numLayers)
527
    {
528
    if( mQuats ==null ) initializeQuats();
529
    return mQuats[0];
530
    }
531
532
///////////////////////////////////////////////////////////////////////////////////////////////////
533
534
  int getNumCubitVariants(int numLayers)
535
    {
536
    return 6*numLayers*numLayers - 12*numLayers + 8;
537
    }
538
539
///////////////////////////////////////////////////////////////////////////////////////////////////
540
541
  int getCubitVariant(int cubit, int numLayers)
542
    {
543
    return cubit;
544
    }
545
546
///////////////////////////////////////////////////////////////////////////////////////////////////
547
548
  int getColor(int face)
549
    {
550
    return FACE_COLORS[face];
551
    }
552
553
///////////////////////////////////////////////////////////////////////////////////////////////////
554
555
  float[][] getCubitPositions(int numLayers)
556
    {
557
    if( mPositions==null )
558
      {
559
      int numCubits = numLayers>1 ? 6*numLayers*numLayers - 12*numLayers + 8 : 1;
560
      mPositions = new float[numCubits][];
561
562
      float diff = 0.5f*(numLayers-1);
563
      int currentPosition = 0;
564
565
      for(int x = 0; x<numLayers; x++)
566
        for(int y = 0; y<numLayers; y++)
567
          for(int z = 0; z<numLayers; z++)
568
            if( x==0 || x==numLayers-1 || y==0 || y==numLayers-1 || z==0 || z==numLayers-1 )
569
              {
570
              mPositions[currentPosition++] = new float[] {x-diff,y-diff,z-diff};
571
              }
572
      }
573
574
    return mPositions;
575
    }
576
577
///////////////////////////////////////////////////////////////////////////////////////////////////
578
579
  Static4D[] getQuats()
580
    {
581
    if( mQuats ==null ) initializeQuats();
582
    return mQuats;
583
    }
584
585
///////////////////////////////////////////////////////////////////////////////////////////////////
586
587
  int getNumFaceColors()
588
    {
589 efa81f0c Leszek Koltunski
    return 1;
590 abf36986 Leszek Koltunski
    }
591
592
///////////////////////////////////////////////////////////////////////////////////////////////////
593
594
  float[][] getCuts(int numLayers)
595
    {
596 ef018c1b Leszek Koltunski
    if( mCuts==null )
597 abf36986 Leszek Koltunski
      {
598 ef018c1b Leszek Koltunski
      mCuts = new float[3][numLayers-1];
599
600
      for(int i=0; i<numLayers-1; i++)
601
        {
602
        float cut = (2-numLayers)*0.5f + i;
603
        mCuts[0][i] = cut;
604
        mCuts[1][i] = cut;
605
        mCuts[2][i] = cut;
606
        }
607 abf36986 Leszek Koltunski
      }
608
609 ef018c1b Leszek Koltunski
    return mCuts;
610
    }
611
612
///////////////////////////////////////////////////////////////////////////////////////////////////
613
614
  private void getLayerRotatable(int numLayers)
615
    {
616
    if( mLayerRotatable==null )
617
      {
618
      int numAxis = ROT_AXIS.length;
619
      boolean[] tmp = new boolean[numLayers];
620
      for(int i=0; i<numLayers; i++) tmp[i] = true;
621
      mLayerRotatable = new boolean[numAxis][];
622
      for(int i=0; i<numAxis; i++) mLayerRotatable[i] = tmp;
623
      }
624 abf36986 Leszek Koltunski
    }
625
626
///////////////////////////////////////////////////////////////////////////////////////////////////
627
628
  int getSolvedFunctionIndex()
629
    {
630
    return 0;
631
    }
632
633
///////////////////////////////////////////////////////////////////////////////////////////////////
634
635
  int getNumCubitFaces()
636
    {
637
    return 6;
638
    }
639
640
///////////////////////////////////////////////////////////////////////////////////////////////////
641
// PUBLIC API
642
643
  public Static3D[] getRotationAxis()
644
    {
645
    return ROT_AXIS;
646
    }
647
648 e9a87113 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
649
650
  public Movement getMovement()
651
    {
652 ef018c1b Leszek Koltunski
    if( mMovement==null )
653
      {
654
      int numLayers = getNumLayers();
655
      if( mCuts==null ) getCuts(numLayers);
656
      getLayerRotatable(numLayers);
657
658
      mMovement = new MovementCube(mCuts,mLayerRotatable,numLayers);
659
      }
660 e9a87113 Leszek Koltunski
    return mMovement;
661
    }
662
663 abf36986 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
664
665
  public int[] getBasicAngle()
666
    {
667
    if( mBasicAngle==null ) mBasicAngle = new int[] { 4,4,4 };
668
    return mBasicAngle;
669
    }
670
671
///////////////////////////////////////////////////////////////////////////////////////////////////
672
673
  public int getObjectName(int numLayers)
674
    {
675
    switch(numLayers)
676
      {
677
      case 2: return R.string.mirr2;
678
      case 3: return R.string.mirr3;
679
      }
680
    return R.string.mirr3;
681
    }
682
683
///////////////////////////////////////////////////////////////////////////////////////////////////
684
685
  public int getInventor(int numLayers)
686
    {
687
    switch(numLayers)
688
      {
689
      case 2: return R.string.mirr2_inventor;
690
      case 3: return R.string.mirr3_inventor;
691
      }
692
    return R.string.mirr3_inventor;
693
    }
694
695
///////////////////////////////////////////////////////////////////////////////////////////////////
696
697
  public int getComplexity(int numLayers)
698
    {
699
    switch(numLayers)
700
      {
701
      case 2: return 5;
702
      case 3: return 7;
703
      }
704
    return 7;
705
    }
706
}