Project

General

Profile

Download (22.4 KB) Statistics
| Branch: | Revision:

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistySkewb.java @ f9a81f52

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