Project

General

Profile

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

magiccube / src / main / java / org / distorted / objects / TwistyDiamond.java @ aec5cc91

1 ece1b58d Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19
20
package org.distorted.objects;
21
22
import android.content.res.Resources;
23
24 f10a88a8 Leszek Koltunski
import org.distorted.helpers.ObjectShape;
25 9c06394a Leszek Koltunski
import org.distorted.helpers.ObjectSticker;
26 6cf89a3e Leszek Koltunski
import org.distorted.helpers.ScrambleState;
27 ece1b58d Leszek Koltunski
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 6fd4a72c Leszek Koltunski
import org.distorted.main.R;
33 ece1b58d Leszek Koltunski
34
import java.util.Random;
35
36
///////////////////////////////////////////////////////////////////////////////////////////////////
37
38 9c2f0c91 Leszek Koltunski
public class TwistyDiamond extends TwistyObject
39 ece1b58d Leszek Koltunski
{
40
  // the four rotation axis of a Diamond. Must be normalized.
41
  static final Static3D[] ROT_AXIS = new Static3D[]
42
         {
43
           new Static3D(+SQ6/3,+SQ3/3,     0),
44
           new Static3D(-SQ6/3,+SQ3/3,     0),
45 cc99cf91 Leszek Koltunski
           new Static3D(     0,-SQ3/3,-SQ6/3),
46
           new Static3D(     0,-SQ3/3,+SQ6/3)
47 ece1b58d Leszek Koltunski
         };
48
49
  private static final int[] FACE_COLORS = new int[]
50
         {
51 2ef489e2 Leszek Koltunski
           COLOR_ORANGE, COLOR_VIOLET,
52
           COLOR_WHITE , COLOR_BLUE  ,
53
           COLOR_YELLOW, COLOR_RED   ,
54
           COLOR_GREEN , COLOR_GREY
55 ece1b58d Leszek Koltunski
         };
56
57
  private static final float DIST = 0.50f;
58 aec5cc91 Leszek Koltunski
  private static final int FACES_PER_CUBIT =8;
59 9c06394a Leszek Koltunski
60 486b3417 Leszek Koltunski
  private int mCurrState;
61
  private int mIndexExcluded;
62 6cf89a3e Leszek Koltunski
  private final ScrambleState[] mStates;
63 e1dc3366 Leszek Koltunski
  private int[][] mScrambleTable;
64
  private int[] mNumOccurences;
65 aec5cc91 Leszek Koltunski
  private int[] mBasicAngle;
66
  private int[] mFaceMap;
67
  private Static4D[] mQuats;
68
  private int[] mTetraToFaceMap;
69
  private ObjectSticker[] mStickers;
70 486b3417 Leszek Koltunski
71 ece1b58d Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
72
73 9c2f0c91 Leszek Koltunski
  TwistyDiamond(int size, Static4D quat, DistortedTexture texture,
74
                MeshSquare mesh, DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
75 ece1b58d Leszek Koltunski
    {
76 db875721 Leszek Koltunski
    super(size, size, quat, texture, mesh, effects, moves, ObjectList.DIAM, res, scrWidth);
77 486b3417 Leszek Koltunski
78
    int[] tmp = new int[3*2*size];
79
80
    for(int i=0; i<2*size; i++)
81
      {
82
      tmp[3*i  ] = (i<size) ?  i:i-size;
83
      tmp[3*i+1] = (i%2==0) ? -1:1;
84
      tmp[3*i+2] = 0;
85
      }
86
87 6cf89a3e Leszek Koltunski
    mStates = new ScrambleState[]
88 486b3417 Leszek Koltunski
      {
89 6cf89a3e Leszek Koltunski
      new ScrambleState( new int[][] {tmp,tmp,tmp,tmp} )
90 486b3417 Leszek Koltunski
      };
91 ece1b58d Leszek Koltunski
    }
92
93 aec5cc91 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
94
95
  private void initializeQuats()
96
    {
97
    mQuats = new Static4D[]
98
         {
99
          new Static4D(  0.0f,  0.0f,   0.0f,  1.0f ),
100
          new Static4D(  0.0f,  1.0f,   0.0f,  0.0f ),
101
          new Static4D(+SQ2/2,  0.0f, -SQ2/2,  0.0f ),
102
          new Static4D(-SQ2/2,  0.0f, -SQ2/2,  0.0f ),
103
104
          new Static4D(+SQ2/2,  0.5f,   0.0f,  0.5f ),
105
          new Static4D(-SQ2/2,  0.5f,   0.0f,  0.5f ),
106
          new Static4D(  0.0f,  0.5f, +SQ2/2,  0.5f ),
107
          new Static4D(  0.0f,  0.5f, -SQ2/2,  0.5f ),
108
          new Static4D(+SQ2/2,  0.5f,   0.0f, -0.5f ),
109
          new Static4D(-SQ2/2,  0.5f,   0.0f, -0.5f ),
110
          new Static4D(  0.0f,  0.5f, +SQ2/2, -0.5f ),
111
          new Static4D(  0.0f,  0.5f, -SQ2/2, -0.5f )
112
         };
113
    }
114
115 a480ee80 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
116
117
  int[] getSolvedQuats(int cubit, int numLayers)
118
    {
119 aec5cc91 Leszek Koltunski
    if( mQuats==null ) initializeQuats();
120
    if( mFaceMap==null ) mFaceMap = new int[] {4,0,6,2,7,3,5,1};
121 a480ee80 Leszek Koltunski
    int status = retCubitSolvedStatus(cubit,numLayers);
122 aec5cc91 Leszek Koltunski
    return status<0 ? null : buildSolvedQuats(MovementDiamond.FACE_AXIS[mFaceMap[status]],mQuats);
123 a480ee80 Leszek Koltunski
    }
124
125 ece1b58d Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
126
127
  float getScreenRatio()
128
    {
129 ab0c28f0 Leszek Koltunski
    return 0.65f;
130 ece1b58d Leszek Koltunski
    }
131
132
///////////////////////////////////////////////////////////////////////////////////////////////////
133
134
  Static4D[] getQuats()
135
    {
136 aec5cc91 Leszek Koltunski
    if( mQuats==null ) initializeQuats();
137
    return mQuats;
138 ece1b58d Leszek Koltunski
    }
139
140
///////////////////////////////////////////////////////////////////////////////////////////////////
141
142
  int getNumFaces()
143
    {
144
    return FACE_COLORS.length;
145
    }
146
147
///////////////////////////////////////////////////////////////////////////////////////////////////
148
149
  boolean shouldResetTextureMaps()
150
    {
151
    return false;
152
    }
153
154 169219a7 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
155
156
  int getSolvedFunctionIndex()
157
    {
158
    return 0;
159
    }
160
161 ece1b58d Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
162
163 a64e07d0 Leszek Koltunski
  int getNumStickerTypes(int numLayers)
164 ece1b58d Leszek Koltunski
    {
165 aec5cc91 Leszek Koltunski
    return 1;
166 ece1b58d Leszek Koltunski
    }
167
168
///////////////////////////////////////////////////////////////////////////////////////////////////
169
170 e6734aa9 Leszek Koltunski
  float[][] getCuts(int numLayers)
171 ece1b58d Leszek Koltunski
    {
172 680f921e Leszek Koltunski
    if( numLayers<2 )
173
      {
174
      return null;
175
      }
176
    else
177
      {
178 e6734aa9 Leszek Koltunski
      float[][] cuts = new float[4][numLayers-1];
179 68b5f9c5 Leszek Koltunski
      float dist = SQ6*0.666f*DIST;
180 680f921e Leszek Koltunski
      float cut  = 0.5f*dist*(2-numLayers);
181
182
      for(int i=0; i<numLayers-1; i++)
183
        {
184 e6734aa9 Leszek Koltunski
        cuts[0][i] = cut;
185
        cuts[1][i] = cut;
186
        cuts[2][i] = cut;
187
        cuts[3][i] = cut;
188 680f921e Leszek Koltunski
        cut += dist;
189
        }
190
191
      return cuts;
192
      }
193 ece1b58d Leszek Koltunski
    }
194
195
///////////////////////////////////////////////////////////////////////////////////////////////////
196
197
  int getNumCubitFaces()
198
    {
199
    return FACES_PER_CUBIT;
200
    }
201
202
///////////////////////////////////////////////////////////////////////////////////////////////////
203
204 680f921e Leszek Koltunski
  private int getNumOctahedrons(int layers)
205
    {
206
    return layers==1 ? 1 : 4*(layers-1)*(layers-1) + 2;
207
    }
208
209
///////////////////////////////////////////////////////////////////////////////////////////////////
210
211
  private int getNumTetrahedrons(int layers)
212
    {
213
    return 4*layers*(layers-1);
214
    }
215
216
///////////////////////////////////////////////////////////////////////////////////////////////////
217
218 31cd7256 Leszek Koltunski
  private int createOctaPositions(float[][] centers, int index, int layers, float height)
219 680f921e Leszek Koltunski
    {
220
    float x = DIST*(layers-1);
221
    float z = DIST*(layers+1);
222
223
    for(int i=0; i<layers; i++, index++)
224
      {
225
      z -= 2*DIST;
226
      centers[index][0] = x;
227
      centers[index][1] = height;
228
      centers[index][2] = z;
229
      }
230
231
    for(int i=0; i<layers-1; i++, index++)
232
      {
233
      x -= 2*DIST;
234
      centers[index][0] = x;
235
      centers[index][1] = height;
236
      centers[index][2] = z;
237
      }
238
239
    for(int i=0; i<layers-1; i++, index++)
240
      {
241
      z += 2*DIST;
242
      centers[index][0] = x;
243
      centers[index][1] = height;
244
      centers[index][2] = z;
245
      }
246
247
    for(int i=0; i<layers-2; i++, index++)
248
      {
249
      x += 2*DIST;
250
      centers[index][0] = x;
251
      centers[index][1] = height;
252
      centers[index][2] = z;
253
      }
254
255
    return index;
256
    }
257
258
///////////////////////////////////////////////////////////////////////////////////////////////////
259
260 31cd7256 Leszek Koltunski
  private int createTetraPositions(float[][] centers, int index, int layers, float height)
261 ece1b58d Leszek Koltunski
    {
262 680f921e Leszek Koltunski
    float x = DIST*(layers-1);
263
    float z = DIST*layers;
264
265
    for(int i=0; i<layers-1; i++, index++)
266
      {
267
      z -= 2*DIST;
268
      centers[index][0] = x;
269
      centers[index][1] = height;
270
      centers[index][2] = z;
271
      }
272
273
    x += DIST;
274
    z -= DIST;
275
276
    for(int i=0; i<layers-1; i++, index++)
277
      {
278
      x -= 2*DIST;
279
      centers[index][0] = x;
280
      centers[index][1] = height;
281
      centers[index][2] = z;
282
      }
283
284
    x -= DIST;
285
    z -= DIST;
286
287
    for(int i=0; i<layers-1; i++, index++)
288
      {
289
      z += 2*DIST;
290
      centers[index][0] = x;
291
      centers[index][1] = height;
292
      centers[index][2] = z;
293
      }
294
295
    x -= DIST;
296
    z += DIST;
297
298
    for(int i=0; i<layers-1; i++, index++)
299
      {
300
      x += 2*DIST;
301
      centers[index][0] = x;
302
      centers[index][1] = height;
303
      centers[index][2] = z;
304
      }
305
306
    return index;
307
    }
308
309
///////////////////////////////////////////////////////////////////////////////////////////////////
310
311
  float[][] getCubitPositions(int layers)
312
    {
313
    int numO = getNumOctahedrons(layers);
314
    int numT = getNumTetrahedrons(layers);
315
    int index = 0;
316
    float height = 0.0f;
317
318
    float[][] CENTERS = new float[numO+numT][3];
319
320 31cd7256 Leszek Koltunski
    index = createOctaPositions(CENTERS,index,layers,height);
321 680f921e Leszek Koltunski
322
    for(int i=layers-1; i>0; i--)
323
      {
324
      height += SQ2*DIST;
325 31cd7256 Leszek Koltunski
      index = createOctaPositions(CENTERS,index,i,+height);
326
      index = createOctaPositions(CENTERS,index,i,-height);
327 680f921e Leszek Koltunski
      }
328
329
    height = DIST*SQ2/2;
330
331
    for(int i=layers; i>1; i--)
332
      {
333 31cd7256 Leszek Koltunski
      index = createTetraPositions(CENTERS,index,i,+height);
334
      index = createTetraPositions(CENTERS,index,i,-height);
335 680f921e Leszek Koltunski
      height += SQ2*DIST;
336
      }
337
338 ece1b58d Leszek Koltunski
    return CENTERS;
339
    }
340
341
///////////////////////////////////////////////////////////////////////////////////////////////////
342
343 680f921e Leszek Koltunski
  private int retFaceTetraBelongsTo(int tetra, int numLayers)
344 ece1b58d Leszek Koltunski
    {
345 aec5cc91 Leszek Koltunski
    if( mTetraToFaceMap==null ) mTetraToFaceMap = new int[] {1,2,3,0,5,6,7,4};
346
347 68b5f9c5 Leszek Koltunski
    for(int i=numLayers-1; i>0; i--)
348 ece1b58d Leszek Koltunski
      {
349 68b5f9c5 Leszek Koltunski
      if( tetra < 8*i ) return mTetraToFaceMap[tetra/i];
350
      tetra -= 8*i;
351 680f921e Leszek Koltunski
      }
352 68b5f9c5 Leszek Koltunski
353
    return -1;
354 680f921e Leszek Koltunski
    }
355
356 f10a88a8 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
357
358
  ObjectShape getObjectShape(int cubit, int numLayers)
359
    {
360
    int variant = getCubitVariant(cubit,numLayers);
361 f56b53cb Leszek Koltunski
    int N = numLayers>3 ? 5:6;
362 7d11f930 Leszek Koltunski
    int E = numLayers>2 ? (numLayers>3 ? 0:1):2;
363 ece1b58d Leszek Koltunski
364 f10a88a8 Leszek Koltunski
    if( variant==0 )
365 ece1b58d Leszek Koltunski
      {
366 aec5cc91 Leszek Koltunski
      double[][] vertices = new double[][]
367
          {
368
             { 0.5,   0.0, 0.5},
369
             { 0.5,   0.0,-0.5},
370
             {-0.5,   0.0,-0.5},
371
             {-0.5,   0.0, 0.5},
372
             { 0.0, SQ2/2, 0.0},
373
             { 0.0,-SQ2/2, 0.0}
374
          };
375
376
      int[][] vert_indices = new int[][]
377
          {
378
             {3,0,4},
379
             {0,1,4},
380
             {1,2,4},
381
             {2,3,4},
382
             {5,0,3},
383
             {5,1,0},
384
             {5,2,1},
385
             {5,3,2}
386
          };
387
388 f10a88a8 Leszek Koltunski
      float[][] bands     = new float[][] { {0.05f,35,0.5f,0.8f,N,E,E} };
389
      int[] bandIndices   = new int[] { 0,0,0,0,0,0,0,0 };
390
      float[][] corners   = new float[][] { {0.04f,0.20f} };
391
      int[] cornerIndices = new int[] { 0,0,0,0,0,0 };
392
      float[][] centers   = new float[][] { {0.0f, 0.0f, 0.0f} };
393
      int[] centerIndices = new int[] { 0,0,0,0,0,0 };
394 aec5cc91 Leszek Koltunski
      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
395 ece1b58d Leszek Koltunski
      }
396
    else
397
      {
398 aec5cc91 Leszek Koltunski
      double[][] vertices = new double[][] { {-0.5, SQ2/4, 0.0}, { 0.5, SQ2/4, 0.0}, { 0.0,-SQ2/4, 0.5}, { 0.0,-SQ2/4,-0.5} };
399
      int[][] vert_indices = new int[][]  { {2,1,0}, {2,3,1}, {3,2,0}, {3,0,1} };
400 f10a88a8 Leszek Koltunski
      float[][] bands     = new float[][] { {0.05f,35,0.5f,0.8f,N,E,E} };
401
      int[] bandIndices   = new int[] { 0,0,0,0 };
402
      float[][] corners   = new float[][] { {0.08f,0.15f} };
403
      int[] cornerIndices = new int[] { 0,0,0,0 };
404
      float[][] centers   = new float[][] { {0.0f, 0.0f, 0.0f} };
405
      int[] centerIndices = new int[] { 0,0,0,0 };
406 aec5cc91 Leszek Koltunski
      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
407 f10a88a8 Leszek Koltunski
      }
408
    }
409
410
///////////////////////////////////////////////////////////////////////////////////////////////////
411
412 3e605536 Leszek Koltunski
  Static4D getQuat(int cubit, int numLayers)
413 f10a88a8 Leszek Koltunski
    {
414 aec5cc91 Leszek Koltunski
    if( mQuats==null ) initializeQuats();
415 3e605536 Leszek Koltunski
    int numO = getNumOctahedrons(numLayers);
416 f10a88a8 Leszek Koltunski
417 aec5cc91 Leszek Koltunski
    if( cubit<numO ) return mQuats[0];
418 f10a88a8 Leszek Koltunski
419 3e605536 Leszek Koltunski
    switch( retFaceTetraBelongsTo(cubit-numO, numLayers) )
420 f10a88a8 Leszek Koltunski
      {
421 aec5cc91 Leszek Koltunski
      case 0: return mQuats[0];                         // unit quat
422 3e605536 Leszek Koltunski
      case 1: return new Static4D(0,-SQ2/2,0,SQ2/2);    //  90 along Y
423 aec5cc91 Leszek Koltunski
      case 2: return mQuats[1];                         // 180 along Y
424 3e605536 Leszek Koltunski
      case 3: return new Static4D(0,+SQ2/2,0,SQ2/2);    //  90 along
425
      case 4: return new Static4D(0,     0,1,    0);    // 180 along Z
426
      case 5: return new Static4D(SQ2/2, 0,SQ2/2,0);    //
427
      case 6: return new Static4D(     1,0,0,    0);    // 180 along X
428
      case 7: return new Static4D(-SQ2/2,0,SQ2/2,0);    //
429 ece1b58d Leszek Koltunski
      }
430
431 3e605536 Leszek Koltunski
    return null;
432
    }
433
434
///////////////////////////////////////////////////////////////////////////////////////////////////
435 ece1b58d Leszek Koltunski
436 3e605536 Leszek Koltunski
  int getNumCubitVariants(int numLayers)
437
    {
438
    return 2;
439
    }
440
441
///////////////////////////////////////////////////////////////////////////////////////////////////
442
443
  int getCubitVariant(int cubit, int numLayers)
444
    {
445
    return cubit<getNumOctahedrons(numLayers) ? 0 : 1;
446 ece1b58d Leszek Koltunski
    }
447
448
///////////////////////////////////////////////////////////////////////////////////////////////////
449
450 2ef489e2 Leszek Koltunski
  int getFaceColor(int cubit, int cubitface, int size)
451 ece1b58d Leszek Koltunski
    {
452 2ef489e2 Leszek Koltunski
    int numO = getNumOctahedrons(size);
453 680f921e Leszek Koltunski
454
    if( cubit<numO )
455
      {
456 2ef489e2 Leszek Koltunski
      int axis = 0;
457
      int layer= 1;
458
459
      switch(cubitface)
460
        {
461
        case 0: axis = 2; layer =             1; break;
462
        case 1: axis = 0; layer = (1<<(size-1)); break;
463
        case 2: axis = 3; layer =             1; break;
464
        case 3: axis = 1; layer = (1<<(size-1)); break;
465
        case 4: axis = 3; layer = (1<<(size-1)); break;
466
        case 5: axis = 1; layer =             1; break;
467
        case 6: axis = 2; layer = (1<<(size-1)); break;
468
        case 7: axis = 0; layer =             1; break;
469
        }
470
471 a4962b9c Leszek Koltunski
      return CUBITS[cubit].mRotationRow[axis] == layer ? cubitface : NUM_TEXTURES;
472 680f921e Leszek Koltunski
      }
473
    else
474
      {
475 a4962b9c Leszek Koltunski
      return cubitface>0 ? NUM_TEXTURES : retFaceTetraBelongsTo(cubit-numO, size);
476 680f921e Leszek Koltunski
      }
477 ece1b58d Leszek Koltunski
    }
478
479
///////////////////////////////////////////////////////////////////////////////////////////////////
480
481 9c06394a Leszek Koltunski
  int getColor(int face)
482 ece1b58d Leszek Koltunski
    {
483 9c06394a Leszek Koltunski
    return FACE_COLORS[face];
484
    }
485
486
///////////////////////////////////////////////////////////////////////////////////////////////////
487 76c2bd07 Leszek Koltunski
488 9c06394a Leszek Koltunski
  ObjectSticker retSticker(int face)
489
    {
490 aec5cc91 Leszek Koltunski
    if( mStickers==null )
491
      {
492
      float[][] STICKERS = new float[][] { { -0.4330127f, -0.25f, 0.4330127f, -0.25f, 0.0f, 0.5f } };
493
      float radius = 0.06f;
494
      float stroke = 0.07f;
495
      float[] radii = new float[] {radius,radius,radius};
496
      mStickers     = new ObjectSticker[STICKERS.length];
497
      mStickers[0]  = new ObjectSticker(STICKERS[0],null,radii,stroke);
498
      }
499
500 9c06394a Leszek Koltunski
    return mStickers[face/NUM_FACES];
501 ece1b58d Leszek Koltunski
    }
502
503
///////////////////////////////////////////////////////////////////////////////////////////////////
504
505
  float returnMultiplier()
506
    {
507 cc99cf91 Leszek Koltunski
    return 1.5f;
508 ece1b58d Leszek Koltunski
    }
509
510
///////////////////////////////////////////////////////////////////////////////////////////////////
511
512 e1dc3366 Leszek Koltunski
  private void initializeScrambling()
513 ece1b58d Leszek Koltunski
    {
514 e1dc3366 Leszek Koltunski
    int numLayers = getNumLayers();
515 ece1b58d Leszek Koltunski
516 e1dc3366 Leszek Koltunski
    if( mScrambleTable ==null )
517
      {
518
      mScrambleTable = new int[NUM_AXIS][numLayers];
519
      }
520
    if( mNumOccurences ==null )
521
      {
522
      int max=0;
523 ece1b58d Leszek Koltunski
524 e1dc3366 Leszek Koltunski
      for (ScrambleState mState : mStates)
525
        {
526
        int tmp = mState.getTotal(-1);
527
        if (max < tmp) max = tmp;
528
        }
529
530
      mNumOccurences = new int[max];
531
      }
532
533
    for(int i=0; i<NUM_AXIS; i++)
534
      for(int j=0; j<numLayers; j++) mScrambleTable[i][j] = 0;
535 ece1b58d Leszek Koltunski
    }
536
537
///////////////////////////////////////////////////////////////////////////////////////////////////
538 e1dc3366 Leszek Koltunski
// PUBLIC API
539 ece1b58d Leszek Koltunski
540 486b3417 Leszek Koltunski
  public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles)
541 ece1b58d Leszek Koltunski
    {
542 9f171eba Leszek Koltunski
    if( curr==0 )
543 ece1b58d Leszek Koltunski
      {
544 486b3417 Leszek Koltunski
      mCurrState     = 0;
545
      mIndexExcluded =-1;
546 e1dc3366 Leszek Koltunski
      initializeScrambling();
547 ece1b58d Leszek Koltunski
      }
548
549 e1dc3366 Leszek Koltunski
    int[] info= mStates[mCurrState].getRandom(rnd, mIndexExcluded, mScrambleTable, mNumOccurences);
550 ece1b58d Leszek Koltunski
551 486b3417 Leszek Koltunski
    scramble[curr][0] = info[0];
552
    scramble[curr][1] = info[1];
553
    scramble[curr][2] = info[2];
554 ece1b58d Leszek Koltunski
555 486b3417 Leszek Koltunski
    mCurrState     = info[3];
556
    mIndexExcluded = info[0];
557 ece1b58d Leszek Koltunski
    }
558
559 e1dc3366 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
560
561
  public Static3D[] getRotationAxis()
562
    {
563
    return ROT_AXIS;
564
    }
565
566
///////////////////////////////////////////////////////////////////////////////////////////////////
567
568
  public int[] getBasicAngle()
569
    {
570 aec5cc91 Leszek Koltunski
    if( mBasicAngle ==null ) mBasicAngle = new int[] { 3,3,3,3 };
571
    return mBasicAngle;
572 e1dc3366 Leszek Koltunski
    }
573
574 6fd4a72c Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
575
576
  public int getObjectName(int numLayers)
577
    {
578 2ef489e2 Leszek Koltunski
    switch(numLayers)
579
      {
580
      case 2: return R.string.diam2;
581
      case 3: return R.string.diam3;
582 2adf1263 Leszek Koltunski
      case 4: return R.string.diam4;
583 2ef489e2 Leszek Koltunski
      }
584
585
    return 0;
586 6fd4a72c Leszek Koltunski
    }
587
588
///////////////////////////////////////////////////////////////////////////////////////////////////
589
590
  public int getInventor(int numLayers)
591
    {
592 2ef489e2 Leszek Koltunski
    switch(numLayers)
593
      {
594
      case 2: return R.string.diam2_inventor;
595
      case 3: return R.string.diam3_inventor;
596 2adf1263 Leszek Koltunski
      case 4: return R.string.diam4_inventor;
597 2ef489e2 Leszek Koltunski
      }
598
599
    return 0;
600 6fd4a72c Leszek Koltunski
    }
601
602
///////////////////////////////////////////////////////////////////////////////////////////////////
603
604
  public int getComplexity(int numLayers)
605
    {
606 2ef489e2 Leszek Koltunski
    switch(numLayers)
607
      {
608 2adf1263 Leszek Koltunski
      case 2: return 4;
609
      case 3: return 6;
610
      case 4: return 8;
611 2ef489e2 Leszek Koltunski
      }
612
613
    return 0;
614 6fd4a72c Leszek Koltunski
    }
615 ece1b58d Leszek Koltunski
}