Project

General

Profile

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

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

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