Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyCube.java @ a57e6870

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 TwistyCube 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 ScrambleState[] mStates;
59
  private Static4D[] mQuats;
60
  private float[][] mCuts;
61
  private boolean[][] mLayerRotatable;
62
  private int[] mBasicAngle;
63
  private ObjectSticker[] mStickers;
64
  private Movement mMovement;
65
66
///////////////////////////////////////////////////////////////////////////////////////////////////
67
68 a57e6870 Leszek Koltunski
  public TwistyCube(int[] numL, Static4D quat, Static3D move, DistortedTexture texture,
69 ecf3d6e3 Leszek Koltunski
                    MeshSquare mesh, DistortedEffects effects, Resources res, int scrWidth)
70 29b82486 Leszek Koltunski
    {
71 a57e6870 Leszek Koltunski
    super(numL, numL[0], quat, move, texture, mesh, effects, res, scrWidth);
72 29b82486 Leszek Koltunski
    }
73
74
///////////////////////////////////////////////////////////////////////////////////////////////////
75
76
  protected ScrambleState[] getScrambleStates()
77
    {
78
    if( mStates==null )
79
      {
80 a57e6870 Leszek Koltunski
      int[] numL = getNumLayers();
81 29b82486 Leszek Koltunski
      int[][] m = new int[16][];
82 a57e6870 Leszek Koltunski
      for(int i=1; i<16; i++) m[i] = createEdges(numL[0],i);
83 29b82486 Leszek Koltunski
84
      mStates = new ScrambleState[]
85
        {
86 7ce20d2a Leszek Koltunski
        new ScrambleState( new int[][] { m[ 1], m[ 2], m[ 3] } ),  //  0 0
87
        new ScrambleState( new int[][] {  null, m[ 4], m[ 5] } ),  //  1 x
88
        new ScrambleState( new int[][] { m[ 6],  null, m[ 7] } ),  //  2 y
89
        new ScrambleState( new int[][] { m[ 8], m[ 9],  null } ),  //  3 z
90
        new ScrambleState( new int[][] { m[10],  null, m[ 7] } ),  //  4 xy
91
        new ScrambleState( new int[][] { m[11], m[ 9],  null } ),  //  5 xz
92
        new ScrambleState( new int[][] {  null, m[12], m[ 5] } ),  //  6 yx
93
        new ScrambleState( new int[][] { m[ 8], m[13],  null } ),  //  7 yz
94
        new ScrambleState( new int[][] {  null, m[ 4], m[14] } ),  //  8 zx
95
        new ScrambleState( new int[][] { m[ 6],  null, m[15] } ),  //  9 zy
96
        new ScrambleState( new int[][] {  null,  null, m[ 5] } ),  // 10 xyx
97
        new ScrambleState( new int[][] {  null, m[ 4],  null } ),  // 11 xzx
98
        new ScrambleState( new int[][] {  null,  null, m[ 7] } ),  // 12 yxy
99
        new ScrambleState( new int[][] { m[ 6],  null,  null } ),  // 13 yzy
100
        new ScrambleState( new int[][] {  null, m[ 9],  null } ),  // 14 zxz
101
        new ScrambleState( new int[][] { m[ 8],  null,  null } ),  // 15 zyz
102 29b82486 Leszek Koltunski
        };
103
      }
104
105
    return mStates;
106
    }
107
108 4e1dc313 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
109
110 a57e6870 Leszek Koltunski
  protected int getResource(int[] numLayers)
111 4e1dc313 Leszek Koltunski
    {
112 a57e6870 Leszek Koltunski
    switch(numLayers[0])
113 4e1dc313 Leszek Koltunski
      {
114
      case 2: return R.raw.cube2;
115
      case 3: return R.raw.cube3;
116
      case 4: return R.raw.cube4;
117
      case 5: return R.raw.cube5;
118
      }
119
120
    return 0;
121
    }
122
123 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
124
125
  private int[] createEdges(int size, int vertex)
126
    {
127
    int[] ret = new int[9*size];
128
129
    for(int l=0; l<size; l++)
130
      {
131
      ret[9*l  ] = l;
132
      ret[9*l+1] =-1;
133
      ret[9*l+2] = vertex;
134
      ret[9*l+3] = l;
135
      ret[9*l+4] = 1;
136
      ret[9*l+5] = vertex;
137
      ret[9*l+6] = l;
138
      ret[9*l+7] = 2;
139
      ret[9*l+8] = vertex;
140
      }
141
142
    return ret;
143
    }
144
145
///////////////////////////////////////////////////////////////////////////////////////////////////
146
147
  private void initializeQuats()
148
    {
149
    mQuats = new Static4D[]
150
         {
151
         new Static4D(  0.0f,   0.0f,   0.0f,   1.0f),
152
         new Static4D(  1.0f,   0.0f,   0.0f,   0.0f),
153
         new Static4D(  0.0f,   1.0f,   0.0f,   0.0f),
154
         new Static4D(  0.0f,   0.0f,   1.0f,   0.0f),
155
156
         new Static4D( SQ2/2,  SQ2/2,  0.0f ,   0.0f),
157
         new Static4D( SQ2/2, -SQ2/2,  0.0f ,   0.0f),
158
         new Static4D( SQ2/2,   0.0f,  SQ2/2,   0.0f),
159
         new Static4D(-SQ2/2,   0.0f,  SQ2/2,   0.0f),
160
         new Static4D( SQ2/2,   0.0f,   0.0f,  SQ2/2),
161
         new Static4D( SQ2/2,   0.0f,   0.0f, -SQ2/2),
162
         new Static4D(  0.0f,  SQ2/2,  SQ2/2,   0.0f),
163
         new Static4D(  0.0f,  SQ2/2, -SQ2/2,   0.0f),
164
         new Static4D(  0.0f,  SQ2/2,   0.0f,  SQ2/2),
165
         new Static4D(  0.0f,  SQ2/2,   0.0f, -SQ2/2),
166
         new Static4D(  0.0f,   0.0f,  SQ2/2,  SQ2/2),
167
         new Static4D(  0.0f,   0.0f,  SQ2/2, -SQ2/2),
168
169
         new Static4D(  0.5f,   0.5f,   0.5f,   0.5f),
170
         new Static4D(  0.5f,   0.5f,  -0.5f,   0.5f),
171
         new Static4D(  0.5f,   0.5f,  -0.5f,  -0.5f),
172
         new Static4D(  0.5f,  -0.5f,   0.5f,  -0.5f),
173
         new Static4D( -0.5f,  -0.5f,  -0.5f,   0.5f),
174
         new Static4D( -0.5f,   0.5f,  -0.5f,  -0.5f),
175
         new Static4D( -0.5f,   0.5f,   0.5f,  -0.5f),
176
         new Static4D( -0.5f,   0.5f,   0.5f,   0.5f)
177
         };
178
    }
179
180
///////////////////////////////////////////////////////////////////////////////////////////////////
181
182 a57e6870 Leszek Koltunski
  protected int[] getSolvedQuats(int cubit, int[] numLayers)
183 29b82486 Leszek Koltunski
    {
184
    if( mQuats ==null ) initializeQuats();
185
    int status = retCubitSolvedStatus(cubit,numLayers);
186
    return status<0 ? null : buildSolvedQuats(Movement6.FACE_AXIS[status], mQuats);
187
    }
188
189 8da6b1c9 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
190
191
  private int getNumCornersAndEdges(int numLayers)
192
    {
193
    return numLayers==1 ? 1 : 12*(numLayers-2) + 8;
194
    }
195
196 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
197
198 a57e6870 Leszek Koltunski
  protected ObjectShape getObjectShape(int cubit, int[] numLayers)
199 29b82486 Leszek Koltunski
    {
200
    int extraI, extraV, num;
201
    float height;
202 8396c548 Leszek Koltunski
    int variant = getCubitVariant(cubit,numLayers);
203 a57e6870 Leszek Koltunski
    int numL = numLayers[0];
204 29b82486 Leszek Koltunski
205 a57e6870 Leszek Koltunski
    switch(numL)
206 8396c548 Leszek Koltunski
        {
207
        case 2 : num = 6; extraI = 2; extraV = 2; height = 0.045f; break;
208
        case 3 : num = 5; extraI = 2; extraV = 2; height = 0.045f; break;
209
        case 4 : num = 5; extraI = 1; extraV = 1; height = 0.045f; break;
210
        default: num = 5; extraI = 0; extraV = 0; height = 0.045f; break;
211
        }
212 29b82486 Leszek Koltunski
213
    double[][] vertices = new double[][]
214
          {
215
              { 0.5, 0.5, 0.5 },
216
              { 0.5, 0.5,-0.5 },
217
              { 0.5,-0.5, 0.5 },
218
              { 0.5,-0.5,-0.5 },
219
              {-0.5, 0.5, 0.5 },
220
              {-0.5, 0.5,-0.5 },
221
              {-0.5,-0.5, 0.5 },
222
              {-0.5,-0.5,-0.5 },
223
          };
224
225
    int[][] vert_indices = new int[][]
226
          {
227
              {2,3,1,0},
228
              {7,6,4,5},
229
              {4,0,1,5},
230
              {7,3,2,6},
231
              {6,2,0,4},
232
              {3,7,5,1}
233
          };
234
235
    float[][] corners   = new float[][] { {0.036f,0.12f} };
236
    int[] cornerIndices = new int[] { 0,0,0,0,0,0,0,0 };
237
    float[][] centers   = new float[][] { {0.0f, 0.0f, 0.0f} };
238
    int[] centerIndices = new int[] { 0,0,0,0,0,0,0,0 };
239
240 8396c548 Leszek Koltunski
    if( variant==0 )
241
      {
242
      float[][] bands   = new float[][] { {height,35,0.5f,0.7f,num,extraI,extraV} };
243
      int[] bandIndices = new int[] { 0,0,0,0,0,0};
244
      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
245
      }
246
    else
247
      {
248
      int extraI2, extraV2, num2;
249
250 a57e6870 Leszek Koltunski
      switch(numL)
251 8396c548 Leszek Koltunski
        {
252
        case 2 : num2 = 6; extraI2 = 2; extraV2 = 2; break;
253
        case 3 : num2 = 5; extraI2 = 1; extraV2 = 0; break;
254
        case 4 : num2 = 4; extraI2 = 0; extraV2 = 0; break;
255
        default: num2 = 3; extraI2 = 0; extraV2 = 0; break;
256
        }
257
258 d309baa5 Leszek Koltunski
      float[][] bands   = new float[][]
259
        {
260
          {height,35,0.5f,0.7f,num ,extraI ,extraV },
261
          {height,35,0.5f,0.7f,num2,extraI2,extraV2},
262
          {height,35,0.5f,0.7f,   2,      0,      0},
263
        };
264
      int[] bandIndices = new int[] { 1,1,1,1,0,2};
265 8396c548 Leszek Koltunski
      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
266
      }
267 29b82486 Leszek Koltunski
    }
268
269 8da6b1c9 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
270
271 a57e6870 Leszek Koltunski
  protected float[][] getCubitPositions(int[] numLayers)
272 8da6b1c9 Leszek Koltunski
    {
273 a57e6870 Leszek Koltunski
    int numL = numLayers[0];
274 8da6b1c9 Leszek Koltunski
275 a57e6870 Leszek Koltunski
    if( numL==1 ) return new float[][] {{ 0.0f, 0.0f, 0.0f }};
276
277
    int numCubits = getNumCornersAndEdges(numL) + 6*(numL-2)*(numL-2);
278 8da6b1c9 Leszek Koltunski
    float[][] tmp = new float[numCubits][];
279
280 a57e6870 Leszek Koltunski
    final float LEN = 0.5f*(numL-1);
281 8da6b1c9 Leszek Koltunski
    int currentPosition = 0;
282
283
    tmp[currentPosition++] = new float[] {-LEN,-LEN,-LEN};
284
    tmp[currentPosition++] = new float[] {-LEN,-LEN,+LEN};
285
    tmp[currentPosition++] = new float[] {-LEN,+LEN,-LEN};
286
    tmp[currentPosition++] = new float[] {-LEN,+LEN,+LEN};
287
    tmp[currentPosition++] = new float[] {+LEN,-LEN,-LEN};
288
    tmp[currentPosition++] = new float[] {+LEN,-LEN,+LEN};
289
    tmp[currentPosition++] = new float[] {+LEN,+LEN,-LEN};
290
    tmp[currentPosition++] = new float[] {+LEN,+LEN,+LEN};
291
292 a57e6870 Leszek Koltunski
    for(int i=1; i<numL-1; i++)
293 8da6b1c9 Leszek Koltunski
      tmp[currentPosition++] = new float[] { i-LEN,  -LEN,  -LEN };
294 a57e6870 Leszek Koltunski
    for(int i=1; i<numL-1; i++)
295 8da6b1c9 Leszek Koltunski
      tmp[currentPosition++] = new float[] { i-LEN,  -LEN,  +LEN };
296 a57e6870 Leszek Koltunski
    for(int i=1; i<numL-1; i++)
297 8da6b1c9 Leszek Koltunski
      tmp[currentPosition++] = new float[] { i-LEN,  +LEN,  -LEN };
298 a57e6870 Leszek Koltunski
    for(int i=1; i<numL-1; i++)
299 8da6b1c9 Leszek Koltunski
      tmp[currentPosition++] = new float[] { i-LEN,  +LEN,  +LEN };
300 a57e6870 Leszek Koltunski
    for(int i=1; i<numL-1; i++)
301 8da6b1c9 Leszek Koltunski
      tmp[currentPosition++] = new float[] {  -LEN, i-LEN,  -LEN };
302 a57e6870 Leszek Koltunski
    for(int i=1; i<numL-1; i++)
303 8da6b1c9 Leszek Koltunski
      tmp[currentPosition++] = new float[] {  -LEN, i-LEN,  +LEN };
304 a57e6870 Leszek Koltunski
    for(int i=1; i<numL-1; i++)
305 8da6b1c9 Leszek Koltunski
      tmp[currentPosition++] = new float[] {  +LEN, i-LEN,  -LEN };
306 a57e6870 Leszek Koltunski
    for(int i=1; i<numL-1; i++)
307 8da6b1c9 Leszek Koltunski
      tmp[currentPosition++] = new float[] {  +LEN, i-LEN,  +LEN };
308 a57e6870 Leszek Koltunski
    for(int i=1; i<numL-1; i++)
309 8da6b1c9 Leszek Koltunski
      tmp[currentPosition++] = new float[] {  -LEN,  -LEN, i-LEN };
310 a57e6870 Leszek Koltunski
    for(int i=1; i<numL-1; i++)
311 8da6b1c9 Leszek Koltunski
      tmp[currentPosition++] = new float[] {  -LEN,  +LEN, i-LEN };
312 a57e6870 Leszek Koltunski
    for(int i=1; i<numL-1; i++)
313 8da6b1c9 Leszek Koltunski
      tmp[currentPosition++] = new float[] {  +LEN,  -LEN, i-LEN };
314 a57e6870 Leszek Koltunski
    for(int i=1; i<numL-1; i++)
315 8da6b1c9 Leszek Koltunski
      tmp[currentPosition++] = new float[] {  +LEN,  +LEN, i-LEN };
316
317 a57e6870 Leszek Koltunski
    for(int y=1; y<numL-1; y++)
318
      for(int z=1; z<numL-1; z++)
319 8da6b1c9 Leszek Koltunski
        tmp[currentPosition++] = new float[] {+LEN,y-LEN,z-LEN};
320
321 a57e6870 Leszek Koltunski
    for(int y=1; y<numL-1; y++)
322
      for(int z=1; z<numL-1; z++)
323 8da6b1c9 Leszek Koltunski
        tmp[currentPosition++] = new float[] {-LEN,y-LEN,z-LEN};
324
325 a57e6870 Leszek Koltunski
    for(int x=1; x<numL-1; x++)
326
      for(int z=1; z<numL-1; z++)
327 8da6b1c9 Leszek Koltunski
        tmp[currentPosition++] = new float[] {x-LEN,+LEN,z-LEN};
328
329 a57e6870 Leszek Koltunski
    for(int x=1; x<numL-1; x++)
330
      for(int z=1; z<numL-1; z++)
331 8da6b1c9 Leszek Koltunski
        tmp[currentPosition++] = new float[] {x-LEN,-LEN,z-LEN};
332
333 a57e6870 Leszek Koltunski
    for(int x=1; x<numL-1; x++)
334
      for(int y=1; y<numL-1; y++)
335 8da6b1c9 Leszek Koltunski
        tmp[currentPosition++] = new float[] {x-LEN,y-LEN,+LEN};
336
337 a57e6870 Leszek Koltunski
    for(int x=1; x<numL-1; x++)
338
      for(int y=1; y<numL-1; y++)
339 8da6b1c9 Leszek Koltunski
        tmp[currentPosition++] = new float[] {x-LEN,y-LEN,-LEN};
340
341
    return tmp;
342
    }
343
344 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
345
346 a57e6870 Leszek Koltunski
  protected Static4D getQuat(int cubit, int[] numLayers)
347 29b82486 Leszek Koltunski
    {
348
    if( mQuats ==null ) initializeQuats();
349 8da6b1c9 Leszek Koltunski
350 a57e6870 Leszek Koltunski
    int numL = numLayers[0];
351
    int num = cubit - getNumCornersAndEdges(numL);
352 8da6b1c9 Leszek Koltunski
353
    if( num>=0 )
354
      {
355 a57e6870 Leszek Koltunski
      int face = num/((numL-2)*(numL-2));
356 8da6b1c9 Leszek Koltunski
357
      switch(face)
358
        {
359
        case 0: return mQuats[13];
360
        case 1: return mQuats[12];
361
        case 2: return mQuats[ 8];
362
        case 3: return mQuats[ 9];
363
        case 4: return mQuats[ 0];
364
        case 5: return mQuats[ 1];
365
        }
366
      }
367
368 29b82486 Leszek Koltunski
    return mQuats[0];
369
    }
370
371
///////////////////////////////////////////////////////////////////////////////////////////////////
372
373 a57e6870 Leszek Koltunski
  protected int getNumCubitVariants(int[] numLayers)
374 29b82486 Leszek Koltunski
    {
375 a57e6870 Leszek Koltunski
    return numLayers[0]>2 ? 2:1;
376 29b82486 Leszek Koltunski
    }
377
378
///////////////////////////////////////////////////////////////////////////////////////////////////
379
380 a57e6870 Leszek Koltunski
  protected int getCubitVariant(int cubit, int[] numLayers)
381 29b82486 Leszek Koltunski
    {
382 a57e6870 Leszek Koltunski
    return cubit < getNumCornersAndEdges(numLayers[0]) ? 0 : 1;
383 8da6b1c9 Leszek Koltunski
    }
384
385
///////////////////////////////////////////////////////////////////////////////////////////////////
386
387 a57e6870 Leszek Koltunski
  protected int getFaceColor(int cubit, int cubitface, int[] numLayers)
388 8da6b1c9 Leszek Koltunski
    {
389 a57e6870 Leszek Koltunski
    int numL = numLayers[0];
390
    int cornersAndEdges = getNumCornersAndEdges(numL);
391 8da6b1c9 Leszek Koltunski
392
    if( cubit<cornersAndEdges )
393
      {
394 a57e6870 Leszek Koltunski
      return CUBITS[cubit].getRotRow(cubitface/2) == (cubitface%2==0 ? (1<<(numL-1)):1) ? cubitface : NUM_TEXTURES;
395 8da6b1c9 Leszek Koltunski
      }
396
    else
397
      {
398 a57e6870 Leszek Koltunski
      int numCentersPerFace = (numL-2)*(numL-2);
399 8da6b1c9 Leszek Koltunski
      return cubitface == 4 ? (cubit-cornersAndEdges)/numCentersPerFace : NUM_TEXTURES;
400
      }
401 29b82486 Leszek Koltunski
    }
402
403
///////////////////////////////////////////////////////////////////////////////////////////////////
404
405
  protected ObjectSticker retSticker(int face)
406
    {
407
    if( mStickers==null )
408
      {
409
      final float[][] STICKERS = new float[][]  { { -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f } };
410
      final float radius = 0.10f;
411
      final float[] radii = {radius,radius,radius,radius};
412
      mStickers = new ObjectSticker[STICKERS.length];
413 8592461c Leszek Koltunski
      float stroke = 0.08f;
414
415
      if( ObjectControl.isInIconMode() )
416
        {
417 a57e6870 Leszek Koltunski
        int[] numLayers = getNumLayers();
418
419
        switch(numLayers[0])
420 8592461c Leszek Koltunski
          {
421
          case 2: stroke*=1.8f; break;
422
          case 3: stroke*=2.0f; break;
423
          case 4: stroke*=2.1f; break;
424
          default:stroke*=2.2f; break;
425
          }
426
        }
427
428 29b82486 Leszek Koltunski
      mStickers[0] = new ObjectSticker(STICKERS[0],null,radii,stroke );
429
      }
430
431
    return mStickers[face/NUM_FACE_COLORS];
432
    }
433
434
///////////////////////////////////////////////////////////////////////////////////////////////////
435
436
  protected Static4D[] getQuats()
437
    {
438
    if( mQuats ==null ) initializeQuats();
439
    return mQuats;
440
    }
441
442
///////////////////////////////////////////////////////////////////////////////////////////////////
443
444 a57e6870 Leszek Koltunski
  protected float[][] getCuts(int[] numLayers)
445 29b82486 Leszek Koltunski
    {
446 a57e6870 Leszek Koltunski
    int numL = numLayers[0];
447
    if( numL<2 ) return null;
448 29b82486 Leszek Koltunski
449
    if( mCuts==null )
450
      {
451 a57e6870 Leszek Koltunski
      mCuts = new float[3][numL-1];
452 29b82486 Leszek Koltunski
453 a57e6870 Leszek Koltunski
      for(int i=0; i<numL-1; i++)
454 29b82486 Leszek Koltunski
        {
455 a57e6870 Leszek Koltunski
        float cut = (2-numL)*0.5f + i;
456 29b82486 Leszek Koltunski
        mCuts[0][i] = cut;
457
        mCuts[1][i] = cut;
458
        mCuts[2][i] = cut;
459
        }
460
      }
461
462
    return mCuts;
463
    }
464
465
///////////////////////////////////////////////////////////////////////////////////////////////////
466
467 a57e6870 Leszek Koltunski
  private void getLayerRotatable(int[] numLayers)
468 29b82486 Leszek Koltunski
    {
469
    if( mLayerRotatable==null )
470
      {
471
      int numAxis = ROT_AXIS.length;
472
      mLayerRotatable = new boolean[numAxis][];
473 a57e6870 Leszek Koltunski
474
      for(int i=0; i<numAxis; i++)
475
        {
476
        mLayerRotatable[i] = new boolean[numLayers[i]];
477
        for(int j=0; j<numLayers[i]; j++) mLayerRotatable[i][j] = true;
478
        }
479 29b82486 Leszek Koltunski
      }
480
    }
481
482
///////////////////////////////////////////////////////////////////////////////////////////////////
483
484
  protected int getSolvedFunctionIndex()
485
    {
486
    return 0;
487
    }
488
489
///////////////////////////////////////////////////////////////////////////////////////////////////
490
491 a57e6870 Leszek Koltunski
  protected int getNumStickerTypes(int[] numLayers)
492 29b82486 Leszek Koltunski
    {
493
    return 1;
494
    }
495
496
///////////////////////////////////////////////////////////////////////////////////////////////////
497
498
  protected int getNumCubitFaces()
499
    {
500
    return 6;
501
    }
502
503
///////////////////////////////////////////////////////////////////////////////////////////////////
504
// PUBLIC API
505
506
  public Static3D[] getRotationAxis()
507
    {
508
    return ROT_AXIS;
509
    }
510
511
///////////////////////////////////////////////////////////////////////////////////////////////////
512
513
  public Movement getMovement()
514
    {
515
    if( mMovement==null )
516
      {
517 a57e6870 Leszek Koltunski
      int[] numLayers = getNumLayers();
518 29b82486 Leszek Koltunski
      if( mCuts==null ) getCuts(numLayers);
519
      getLayerRotatable(numLayers);
520 a57e6870 Leszek Koltunski
      mMovement = new Movement6(ROT_AXIS,mCuts,mLayerRotatable,numLayers[0],TYPE_NOT_SPLIT,ENABLED);
521 29b82486 Leszek Koltunski
      }
522
    return mMovement;
523
    }
524
525
///////////////////////////////////////////////////////////////////////////////////////////////////
526
527
  public int[] getBasicAngle()
528
    {
529
    if( mBasicAngle==null ) mBasicAngle = new int[] { 4,4,4 };
530
    return mBasicAngle;
531
    }
532
533 61aa85e4 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
534
535 a57e6870 Leszek Koltunski
  public ObjectType intGetObjectType(int[] numLayers)
536 61aa85e4 Leszek Koltunski
    {
537 a57e6870 Leszek Koltunski
    switch(numLayers[0])
538 61aa85e4 Leszek Koltunski
      {
539 8005e762 Leszek Koltunski
      case 2: return ObjectType.CUBE_2;
540
      case 3: return ObjectType.CUBE_3;
541
      case 4: return ObjectType.CUBE_4;
542
      case 5: return ObjectType.CUBE_5;
543 61aa85e4 Leszek Koltunski
      }
544
545 8005e762 Leszek Koltunski
    return ObjectType.CUBE_3;
546 61aa85e4 Leszek Koltunski
    }
547
548 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
549
550 a57e6870 Leszek Koltunski
  public int getObjectName(int[] numLayers)
551 29b82486 Leszek Koltunski
    {
552 a57e6870 Leszek Koltunski
    switch(numLayers[0])
553 29b82486 Leszek Koltunski
      {
554
      case 2: return R.string.cube2;
555
      case 3: return R.string.cube3;
556
      case 4: return R.string.cube4;
557
      case 5: return R.string.cube5;
558
      }
559
    return R.string.cube3;
560
    }
561
562
///////////////////////////////////////////////////////////////////////////////////////////////////
563
564 a57e6870 Leszek Koltunski
  public int getInventor(int[] numLayers)
565 29b82486 Leszek Koltunski
    {
566 a57e6870 Leszek Koltunski
    switch(numLayers[0])
567 29b82486 Leszek Koltunski
      {
568
      case 2: return R.string.cube2_inventor;
569
      case 3: return R.string.cube3_inventor;
570
      case 4: return R.string.cube4_inventor;
571
      case 5: return R.string.cube5_inventor;
572
      }
573
    return R.string.cube3_inventor;
574
    }
575
576
///////////////////////////////////////////////////////////////////////////////////////////////////
577
578 a57e6870 Leszek Koltunski
  public int getComplexity(int[] numLayers)
579 29b82486 Leszek Koltunski
    {
580 a57e6870 Leszek Koltunski
    switch(numLayers[0])
581 29b82486 Leszek Koltunski
      {
582
      case 2: return 4;
583
      case 3: return 6;
584
      case 4: return 8;
585
      case 5: return 10;
586
      }
587
    return 6;
588
    }
589
}