Project

General

Profile

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

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

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 7b832206 Leszek Koltunski
  public 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 1bb09f88 Leszek Koltunski
  public Static4D[] getQuats()
157 29b82486 Leszek Koltunski
    {
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 1bb09f88 Leszek Koltunski
  public int getNumStickerTypes(int[] numLayers)
172 29b82486 Leszek Koltunski
    {
173
    return 3;
174
    }
175
176
///////////////////////////////////////////////////////////////////////////////////////////////////
177
178 7bbfc84f Leszek Koltunski
  public 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 7b832206 Leszek Koltunski
  public 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 7b832206 Leszek Koltunski
  public 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 e30c522a Leszek Koltunski
  public ObjectShape getObjectShape(int variant)
438 29b82486 Leszek Koltunski
    {
439 e30c522a Leszek Koltunski
    int numL = getNumLayers()[0];
440 29b82486 Leszek Koltunski
441
    if( variant==0 )
442
      {
443
      double[][] vertices = new double[][] { {-1,0,0},{0,-1,0},{0,0,-1},{-1,-1,-1},{0,0,0} };
444
      int[][] vert_indices = new int[][] { {0,1,4},{2,0,4},{1,2,4},{3,1,0},{3,2,1},{3,0,2} };
445 a57e6870 Leszek Koltunski
      int N = numL==2 ? 7:5;
446
      int E1= numL==2 ? 3:2;
447
      int E2= numL==2 ? 5:3;
448 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} };
449
      int[] bandIndices   = new int[] { 0,0,0,1,1,1 };
450
      float[][] corners   = new float[][] { {0.05f,0.25f}, {0.05f,0.20f} };
451
      int[] cornerIndices = new int[] { 1,1,1,0,0 };
452
      float[][] centers   = new float[][] { {-0.5f, -0.5f, -0.5f} };
453
      int[] centerIndices = new int[] { 0,0,0,-1,0 };
454
      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
455
      }
456
    else if( variant==1 )
457
      {
458
      double[][] vertices = new double[][] { {-1,0,0},{1,0,0},{0,-1,0},{0,0,-1} };
459
      int[][] vert_indices = new int[][] { {2,1,0},{3,0,1},{2,3,1},{3,2,0} };
460 a57e6870 Leszek Koltunski
      int N = numL==2 ? 7:5;
461
      int E = numL==2 ? 5:2;
462 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} };
463
      int[] bandIndices   = new int[] { 0,0,1,1 };
464
      float[][] corners   = new float[][] { {0.07f,0.20f}, {0.02f,0.30f} };
465
      int[] cornerIndices = new int[] { 0,0,1,1 };
466
      float[][] centers   = new float[][] { {0.0f, -0.5f, -0.5f} };
467
      int[] centerIndices = new int[] { 0,0,0,0 };
468
      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
469
      }
470
    else
471
      {
472
      double[][] vertices = new double[][] { {-1,0,0},{0,-1,0},{1,0,0},{0,1,0},{0,0,-1} };
473
      int[][] vert_indices = new int[][] { {0,1,2,3},{4,1,0},{4,2,1},{4,3,2},{4,0,3} };
474 a57e6870 Leszek Koltunski
      int N = numL==2 ? 7:6;
475
      int E = numL==2 ? 3:1;
476 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} };
477
      int[] bandIndices   = new int[] { 0,1,1,1,1 };
478
      float[][] corners   = new float[][] { {0.06f,0.15f} };
479
      int[] cornerIndices = new int[] { 0,0,0,0,0 };
480
      float[][] centers   = new float[][] { {0,0,-0.4f} };
481
      int[] centerIndices = new int[] { 0,0,0,0,-1 };
482
      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
483
      }
484
    }
485
486
///////////////////////////////////////////////////////////////////////////////////////////////////
487
488 e30c522a Leszek Koltunski
  public int getNumCubitVariants(int[] numLayers)
489 29b82486 Leszek Koltunski
    {
490
    return 3;
491
    }
492
493
///////////////////////////////////////////////////////////////////////////////////////////////////
494
495 e30c522a Leszek Koltunski
  public int getCubitVariant(int cubit, int[] numLayers)
496 29b82486 Leszek Koltunski
    {
497
    int numCorners = getNumCorners();
498
    if( cubit<numCorners ) return 0;
499 a57e6870 Leszek Koltunski
    int numEdges = getNumEdges(numLayers[0]);
500 29b82486 Leszek Koltunski
    return cubit<numCorners+numEdges ? 1:2;
501
    }
502
503
///////////////////////////////////////////////////////////////////////////////////////////////////
504
505 a57e6870 Leszek Koltunski
  protected int getFaceColor(int cubit, int cubitface, int[] numLayers)
506 29b82486 Leszek Koltunski
    {
507
    if( mCornerMap==null || mEdgeMap==null || mCenterMap==null )
508
      {
509
      mCornerMap = new int[][]
510
         {
511
           {  4, 2, 0, 18,18,18 },
512
           {  2, 5, 0, 18,18,18 },
513
           {  3, 4, 0, 18,18,18 },
514
           {  5, 3, 0, 18,18,18 },
515
           {  1, 2, 4, 18,18,18 },
516
           {  5, 2, 1, 18,18,18 },
517
           {  4, 3, 1, 18,18,18 },
518
           {  1, 3, 5, 18,18,18 },
519
         };
520
521
      mEdgeMap = new int[][]
522
         {
523
           { 10, 8, 18,18,18,18 },
524
           {  6,10, 18,18,18,18 },
525
           { 10, 9, 18,18,18,18 },
526
           {  7,10, 18,18,18,18 },
527
           {  8, 6, 18,18,18,18 },
528
           {  9, 6, 18,18,18,18 },
529
           {  9, 7, 18,18,18,18 },
530
           {  8, 7, 18,18,18,18 },
531
           { 11, 8, 18,18,18,18 },
532
           {  6,11, 18,18,18,18 },
533
           { 11, 9, 18,18,18,18 },
534
           {  7,11, 18,18,18,18 }
535
         };
536
537
      mCenterMap = new int[][]
538
         {
539
           { 12, 18,18,18,18,18 },
540
           { 13, 18,18,18,18,18 },
541
           { 14, 18,18,18,18,18 },
542
           { 15, 18,18,18,18,18 },
543
           { 16, 18,18,18,18,18 },
544
           { 17, 18,18,18,18,18 },
545
         };
546
      }
547
548 a57e6870 Leszek Koltunski
    int numL = numLayers[0];
549 29b82486 Leszek Koltunski
    int numCorners = getNumCorners();
550 a57e6870 Leszek Koltunski
    int numEdges   = getNumEdges(numL);
551 29b82486 Leszek Koltunski
552
    if( cubit<numCorners )
553
      {
554
      return mCornerMap[cubit][cubitface];
555
      }
556
    else if( cubit<numCorners+numEdges )
557
      {
558 a57e6870 Leszek Koltunski
      int edge = (cubit-numCorners)/(numL-2);
559 29b82486 Leszek Koltunski
      return mEdgeMap[edge][cubitface];
560
      }
561
    else
562
      {
563 a57e6870 Leszek Koltunski
      int center = (cubit-numCorners-numEdges)/getNumCentersPerFace(numL);
564 29b82486 Leszek Koltunski
      return mCenterMap[center][cubitface];
565
      }
566
    }
567
568
///////////////////////////////////////////////////////////////////////////////////////////////////
569
570 1bb09f88 Leszek Koltunski
  public ObjectSticker retSticker(int sticker)
571 29b82486 Leszek Koltunski
    {
572
    if( mStickers==null )
573
      {
574
      float[][] STICKERS = new float[][]
575
          {
576 59c20632 Leszek Koltunski
             { -0.5f, 0.25f, 0.25f,  -0.5f, 0.25f, 0.25f  },
577 29b82486 Leszek Koltunski
             { -0.5f, 0.25f, 0.25f,  -0.5f, 0.25f, 0.25f  },
578
             { -0.5f, 0.00f, 0.00f,  -0.5f, 0.50f, 0.0f, 0.0f, 0.5f }
579
          };
580
581
      final float R1 = 0.025f;
582
      final float R2 = 0.025f;
583
      final float R3 = 0.055f;
584
      final float[][] radii  = { { R1,R1,R1 },{ R2,R2,R2 },{ R3,R3,R3,R3 } };
585 21aaab9a Leszek Koltunski
      final float[] strokes = { 0.05f, 0.04f, 0.04f };
586 29b82486 Leszek Koltunski
587 8592461c Leszek Koltunski
      if( ObjectControl.isInIconMode() )
588
        {
589 a57e6870 Leszek Koltunski
        int[] numLayers = getNumLayers();
590
        float mult = numLayers[0]==2 ? 2.0f : 2.7f;
591 8592461c Leszek Koltunski
        strokes[0]*=mult;
592
        strokes[1]*=mult;
593
        strokes[2]*=mult;
594
        }
595
596 59c20632 Leszek Koltunski
      mStickers = new ObjectSticker[STICKERS.length];
597 29b82486 Leszek Koltunski
598 59c20632 Leszek Koltunski
      for(int s=0; s<STICKERS.length; s++)
599 29b82486 Leszek Koltunski
        {
600 59c20632 Leszek Koltunski
        mStickers[s] = new ObjectSticker(STICKERS[s],null,radii[s],strokes[s]);
601 29b82486 Leszek Koltunski
        }
602
      }
603
604 1bb09f88 Leszek Koltunski
    return mStickers[sticker];
605
    }
606
607 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
608
// PUBLIC API
609
610
  public Static3D[] getRotationAxis()
611
    {
612
    return ROT_AXIS;
613
    }
614
615
///////////////////////////////////////////////////////////////////////////////////////////////////
616
617
  public int[] getBasicAngle()
618
    {
619
    if( mBasicAngle ==null ) mBasicAngle = new int[] { 3,3,3,3 };
620
    return mBasicAngle;
621
    }
622
623 61aa85e4 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
624
625 a57e6870 Leszek Koltunski
  public ObjectType intGetObjectType(int[] numLayers)
626 61aa85e4 Leszek Koltunski
    {
627 a57e6870 Leszek Koltunski
    switch(numLayers[0])
628 61aa85e4 Leszek Koltunski
      {
629 8005e762 Leszek Koltunski
      case 2: return ObjectType.SKEW_2;
630
      case 3: return ObjectType.SKEW_3;
631 61aa85e4 Leszek Koltunski
      }
632
633 8005e762 Leszek Koltunski
    return ObjectType.SKEW_2;
634 61aa85e4 Leszek Koltunski
    }
635
636 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
637
638 a57e6870 Leszek Koltunski
  public int getObjectName(int[] numLayers)
639 29b82486 Leszek Koltunski
    {
640 a57e6870 Leszek Koltunski
    switch(numLayers[0])
641 29b82486 Leszek Koltunski
      {
642
      case 2: return R.string.skew2;
643
      case 3: return R.string.skew3;
644
      }
645
    return R.string.skew2;
646
    }
647
648
///////////////////////////////////////////////////////////////////////////////////////////////////
649
650 a57e6870 Leszek Koltunski
  public int getInventor(int[] numLayers)
651 29b82486 Leszek Koltunski
    {
652 a57e6870 Leszek Koltunski
    switch(numLayers[0])
653 29b82486 Leszek Koltunski
      {
654
      case 2: return R.string.skew2_inventor;
655
      case 3: return R.string.skew3_inventor;
656
      }
657
    return R.string.skew2_inventor;
658
    }
659
660 59c20632 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
661
662
  public int getYearOfInvention(int[] numLayers)
663
    {
664
    switch(numLayers[0])
665
      {
666
      case 2: return 1982;
667
      case 3: return 2003;
668
      }
669
    return 1982;
670
    }
671
672 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
673
674 a57e6870 Leszek Koltunski
  public int getComplexity(int[] numLayers)
675 29b82486 Leszek Koltunski
    {
676 a57e6870 Leszek Koltunski
    switch(numLayers[0])
677 29b82486 Leszek Koltunski
      {
678
      case 2: return 4;
679
      case 3: return 8;
680
      }
681
    return 5;
682
    }
683
}