Project

General

Profile

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

magiccube / src / main / java / org / distorted / objects / TwistyMirror.java @ 967c1d17

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