Project

General

Profile

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

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

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