Project

General

Profile

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

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

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