Project

General

Profile

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

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

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