Project

General

Profile

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

magiccube / src / main / java / org / distorted / objects / TwistyMirror.java @ 7ee89540

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.objects;
21

    
22
import static org.distorted.objects.Movement.TYPE_NOT_SPLIT;
23

    
24
import android.content.res.Resources;
25

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

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

    
38
class TwistyMirror extends Twisty6
39
{
40
  static final Static3D[] ROT_AXIS = new Static3D[]
41
         {
42
           new Static3D(1,0,0),
43
           new Static3D(0,1,0),
44
           new Static3D(0,0,1)
45
         };
46

    
47
  private static final int[][][] ENABLED = new int[][][]
48
      {
49
          {{1,2}},{{1,2}},{{0,2}},{{0,2}},{{0,1}},{{0,1}},
50
      };
51

    
52
  private static final int[] FACE_COLORS = new int[] { COLOR_WHITE };
53
  private static final float DX = 0.10f;
54
  private static final float DY = 0.25f;
55
  private static final float DZ = 0.40f;
56

    
57
  private ScrambleState[] mStates;
58
  private Static4D[] mQuats;
59
  private float[][] mCuts;
60
  private boolean[][] mLayerRotatable;
61
  private int[] mBasicAngle;
62
  private ObjectSticker[] mStickers;
63
  private float[][] mPositions;
64
  private Movement mMovement;
65

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

    
68
  TwistyMirror(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
69
               DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
70
    {
71
    super(size, size, quat, texture, mesh, effects, moves, ObjectList.MIRR, res, scrWidth);
72
    }
73

    
74
///////////////////////////////////////////////////////////////////////////////////////////////////
75

    
76
  ScrambleState[] getScrambleStates()
77
    {
78
    if( mStates==null )
79
      {
80
      int size = getNumLayers();
81
      int[][] m = new int[16][];
82
      for(int i=1; i<16; i++) m[i] = createEdges(size,i);
83

    
84
      mStates = new ScrambleState[]
85
        {
86
        new ScrambleState( new int[][] { m[ 1], m[ 2], m[ 3] } ),  // 0
87
        new ScrambleState( new int[][] {  null, m[ 4], m[ 5] } ),  // x
88
        new ScrambleState( new int[][] { m[ 6],  null, m[ 7] } ),  // y
89
        new ScrambleState( new int[][] { m[ 8], m[ 8],  null } ),  // z
90
        new ScrambleState( new int[][] { m[10],  null, m[ 7] } ),  // xy
91
        new ScrambleState( new int[][] { m[11], m[ 9],  null } ),  // xz
92
        new ScrambleState( new int[][] {  null, m[12], m[ 5] } ),  // yx
93
        new ScrambleState( new int[][] { m[ 8], m[13],  null } ),  // yz
94
        new ScrambleState( new int[][] {  null, m[ 4], m[14] } ),  // zx
95
        new ScrambleState( new int[][] { m[ 6],  null, m[15] } ),  // zy
96
        new ScrambleState( new int[][] {  null,  null, m[ 5] } ),  // xyx
97
        new ScrambleState( new int[][] {  null, m[ 4],  null } ),  // xzx
98
        new ScrambleState( new int[][] {  null,  null, m[ 7] } ),  // yxy
99
        new ScrambleState( new int[][] { m[ 6],  null,  null } ),  // yzy
100
        new ScrambleState( new int[][] {  null, m[ 9],  null } ),  // zxz
101
        new ScrambleState( new int[][] { m[ 8],  null,  null } ),  // zyz
102
        };
103
      }
104

    
105
    return mStates;
106
    }
107

    
108
///////////////////////////////////////////////////////////////////////////////////////////////////
109

    
110
  private int[] createEdges(int size, int vertex)
111
    {
112
    int[] ret = new int[9*size];
113

    
114
    for(int l=0; l<size; l++)
115
      {
116
      ret[9*l  ] = l;
117
      ret[9*l+1] =-1;
118
      ret[9*l+2] = vertex;
119
      ret[9*l+3] = l;
120
      ret[9*l+4] = 1;
121
      ret[9*l+5] = vertex;
122
      ret[9*l+6] = l;
123
      ret[9*l+7] = 2;
124
      ret[9*l+8] = vertex;
125
      }
126

    
127
    return ret;
128
    }
129

    
130
///////////////////////////////////////////////////////////////////////////////////////////////////
131

    
132
  private void initializeQuats()
133
    {
134
    mQuats = new Static4D[]
135
         {
136
         new Static4D(  0.0f,   0.0f,   0.0f,   1.0f),
137
         new Static4D(  1.0f,   0.0f,   0.0f,   0.0f),
138
         new Static4D(  0.0f,   1.0f,   0.0f,   0.0f),
139
         new Static4D(  0.0f,   0.0f,   1.0f,   0.0f),
140

    
141
         new Static4D( SQ2/2,  SQ2/2,  0.0f ,   0.0f),
142
         new Static4D( SQ2/2, -SQ2/2,  0.0f ,   0.0f),
143
         new Static4D( SQ2/2,   0.0f,  SQ2/2,   0.0f),
144
         new Static4D(-SQ2/2,   0.0f,  SQ2/2,   0.0f),
145
         new Static4D( SQ2/2,   0.0f,   0.0f,  SQ2/2),
146
         new Static4D( SQ2/2,   0.0f,   0.0f, -SQ2/2),
147
         new Static4D(  0.0f,  SQ2/2,  SQ2/2,   0.0f),
148
         new Static4D(  0.0f,  SQ2/2, -SQ2/2,   0.0f),
149
         new Static4D(  0.0f,  SQ2/2,   0.0f,  SQ2/2),
150
         new Static4D(  0.0f,  SQ2/2,   0.0f, -SQ2/2),
151
         new Static4D(  0.0f,   0.0f,  SQ2/2,  SQ2/2),
152
         new Static4D(  0.0f,   0.0f,  SQ2/2, -SQ2/2),
153

    
154
         new Static4D(  0.5f,   0.5f,   0.5f,   0.5f),
155
         new Static4D(  0.5f,   0.5f,  -0.5f,   0.5f),
156
         new Static4D(  0.5f,   0.5f,  -0.5f,  -0.5f),
157
         new Static4D(  0.5f,  -0.5f,   0.5f,  -0.5f),
158
         new Static4D( -0.5f,  -0.5f,  -0.5f,   0.5f),
159
         new Static4D( -0.5f,   0.5f,  -0.5f,  -0.5f),
160
         new Static4D( -0.5f,   0.5f,   0.5f,  -0.5f),
161
         new Static4D( -0.5f,   0.5f,   0.5f,   0.5f)
162
         };
163
    }
164

    
165
///////////////////////////////////////////////////////////////////////////////////////////////////
166
// we cannot do this the standard, automatic way because there's only 1 color in the FACE_COLORS
167
// table and retCubitSolvedStatus() always returns -1,-1 or 0.
168

    
169
  int[] getSolvedQuats(int cubit, int numLayers)
170
    {
171
    if( numLayers==3 )
172
      {
173
      switch(cubit)
174
        {
175
        case  4:
176
        case 21: return new int[] {1,8,9};
177
        case 10:
178
        case 15: return new int[] {2,12,13};
179
        case 12:
180
        case 13: return new int[] {3,14,15};
181
        }
182
      }
183

    
184
    return null;
185
    }
186

    
187
///////////////////////////////////////////////////////////////////////////////////////////////////
188

    
189
  int getFaceColor(int cubit, int cubitface, int numLayers)
190
    {
191
    if( numLayers==2 )
192
      {
193
      switch(cubitface)
194
        {
195
        case 0: if( cubit==4 ) return 11;
196
                if( cubit==5 ) return 10;
197
                if( cubit==6 ) return  9;
198
                if( cubit==7 ) return  8;
199
                return NUM_TEXTURES;
200
        case 1: if( cubit==0 ) return 11;
201
                if( cubit==1 ) return 10;
202
                if( cubit==2 ) return  9;
203
                if( cubit==3 ) return  8;
204
                return NUM_TEXTURES;
205
        case 2: if( cubit==3 ) return  4;
206
                if( cubit==7 ) return  5;
207
                if( cubit==2 ) return  6;
208
                if( cubit==6 ) return  7;
209
                return NUM_TEXTURES;
210
        case 3: if( cubit==1 ) return  4;
211
                if( cubit==5 ) return  5;
212
                if( cubit==0 ) return  6;
213
                if( cubit==4 ) return  7;
214
                return NUM_TEXTURES;
215
        case 4: if( cubit==3 ) return  0;
216
                if( cubit==7 ) return  1;
217
                if( cubit==1 ) return  2;
218
                if( cubit==5 ) return  3;
219
                return NUM_TEXTURES;
220
        case 5: if( cubit==2 ) return  0;
221
                if( cubit==6 ) return  1;
222
                if( cubit==0 ) return  2;
223
                if( cubit==4 ) return  3;
224
                return NUM_TEXTURES;
225
        }
226
      }
227
    if( numLayers==3 )
228
      {
229
      switch(cubitface)
230
        {
231
        case 0: if( cubit==17 ) return 24;
232
                if( cubit==18 ) return 23;
233
                if( cubit==19 ) return 22;
234
                if( cubit==20 ) return 21;
235
                if( cubit==21 ) return  0;
236
                if( cubit==22 ) return 20;
237
                if( cubit==23 ) return 19;
238
                if( cubit==24 ) return 18;
239
                if( cubit==25 ) return 17;
240
                return NUM_TEXTURES;
241
        case 1: if( cubit== 0 ) return 24;
242
                if( cubit== 1 ) return 23;
243
                if( cubit== 2 ) return 22;
244
                if( cubit== 3 ) return 21;
245
                if( cubit== 4 ) return  0;
246
                if( cubit== 5 ) return 20;
247
                if( cubit== 6 ) return 19;
248
                if( cubit== 7 ) return 18;
249
                if( cubit== 8 ) return 17;
250
                return NUM_TEXTURES;
251
        case 2: if( cubit== 6 ) return 14;
252
                if( cubit==14 ) return  2; // theoretically should have been 15, but this must have gotten collapsed in the Factory
253
                if( cubit==23 ) return 16;
254
                if( cubit== 7 ) return 12;
255
                if( cubit==15 ) return  0;
256
                if( cubit==24 ) return 13;
257
                if( cubit== 8 ) return  9;
258
                if( cubit==16 ) return 20; // ditto, theoretically 10
259
                if( cubit==25 ) return 11;
260
                return NUM_TEXTURES;
261
        case 3: if( cubit== 0 ) return 14;
262
                if( cubit== 9 ) return  2; // ditto, theoretically 15
263
                if( cubit==17 ) return 16;
264
                if( cubit== 1 ) return 12;
265
                if( cubit==10 ) return  0;
266
                if( cubit==18 ) return 13;
267
                if( cubit== 2 ) return  9;
268
                if( cubit==11 ) return 20; // ditto, theoretically 10
269
                if( cubit==19 ) return 11;
270
                return NUM_TEXTURES;
271
        case 4: if( cubit== 8 ) return  1;
272
                if( cubit==16 ) return  2;
273
                if( cubit==25 ) return  3;
274
                if( cubit== 5 ) return  4;
275
                if( cubit==13 ) return  0;
276
                if( cubit==22 ) return  5;
277
                if( cubit== 2 ) return  6;
278
                if( cubit==11 ) return  7;
279
                if( cubit==19 ) return  8;
280
                return NUM_TEXTURES;
281
        case 5: if( cubit== 6 ) return  1;
282
                if( cubit==14 ) return  2;
283
                if( cubit==23 ) return  3;
284
                if( cubit== 3 ) return  4;
285
                if( cubit==12 ) return  0;
286
                if( cubit==20 ) return  5;
287
                if( cubit== 0 ) return  6;
288
                if( cubit== 9 ) return  7;
289
                if( cubit==17 ) return  8;
290
                return NUM_TEXTURES;
291
        }
292
      }
293

    
294
    return 0;
295
    }
296

    
297
///////////////////////////////////////////////////////////////////////////////////////////////////
298

    
299
  private float returnStroke(float x, float y)
300
    {
301
    return 0.08f/(Math.max(x,y));
302
    }
303

    
304
///////////////////////////////////////////////////////////////////////////////////////////////////
305

    
306
  private float[] generateStrokes()
307
    {
308
    int num = getNumLayers();
309
    final float A = 0.08f;
310

    
311
    if( num==2 )
312
      {
313
      return new float[] {
314
                           returnStroke(1-DX,1-DY),
315
                           returnStroke(1+DX,1-DY),
316
                           returnStroke(1-DX,1+DY),
317
                           returnStroke(1+DX,1+DY),
318
                           returnStroke(1-DX,1-DZ),
319
                           returnStroke(1+DX,1-DZ),
320
                           returnStroke(1-DX,1+DZ),
321
                           returnStroke(1+DX,1+DZ),
322
                           returnStroke(1-DZ,1-DY),
323
                           returnStroke(1+DZ,1-DY),
324
                           returnStroke(1-DZ,1+DY),
325
                           returnStroke(1+DZ,1+DY),
326

    
327
                           A/(1-DX), A/(1+DX), A/(1+DY), A/(1+DY),
328
                           A/(1-DX), A/(1+DX), A/(1+DZ), A/(1+DZ),
329
                           A/(1-DY), A/(1+DY), A/(1+DZ), A/(1+DZ),
330
                         };
331
      }
332
    else
333
      {
334
      return new float[] {
335
                           returnStroke(1   ,1   ),
336

    
337
                           returnStroke(1-DX,1-DY),
338
                           returnStroke(1   ,1-DY),
339
                           returnStroke(1+DX,1-DY),
340
                           returnStroke(1-DX,1   ),
341
                           returnStroke(1+DX,1   ),
342
                           returnStroke(1-DX,1+DY),
343
                           returnStroke(1   ,1+DY),
344
                           returnStroke(1+DX,1+DY),
345

    
346
                           returnStroke(1-DX,1-DZ),
347
                           returnStroke(1   ,1-DZ),
348
                           returnStroke(1+DX,1-DZ),
349
                           returnStroke(1-DX,1   ),
350
                           returnStroke(1+DX,1   ),
351
                           returnStroke(1-DX,1+DZ),
352
                           returnStroke(1   ,1+DZ),
353
                           returnStroke(1+DX,1+DZ),
354

    
355
                           returnStroke(1-DZ,1-DY),
356
                           returnStroke(1   ,1-DY),
357
                           returnStroke(1+DZ,1-DY),
358
                           returnStroke(1-DZ,1   ),
359
                           returnStroke(1+DZ,1   ),
360
                           returnStroke(1-DZ,1+DY),
361
                           returnStroke(1   ,1+DY),
362
                           returnStroke(1+DZ,1+DY),
363
                         };
364
      }
365
    }
366

    
367
///////////////////////////////////////////////////////////////////////////////////////////////////
368

    
369
  private float[] returnSticker(float x, float y)
370
    {
371
      float H = 0.5f;
372

    
373
      if( x<y ) { float D=H*x/y; return new float[] {-D,-H,+D,-H,+D,+H,-D,+H}; }
374
      else      { float D=H*y/x; return new float[] {-H,-D,+H,-D,+H,+D,-H,+D}; }
375
    }
376

    
377
///////////////////////////////////////////////////////////////////////////////////////////////////
378

    
379
  private float[][] generateStickers()
380
    {
381
    int num = getNumLayers();
382

    
383
    if( num==2 )
384
      {
385
      return new float[][]
386
          {
387
              returnSticker(1-DX,1-DY),
388
              returnSticker(1+DX,1-DY),
389
              returnSticker(1-DX,1+DY),
390
              returnSticker(1+DX,1+DY),
391
              returnSticker(1-DX,1-DZ),
392
              returnSticker(1+DX,1-DZ),
393
              returnSticker(1-DX,1+DZ),
394
              returnSticker(1+DX,1+DZ),
395
              returnSticker(1-DZ,1-DY),
396
              returnSticker(1+DZ,1-DY),
397
              returnSticker(1-DZ,1+DY),
398
              returnSticker(1+DZ,1+DY),
399
          };
400
      }
401
    else
402
      {
403
      return new float[][]
404
          {
405
              returnSticker(1   ,1   ),
406

    
407
              returnSticker(1-DX,1-DY),
408
              returnSticker(1   ,1-DY),
409
              returnSticker(1+DX,1-DY),
410
              returnSticker(1-DX,1   ),
411
              returnSticker(1+DX,1   ),
412
              returnSticker(1-DX,1+DY),
413
              returnSticker(1   ,1+DY),
414
              returnSticker(1+DX,1+DY),
415

    
416
              returnSticker(1-DX,1-DZ),
417
              returnSticker(1   ,1-DZ),
418
              returnSticker(1+DX,1-DZ),
419
              returnSticker(1-DX,1   ),
420
              returnSticker(1+DX,1   ),
421
              returnSticker(1-DX,1+DZ),
422
              returnSticker(1   ,1+DZ),
423
              returnSticker(1+DX,1+DZ),
424

    
425
              returnSticker(1-DZ,1-DY),
426
              returnSticker(1   ,1-DY),
427
              returnSticker(1+DZ,1-DY),
428
              returnSticker(1-DZ,1   ),
429
              returnSticker(1+DZ,1   ),
430
              returnSticker(1-DZ,1+DY),
431
              returnSticker(1   ,1+DY),
432
              returnSticker(1+DZ,1+DY),
433
          };
434
      }
435
    }
436

    
437
///////////////////////////////////////////////////////////////////////////////////////////////////
438

    
439
  ObjectSticker retSticker(int face)
440
    {
441
    if( mStickers==null )
442
      {
443
      final float[][] STICKERS = generateStickers();
444
      final float[] STROKES = generateStrokes();
445
      final int NUM_STICKERS = STICKERS.length;
446
      final float radius = 0.10f;
447
      final float[] radii = {radius,radius,radius,radius};
448
      mStickers = new ObjectSticker[NUM_STICKERS];
449

    
450
      for(int i=0; i<NUM_STICKERS; i++)
451
        {
452
        mStickers[i] = new ObjectSticker(STICKERS[i],null,radii,STROKES[i]);
453
        }
454
      }
455

    
456
    return mStickers[face/NUM_FACE_COLORS];
457
    }
458

    
459
///////////////////////////////////////////////////////////////////////////////////////////////////
460

    
461
  int getNumStickerTypes(int numLayers)
462
    {
463
    return numLayers==2 ? 12 : 25;
464
    }
465

    
466
///////////////////////////////////////////////////////////////////////////////////////////////////
467

    
468
  private int getRow(int cubit, int numLayers, int dim)
469
    {
470
    return (int)(mPositions[cubit][dim] + 0.5f*(numLayers-1));
471
    }
472

    
473
///////////////////////////////////////////////////////////////////////////////////////////////////
474

    
475
  ObjectShape getObjectShape(int cubit, int numLayers)
476
    {
477
    int extraI, extraV, num;
478
    float height;
479

    
480
    switch(numLayers)
481
      {
482
      case 2 : num = 6; extraI = 2; extraV = 2; height = 0.045f; break;
483
      case 3 : num = 5; extraI = 2; extraV = 2; height = 0.045f; break;
484
      case 4 : num = 5; extraI = 1; extraV = 1; height = 0.045f; break;
485
      default: num = 5; extraI = 0; extraV = 0; height = 0.045f; break;
486
      }
487

    
488
    int xrow = getRow(cubit,numLayers,0);
489
    int yrow = getRow(cubit,numLayers,1);
490
    int zrow = getRow(cubit,numLayers,2);
491

    
492
    float XL = -0.5f + (xrow==          0 ? DX : 0);
493
    float XR = +0.5f + (xrow==numLayers-1 ? DX : 0);
494
    float YL = -0.5f - (yrow==          0 ? DY : 0);
495
    float YR = +0.5f - (yrow==numLayers-1 ? DY : 0);
496
    float ZL = -0.5f - (zrow==          0 ? DZ : 0);
497
    float ZR = +0.5f - (zrow==numLayers-1 ? DZ : 0);
498

    
499
    double[][] vertices = new double[][]
500
          {
501
              { XR, YR, ZR },
502
              { XR, YR, ZL },
503
              { XR, YL, ZR },
504
              { XR, YL, ZL },
505
              { XL, YR, ZR },
506
              { XL, YR, ZL },
507
              { XL, YL, ZR },
508
              { XL, YL, ZL },
509
          };
510

    
511
    int[][] vert_indices = new int[][]
512
          {
513
              {2,3,1,0},
514
              {7,6,4,5},
515
              {4,0,1,5},
516
              {7,3,2,6},
517
              {6,2,0,4},
518
              {3,7,5,1}
519
          };
520

    
521
    float[][] bands     = new float[][] { {height,35,0.5f,0.7f,num,extraI,extraV} };
522
    int[] bandIndices   = new int[] { 0,0,0,0,0,0};
523
    float[][] corners   = new float[][] { {0.036f,0.12f} };
524
    int[] cornerIndices = new int[] { 0,0,0,0,0,0,0,0 };
525
    float[][] centers   = new float[][] { {0.0f, 0.0f, 0.0f} };
526
    int[] centerIndices = new int[] { 0,0,0,0,0,0,0,0 };
527

    
528
    return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
529
    }
530

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

    
533
  Static4D getQuat(int cubit, int numLayers)
534
    {
535
    if( mQuats ==null ) initializeQuats();
536
    return mQuats[0];
537
    }
538

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

    
541
  int getNumCubitVariants(int numLayers)
542
    {
543
    return 6*numLayers*numLayers - 12*numLayers + 8;
544
    }
545

    
546
///////////////////////////////////////////////////////////////////////////////////////////////////
547

    
548
  int getCubitVariant(int cubit, int numLayers)
549
    {
550
    return cubit;
551
    }
552

    
553
///////////////////////////////////////////////////////////////////////////////////////////////////
554

    
555
  int getColor(int face)
556
    {
557
    return FACE_COLORS[face];
558
    }
559

    
560
///////////////////////////////////////////////////////////////////////////////////////////////////
561

    
562
  float[][] getCubitPositions(int numLayers)
563
    {
564
    if( mPositions==null )
565
      {
566
      int numCubits = numLayers>1 ? 6*numLayers*numLayers - 12*numLayers + 8 : 1;
567
      mPositions = new float[numCubits][];
568

    
569
      float diff = 0.5f*(numLayers-1);
570
      int currentPosition = 0;
571

    
572
      for(int x = 0; x<numLayers; x++)
573
        for(int y = 0; y<numLayers; y++)
574
          for(int z = 0; z<numLayers; z++)
575
            if( x==0 || x==numLayers-1 || y==0 || y==numLayers-1 || z==0 || z==numLayers-1 )
576
              {
577
              mPositions[currentPosition++] = new float[] {x-diff,y-diff,z-diff};
578
              }
579
      }
580

    
581
    return mPositions;
582
    }
583

    
584
///////////////////////////////////////////////////////////////////////////////////////////////////
585

    
586
  Static4D[] getQuats()
587
    {
588
    if( mQuats ==null ) initializeQuats();
589
    return mQuats;
590
    }
591

    
592
///////////////////////////////////////////////////////////////////////////////////////////////////
593

    
594
  int getNumFaceColors()
595
    {
596
    return 1;
597
    }
598

    
599
///////////////////////////////////////////////////////////////////////////////////////////////////
600

    
601
  float[][] getCuts(int numLayers)
602
    {
603
    if( mCuts==null )
604
      {
605
      mCuts = new float[3][numLayers-1];
606

    
607
      for(int i=0; i<numLayers-1; i++)
608
        {
609
        float cut = (2-numLayers)*0.5f + i;
610
        mCuts[0][i] = cut;
611
        mCuts[1][i] = cut;
612
        mCuts[2][i] = cut;
613
        }
614
      }
615

    
616
    return mCuts;
617
    }
618

    
619
///////////////////////////////////////////////////////////////////////////////////////////////////
620

    
621
  private void getLayerRotatable(int numLayers)
622
    {
623
    if( mLayerRotatable==null )
624
      {
625
      int numAxis = ROT_AXIS.length;
626
      boolean[] tmp = new boolean[numLayers];
627
      for(int i=0; i<numLayers; i++) tmp[i] = true;
628
      mLayerRotatable = new boolean[numAxis][];
629
      for(int i=0; i<numAxis; i++) mLayerRotatable[i] = tmp;
630
      }
631
    }
632

    
633
///////////////////////////////////////////////////////////////////////////////////////////////////
634

    
635
  int getSolvedFunctionIndex()
636
    {
637
    return 0;
638
    }
639

    
640
///////////////////////////////////////////////////////////////////////////////////////////////////
641

    
642
  int getNumCubitFaces()
643
    {
644
    return 6;
645
    }
646

    
647
///////////////////////////////////////////////////////////////////////////////////////////////////
648
// PUBLIC API
649

    
650
  public Static3D[] getRotationAxis()
651
    {
652
    return ROT_AXIS;
653
    }
654

    
655
///////////////////////////////////////////////////////////////////////////////////////////////////
656

    
657
  public Movement getMovement()
658
    {
659
    if( mMovement==null )
660
      {
661
      int numLayers = getNumLayers();
662
      if( mCuts==null ) getCuts(numLayers);
663
      getLayerRotatable(numLayers);
664
      mMovement = new Movement6(ROT_AXIS,mCuts,mLayerRotatable,numLayers,TYPE_NOT_SPLIT,ENABLED);
665
      }
666
    return mMovement;
667
    }
668

    
669
///////////////////////////////////////////////////////////////////////////////////////////////////
670

    
671
  public int[] getBasicAngle()
672
    {
673
    if( mBasicAngle==null ) mBasicAngle = new int[] { 4,4,4 };
674
    return mBasicAngle;
675
    }
676

    
677
///////////////////////////////////////////////////////////////////////////////////////////////////
678

    
679
  public int getObjectName(int numLayers)
680
    {
681
    switch(numLayers)
682
      {
683
      case 2: return R.string.mirr2;
684
      case 3: return R.string.mirr3;
685
      }
686
    return R.string.mirr3;
687
    }
688

    
689
///////////////////////////////////////////////////////////////////////////////////////////////////
690

    
691
  public int getInventor(int numLayers)
692
    {
693
    switch(numLayers)
694
      {
695
      case 2: return R.string.mirr2_inventor;
696
      case 3: return R.string.mirr3_inventor;
697
      }
698
    return R.string.mirr3_inventor;
699
    }
700

    
701
///////////////////////////////////////////////////////////////////////////////////////////////////
702

    
703
  public int getComplexity(int numLayers)
704
    {
705
    switch(numLayers)
706
      {
707
      case 2: return 5;
708
      case 3: return 7;
709
      }
710
    return 7;
711
    }
712
}
(28-28/38)