Project

General

Profile

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

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

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