Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyMirror.java @ 7ba38dd4

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