Project

General

Profile

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

magiccube / src / main / java / org / distorted / objects / TwistySkewb.java @ 588ace55

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