Project

General

Profile

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

magiccube / src / main / java / org / distorted / objects / TwistyMinx.java @ f242ba04

1
///////////////////////////////////////////////////////////////////////////////////////////////////
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
import org.distorted.helpers.ObjectSticker;
25
import org.distorted.helpers.ScrambleState;
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 java.util.Random;
33

    
34
///////////////////////////////////////////////////////////////////////////////////////////////////
35

    
36
abstract class TwistyMinx extends TwistyObject
37
{
38
  private static final int FACES_PER_CUBIT =6;
39

    
40
  static final int NUM_CORNERS = 20;
41
  static final int NUM_CENTERS = 12;
42
  static final int NUM_EDGES   = 30;
43

    
44
  static final float C2       = (SQ5+3)/4;
45
  static final float LEN      = (float)(Math.sqrt(1.25f+0.5f*SQ5));
46
  static final float SIN54    = (SQ5+1)/4;
47
  static final float COS54    = (float)(Math.sqrt(10-2*SQ5)/4);
48
  static final float SIN18    = (SQ5-1)/4;
49
  static final float COS18    = (float)(0.25f*Math.sqrt(10.0f+2.0f*SQ5));
50
  static final float COS_HALFD= (float)(Math.sqrt(0.5f-0.1f*SQ5)); // cos(half the dihedral angle)
51
  static final float SIN_HALFD= (float)(Math.sqrt(0.5f+0.1f*SQ5)); // sin(half the dihedral angle)
52

    
53
  // the six rotation axis of a Minx. Must be normalized.
54
  static final Static3D[] ROT_AXIS = new Static3D[]
55
         {
56
           new Static3D(    C2/LEN, SIN54/LEN,    0      ),
57
           new Static3D(   -C2/LEN, SIN54/LEN,    0      ),
58
           new Static3D( 0        ,    C2/LEN, SIN54/LEN ),
59
           new Static3D( 0        ,   -C2/LEN, SIN54/LEN ),
60
           new Static3D( SIN54/LEN,    0     ,    C2/LEN ),
61
           new Static3D( SIN54/LEN,    0     ,   -C2/LEN )
62
         };
63

    
64
  static final int MINX_LGREEN = 0xff53aa00;
65
  static final int MINX_PINK   = 0xfffd7ab7;
66
  static final int MINX_SANDY  = 0xffefd48b;
67
  static final int MINX_LBLUE  = 0xff00a2d7;
68
  static final int MINX_ORANGE = 0xffff6200;
69
  static final int MINX_VIOLET = 0xff7d59a4;
70
  static final int MINX_DGREEN = 0xff007a47;
71
  static final int MINX_DRED   = 0xffbd0000;
72
  static final int MINX_DBLUE  = 0xff1a29b2;
73
  static final int MINX_DYELLOW= 0xffffc400;
74
  static final int MINX_WHITE  = 0xffffffff;
75
  static final int MINX_GREY   = 0xff727c7b;
76

    
77
  static final int[] FACE_COLORS = new int[]
78
         {
79
           MINX_LGREEN, MINX_PINK   , MINX_SANDY , MINX_LBLUE,
80
           MINX_ORANGE, MINX_VIOLET , MINX_DGREEN, MINX_DRED ,
81
           MINX_DBLUE , MINX_DYELLOW, MINX_WHITE , MINX_GREY
82
         };
83

    
84
  private int mCurrState;
85
  private int mIndexExcluded;
86
  private ScrambleState[] mStates;
87
  private int[][] mScrambleTable;
88
  private int[] mNumOccurences;
89
  private int[] mBasicAngle;
90
  private int[] mFaceMap;
91
  Static4D[] mQuats;
92
  float[][] mCenterCoords;
93
  float[][] mCorners;
94
  int[][] mCornerFaceMap;
95
  int[] mQuatEdgeIndices;
96
  int[] mQuatCornerIndices;
97
  int[][] mEdgeMap;
98
  int[][] mCenterMap;
99
  Static4D[] mBasicCornerV, mCurrCornerV;
100
  ObjectSticker[] mStickers;
101

    
102
///////////////////////////////////////////////////////////////////////////////////////////////////
103

    
104
  TwistyMinx(int numLayers, int realSize, Static4D quat, DistortedTexture texture, MeshSquare mesh,
105
             DistortedEffects effects, int[][] moves, ObjectList obj, Resources res, int scrWidth)
106
    {
107
    super(numLayers, realSize, quat, texture, mesh, effects, moves, obj, res, scrWidth);
108

    
109
    initializeScrambleStates(numLayers);
110
    }
111

    
112

    
113
///////////////////////////////////////////////////////////////////////////////////////////////////
114

    
115
  void initializeCornerV()
116
    {
117
    mBasicCornerV = new Static4D[3];
118
    mCurrCornerV  = new Static4D[3];
119

    
120
    mBasicCornerV[0] = new Static4D( (SQ5+1)*0.125f, (SQ5-1)*0.125f, -0.250f, 0.0f );
121
    mBasicCornerV[1] = new Static4D(-(SQ5+1)*0.125f, (SQ5-1)*0.125f, -0.250f, 0.0f );
122
    mBasicCornerV[2] = new Static4D(              0,        -0.500f,    0.0f, 0.0f );
123
    }
124

    
125
///////////////////////////////////////////////////////////////////////////////////////////////////
126
// the five vertices that form a given face. Order: the same as colors of the faces in TwistyMinx.
127

    
128
  void initializeCenterMap()
129
    {
130
    mCenterMap = new int[][]
131
         {
132
           { 0, 12,  4, 14,  2},
133
           { 0,  2, 18,  6, 16},
134
           { 6, 18, 11, 19,  7},
135
           { 3, 15,  9, 11, 19},
136
           { 4,  5, 15,  9, 14},
137
           { 1, 13,  5, 15,  3},
138
           { 1,  3, 19,  7, 17},
139
           {10, 16,  6,  7, 17},
140
           { 0, 12,  8, 10, 16},
141
           { 8, 13,  5,  4, 12},
142
           { 1, 13,  8, 10, 17},
143
           { 2, 14,  9, 11, 18},
144
         };
145
    }
146

    
147
///////////////////////////////////////////////////////////////////////////////////////////////////
148
// the quadruple ( corner1, corner2, face1, face2 ) defining an edge.
149
// In fact the 2 corners already define it, the faces only provide easy
150
// way to get to know the colors. Order: arbitrary. Face1 arbitrarily on
151
// the 'left' or right of vector corner1 --> corner2, according to Quat.
152

    
153
  void initializeEdgeMap()
154
    {
155
    mEdgeMap = new int[][]
156
         {
157
           {  0, 12,  0,  8}, //0
158
           { 12,  4,  0,  9},
159
           {  4, 14,  0,  4},
160
           { 14,  2,  0, 11},
161
           {  2,  0,  0,  1},
162
           { 14,  9, 11,  4}, //5
163
           {  9, 11, 11,  3},
164
           { 11, 18, 11,  2},
165
           { 18,  2, 11,  1},
166
           { 18,  6,  1,  2},
167
           {  6, 16,  1,  7}, //10
168
           { 16,  0,  1,  8},
169
           { 16, 10,  8,  7},
170
           { 10,  8,  8, 10},
171
           {  8, 12,  8,  9},
172
           {  8, 13,  9, 10}, //15
173
           { 13,  5,  9,  5},
174
           {  5,  4,  9,  4},
175
           {  5, 15,  4,  5},
176
           { 15,  9,  4,  3},
177
           { 11, 19,  2,  3}, //20
178
           { 19,  7,  2,  6},
179
           {  7,  6,  2,  7},
180
           {  7, 17,  7,  6},
181
           { 17, 10,  7, 10},
182
           { 17,  1, 10,  6}, //25
183
           {  1,  3,  5,  6},
184
           {  3, 19,  3,  6},
185
           {  1, 13, 10,  5},
186
           {  3, 15,  5,  3},
187
         };
188
    }
189

    
190
///////////////////////////////////////////////////////////////////////////////////////////////////
191

    
192
  void initializeQuatIndices()
193
    {
194
    mQuatEdgeIndices = new int[]
195
      {
196
        56, 40, 43, 59,  0, 19,  9, 54, 58, 49,
197
        48, 24, 52,  4, 16, 32, 20, 11, 21, 35,
198
        37, 30,  8, 28, 36, 44,  1, 46, 12, 47
199
      };
200
    mQuatCornerIndices = new int[]
201
      {
202
         0,  2,  3,  1, 40, 31, 41, 30, 39, 35,
203
        36, 34, 56, 32, 43, 21, 48, 28, 42, 23
204
      };
205
    }
206

    
207
///////////////////////////////////////////////////////////////////////////////////////////////////
208

    
209
  void initializeCornerFaceMap()
210
    {
211
    mCornerFaceMap = new int[][]
212
         {
213
           {  0, 1, 8 },
214
           {  6, 5,10 },
215
           {  1, 0,11 },
216
           {  5, 6, 3 },
217
           {  0, 9, 4 },
218
           {  5, 4, 9 },
219
           {  7, 1, 2 },
220
           {  2, 6, 7 },
221
           { 10, 9, 8 },
222
           {  4, 3,11 },
223
           {  7,10, 8 },
224
           {  3, 2,11 },
225
           {  0, 8, 9 },
226
           {  9,10, 5 },
227
           {  0, 4,11 },
228
           {  4, 5, 3 },
229
           {  1, 7, 8 },
230
           {  7, 6,10 },
231
           {  2, 1,11 },
232
           {  6, 2, 3 },
233
         };
234
    }
235

    
236
///////////////////////////////////////////////////////////////////////////////////////////////////
237

    
238
  void initializeQuats()
239
    {
240
    mQuats = new Static4D[]
241
         {
242
         new Static4D(  0.0f,  0.0f,  0.0f,  1.0f ),  //0
243
         new Static4D(  1.0f,  0.0f,  0.0f,  0.0f ),
244
         new Static4D(  0.0f,  1.0f,  0.0f,  0.0f ),
245
         new Static4D(  0.0f,  0.0f,  1.0f,  0.0f ),
246

    
247
         new Static4D(  0.5f,  0.5f,  0.5f,  0.5f ),  //4
248
         new Static4D(  0.5f,  0.5f, -0.5f,  0.5f ),
249
         new Static4D(  0.5f, -0.5f,  0.5f,  0.5f ),
250
         new Static4D(  0.5f, -0.5f, -0.5f,  0.5f ),
251
         new Static4D( -0.5f,  0.5f,  0.5f,  0.5f ),
252
         new Static4D( -0.5f,  0.5f, -0.5f,  0.5f ),
253
         new Static4D( -0.5f, -0.5f,  0.5f,  0.5f ),
254
         new Static4D( -0.5f, -0.5f, -0.5f,  0.5f ),
255

    
256
         new Static4D(  0.5f, SIN54, SIN18,  0.0f ), // 12
257
         new Static4D(  0.5f, SIN54,-SIN18,  0.0f ),
258
         new Static4D(  0.5f,-SIN54, SIN18,  0.0f ),
259
         new Static4D(  0.5f,-SIN54,-SIN18,  0.0f ),
260
         new Static4D( SIN18,  0.5f, SIN54,  0.0f ),
261
         new Static4D( SIN18,  0.5f,-SIN54,  0.0f ),
262
         new Static4D(-SIN18,  0.5f, SIN54,  0.0f ),
263
         new Static4D(-SIN18,  0.5f,-SIN54,  0.0f ),
264
         new Static4D( SIN54, SIN18,  0.5f,  0.0f ),
265
         new Static4D( SIN54,-SIN18,  0.5f,  0.0f ),
266
         new Static4D(-SIN54, SIN18,  0.5f,  0.0f ),
267
         new Static4D(-SIN54,-SIN18,  0.5f,  0.0f ),
268

    
269
         new Static4D(  0.0f, SIN18, SIN54,  0.5f ), //24
270
         new Static4D(  0.0f, SIN18,-SIN54,  0.5f ),
271
         new Static4D(  0.0f,-SIN18, SIN54,  0.5f ),
272
         new Static4D(  0.0f,-SIN18,-SIN54,  0.5f ),
273
         new Static4D( SIN18, SIN54,  0.0f,  0.5f ),
274
         new Static4D( SIN18,-SIN54,  0.0f,  0.5f ),
275
         new Static4D(-SIN18, SIN54,  0.0f,  0.5f ),
276
         new Static4D(-SIN18,-SIN54,  0.0f,  0.5f ),
277
         new Static4D( SIN54,  0.0f, SIN18,  0.5f ),
278
         new Static4D( SIN54,  0.0f,-SIN18,  0.5f ),
279
         new Static4D(-SIN54,  0.0f, SIN18,  0.5f ),
280
         new Static4D(-SIN54,  0.0f,-SIN18,  0.5f ),
281

    
282
         new Static4D(  0.0f, SIN54,  0.5f, SIN18 ), //36
283
         new Static4D(  0.0f, SIN54, -0.5f, SIN18 ),
284
         new Static4D(  0.0f,-SIN54,  0.5f, SIN18 ),
285
         new Static4D(  0.0f,-SIN54, -0.5f, SIN18 ),
286
         new Static4D(  0.5f,  0.0f, SIN54, SIN18 ),
287
         new Static4D(  0.5f,  0.0f,-SIN54, SIN18 ),
288
         new Static4D( -0.5f,  0.0f, SIN54, SIN18 ),
289
         new Static4D( -0.5f,  0.0f,-SIN54, SIN18 ),
290
         new Static4D( SIN54,  0.5f,  0.0f, SIN18 ),
291
         new Static4D( SIN54, -0.5f,  0.0f, SIN18 ),
292
         new Static4D(-SIN54,  0.5f,  0.0f, SIN18 ),
293
         new Static4D(-SIN54, -0.5f,  0.0f, SIN18 ),
294

    
295
         new Static4D(  0.0f,  0.5f, SIN18, SIN54 ), //48
296
         new Static4D(  0.0f,  0.5f,-SIN18, SIN54 ),
297
         new Static4D(  0.0f, -0.5f, SIN18, SIN54 ),
298
         new Static4D(  0.0f, -0.5f,-SIN18, SIN54 ),
299
         new Static4D(  0.5f, SIN18,  0.0f, SIN54 ),
300
         new Static4D(  0.5f,-SIN18,  0.0f, SIN54 ),
301
         new Static4D( -0.5f, SIN18,  0.0f, SIN54 ),
302
         new Static4D( -0.5f,-SIN18,  0.0f, SIN54 ),
303
         new Static4D( SIN18,  0.0f,  0.5f, SIN54 ),
304
         new Static4D( SIN18,  0.0f, -0.5f, SIN54 ),
305
         new Static4D(-SIN18,  0.0f,  0.5f, SIN54 ),
306
         new Static4D(-SIN18,  0.0f, -0.5f, SIN54 ),
307
         };
308
    }
309

    
310
///////////////////////////////////////////////////////////////////////////////////////////////////
311
// Coordinates of all 20 corners of a Minx
312

    
313
  void initializeCorners()
314
    {
315
    mCorners = new float[][]
316
         {
317
             {  0.0f,  0.5f,    C2},
318
             {  0.0f,  0.5f,   -C2},
319
             {  0.0f, -0.5f,    C2},
320
             {  0.0f, -0.5f,   -C2},
321
             {    C2,  0.0f,  0.5f},
322
             {    C2,  0.0f, -0.5f},
323
             {   -C2,  0.0f,  0.5f},
324
             {   -C2,  0.0f, -0.5f},
325
             {  0.5f,    C2,  0.0f},
326
             {  0.5f,   -C2,  0.0f},
327
             { -0.5f,    C2,  0.0f},
328
             { -0.5f,   -C2,  0.0f},
329
             { SIN54, SIN54, SIN54},
330
             { SIN54, SIN54,-SIN54},
331
             { SIN54,-SIN54, SIN54},
332
             { SIN54,-SIN54,-SIN54},
333
             {-SIN54, SIN54, SIN54},
334
             {-SIN54, SIN54,-SIN54},
335
             {-SIN54,-SIN54, SIN54},
336
             {-SIN54,-SIN54,-SIN54},
337
         };
338
    }
339

    
340
///////////////////////////////////////////////////////////////////////////////////////////////////
341

    
342
  void initializeCenterCoords()
343
    {
344
    if( mCorners==null ) initializeCorners();
345
    if( mCenterMap==null ) initializeCenterMap();
346

    
347
    mCenterCoords = new float[NUM_CENTERS][3];
348

    
349
    for(int center=0; center<NUM_CENTERS; center++)
350
      {
351
      int[] map = mCenterMap[center];
352

    
353
      float x = mCorners[map[0]][0] +
354
                mCorners[map[1]][0] +
355
                mCorners[map[2]][0] +
356
                mCorners[map[3]][0] +
357
                mCorners[map[4]][0] ;
358

    
359
      float y = mCorners[map[0]][1] +
360
                mCorners[map[1]][1] +
361
                mCorners[map[2]][1] +
362
                mCorners[map[3]][1] +
363
                mCorners[map[4]][1] ;
364

    
365
      float z = mCorners[map[0]][2] +
366
                mCorners[map[1]][2] +
367
                mCorners[map[2]][2] +
368
                mCorners[map[3]][2] +
369
                mCorners[map[4]][2] ;
370

    
371
      mCenterCoords[center][0] = x/5;
372
      mCenterCoords[center][1] = y/5;
373
      mCenterCoords[center][2] = z/5;
374
      }
375
    }
376

    
377
///////////////////////////////////////////////////////////////////////////////////////////////////
378

    
379
  private int[] generateL(int numLayers, int index)
380
    {
381
    int rows = (numLayers-1)/2;
382
    int[] ret = new int[3*4*rows];
383

    
384
    for(int i=0; i<rows; i++)
385
      {
386
      ret[12*i   ] = i;
387
      ret[12*i+ 1] =-2;
388
      ret[12*i+ 2] = index;
389
      ret[12*i+ 3] = i;
390
      ret[12*i+ 4] =-1;
391
      ret[12*i+ 5] = index;
392
      ret[12*i+ 6] = i;
393
      ret[12*i+ 7] =+1;
394
      ret[12*i+ 8] = index;
395
      ret[12*i+ 9] = i;
396
      ret[12*i+10] =+2;
397
      ret[12*i+11] = index;
398
      }
399

    
400
    return ret;
401
    }
402

    
403
///////////////////////////////////////////////////////////////////////////////////////////////////
404

    
405
  private int[] generateR(int numLayers, int index)
406
    {
407
    int rows = (numLayers-1)/2;
408
    int[] ret = new int[3*4*rows];
409

    
410
    for(int i=0; i<rows; i++)
411
      {
412
      int lay = rows+i+1;
413

    
414
      ret[12*i   ] = lay;
415
      ret[12*i+ 1] =-2;
416
      ret[12*i+ 2] = index;
417
      ret[12*i+ 3] = lay;
418
      ret[12*i+ 4] =-1;
419
      ret[12*i+ 5] = index;
420
      ret[12*i+ 6] = lay;
421
      ret[12*i+ 7] =+1;
422
      ret[12*i+ 8] = index;
423
      ret[12*i+ 9] = lay;
424
      ret[12*i+10] =+2;
425
      ret[12*i+11] = index;
426
      }
427

    
428
    return ret;
429
    }
430

    
431
///////////////////////////////////////////////////////////////////////////////////////////////////
432

    
433
  private int[] generateB(int numLayers, int index)
434
    {
435
    int rows = (numLayers-1);
436
    int half = rows/2;
437
    int[] ret = new int[3*4*rows];
438

    
439
    for(int i=0; i<rows; i++)
440
      {
441
      int ind = i<half? index : index+1;
442
      int lay = i<half? i : i+1;
443

    
444
      ret[12*i   ] = lay;
445
      ret[12*i+ 1] =-2;
446
      ret[12*i+ 2] = ind;
447
      ret[12*i+ 3] = lay;
448
      ret[12*i+ 4] =-1;
449
      ret[12*i+ 5] = ind;
450
      ret[12*i+ 6] = lay;
451
      ret[12*i+ 7] =+1;
452
      ret[12*i+ 8] = ind;
453
      ret[12*i+ 9] = lay;
454
      ret[12*i+10] =+2;
455
      ret[12*i+11] = ind;
456
      }
457

    
458
    return ret;
459
    }
460

    
461
///////////////////////////////////////////////////////////////////////////////////////////////////
462

    
463
  private void initializeScrambleStates(int numLayers)
464
    {
465
    int[] LEFT0 = generateL(numLayers,1);
466
    int[] RIGH0 = generateR(numLayers,2);
467
    int[] LEFT1 = generateL(numLayers,3);
468
    int[] RIGH1 = generateR(numLayers,4);
469
    int[] LEFT2 = generateL(numLayers,5);
470
    int[] RIGH2 = generateR(numLayers,6);
471
    int[] LEFT3 = generateL(numLayers,7);
472
    int[] RIGH3 = generateR(numLayers,8);
473
    int[] LEFT4 = generateL(numLayers,9);
474
    int[] RIGH4 = generateR(numLayers,10);
475
    int[] LEFT5 = generateL(numLayers,11);
476
    int[] RIGH5 = generateR(numLayers,12);
477

    
478
    int[] BOTH1 = generateB(numLayers,1);
479
    int[] BOTH3 = generateB(numLayers,3);
480
    int[] BOTH5 = generateB(numLayers,5);
481
    int[] BOTH7 = generateB(numLayers,7);
482
    int[] BOTH9 = generateB(numLayers,9);
483
    int[] BOTH11= generateB(numLayers,11);
484

    
485
    mStates = new ScrambleState[]
486
      {
487
      new ScrambleState( new int[][] { BOTH1,BOTH3,BOTH5,BOTH7,BOTH9,BOTH11 } ), // beg
488
      new ScrambleState( new int[][] { {}   ,RIGH1,LEFT2,RIGH3,LEFT4,LEFT5  } ), // 0L
489
      new ScrambleState( new int[][] { {}   ,LEFT1,RIGH2,LEFT3,RIGH4,RIGH5  } ), // 0R
490
      new ScrambleState( new int[][] { RIGH0,{}   ,LEFT2,RIGH3,RIGH4,RIGH5  } ), // 1L
491
      new ScrambleState( new int[][] { LEFT0,{}   ,RIGH2,LEFT3,LEFT4,LEFT5  } ), // 1R
492
      new ScrambleState( new int[][] { LEFT0,LEFT1,{}   ,RIGH3,LEFT4,RIGH5  } ), // 2L
493
      new ScrambleState( new int[][] { RIGH0,RIGH1,{}   ,LEFT3,RIGH4,LEFT5  } ), // 2R
494
      new ScrambleState( new int[][] { RIGH0,RIGH1,RIGH2,{}   ,LEFT4,RIGH5  } ), // 3L
495
      new ScrambleState( new int[][] { LEFT0,LEFT1,LEFT2,{}   ,RIGH4,LEFT5  } ), // 3R
496
      new ScrambleState( new int[][] { LEFT0,RIGH1,LEFT2,LEFT3,{}   ,RIGH5  } ), // 4L
497
      new ScrambleState( new int[][] { RIGH0,LEFT1,RIGH2,RIGH3,{}   ,LEFT5  } ), // 4R
498
      new ScrambleState( new int[][] { LEFT0,RIGH1,RIGH2,RIGH3,RIGH4,{}     } ), // 5L
499
      new ScrambleState( new int[][] { RIGH0,LEFT1,LEFT2,LEFT3,LEFT4,{}     } ), // 5R
500
      };
501
    }
502

    
503
///////////////////////////////////////////////////////////////////////////////////////////////////
504

    
505
  int[] getSolvedQuats(int cubit, int numLayers)
506
    {
507
    if( mQuats==null ) initializeQuats();
508
    if( mFaceMap==null ) mFaceMap = new int[] {8,10,3,7,1,11,9,2,4,0,5,6};
509
    int status = retCubitSolvedStatus(cubit,numLayers);
510
    return status<0 ? null : buildSolvedQuats(MovementMinx.FACE_AXIS[mFaceMap[status]],mQuats);
511
    }
512

    
513
///////////////////////////////////////////////////////////////////////////////////////////////////
514

    
515
  Static4D[] getQuats()
516
    {
517
    if( mQuats==null ) initializeQuats();
518
    return mQuats;
519
    }
520

    
521
///////////////////////////////////////////////////////////////////////////////////////////////////
522

    
523
  int getNumFaces()
524
    {
525
    return FACE_COLORS.length;
526
    }
527

    
528
///////////////////////////////////////////////////////////////////////////////////////////////////
529

    
530
  int getSolvedFunctionIndex()
531
    {
532
    return 0;
533
    }
534

    
535
///////////////////////////////////////////////////////////////////////////////////////////////////
536

    
537
  boolean shouldResetTextureMaps()
538
    {
539
    return false;
540
    }
541

    
542
///////////////////////////////////////////////////////////////////////////////////////////////////
543

    
544
  int getNumCubitFaces()
545
    {
546
    return FACES_PER_CUBIT;
547
    }
548

    
549
///////////////////////////////////////////////////////////////////////////////////////////////////
550

    
551
  float returnMultiplier()
552
    {
553
    return 2.0f;
554
    }
555

    
556
///////////////////////////////////////////////////////////////////////////////////////////////////
557

    
558
  private void initializeScrambling()
559
    {
560
    int numLayers = getNumLayers();
561

    
562
    if( mScrambleTable ==null )
563
      {
564
      mScrambleTable = new int[NUM_AXIS][numLayers];
565
      }
566
    if( mNumOccurences ==null )
567
      {
568
      int max=0;
569

    
570
      for (ScrambleState mState : mStates)
571
        {
572
        int tmp = mState.getTotal(-1);
573
        if (max < tmp) max = tmp;
574
        }
575

    
576
      mNumOccurences = new int[max];
577
      }
578

    
579
    for(int i=0; i<NUM_AXIS; i++)
580
      for(int j=0; j<numLayers; j++) mScrambleTable[i][j] = 0;
581
    }
582

    
583
///////////////////////////////////////////////////////////////////////////////////////////////////
584
// PUBLIC API
585

    
586
  public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles)
587
    {
588
    if( curr==0 )
589
      {
590
      mCurrState     = 0;
591
      mIndexExcluded =-1;
592
      initializeScrambling();
593
      }
594

    
595
    int[] info= mStates[mCurrState].getRandom(rnd, mIndexExcluded, mScrambleTable, mNumOccurences);
596

    
597
    scramble[curr][0] = info[0];
598
    scramble[curr][1] = info[1];
599
    scramble[curr][2] = info[2];
600

    
601
    mCurrState     = info[3];
602
    mIndexExcluded = info[0];
603
    }
604

    
605
///////////////////////////////////////////////////////////////////////////////////////////////////
606

    
607
  public Static3D[] getRotationAxis()
608
    {
609
    return ROT_AXIS;
610
    }
611

    
612
///////////////////////////////////////////////////////////////////////////////////////////////////
613

    
614
  public int[] getBasicAngle()
615
    {
616
    if( mBasicAngle ==null ) mBasicAngle = new int[] { 5,5,5,5,5,5 };
617
    return mBasicAngle;
618
    }
619
}
(32-32/41)