Project

General

Profile

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

magiccube / src / main / java / org / distorted / objects / TwistySkewb.java @ 7ee89540

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