Project

General

Profile

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

magiccube / src / main / java / org / distorted / objects / TwistySkewb.java @ 8c3148e2

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