Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyMirror.java @ 8592461c

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