Project

General

Profile

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

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

1 a64e07d0 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 aa26ba7f Leszek Koltunski
import org.distorted.helpers.ScrambleState;
25 a64e07d0 Leszek Koltunski
import org.distorted.library.main.DistortedEffects;
26
import org.distorted.library.main.DistortedTexture;
27
import org.distorted.library.mesh.MeshSquare;
28
import org.distorted.library.type.Static3D;
29
import org.distorted.library.type.Static4D;
30
31
import java.util.Random;
32
33
///////////////////////////////////////////////////////////////////////////////////////////////////
34
35
abstract class TwistyMinx extends TwistyObject
36
{
37
  private static final int FACES_PER_CUBIT =6;
38
39 ead91342 Leszek Koltunski
  static final int NUM_CORNERS = 20;
40
  static final int NUM_CENTERS = 12;
41
  static final int NUM_EDGES   = 30;
42
43 bb11be2a Leszek Koltunski
  static final float C2       = (SQ5+3)/4;
44
  static final float LEN      = (float)(Math.sqrt(1.25f+0.5f*SQ5));
45
  static final float SIN54    = (SQ5+1)/4;
46
  static final float COS54    = (float)(Math.sqrt(10-2*SQ5)/4);
47
  static final float SIN18    = (SQ5-1)/4;
48
  static final float COS18    = (float)(0.25f*Math.sqrt(10.0f+2.0f*SQ5));
49
  static final float COS_HALFD= (float)(Math.sqrt(0.5f-0.1f*SQ5)); // cos(half the dihedral angle)
50
  static final float SIN_HALFD= (float)(Math.sqrt(0.5f+0.1f*SQ5)); // sin(half the dihedral angle)
51 a64e07d0 Leszek Koltunski
52
  // the six rotation axis of a Minx. Must be normalized.
53
  static final Static3D[] ROT_AXIS = new Static3D[]
54
         {
55 bb11be2a Leszek Koltunski
           new Static3D(    C2/LEN, SIN54/LEN,    0      ),
56
           new Static3D(   -C2/LEN, SIN54/LEN,    0      ),
57
           new Static3D( 0        ,    C2/LEN, SIN54/LEN ),
58
           new Static3D( 0        ,   -C2/LEN, SIN54/LEN ),
59
           new Static3D( SIN54/LEN,    0     ,    C2/LEN ),
60
           new Static3D( SIN54/LEN,    0     ,   -C2/LEN )
61 a64e07d0 Leszek Koltunski
         };
62
63 925ed78f Leszek Koltunski
  private static final int[] BASIC_ANGLE = new int[] { 5,5,5,5,5,5 };
64
65 bc649d9a Leszek Koltunski
  static final int MINX_LGREEN = 0xff53aa00;
66
  static final int MINX_PINK   = 0xfffd7ab7;
67
  static final int MINX_SANDY  = 0xffefd48b;
68
  static final int MINX_LBLUE  = 0xff00a2d7;
69
  static final int MINX_ORANGE = 0xffff6200;
70
  static final int MINX_VIOLET = 0xff7d59a4;
71
  static final int MINX_DGREEN = 0xff007a47;
72
  static final int MINX_DRED   = 0xffbd0000;
73
  static final int MINX_DBLUE  = 0xff1a29b2;
74
  static final int MINX_DYELLOW= 0xffffc400;
75
  static final int MINX_WHITE  = 0xffffffff;
76
  static final int MINX_GREY   = 0xff727c7b;
77 a64e07d0 Leszek Koltunski
78
  static final int[] FACE_COLORS = new int[]
79
         {
80
           MINX_LGREEN, MINX_PINK   , MINX_SANDY , MINX_LBLUE,
81
           MINX_ORANGE, MINX_VIOLET , MINX_DGREEN, MINX_DRED ,
82
           MINX_DBLUE , MINX_DYELLOW, MINX_WHITE , MINX_GREY
83
         };
84
85 a480ee80 Leszek Koltunski
  private static final int[] mFaceMap = new int[] {8,10,3,7,1,11,9,2,4,0,5,6};
86
87 a64e07d0 Leszek Koltunski
  // All 60 legal rotation quats of a Minx
88
  static final Static4D[] QUATS = new Static4D[]
89
         {
90 7a606778 Leszek Koltunski
           new Static4D(  0.0f,  0.0f,  0.0f,  1.0f ),  //0
91 a64e07d0 Leszek Koltunski
           new Static4D(  1.0f,  0.0f,  0.0f,  0.0f ),
92
           new Static4D(  0.0f,  1.0f,  0.0f,  0.0f ),
93
           new Static4D(  0.0f,  0.0f,  1.0f,  0.0f ),
94
95 7a606778 Leszek Koltunski
           new Static4D(  0.5f,  0.5f,  0.5f,  0.5f ),  //4
96 a64e07d0 Leszek Koltunski
           new Static4D(  0.5f,  0.5f, -0.5f,  0.5f ),
97
           new Static4D(  0.5f, -0.5f,  0.5f,  0.5f ),
98
           new Static4D(  0.5f, -0.5f, -0.5f,  0.5f ),
99
           new Static4D( -0.5f,  0.5f,  0.5f,  0.5f ),
100
           new Static4D( -0.5f,  0.5f, -0.5f,  0.5f ),
101
           new Static4D( -0.5f, -0.5f,  0.5f,  0.5f ),
102
           new Static4D( -0.5f, -0.5f, -0.5f,  0.5f ),
103
104 bb11be2a Leszek Koltunski
           new Static4D(  0.5f, SIN54, SIN18,  0.0f ), // 12
105
           new Static4D(  0.5f, SIN54,-SIN18,  0.0f ),
106
           new Static4D(  0.5f,-SIN54, SIN18,  0.0f ),
107
           new Static4D(  0.5f,-SIN54,-SIN18,  0.0f ),
108
           new Static4D( SIN18,  0.5f, SIN54,  0.0f ),
109
           new Static4D( SIN18,  0.5f,-SIN54,  0.0f ),
110
           new Static4D(-SIN18,  0.5f, SIN54,  0.0f ),
111
           new Static4D(-SIN18,  0.5f,-SIN54,  0.0f ),
112
           new Static4D( SIN54, SIN18,  0.5f,  0.0f ),
113
           new Static4D( SIN54,-SIN18,  0.5f,  0.0f ),
114
           new Static4D(-SIN54, SIN18,  0.5f,  0.0f ),
115
           new Static4D(-SIN54,-SIN18,  0.5f,  0.0f ),
116
117
           new Static4D(  0.0f, SIN18, SIN54,  0.5f ), //24
118
           new Static4D(  0.0f, SIN18,-SIN54,  0.5f ),
119
           new Static4D(  0.0f,-SIN18, SIN54,  0.5f ),
120
           new Static4D(  0.0f,-SIN18,-SIN54,  0.5f ),
121
           new Static4D( SIN18, SIN54,  0.0f,  0.5f ),
122
           new Static4D( SIN18,-SIN54,  0.0f,  0.5f ),
123
           new Static4D(-SIN18, SIN54,  0.0f,  0.5f ),
124
           new Static4D(-SIN18,-SIN54,  0.0f,  0.5f ),
125
           new Static4D( SIN54,  0.0f, SIN18,  0.5f ),
126
           new Static4D( SIN54,  0.0f,-SIN18,  0.5f ),
127
           new Static4D(-SIN54,  0.0f, SIN18,  0.5f ),
128
           new Static4D(-SIN54,  0.0f,-SIN18,  0.5f ),
129
130
           new Static4D(  0.0f, SIN54,  0.5f, SIN18 ), //36
131
           new Static4D(  0.0f, SIN54, -0.5f, SIN18 ),
132
           new Static4D(  0.0f,-SIN54,  0.5f, SIN18 ),
133
           new Static4D(  0.0f,-SIN54, -0.5f, SIN18 ),
134
           new Static4D(  0.5f,  0.0f, SIN54, SIN18 ),
135
           new Static4D(  0.5f,  0.0f,-SIN54, SIN18 ),
136
           new Static4D( -0.5f,  0.0f, SIN54, SIN18 ),
137
           new Static4D( -0.5f,  0.0f,-SIN54, SIN18 ),
138
           new Static4D( SIN54,  0.5f,  0.0f, SIN18 ),
139
           new Static4D( SIN54, -0.5f,  0.0f, SIN18 ),
140
           new Static4D(-SIN54,  0.5f,  0.0f, SIN18 ),
141
           new Static4D(-SIN54, -0.5f,  0.0f, SIN18 ),
142
143
           new Static4D(  0.0f,  0.5f, SIN18, SIN54 ), //48
144
           new Static4D(  0.0f,  0.5f,-SIN18, SIN54 ),
145
           new Static4D(  0.0f, -0.5f, SIN18, SIN54 ),
146
           new Static4D(  0.0f, -0.5f,-SIN18, SIN54 ),
147
           new Static4D(  0.5f, SIN18,  0.0f, SIN54 ),
148
           new Static4D(  0.5f,-SIN18,  0.0f, SIN54 ),
149
           new Static4D( -0.5f, SIN18,  0.0f, SIN54 ),
150
           new Static4D( -0.5f,-SIN18,  0.0f, SIN54 ),
151
           new Static4D( SIN18,  0.0f,  0.5f, SIN54 ),
152
           new Static4D( SIN18,  0.0f, -0.5f, SIN54 ),
153
           new Static4D(-SIN18,  0.0f,  0.5f, SIN54 ),
154
           new Static4D(-SIN18,  0.0f, -0.5f, SIN54 ),
155 a64e07d0 Leszek Koltunski
         };
156
157
  // Coordinates of all 20 corners of a Minx
158 e6cf7283 Leszek Koltunski
  static final float[][] CORNERS = new float[][]
159 a64e07d0 Leszek Koltunski
         {
160 bb11be2a Leszek Koltunski
             {  0.0f,  0.5f,    C2},
161
             {  0.0f,  0.5f,   -C2},
162
             {  0.0f, -0.5f,    C2},
163
             {  0.0f, -0.5f,   -C2},
164
             {    C2,  0.0f,  0.5f},
165
             {    C2,  0.0f, -0.5f},
166
             {   -C2,  0.0f,  0.5f},
167
             {   -C2,  0.0f, -0.5f},
168
             {  0.5f,    C2,  0.0f},
169
             {  0.5f,   -C2,  0.0f},
170
             { -0.5f,    C2,  0.0f},
171
             { -0.5f,   -C2,  0.0f},
172
             { SIN54, SIN54, SIN54},
173
             { SIN54, SIN54,-SIN54},
174
             { SIN54,-SIN54, SIN54},
175
             { SIN54,-SIN54,-SIN54},
176
             {-SIN54, SIN54, SIN54},
177
             {-SIN54, SIN54,-SIN54},
178
             {-SIN54,-SIN54, SIN54},
179
             {-SIN54,-SIN54,-SIN54},
180 a64e07d0 Leszek Koltunski
         };
181
182
  static final int[][] mCornerFaceMap =
183
         {
184
           {  0, 1, 8 },
185
           {  6, 5,10 },
186
           {  1, 0,11 },
187
           {  5, 6, 3 },
188
           {  0, 9, 4 },
189
           {  5, 4, 9 },
190
           {  7, 1, 2 },
191
           {  2, 6, 7 },
192
           { 10, 9, 8 },
193
           {  4, 3,11 },
194
           {  7,10, 8 },
195
           {  3, 2,11 },
196
           {  0, 8, 9 },
197
           {  9,10, 5 },
198
           {  0, 4,11 },
199
           {  4, 5, 3 },
200
           {  1, 7, 8 },
201
           {  7, 6,10 },
202
           {  2, 1,11 },
203
           {  6, 2, 3 },
204
         };
205
206 7764a67a Leszek Koltunski
  static final int[] QUAT_EDGE_INDICES =
207
      {
208 7a606778 Leszek Koltunski
        56, 40, 43, 59,  0, 19,  9, 54, 58, 49,
209
        48, 24, 52,  4, 16, 32, 20, 11, 21, 35 ,
210
        37, 30,  8, 28, 36, 44,  1, 46, 12, 47
211 7764a67a Leszek Koltunski
      };
212
213
214 e4bf4d02 Leszek Koltunski
  static final int[] QUAT_CORNER_INDICES =
215
      {
216 d38f1397 Leszek Koltunski
         0,  2,  3,  1, 40, 31, 41, 30, 39, 35,
217
        36, 34, 56, 32, 43, 21, 48, 28, 42, 23
218
      };
219
220 16f34a98 Leszek Koltunski
  // the quadruple ( corner1, corner2, face1, face2 ) defining an edge.
221
  // In fact the 2 corners already define it, the faces only provide easy
222 ead91342 Leszek Koltunski
  // way to get to know the colors. Order: arbitrary. Face1 arbitrarily on
223 16f34a98 Leszek Koltunski
  // the 'left' or right of vector corner1 --> corner2, according to Quat.
224 ead91342 Leszek Koltunski
  static final int[][] mEdgeMap =
225
         {
226 7a606778 Leszek Koltunski
           {  0, 12,  0,  8}, //0
227 ead91342 Leszek Koltunski
           { 12,  4,  0,  9},
228
           {  4, 14,  0,  4},
229
           { 14,  2,  0, 11},
230
           {  2,  0,  0,  1},
231 7a606778 Leszek Koltunski
           { 14,  9, 11,  4}, //5
232
           {  9, 11, 11,  3},
233
           { 11, 18, 11,  2},
234
           { 18,  2, 11,  1},
235 ead91342 Leszek Koltunski
           { 18,  6,  1,  2},
236 7a606778 Leszek Koltunski
           {  6, 16,  1,  7}, //10
237
           { 16,  0,  1,  8},
238
           { 16, 10,  8,  7},
239
           { 10,  8,  8, 10},
240
           {  8, 12,  8,  9},
241
           {  8, 13,  9, 10}, //15
242 ead91342 Leszek Koltunski
           { 13,  5,  9,  5},
243
           {  5,  4,  9,  4},
244 7a606778 Leszek Koltunski
           {  5, 15,  4,  5},
245
           { 15,  9,  4,  3},
246
           { 11, 19,  2,  3}, //20
247 ead91342 Leszek Koltunski
           { 19,  7,  2,  6},
248
           {  7,  6,  2,  7},
249
           {  7, 17,  7,  6},
250
           { 17, 10,  7, 10},
251 7a606778 Leszek Koltunski
           { 17,  1, 10,  6}, //25
252 ead91342 Leszek Koltunski
           {  1,  3,  5,  6},
253
           {  3, 19,  3,  6},
254
           {  1, 13, 10,  5},
255 7a606778 Leszek Koltunski
           {  3, 15,  5,  3},
256 ead91342 Leszek Koltunski
         };
257
258
  // the five vertices that form a given face. Order: the same as colors
259
  // of the faces in TwistyMinx.
260
  static final int[][] mCenterMap =
261
         {
262
           { 0, 12,  4, 14,  2},
263
           { 0,  2, 18,  6, 16},
264
           { 6, 18, 11, 19,  7},
265
           { 3, 15,  9, 11, 19},
266
           { 4,  5, 15,  9, 14},
267
           { 1, 13,  5, 15,  3},
268
           { 1,  3, 19,  7, 17},
269
           {10, 16,  6,  7, 17},
270
           { 0, 12,  8, 10, 16},
271
           { 8, 13,  5,  4, 12},
272
           { 1, 13,  8, 10, 17},
273
           { 2, 14,  9, 11, 18},
274
         };
275
276
  static final float[][] mCenterCoords = new float[NUM_CENTERS][3];
277
278
  static
279
    {
280
    for(int center=0; center<NUM_CENTERS; center++)
281
      {
282
      int[] map = mCenterMap[center];
283
284
      float x = CORNERS[map[0]][0] +
285
                CORNERS[map[1]][0] +
286
                CORNERS[map[2]][0] +
287
                CORNERS[map[3]][0] +
288
                CORNERS[map[4]][0] ;
289
290
      float y = CORNERS[map[0]][1] +
291
                CORNERS[map[1]][1] +
292
                CORNERS[map[2]][1] +
293
                CORNERS[map[3]][1] +
294
                CORNERS[map[4]][1] ;
295
296
      float z = CORNERS[map[0]][2] +
297
                CORNERS[map[1]][2] +
298
                CORNERS[map[2]][2] +
299
                CORNERS[map[3]][2] +
300
                CORNERS[map[4]][2] ;
301
302
      mCenterCoords[center][0] = x/5;
303
      mCenterCoords[center][1] = y/5;
304
      mCenterCoords[center][2] = z/5;
305
      }
306
    }
307
308
  static final Static4D[] mBasicCornerV, mCurrCornerV;
309
310
  static
311
    {
312
    mBasicCornerV = new Static4D[3];
313
    mCurrCornerV  = new Static4D[3];
314
315
    mBasicCornerV[0] = new Static4D( (SQ5+1)*0.125f, (SQ5-1)*0.125f, -0.250f, 0.0f );
316
    mBasicCornerV[1] = new Static4D(-(SQ5+1)*0.125f, (SQ5-1)*0.125f, -0.250f, 0.0f );
317
    mBasicCornerV[2] = new Static4D(              0,        -0.500f,    0.0f, 0.0f );
318
    }
319
320 aa26ba7f Leszek Koltunski
  private int mCurrState;
321
  private int mIndexExcluded;
322
  private ScrambleState[] mStates;
323
  private int[][] mScrambleTable;
324
  private int[] mNumOccurences;
325 0812242b Leszek Koltunski
326 a64e07d0 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
327
328
  TwistyMinx(int numLayers, int realSize, Static4D quat, DistortedTexture texture, MeshSquare mesh,
329
             DistortedEffects effects, int[][] moves, ObjectList obj, Resources res, int scrWidth)
330
    {
331 db875721 Leszek Koltunski
    super(numLayers, realSize, quat, texture, mesh, effects, moves, obj, res, scrWidth);
332 aa26ba7f Leszek Koltunski
333
    initializeScrambleStates(numLayers);
334 a64e07d0 Leszek Koltunski
    }
335
336 a480ee80 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
337
338 aa26ba7f Leszek Koltunski
  private int[] generateL(int numLayers, int index)
339 a480ee80 Leszek Koltunski
    {
340 aa26ba7f Leszek Koltunski
    int rows = (numLayers-1)/2;
341
    int[] ret = new int[3*4*rows];
342
343
    for(int i=0; i<rows; i++)
344
      {
345
      ret[12*i   ] = i;
346
      ret[12*i+ 1] =-2;
347
      ret[12*i+ 2] = index;
348
      ret[12*i+ 3] = i;
349
      ret[12*i+ 4] =-1;
350
      ret[12*i+ 5] = index;
351
      ret[12*i+ 6] = i;
352
      ret[12*i+ 7] =+1;
353
      ret[12*i+ 8] = index;
354
      ret[12*i+ 9] = i;
355
      ret[12*i+10] =+2;
356
      ret[12*i+11] = index;
357
      }
358
359
    return ret;
360 a480ee80 Leszek Koltunski
    }
361
362 a64e07d0 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
363
364 aa26ba7f Leszek Koltunski
  private int[] generateR(int numLayers, int index)
365 a64e07d0 Leszek Koltunski
    {
366 aa26ba7f Leszek Koltunski
    int rows = (numLayers-1)/2;
367
    int[] ret = new int[3*4*rows];
368
369
    for(int i=0; i<rows; i++)
370
      {
371
      int lay = rows+i+1;
372
373
      ret[12*i   ] = lay;
374
      ret[12*i+ 1] =-2;
375
      ret[12*i+ 2] = index;
376
      ret[12*i+ 3] = lay;
377
      ret[12*i+ 4] =-1;
378
      ret[12*i+ 5] = index;
379
      ret[12*i+ 6] = lay;
380
      ret[12*i+ 7] =+1;
381
      ret[12*i+ 8] = index;
382
      ret[12*i+ 9] = lay;
383
      ret[12*i+10] =+2;
384
      ret[12*i+11] = index;
385
      }
386
387
    return ret;
388 a64e07d0 Leszek Koltunski
    }
389
390
///////////////////////////////////////////////////////////////////////////////////////////////////
391
392 aa26ba7f Leszek Koltunski
  private int[] generateB(int numLayers, int index)
393 a64e07d0 Leszek Koltunski
    {
394 aa26ba7f Leszek Koltunski
    int rows = (numLayers-1);
395
    int half = rows/2;
396
    int[] ret = new int[3*4*rows];
397
398
    for(int i=0; i<rows; i++)
399
      {
400
      int ind = i<half? index : index+1;
401
      int lay = i<half? i : i+1;
402
403
      ret[12*i   ] = lay;
404
      ret[12*i+ 1] =-2;
405
      ret[12*i+ 2] = ind;
406
      ret[12*i+ 3] = lay;
407
      ret[12*i+ 4] =-1;
408
      ret[12*i+ 5] = ind;
409
      ret[12*i+ 6] = lay;
410
      ret[12*i+ 7] =+1;
411
      ret[12*i+ 8] = ind;
412
      ret[12*i+ 9] = lay;
413
      ret[12*i+10] =+2;
414
      ret[12*i+11] = ind;
415
      }
416
417
    return ret;
418 a64e07d0 Leszek Koltunski
    }
419
420 169219a7 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
421
422 aa26ba7f Leszek Koltunski
  private void initializeScrambleStates(int numLayers)
423 169219a7 Leszek Koltunski
    {
424 aa26ba7f Leszek Koltunski
    int[] LEFT0 = generateL(numLayers,1);
425
    int[] RIGH0 = generateR(numLayers,2);
426
    int[] LEFT1 = generateL(numLayers,3);
427
    int[] RIGH1 = generateR(numLayers,4);
428
    int[] LEFT2 = generateL(numLayers,5);
429
    int[] RIGH2 = generateR(numLayers,6);
430
    int[] LEFT3 = generateL(numLayers,7);
431
    int[] RIGH3 = generateR(numLayers,8);
432
    int[] LEFT4 = generateL(numLayers,9);
433
    int[] RIGH4 = generateR(numLayers,10);
434
    int[] LEFT5 = generateL(numLayers,11);
435
    int[] RIGH5 = generateR(numLayers,12);
436
437
    int[] BOTH1 = generateB(numLayers,1);
438
    int[] BOTH3 = generateB(numLayers,3);
439
    int[] BOTH5 = generateB(numLayers,5);
440
    int[] BOTH7 = generateB(numLayers,7);
441
    int[] BOTH9 = generateB(numLayers,9);
442
    int[] BOTH11= generateB(numLayers,11);
443
444
    mStates = new ScrambleState[]
445
      {
446
      new ScrambleState( new int[][] { BOTH1,BOTH3,BOTH5,BOTH7,BOTH9,BOTH11 } ), // beg
447
      new ScrambleState( new int[][] { {}   ,RIGH1,LEFT2,RIGH3,LEFT4,LEFT5  } ), // 0L
448
      new ScrambleState( new int[][] { {}   ,LEFT1,RIGH2,LEFT3,RIGH4,RIGH5  } ), // 0R
449
      new ScrambleState( new int[][] { RIGH0,{}   ,LEFT2,RIGH3,RIGH4,RIGH5  } ), // 1L
450
      new ScrambleState( new int[][] { LEFT0,{}   ,RIGH2,LEFT3,LEFT4,LEFT5  } ), // 1R
451
      new ScrambleState( new int[][] { LEFT0,LEFT1,{}   ,RIGH3,LEFT4,RIGH5  } ), // 2L
452
      new ScrambleState( new int[][] { RIGH0,RIGH1,{}   ,LEFT3,RIGH4,LEFT5  } ), // 2R
453
      new ScrambleState( new int[][] { RIGH0,RIGH1,RIGH2,{}   ,LEFT4,RIGH5  } ), // 3L
454
      new ScrambleState( new int[][] { LEFT0,LEFT1,LEFT2,{}   ,RIGH4,LEFT5  } ), // 3R
455
      new ScrambleState( new int[][] { LEFT0,RIGH1,LEFT2,LEFT3,{}   ,RIGH5  } ), // 4L
456
      new ScrambleState( new int[][] { RIGH0,LEFT1,RIGH2,RIGH3,{}   ,LEFT5  } ), // 4R
457
      new ScrambleState( new int[][] { LEFT0,RIGH1,RIGH2,RIGH3,RIGH4,{}     } ), // 5L
458
      new ScrambleState( new int[][] { RIGH0,LEFT1,LEFT2,LEFT3,LEFT4,{}     } ), // 5R
459
      };
460 169219a7 Leszek Koltunski
    }
461
462 a64e07d0 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
463
464 aa26ba7f Leszek Koltunski
  int[] getSolvedQuats(int cubit, int numLayers)
465 a64e07d0 Leszek Koltunski
    {
466 aa26ba7f Leszek Koltunski
    int status = retCubitSolvedStatus(cubit,numLayers);
467
    return status<0 ? null : buildSolvedQuats(MovementMinx.FACE_AXIS[mFaceMap[status]],QUATS);
468 a64e07d0 Leszek Koltunski
    }
469
470
///////////////////////////////////////////////////////////////////////////////////////////////////
471
472 aa26ba7f Leszek Koltunski
  Static4D[] getQuats()
473 a64e07d0 Leszek Koltunski
    {
474 aa26ba7f Leszek Koltunski
    return QUATS;
475 a64e07d0 Leszek Koltunski
    }
476
477
///////////////////////////////////////////////////////////////////////////////////////////////////
478
479 aa26ba7f Leszek Koltunski
  int getNumFaces()
480 a64e07d0 Leszek Koltunski
    {
481 aa26ba7f Leszek Koltunski
    return FACE_COLORS.length;
482 a64e07d0 Leszek Koltunski
    }
483
484
///////////////////////////////////////////////////////////////////////////////////////////////////
485
486 aa26ba7f Leszek Koltunski
  int getSolvedFunctionIndex()
487 a64e07d0 Leszek Koltunski
    {
488 aa26ba7f Leszek Koltunski
    return 0;
489 a64e07d0 Leszek Koltunski
    }
490
491
///////////////////////////////////////////////////////////////////////////////////////////////////
492
493 aa26ba7f Leszek Koltunski
  boolean shouldResetTextureMaps()
494 a64e07d0 Leszek Koltunski
    {
495 aa26ba7f Leszek Koltunski
    return false;
496 0812242b Leszek Koltunski
    }
497
498
///////////////////////////////////////////////////////////////////////////////////////////////////
499
500 aa26ba7f Leszek Koltunski
  int getNumCubitFaces()
501 0812242b Leszek Koltunski
    {
502 aa26ba7f Leszek Koltunski
    return FACES_PER_CUBIT;
503 a64e07d0 Leszek Koltunski
    }
504
505 4c737817 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
506
507 aa26ba7f Leszek Koltunski
  float returnMultiplier()
508 4c737817 Leszek Koltunski
    {
509 aa26ba7f Leszek Koltunski
    return 2.0f;
510 4c737817 Leszek Koltunski
    }
511
512 a64e07d0 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
513
514 aa26ba7f Leszek Koltunski
  private void initializeScrambling()
515 0812242b Leszek Koltunski
    {
516 aa26ba7f Leszek Koltunski
    int numLayers = getNumLayers();
517 0812242b Leszek Koltunski
518 aa26ba7f Leszek Koltunski
    if( mScrambleTable ==null )
519 0812242b Leszek Koltunski
      {
520 aa26ba7f Leszek Koltunski
      mScrambleTable = new int[NUM_AXIS][numLayers];
521 0812242b Leszek Koltunski
      }
522 aa26ba7f Leszek Koltunski
    if( mNumOccurences ==null )
523 0812242b Leszek Koltunski
      {
524 aa26ba7f Leszek Koltunski
      int max=0;
525 0812242b Leszek Koltunski
526 aa26ba7f Leszek Koltunski
      for (ScrambleState mState : mStates)
527 0812242b Leszek Koltunski
        {
528 aa26ba7f Leszek Koltunski
        int tmp = mState.getTotal(-1);
529
        if (max < tmp) max = tmp;
530 0812242b Leszek Koltunski
        }
531
532 aa26ba7f Leszek Koltunski
      mNumOccurences = new int[max];
533
      }
534 0812242b Leszek Koltunski
535 aa26ba7f Leszek Koltunski
    for(int i=0; i<NUM_AXIS; i++)
536
      for(int j=0; j<numLayers; j++) mScrambleTable[i][j] = 0;
537 0812242b Leszek Koltunski
    }
538
539
///////////////////////////////////////////////////////////////////////////////////////////////////
540
// PUBLIC API
541
542 aa26ba7f Leszek Koltunski
  public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles)
543 a64e07d0 Leszek Koltunski
    {
544 9f171eba Leszek Koltunski
    if( curr==0 )
545 a64e07d0 Leszek Koltunski
      {
546 aa26ba7f Leszek Koltunski
      mCurrState     = 0;
547
      mIndexExcluded =-1;
548
      initializeScrambling();
549 a64e07d0 Leszek Koltunski
      }
550 bbc6471c Leszek Koltunski
551 aa26ba7f Leszek Koltunski
    int[] info= mStates[mCurrState].getRandom(rnd, mIndexExcluded, mScrambleTable, mNumOccurences);
552
553
    scramble[curr][0] = info[0];
554
    scramble[curr][1] = info[1];
555
    scramble[curr][2] = info[2];
556
557
    mCurrState     = info[3];
558
    mIndexExcluded = info[0];
559 a64e07d0 Leszek Koltunski
    }
560
561 0812242b Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
562
563
  public Static3D[] getRotationAxis()
564
    {
565
    return ROT_AXIS;
566
    }
567
568
///////////////////////////////////////////////////////////////////////////////////////////////////
569
570
  public int[] getBasicAngle()
571
    {
572
    return BASIC_ANGLE;
573
    }
574 a64e07d0 Leszek Koltunski
}