Project

General

Profile

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

magiccube / src / main / java / org / distorted / objects / TwistySkewb.java @ e1dc3366

1 fb52fae9 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 8655f3fe 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 fb52fae9 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 fb52fae9 Leszek Koltunski
34
import java.util.Random;
35
36
///////////////////////////////////////////////////////////////////////////////////////////////////
37
38 9c2f0c91 Leszek Koltunski
public class TwistySkewb extends TwistyObject
39 fb52fae9 Leszek Koltunski
{
40
  private static final int FACES_PER_CUBIT =6;
41
42
  // the four rotation axis of a RubikSkewb. Must be normalized.
43
  static final Static3D[] ROT_AXIS = new Static3D[]
44
         {
45
           new Static3D(+SQ3/3,+SQ3/3,+SQ3/3),
46
           new Static3D(+SQ3/3,+SQ3/3,-SQ3/3),
47
           new Static3D(+SQ3/3,-SQ3/3,+SQ3/3),
48
           new Static3D(+SQ3/3,-SQ3/3,-SQ3/3)
49
         };
50
51 925ed78f Leszek Koltunski
  private static final int[] BASIC_ANGLE = new int[] { 3,3,3,3 };
52
53 fb52fae9 Leszek Koltunski
  private static final int[] FACE_COLORS = new int[]
54
         {
55 ece1b58d Leszek Koltunski
           COLOR_YELLOW, COLOR_WHITE,
56
           COLOR_BLUE  , COLOR_GREEN,
57 323b217c Leszek Koltunski
           COLOR_RED   , COLOR_ORANGE
58 fb52fae9 Leszek Koltunski
         };
59
60
  // All legal rotation quats of a RubikSkewb
61
  private static final Static4D[] QUATS = new Static4D[]
62
         {
63
           new Static4D(  0.0f,  0.0f,  0.0f,  1.0f ),
64
           new Static4D(  1.0f,  0.0f,  0.0f,  0.0f ),
65
           new Static4D(  0.0f,  1.0f,  0.0f,  0.0f ),
66
           new Static4D(  0.0f,  0.0f,  1.0f,  0.0f ),
67
68
           new Static4D(  0.5f,  0.5f,  0.5f,  0.5f ),
69
           new Static4D(  0.5f,  0.5f,  0.5f, -0.5f ),
70
           new Static4D(  0.5f,  0.5f, -0.5f,  0.5f ),
71
           new Static4D(  0.5f,  0.5f, -0.5f, -0.5f ),
72
           new Static4D(  0.5f, -0.5f,  0.5f,  0.5f ),
73
           new Static4D(  0.5f, -0.5f,  0.5f, -0.5f ),
74
           new Static4D(  0.5f, -0.5f, -0.5f,  0.5f ),
75
           new Static4D(  0.5f, -0.5f, -0.5f, -0.5f )
76
         };
77
78 3f3ff476 Leszek Koltunski
  private static final int[][] mCornerMap =
79
         {
80
           {  4, 2, 0, 18,18,18 },
81
           {  2, 5, 0, 18,18,18 },
82
           {  3, 4, 0, 18,18,18 },
83
           {  5, 3, 0, 18,18,18 },
84
           {  1, 2, 4, 18,18,18 },
85
           {  5, 2, 1, 18,18,18 },
86
           {  4, 3, 1, 18,18,18 },
87
           {  1, 3, 5, 18,18,18 },
88
         };
89 63002261 Leszek Koltunski
90 3f3ff476 Leszek Koltunski
  private static final int[][] mEdgeMap =
91 fb52fae9 Leszek Koltunski
         {
92 3f3ff476 Leszek Koltunski
           { 10, 8, 18,18,18,18 },
93
           {  6,10, 18,18,18,18 },
94
           { 10, 9, 18,18,18,18 },
95
           {  7,10, 18,18,18,18 },
96
           {  8, 6, 18,18,18,18 },
97
           {  9, 6, 18,18,18,18 },
98
           {  9, 7, 18,18,18,18 },
99
           {  8, 7, 18,18,18,18 },
100
           { 11, 8, 18,18,18,18 },
101
           {  6,11, 18,18,18,18 },
102
           { 11, 9, 18,18,18,18 },
103
           {  7,11, 18,18,18,18 }
104 fb52fae9 Leszek Koltunski
         };
105
106 3f3ff476 Leszek Koltunski
  private static final int[][] mCenterMap =
107 fb52fae9 Leszek Koltunski
         {
108 3f3ff476 Leszek Koltunski
           { 12, 18,18,18,18,18 },
109
           { 13, 18,18,18,18,18 },
110
           { 14, 18,18,18,18,18 },
111
           { 15, 18,18,18,18,18 },
112
           { 16, 18,18,18,18,18 },
113
           { 17, 18,18,18,18,18 },
114 fb52fae9 Leszek Koltunski
         };
115
116 596d62a4 Leszek Koltunski
  private static final double[][] VERTICES_CORNER = new double[][]
117
          {
118 7dc57f89 Leszek Koltunski
              {-0.5f, 0.0f, 0.0f},
119
              { 0.0f,-0.5f, 0.0f},
120
              { 0.0f, 0.0f,-0.5f},
121
              {-0.5f,-0.5f,-0.5f},
122
              { 0.0f, 0.0f, 0.0f}
123 596d62a4 Leszek Koltunski
          };
124
125
  private static final int[][] VERT_INDEXES_CORNER = new int[][]
126
          {
127 7dc57f89 Leszek Koltunski
              {0,1,4},
128
              {2,0,4},
129
              {1,2,4},
130
              {3,1,0},
131
              {3,2,1},
132
              {3,0,2}
133 596d62a4 Leszek Koltunski
          };
134
135
  private static final double[][] VERTICES_EDGE = new double[][]
136
          {
137
             {-0.5, 0.0, 0.0},
138
             { 0.5, 0.0, 0.0},
139
             { 0.0,-0.5, 0.0},
140
             { 0.0, 0.0,-0.5}
141
          };
142
143
  private static final int[][] VERT_INDEXES_EDGE = new int[][]
144
          {
145
             {2,1,0},   // counterclockwise!
146
             {3,0,1},
147
             {2,3,1},
148
             {3,2,0},
149
          };
150
151
  private static final double[][] VERTICES_FACE = new double[][]
152
          {
153 7dc57f89 Leszek Koltunski
             {-0.5f, 0.0f, 0.0f },
154
             { 0.0f,-0.5f, 0.0f },
155
             { 0.5f, 0.0f, 0.0f },
156
             { 0.0f, 0.5f, 0.0f },
157
             { 0.0f, 0.0f,-0.5f }
158 596d62a4 Leszek Koltunski
          };
159
160
  private static final int[][] VERT_INDEXES_FACE = new int[][]
161
          {
162 7dc57f89 Leszek Koltunski
             {0,1,2,3},
163
             {4,1,0},
164
             {4,2,1},
165
             {4,3,2},
166
             {4,0,3}
167
          };
168
169
  private static final float[][] STICKERS = new float[][]
170
          {
171 be56193c Leszek Koltunski
             { -0.5f, 0.25f, 0.25f,  -0.5f, 0.25f, 0.25f  },
172
             { -0.5f, 0.00f, 0.00f,  -0.5f, 0.50f, 0.0f, 0.0f, 0.5f }
173 596d62a4 Leszek Koltunski
          };
174
175 9c06394a Leszek Koltunski
  private static final ObjectSticker[] mStickers;
176
177
  static
178
    {
179
    mStickers = new ObjectSticker[STICKERS.length+1];
180
    final float R1 = 0.025f;
181
    final float R2 = 0.025f;
182
    final float R3 = 0.055f;
183
    final float[][] radii  = { { R1,R1,R1 },{ R2,R2,R2 },{ R3,R3,R3,R3 } };
184
    final float[] strokes = { 0.045f, 0.035f, 0.035f };
185
186
    for(int s=0; s<STICKERS.length+1; s++)
187
      {
188
      int index = s<2 ? 0:1;
189
      mStickers[s] = new ObjectSticker(STICKERS[index],null,radii[s],strokes[s]);
190
      }
191
    }
192
193 01b2ef5a Leszek Koltunski
  private int mCurrState;
194
  private int mIndexExcluded;
195 6cf89a3e Leszek Koltunski
  private final ScrambleState[] mStates;
196 e1dc3366 Leszek Koltunski
  private int[][] mScrambleTable;
197
  private int[] mNumOccurences;
198 01b2ef5a Leszek Koltunski
199 fb52fae9 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
200
201 9c2f0c91 Leszek Koltunski
  TwistySkewb(int size, Static4D quat, DistortedTexture texture,
202
              MeshSquare mesh, DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
203 fb52fae9 Leszek Koltunski
    {
204 db875721 Leszek Koltunski
    super(size, 2*size-2, quat, texture, mesh, effects, moves, ObjectList.SKEW, res, scrWidth);
205 01b2ef5a Leszek Koltunski
206
    int[] tmp = {0,-1,0, 0,1,0, size-1,-1,0, size-1,1,0 };
207
208 6cf89a3e Leszek Koltunski
    mStates = new ScrambleState[]
209 01b2ef5a Leszek Koltunski
      {
210 6cf89a3e Leszek Koltunski
      new ScrambleState( new int[][] {tmp,tmp,tmp,tmp} )
211 01b2ef5a Leszek Koltunski
      };
212 fb52fae9 Leszek Koltunski
    }
213
214 a480ee80 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
215
216
  int[] getSolvedQuats(int cubit, int numLayers)
217
    {
218
    int status = retCubitSolvedStatus(cubit,numLayers);
219
    return status<0 ? null : buildSolvedQuats(MovementSkewb.FACE_AXIS[status],QUATS);
220
    }
221
222 3f3ff476 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
223
224 d92030e4 Leszek Koltunski
  private int getNumCorners()
225 3f3ff476 Leszek Koltunski
    {
226
    return 8;
227
    }
228
229
///////////////////////////////////////////////////////////////////////////////////////////////////
230
231 b89898c5 Leszek Koltunski
  private int getNumEdges(int layers)
232 3f3ff476 Leszek Koltunski
    {
233 b89898c5 Leszek Koltunski
    return (layers-2)*12;
234 3f3ff476 Leszek Koltunski
    }
235
236
///////////////////////////////////////////////////////////////////////////////////////////////////
237
238 d92030e4 Leszek Koltunski
  private int getNumCentersPerFace(int layers)
239 3f3ff476 Leszek Koltunski
    {
240 d92030e4 Leszek Koltunski
    return ((layers-2)*(layers-2) + (layers-1)*(layers-1));
241 3f3ff476 Leszek Koltunski
    }
242
243 fb52fae9 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
244
245
  float getScreenRatio()
246
    {
247 d99f3a48 Leszek Koltunski
    return 1.0f;
248 fb52fae9 Leszek Koltunski
    }
249
250
///////////////////////////////////////////////////////////////////////////////////////////////////
251
252
  Static4D[] getQuats()
253
    {
254
    return QUATS;
255
    }
256
257
///////////////////////////////////////////////////////////////////////////////////////////////////
258
259
  int getNumFaces()
260
    {
261
    return FACE_COLORS.length;
262
    }
263
264 169219a7 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
265
266
  int getSolvedFunctionIndex()
267
    {
268
    return 0;
269
    }
270
271 eaee1ddc Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
272
273
  boolean shouldResetTextureMaps()
274
    {
275
    return false;
276
    }
277
278 eab9d8f8 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
279
280 a64e07d0 Leszek Koltunski
  int getNumStickerTypes(int numLayers)
281 eab9d8f8 Leszek Koltunski
    {
282 3f3ff476 Leszek Koltunski
    return 3;
283 eab9d8f8 Leszek Koltunski
    }
284
285 7403cdfa Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
286
287 e6734aa9 Leszek Koltunski
  float[][] getCuts(int numLayers)
288 7403cdfa Leszek Koltunski
    {
289 b89898c5 Leszek Koltunski
    switch(numLayers)
290 a97e02b7 Leszek Koltunski
      {
291 e6734aa9 Leszek Koltunski
      case 2: float[] c2 = new float[] {0.0f};
292
              return new float[][] { c2,c2,c2,c2 };
293
      case 3: float[] c3 = new float[] {-SQ3/12,+SQ3/12};
294
              return new float[][] { c3,c3,c3,c3 };
295 a97e02b7 Leszek Koltunski
      }
296 e6734aa9 Leszek Koltunski
    return null;
297 7403cdfa Leszek Koltunski
    }
298
299 fb52fae9 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
300
301
  int getNumCubitFaces()
302
    {
303
    return FACES_PER_CUBIT;
304
    }
305
306
///////////////////////////////////////////////////////////////////////////////////////////////////
307
308 e6cf7283 Leszek Koltunski
  float[][] getCubitPositions(int numLayers)
309 fb52fae9 Leszek Koltunski
    {
310 b89898c5 Leszek Koltunski
    final float DIST_CORNER = (numLayers-1)*0.50f;
311
    final float DIST_EDGE   = (numLayers-1)*0.50f;
312
    final float DIST_CENTER = (numLayers-1)*0.50f;
313 3f3ff476 Leszek Koltunski
314 d92030e4 Leszek Koltunski
    final int numCorners = getNumCorners();
315 b89898c5 Leszek Koltunski
    final int numEdges   = getNumEdges(numLayers);
316 d92030e4 Leszek Koltunski
    final int numCenters = 6*getNumCentersPerFace(numLayers);
317 3f3ff476 Leszek Koltunski
318 e6cf7283 Leszek Koltunski
    final float[][] CENTERS = new float[numCorners+numEdges+numCenters][];
319 3f3ff476 Leszek Koltunski
320
    /// CORNERS //////////////////////////////////////////////
321
322 e6cf7283 Leszek Koltunski
    CENTERS[0] = new float[] { DIST_CORNER, DIST_CORNER, DIST_CORNER };
323
    CENTERS[1] = new float[] { DIST_CORNER, DIST_CORNER,-DIST_CORNER };
324
    CENTERS[2] = new float[] { DIST_CORNER,-DIST_CORNER, DIST_CORNER };
325
    CENTERS[3] = new float[] { DIST_CORNER,-DIST_CORNER,-DIST_CORNER };
326
    CENTERS[4] = new float[] {-DIST_CORNER, DIST_CORNER, DIST_CORNER };
327
    CENTERS[5] = new float[] {-DIST_CORNER, DIST_CORNER,-DIST_CORNER };
328
    CENTERS[6] = new float[] {-DIST_CORNER,-DIST_CORNER, DIST_CORNER };
329
    CENTERS[7] = new float[] {-DIST_CORNER,-DIST_CORNER,-DIST_CORNER };
330 3f3ff476 Leszek Koltunski
331
    /// EDGES ///////////////////////////////////////////////
332
333
    final float[][]  edgeTable =
334
        {
335
            {0,+DIST_EDGE,+DIST_EDGE},
336
            {+DIST_EDGE,0,+DIST_EDGE},
337
            {0,-DIST_EDGE,+DIST_EDGE},
338
            {-DIST_EDGE,0,+DIST_EDGE},
339
            {+DIST_EDGE,+DIST_EDGE,0},
340
            {+DIST_EDGE,-DIST_EDGE,0},
341
            {-DIST_EDGE,-DIST_EDGE,0},
342
            {-DIST_EDGE,+DIST_EDGE,0},
343
            {0,+DIST_EDGE,-DIST_EDGE},
344
            {+DIST_EDGE,0,-DIST_EDGE},
345
            {0,-DIST_EDGE,-DIST_EDGE},
346
            {-DIST_EDGE,0,-DIST_EDGE}
347
        };
348
349
    int index=8;
350
351
    for (float[] edges : edgeTable)
352
      {
353 b89898c5 Leszek Koltunski
      float c = (3-numLayers)*0.5f;
354 3f3ff476 Leszek Koltunski
355 b89898c5 Leszek Koltunski
      for (int j=0; j<numLayers-2; j++, c+=1.0f, index++)
356 3f3ff476 Leszek Koltunski
        {
357 e6cf7283 Leszek Koltunski
        CENTERS[index] = new float[] { edges[0]==0 ? c : edges[0] ,
358 3f3ff476 Leszek Koltunski
                                       edges[1]==0 ? c : edges[1] ,
359 e6cf7283 Leszek Koltunski
                                       edges[2]==0 ? c : edges[2] };
360 3f3ff476 Leszek Koltunski
        }
361
      }
362
363
    /// CENTERS //////////////////////////////////////////////
364
365
    final float X= -1000.0f;
366
    final float Y= -1001.0f;
367
368
    final float[][]  centerTable =
369
        {
370
            {+DIST_CENTER,X,Y},
371
            {-DIST_CENTER,X,Y},
372
            {X,+DIST_CENTER,Y},
373
            {X,-DIST_CENTER,Y},
374
            {X,Y,+DIST_CENTER},
375
            {X,Y,-DIST_CENTER}
376
        };
377
378
    float x,y, cen0, cen1, cen2;
379
380
    for( float[] centers : centerTable )
381
      {
382 b89898c5 Leszek Koltunski
      x = (2-numLayers)*0.5f;
383 3f3ff476 Leszek Koltunski
384 b89898c5 Leszek Koltunski
      for(int i=0; i<numLayers-1; i++, x+=1.0f)
385 3f3ff476 Leszek Koltunski
        {
386 b89898c5 Leszek Koltunski
        y = (2-numLayers)*0.5f;
387 3f3ff476 Leszek Koltunski
388 b89898c5 Leszek Koltunski
        for(int j=0; j<numLayers-1; j++, y+=1.0f, index++)
389 3f3ff476 Leszek Koltunski
          {
390
               if( centers[0]==Y ) cen0 = y;
391
          else if( centers[0]==X ) cen0 = x;
392
          else                     cen0 = centers[0];
393
394
               if( centers[1]==Y ) cen1 = y;
395
          else if( centers[1]==X ) cen1 = x;
396
          else                     cen1 = centers[1];
397
398
               if( centers[2]==Y ) cen2 = y;
399
          else if( centers[2]==X ) cen2 = x;
400
          else                     cen2 = centers[2];
401
402 e6cf7283 Leszek Koltunski
          CENTERS[index] = new float[] {cen0,cen1,cen2};
403 3f3ff476 Leszek Koltunski
          }
404
        }
405
406 b89898c5 Leszek Koltunski
      x = (3-numLayers)*0.5f;
407 3f3ff476 Leszek Koltunski
408 b89898c5 Leszek Koltunski
      for(int i=0; i<numLayers-2; i++, x+=1.0f)
409 3f3ff476 Leszek Koltunski
        {
410 b89898c5 Leszek Koltunski
        y = (3-numLayers)*0.5f;
411 3f3ff476 Leszek Koltunski
412 b89898c5 Leszek Koltunski
        for(int j=0; j<numLayers-2; j++, y+=1.0f, index++)
413 3f3ff476 Leszek Koltunski
          {
414
               if( centers[0]==Y ) cen0 = y;
415
          else if( centers[0]==X ) cen0 = x;
416
          else                     cen0 = centers[0];
417
418
               if( centers[1]==Y ) cen1 = y;
419
          else if( centers[1]==X ) cen1 = x;
420
          else                     cen1 = centers[1];
421
422
               if( centers[2]==Y ) cen2 = y;
423
          else if( centers[2]==X ) cen2 = x;
424
          else                     cen2 = centers[2];
425
426 e6cf7283 Leszek Koltunski
          CENTERS[index] = new float[] {cen0,cen1,cen2};
427 3f3ff476 Leszek Koltunski
          }
428
        }
429
      }
430
431 fb52fae9 Leszek Koltunski
    return CENTERS;
432
    }
433
434
///////////////////////////////////////////////////////////////////////////////////////////////////
435
436 3e605536 Leszek Koltunski
  Static4D getQuat(int cubit, int numLayers)
437 fb52fae9 Leszek Koltunski
    {
438 d92030e4 Leszek Koltunski
    int numCorners = getNumCorners();
439
    int numEdges   = getNumEdges(numLayers);
440 3f3ff476 Leszek Koltunski
441
    if( cubit<numCorners )
442
      {
443
      switch(cubit)
444
        {
445
        case  0: return QUATS[0];                          //  unit quat
446
        case  1: return new Static4D( SQ2/2,0,0,SQ2/2);    //  90 along X
447
        case  2: return new Static4D(-SQ2/2,0,0,SQ2/2);    // -90 along X
448
        case  3: return QUATS[1];                          // 180 along X
449
        case  4: return new Static4D(0, SQ2/2,0,SQ2/2);    //  90 along Y
450
        case  5: return QUATS[2];                          // 180 along Y
451
        case  6: return QUATS[3];                          // 180 along Z
452
        case  7: return new Static4D(SQ2/2,0,-SQ2/2,0);    // 180 along (SQ2/2,0,-SQ2/2)
453
        }
454
      }
455
    else if( cubit<numCorners+numEdges )
456
      {
457 d92030e4 Leszek Koltunski
      int edge = (cubit-numCorners)/(numLayers-2);
458 3f3ff476 Leszek Koltunski
459
      switch(edge)
460
        {
461
        case  0: return QUATS[ 0];
462
        case  1: return QUATS[ 5];
463
        case  2: return QUATS[ 3];
464
        case  3: return QUATS[11];
465
        case  4: return QUATS[ 4];
466
        case  5: return QUATS[ 7];
467
        case  6: return QUATS[ 9];
468
        case  7: return QUATS[10];
469
        case  8: return QUATS[ 2];
470
        case  9: return QUATS[ 8];
471
        case 10: return QUATS[ 1];
472
        case 11: return QUATS[ 6];
473
        }
474
      }
475
    else
476 fb52fae9 Leszek Koltunski
      {
477 d92030e4 Leszek Koltunski
      int center = (cubit-numCorners-numEdges)/getNumCentersPerFace(numLayers);
478 3f3ff476 Leszek Koltunski
479
      switch(center)
480
        {
481
        case 0: return new Static4D(0,-SQ2/2,0,SQ2/2);    // -90 along Y
482
        case 1: return new Static4D(0, SQ2/2,0,SQ2/2);    //  90 along Y
483
        case 2: return new Static4D( SQ2/2,0,0,SQ2/2);    //  90 along X
484
        case 3: return new Static4D(-SQ2/2,0,0,SQ2/2);    // -90 along X
485
        case 4: return QUATS[0];                          //  unit quaternion
486
        case 5: return QUATS[1];                          // 180 along X
487
        }
488 fb52fae9 Leszek Koltunski
      }
489
490
    return null;
491
    }
492
493
///////////////////////////////////////////////////////////////////////////////////////////////////
494
495 8655f3fe Leszek Koltunski
  ObjectShape getObjectShape(int cubit, int numLayers)
496 fb52fae9 Leszek Koltunski
    {
497 8655f3fe Leszek Koltunski
    int variant = getCubitVariant(cubit,numLayers);
498 fb52fae9 Leszek Koltunski
499 8655f3fe Leszek Koltunski
    if( variant==0 )
500 fb52fae9 Leszek Koltunski
      {
501 8655f3fe Leszek Koltunski
      int N = numLayers==2 ? 7:5;
502
      int E1= numLayers==2 ? 3:2;
503
      int E2= numLayers==2 ? 5:3;
504 3e605536 Leszek Koltunski
      float[][] bands     = new float[][] { {0.028f,35,0.16f,0.7f,N,E1,E1}, {0.000f, 0,1.00f,0.0f,3,1,E2} };
505 8655f3fe Leszek Koltunski
      int[] bandIndices   = new int[] { 0,0,0,1,1,1 };
506
      float[][] corners   = new float[][] { {0.08f,0.15f}, {0.08f,0.20f} };
507
      int[] cornerIndices = new int[] { 1,1,1,0,0 };
508
      float[][] centers   = new float[][] { {-0.25f, -0.25f, -0.25f} };
509
      int[] centerIndices = new int[] { 0,0,0,-1,0 };
510
      return new ObjectShape(VERTICES_CORNER,VERT_INDEXES_CORNER,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
511 fb52fae9 Leszek Koltunski
      }
512 8655f3fe Leszek Koltunski
    else if( variant==1 )
513 3f3ff476 Leszek Koltunski
      {
514 8655f3fe Leszek Koltunski
      int N = numLayers==2 ? 7:5;
515
      int E = numLayers==2 ? 5:2;
516 3e605536 Leszek Koltunski
      float[][] bands     = new float[][] { {0.035f,30,0.16f,0.8f,N,2,E}, {0.020f,45,0.16f,0.2f,3,1,2} };
517 8655f3fe Leszek Koltunski
      int[] bandIndices   = new int[] { 0,0,1,1 };
518
      float[][] corners   = new float[][] { {0.07f,0.20f}, {0.02f,0.30f} };
519
      int[] cornerIndices = new int[] { 0,0,1,1 };
520
      float[][] centers   = new float[][] { {0.0f, -0.25f, -0.25f} };
521
      int[] centerIndices = new int[] { 0,0,0,0 };
522
      return new ObjectShape(VERTICES_EDGE,VERT_INDEXES_EDGE,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
523 3f3ff476 Leszek Koltunski
      }
524 fb52fae9 Leszek Koltunski
    else
525
      {
526 8655f3fe Leszek Koltunski
      int N = numLayers==2 ? 7:6;
527
      int E = numLayers==2 ? 3:1;
528 3e605536 Leszek Koltunski
      float[][] bands     = new float[][] { {0.051f,35,SQ2/8,0.9f,N,E,E}, {0.000f,0,1,0.0f,3,0,0} };
529 8655f3fe Leszek Koltunski
      int[] bandIndices   = new int[] { 0,1,1,1,1 };
530
      float[][] corners   = new float[][] { {0.06f,0.10f} };
531
      int[] cornerIndices = new int[] { 0,0,0,0,0 };
532
      float[][] centers   = new float[][] { {0,0,-0.2f} };
533
      int[] centerIndices = new int[] { 0,0,0,0,-1 };
534
      return new ObjectShape(VERTICES_FACE,VERT_INDEXES_FACE,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
535
      }
536
    }
537
538
///////////////////////////////////////////////////////////////////////////////////////////////////
539
540 3e605536 Leszek Koltunski
  int getNumCubitVariants(int numLayers)
541 8655f3fe Leszek Koltunski
    {
542
    return 3;
543
    }
544
545
///////////////////////////////////////////////////////////////////////////////////////////////////
546
547
  int getCubitVariant(int cubit, int numLayers)
548
    {
549
    int numCorners = getNumCorners();
550
    if( cubit<numCorners ) return 0;
551
    int numEdges = getNumEdges(numLayers);
552
    return cubit<numCorners+numEdges ? 1:2;
553
    }
554
555 fb52fae9 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
556
557 d92030e4 Leszek Koltunski
  int getFaceColor(int cubit, int cubitface, int numLayers)
558 fb52fae9 Leszek Koltunski
    {
559 d92030e4 Leszek Koltunski
    int numCorners = getNumCorners();
560
    int numEdges   = getNumEdges(numLayers);
561 3f3ff476 Leszek Koltunski
562
    if( cubit<numCorners )
563
      {
564
      return mCornerMap[cubit][cubitface];
565
      }
566
    else if( cubit<numCorners+numEdges )
567
      {
568 d92030e4 Leszek Koltunski
      int edge = (cubit-numCorners)/(numLayers-2);
569 3f3ff476 Leszek Koltunski
      return mEdgeMap[edge][cubitface];
570
      }
571
    else
572
      {
573 d92030e4 Leszek Koltunski
      int center = (cubit-numCorners-numEdges)/getNumCentersPerFace(numLayers);
574 3f3ff476 Leszek Koltunski
      return mCenterMap[center][cubitface];
575
      }
576 fb52fae9 Leszek Koltunski
    }
577
578
///////////////////////////////////////////////////////////////////////////////////////////////////
579
580 9c06394a Leszek Koltunski
  int getColor(int face)
581 fb52fae9 Leszek Koltunski
    {
582 9c06394a Leszek Koltunski
    return FACE_COLORS[face];
583
    }
584 eab9d8f8 Leszek Koltunski
585 9c06394a Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
586 ae755eda Leszek Koltunski
587 9c06394a Leszek Koltunski
  ObjectSticker retSticker(int face)
588
    {
589
    return mStickers[face/NUM_FACES];
590 fb52fae9 Leszek Koltunski
    }
591
592
///////////////////////////////////////////////////////////////////////////////////////////////////
593
594
  float returnMultiplier()
595
    {
596
    return 2.0f;
597
    }
598
599
///////////////////////////////////////////////////////////////////////////////////////////////////
600
601 e1dc3366 Leszek Koltunski
  private void initializeScrambling()
602 fb52fae9 Leszek Koltunski
    {
603 e1dc3366 Leszek Koltunski
    int numLayers = getNumLayers();
604 fb52fae9 Leszek Koltunski
605 e1dc3366 Leszek Koltunski
    if( mScrambleTable ==null )
606
      {
607
      mScrambleTable = new int[NUM_AXIS][numLayers];
608
      }
609
    if( mNumOccurences ==null )
610
      {
611
      int max=0;
612 fb52fae9 Leszek Koltunski
613 e1dc3366 Leszek Koltunski
      for (ScrambleState mState : mStates)
614
        {
615
        int tmp = mState.getTotal(-1);
616
        if (max < tmp) max = tmp;
617
        }
618
619
      mNumOccurences = new int[max];
620
      }
621
622
    for(int i=0; i<NUM_AXIS; i++)
623
      for(int j=0; j<numLayers; j++) mScrambleTable[i][j] = 0;
624 fb52fae9 Leszek Koltunski
    }
625
626
///////////////////////////////////////////////////////////////////////////////////////////////////
627 e1dc3366 Leszek Koltunski
// PUBLIC API
628 fb52fae9 Leszek Koltunski
629 01b2ef5a Leszek Koltunski
  public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles)
630 fb52fae9 Leszek Koltunski
    {
631 9f171eba Leszek Koltunski
    if( curr==0 )
632 fb52fae9 Leszek Koltunski
      {
633 01b2ef5a Leszek Koltunski
      mCurrState     = 0;
634
      mIndexExcluded =-1;
635 e1dc3366 Leszek Koltunski
      initializeScrambling();
636 fb52fae9 Leszek Koltunski
      }
637
638 e1dc3366 Leszek Koltunski
    int[] info= mStates[mCurrState].getRandom(rnd, mIndexExcluded, mScrambleTable, mNumOccurences);
639 fb52fae9 Leszek Koltunski
640 01b2ef5a Leszek Koltunski
    scramble[curr][0] = info[0];
641
    scramble[curr][1] = info[1];
642
    scramble[curr][2] = info[2];
643
644
    mCurrState     = info[3];
645
    mIndexExcluded = info[0];
646 fb52fae9 Leszek Koltunski
    }
647
648 e1dc3366 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
649
650
  public Static3D[] getRotationAxis()
651
    {
652
    return ROT_AXIS;
653
    }
654
655
///////////////////////////////////////////////////////////////////////////////////////////////////
656
657
  public int[] getBasicAngle()
658
    {
659
    return BASIC_ANGLE;
660
    }
661
662 6fd4a72c Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
663
664
  public int getObjectName(int numLayers)
665
    {
666
    switch(numLayers)
667
      {
668
      case 2: return R.string.skew2;
669
      case 3: return R.string.skew3;
670
      }
671
    return R.string.skew2;
672
    }
673
674
///////////////////////////////////////////////////////////////////////////////////////////////////
675
676
  public int getInventor(int numLayers)
677
    {
678
    switch(numLayers)
679
      {
680
      case 2: return R.string.skew2_inventor;
681
      case 3: return R.string.skew3_inventor;
682
      }
683
    return R.string.skew2_inventor;
684
    }
685
686
///////////////////////////////////////////////////////////////////////////////////////////////////
687
688
  public int getComplexity(int numLayers)
689
    {
690
    switch(numLayers)
691
      {
692 d5ca9927 Leszek Koltunski
      case 2: return 4;
693
      case 3: return 8;
694 6fd4a72c Leszek Koltunski
      }
695
    return 5;
696
    }
697 fb52fae9 Leszek Koltunski
}