Project

General

Profile

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

magiccube / src / main / java / org / distorted / objects / TwistySkewb.java @ 6cf89a3e

1 fb52fae9 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19
20
package org.distorted.objects;
21
22
import android.content.res.Resources;
23
24 8655f3fe Leszek Koltunski
import org.distorted.helpers.ObjectShape;
25 9c06394a Leszek Koltunski
import org.distorted.helpers.ObjectSticker;
26 6cf89a3e Leszek Koltunski
import org.distorted.helpers.ScrambleState;
27 fb52fae9 Leszek Koltunski
import org.distorted.library.main.DistortedEffects;
28
import org.distorted.library.main.DistortedTexture;
29
import org.distorted.library.mesh.MeshSquare;
30
import org.distorted.library.type.Static3D;
31
import org.distorted.library.type.Static4D;
32 6fd4a72c Leszek Koltunski
import org.distorted.main.R;
33 fb52fae9 Leszek Koltunski
34
import java.util.Random;
35
36
///////////////////////////////////////////////////////////////////////////////////////////////////
37
38 9c2f0c91 Leszek Koltunski
public class TwistySkewb extends TwistyObject
39 fb52fae9 Leszek Koltunski
{
40
  private static final int FACES_PER_CUBIT =6;
41
42
  // the four rotation axis of a RubikSkewb. Must be normalized.
43
  static final Static3D[] ROT_AXIS = new Static3D[]
44
         {
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
           new Static3D(+SQ3/3,-SQ3/3,-SQ3/3)
49
         };
50
51 925ed78f Leszek Koltunski
  private static final int[] BASIC_ANGLE = new int[] { 3,3,3,3 };
52
53 fb52fae9 Leszek Koltunski
  private static final int[] FACE_COLORS = new int[]
54
         {
55 ece1b58d Leszek Koltunski
           COLOR_YELLOW, COLOR_WHITE,
56
           COLOR_BLUE  , COLOR_GREEN,
57 323b217c Leszek Koltunski
           COLOR_RED   , COLOR_ORANGE
58 fb52fae9 Leszek Koltunski
         };
59
60
  // All legal rotation quats of a RubikSkewb
61
  private static final Static4D[] QUATS = new Static4D[]
62
         {
63
           new Static4D(  0.0f,  0.0f,  0.0f,  1.0f ),
64
           new Static4D(  1.0f,  0.0f,  0.0f,  0.0f ),
65
           new Static4D(  0.0f,  1.0f,  0.0f,  0.0f ),
66
           new Static4D(  0.0f,  0.0f,  1.0f,  0.0f ),
67
68
           new Static4D(  0.5f,  0.5f,  0.5f,  0.5f ),
69
           new Static4D(  0.5f,  0.5f,  0.5f, -0.5f ),
70
           new Static4D(  0.5f,  0.5f, -0.5f,  0.5f ),
71
           new Static4D(  0.5f,  0.5f, -0.5f, -0.5f ),
72
           new Static4D(  0.5f, -0.5f,  0.5f,  0.5f ),
73
           new Static4D(  0.5f, -0.5f,  0.5f, -0.5f ),
74
           new Static4D(  0.5f, -0.5f, -0.5f,  0.5f ),
75
           new Static4D(  0.5f, -0.5f, -0.5f, -0.5f )
76
         };
77
78 3f3ff476 Leszek Koltunski
  private static final int[][] mCornerMap =
79
         {
80
           {  4, 2, 0, 18,18,18 },
81
           {  2, 5, 0, 18,18,18 },
82
           {  3, 4, 0, 18,18,18 },
83
           {  5, 3, 0, 18,18,18 },
84
           {  1, 2, 4, 18,18,18 },
85
           {  5, 2, 1, 18,18,18 },
86
           {  4, 3, 1, 18,18,18 },
87
           {  1, 3, 5, 18,18,18 },
88
         };
89 63002261 Leszek Koltunski
90 3f3ff476 Leszek Koltunski
  private static final int[][] mEdgeMap =
91 fb52fae9 Leszek Koltunski
         {
92 3f3ff476 Leszek Koltunski
           { 10, 8, 18,18,18,18 },
93
           {  6,10, 18,18,18,18 },
94
           { 10, 9, 18,18,18,18 },
95
           {  7,10, 18,18,18,18 },
96
           {  8, 6, 18,18,18,18 },
97
           {  9, 6, 18,18,18,18 },
98
           {  9, 7, 18,18,18,18 },
99
           {  8, 7, 18,18,18,18 },
100
           { 11, 8, 18,18,18,18 },
101
           {  6,11, 18,18,18,18 },
102
           { 11, 9, 18,18,18,18 },
103
           {  7,11, 18,18,18,18 }
104 fb52fae9 Leszek Koltunski
         };
105
106 3f3ff476 Leszek Koltunski
  private static final int[][] mCenterMap =
107 fb52fae9 Leszek Koltunski
         {
108 3f3ff476 Leszek Koltunski
           { 12, 18,18,18,18,18 },
109
           { 13, 18,18,18,18,18 },
110
           { 14, 18,18,18,18,18 },
111
           { 15, 18,18,18,18,18 },
112
           { 16, 18,18,18,18,18 },
113
           { 17, 18,18,18,18,18 },
114 fb52fae9 Leszek Koltunski
         };
115
116 596d62a4 Leszek Koltunski
  private static final double[][] VERTICES_CORNER = new double[][]
117
          {
118 7dc57f89 Leszek Koltunski
              {-0.5f, 0.0f, 0.0f},
119
              { 0.0f,-0.5f, 0.0f},
120
              { 0.0f, 0.0f,-0.5f},
121
              {-0.5f,-0.5f,-0.5f},
122
              { 0.0f, 0.0f, 0.0f}
123 596d62a4 Leszek Koltunski
          };
124
125
  private static final int[][] VERT_INDEXES_CORNER = new int[][]
126
          {
127 7dc57f89 Leszek Koltunski
              {0,1,4},
128
              {2,0,4},
129
              {1,2,4},
130
              {3,1,0},
131
              {3,2,1},
132
              {3,0,2}
133 596d62a4 Leszek Koltunski
          };
134
135
  private static final double[][] VERTICES_EDGE = new double[][]
136
          {
137
             {-0.5, 0.0, 0.0},
138
             { 0.5, 0.0, 0.0},
139
             { 0.0,-0.5, 0.0},
140
             { 0.0, 0.0,-0.5}
141
          };
142
143
  private static final int[][] VERT_INDEXES_EDGE = new int[][]
144
          {
145
             {2,1,0},   // counterclockwise!
146
             {3,0,1},
147
             {2,3,1},
148
             {3,2,0},
149
          };
150
151
  private static final double[][] VERTICES_FACE = new double[][]
152
          {
153 7dc57f89 Leszek Koltunski
             {-0.5f, 0.0f, 0.0f },
154
             { 0.0f,-0.5f, 0.0f },
155
             { 0.5f, 0.0f, 0.0f },
156
             { 0.0f, 0.5f, 0.0f },
157
             { 0.0f, 0.0f,-0.5f }
158 596d62a4 Leszek Koltunski
          };
159
160
  private static final int[][] VERT_INDEXES_FACE = new int[][]
161
          {
162 7dc57f89 Leszek Koltunski
             {0,1,2,3},
163
             {4,1,0},
164
             {4,2,1},
165
             {4,3,2},
166
             {4,0,3}
167
          };
168
169
  private static final float[][] STICKERS = new float[][]
170
          {
171 be56193c Leszek Koltunski
             { -0.5f, 0.25f, 0.25f,  -0.5f, 0.25f, 0.25f  },
172
             { -0.5f, 0.00f, 0.00f,  -0.5f, 0.50f, 0.0f, 0.0f, 0.5f }
173 596d62a4 Leszek Koltunski
          };
174
175 9c06394a Leszek Koltunski
  private static final ObjectSticker[] mStickers;
176
177
  static
178
    {
179
    mStickers = new ObjectSticker[STICKERS.length+1];
180
    final float R1 = 0.025f;
181
    final float R2 = 0.025f;
182
    final float R3 = 0.055f;
183
    final float[][] radii  = { { R1,R1,R1 },{ R2,R2,R2 },{ R3,R3,R3,R3 } };
184
    final float[] strokes = { 0.045f, 0.035f, 0.035f };
185
186
    for(int s=0; s<STICKERS.length+1; s++)
187
      {
188
      int index = s<2 ? 0:1;
189
      mStickers[s] = new ObjectSticker(STICKERS[index],null,radii[s],strokes[s]);
190
      }
191
    }
192
193 01b2ef5a Leszek Koltunski
  private int mCurrState;
194
  private int mIndexExcluded;
195 6cf89a3e Leszek Koltunski
  private final ScrambleState[] mStates;
196 01b2ef5a Leszek Koltunski
197 fb52fae9 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
198
199 9c2f0c91 Leszek Koltunski
  TwistySkewb(int size, Static4D quat, DistortedTexture texture,
200
              MeshSquare mesh, DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
201 fb52fae9 Leszek Koltunski
    {
202 db875721 Leszek Koltunski
    super(size, 2*size-2, quat, texture, mesh, effects, moves, ObjectList.SKEW, res, scrWidth);
203 01b2ef5a Leszek Koltunski
204
    int[] tmp = {0,-1,0, 0,1,0, size-1,-1,0, size-1,1,0 };
205
206 6cf89a3e Leszek Koltunski
    mStates = new ScrambleState[]
207 01b2ef5a Leszek Koltunski
      {
208 6cf89a3e Leszek Koltunski
      new ScrambleState( new int[][] {tmp,tmp,tmp,tmp} )
209 01b2ef5a Leszek Koltunski
      };
210 fb52fae9 Leszek Koltunski
    }
211
212 a480ee80 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
213
214
  int[] getSolvedQuats(int cubit, int numLayers)
215
    {
216
    int status = retCubitSolvedStatus(cubit,numLayers);
217
    return status<0 ? null : buildSolvedQuats(MovementSkewb.FACE_AXIS[status],QUATS);
218
    }
219
220 3f3ff476 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
221
222 d92030e4 Leszek Koltunski
  private int getNumCorners()
223 3f3ff476 Leszek Koltunski
    {
224
    return 8;
225
    }
226
227
///////////////////////////////////////////////////////////////////////////////////////////////////
228
229 b89898c5 Leszek Koltunski
  private int getNumEdges(int layers)
230 3f3ff476 Leszek Koltunski
    {
231 b89898c5 Leszek Koltunski
    return (layers-2)*12;
232 3f3ff476 Leszek Koltunski
    }
233
234
///////////////////////////////////////////////////////////////////////////////////////////////////
235
236 d92030e4 Leszek Koltunski
  private int getNumCentersPerFace(int layers)
237 3f3ff476 Leszek Koltunski
    {
238 d92030e4 Leszek Koltunski
    return ((layers-2)*(layers-2) + (layers-1)*(layers-1));
239 3f3ff476 Leszek Koltunski
    }
240
241 fb52fae9 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
242
243
  float getScreenRatio()
244
    {
245 d99f3a48 Leszek Koltunski
    return 1.0f;
246 fb52fae9 Leszek Koltunski
    }
247
248
///////////////////////////////////////////////////////////////////////////////////////////////////
249
250
  Static4D[] getQuats()
251
    {
252
    return QUATS;
253
    }
254
255
///////////////////////////////////////////////////////////////////////////////////////////////////
256
257
  int getNumFaces()
258
    {
259
    return FACE_COLORS.length;
260
    }
261
262 169219a7 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
263
264
  int getSolvedFunctionIndex()
265
    {
266
    return 0;
267
    }
268
269 eaee1ddc Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
270
271
  boolean shouldResetTextureMaps()
272
    {
273
    return false;
274
    }
275
276 eab9d8f8 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
277
278 a64e07d0 Leszek Koltunski
  int getNumStickerTypes(int numLayers)
279 eab9d8f8 Leszek Koltunski
    {
280 3f3ff476 Leszek Koltunski
    return 3;
281 eab9d8f8 Leszek Koltunski
    }
282
283 7403cdfa Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
284
285 e6734aa9 Leszek Koltunski
  float[][] getCuts(int numLayers)
286 7403cdfa Leszek Koltunski
    {
287 b89898c5 Leszek Koltunski
    switch(numLayers)
288 a97e02b7 Leszek Koltunski
      {
289 e6734aa9 Leszek Koltunski
      case 2: float[] c2 = new float[] {0.0f};
290
              return new float[][] { c2,c2,c2,c2 };
291
      case 3: float[] c3 = new float[] {-SQ3/12,+SQ3/12};
292
              return new float[][] { c3,c3,c3,c3 };
293 a97e02b7 Leszek Koltunski
      }
294 e6734aa9 Leszek Koltunski
    return null;
295 7403cdfa Leszek Koltunski
    }
296
297 fb52fae9 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
298
299
  int getNumCubitFaces()
300
    {
301
    return FACES_PER_CUBIT;
302
    }
303
304
///////////////////////////////////////////////////////////////////////////////////////////////////
305
306 e6cf7283 Leszek Koltunski
  float[][] getCubitPositions(int numLayers)
307 fb52fae9 Leszek Koltunski
    {
308 b89898c5 Leszek Koltunski
    final float DIST_CORNER = (numLayers-1)*0.50f;
309
    final float DIST_EDGE   = (numLayers-1)*0.50f;
310
    final float DIST_CENTER = (numLayers-1)*0.50f;
311 3f3ff476 Leszek Koltunski
312 d92030e4 Leszek Koltunski
    final int numCorners = getNumCorners();
313 b89898c5 Leszek Koltunski
    final int numEdges   = getNumEdges(numLayers);
314 d92030e4 Leszek Koltunski
    final int numCenters = 6*getNumCentersPerFace(numLayers);
315 3f3ff476 Leszek Koltunski
316 e6cf7283 Leszek Koltunski
    final float[][] CENTERS = new float[numCorners+numEdges+numCenters][];
317 3f3ff476 Leszek Koltunski
318
    /// CORNERS //////////////////////////////////////////////
319
320 e6cf7283 Leszek Koltunski
    CENTERS[0] = new float[] { DIST_CORNER, DIST_CORNER, DIST_CORNER };
321
    CENTERS[1] = new float[] { DIST_CORNER, DIST_CORNER,-DIST_CORNER };
322
    CENTERS[2] = new float[] { DIST_CORNER,-DIST_CORNER, DIST_CORNER };
323
    CENTERS[3] = new float[] { DIST_CORNER,-DIST_CORNER,-DIST_CORNER };
324
    CENTERS[4] = new float[] {-DIST_CORNER, DIST_CORNER, DIST_CORNER };
325
    CENTERS[5] = new float[] {-DIST_CORNER, DIST_CORNER,-DIST_CORNER };
326
    CENTERS[6] = new float[] {-DIST_CORNER,-DIST_CORNER, DIST_CORNER };
327
    CENTERS[7] = new float[] {-DIST_CORNER,-DIST_CORNER,-DIST_CORNER };
328 3f3ff476 Leszek Koltunski
329
    /// EDGES ///////////////////////////////////////////////
330
331
    final float[][]  edgeTable =
332
        {
333
            {0,+DIST_EDGE,+DIST_EDGE},
334
            {+DIST_EDGE,0,+DIST_EDGE},
335
            {0,-DIST_EDGE,+DIST_EDGE},
336
            {-DIST_EDGE,0,+DIST_EDGE},
337
            {+DIST_EDGE,+DIST_EDGE,0},
338
            {+DIST_EDGE,-DIST_EDGE,0},
339
            {-DIST_EDGE,-DIST_EDGE,0},
340
            {-DIST_EDGE,+DIST_EDGE,0},
341
            {0,+DIST_EDGE,-DIST_EDGE},
342
            {+DIST_EDGE,0,-DIST_EDGE},
343
            {0,-DIST_EDGE,-DIST_EDGE},
344
            {-DIST_EDGE,0,-DIST_EDGE}
345
        };
346
347
    int index=8;
348
349
    for (float[] edges : edgeTable)
350
      {
351 b89898c5 Leszek Koltunski
      float c = (3-numLayers)*0.5f;
352 3f3ff476 Leszek Koltunski
353 b89898c5 Leszek Koltunski
      for (int j=0; j<numLayers-2; j++, c+=1.0f, index++)
354 3f3ff476 Leszek Koltunski
        {
355 e6cf7283 Leszek Koltunski
        CENTERS[index] = new float[] { edges[0]==0 ? c : edges[0] ,
356 3f3ff476 Leszek Koltunski
                                       edges[1]==0 ? c : edges[1] ,
357 e6cf7283 Leszek Koltunski
                                       edges[2]==0 ? c : edges[2] };
358 3f3ff476 Leszek Koltunski
        }
359
      }
360
361
    /// CENTERS //////////////////////////////////////////////
362
363
    final float X= -1000.0f;
364
    final float Y= -1001.0f;
365
366
    final float[][]  centerTable =
367
        {
368
            {+DIST_CENTER,X,Y},
369
            {-DIST_CENTER,X,Y},
370
            {X,+DIST_CENTER,Y},
371
            {X,-DIST_CENTER,Y},
372
            {X,Y,+DIST_CENTER},
373
            {X,Y,-DIST_CENTER}
374
        };
375
376
    float x,y, cen0, cen1, cen2;
377
378
    for( float[] centers : centerTable )
379
      {
380 b89898c5 Leszek Koltunski
      x = (2-numLayers)*0.5f;
381 3f3ff476 Leszek Koltunski
382 b89898c5 Leszek Koltunski
      for(int i=0; i<numLayers-1; i++, x+=1.0f)
383 3f3ff476 Leszek Koltunski
        {
384 b89898c5 Leszek Koltunski
        y = (2-numLayers)*0.5f;
385 3f3ff476 Leszek Koltunski
386 b89898c5 Leszek Koltunski
        for(int j=0; j<numLayers-1; j++, y+=1.0f, index++)
387 3f3ff476 Leszek Koltunski
          {
388
               if( centers[0]==Y ) cen0 = y;
389
          else if( centers[0]==X ) cen0 = x;
390
          else                     cen0 = centers[0];
391
392
               if( centers[1]==Y ) cen1 = y;
393
          else if( centers[1]==X ) cen1 = x;
394
          else                     cen1 = centers[1];
395
396
               if( centers[2]==Y ) cen2 = y;
397
          else if( centers[2]==X ) cen2 = x;
398
          else                     cen2 = centers[2];
399
400 e6cf7283 Leszek Koltunski
          CENTERS[index] = new float[] {cen0,cen1,cen2};
401 3f3ff476 Leszek Koltunski
          }
402
        }
403
404 b89898c5 Leszek Koltunski
      x = (3-numLayers)*0.5f;
405 3f3ff476 Leszek Koltunski
406 b89898c5 Leszek Koltunski
      for(int i=0; i<numLayers-2; i++, x+=1.0f)
407 3f3ff476 Leszek Koltunski
        {
408 b89898c5 Leszek Koltunski
        y = (3-numLayers)*0.5f;
409 3f3ff476 Leszek Koltunski
410 b89898c5 Leszek Koltunski
        for(int j=0; j<numLayers-2; j++, y+=1.0f, index++)
411 3f3ff476 Leszek Koltunski
          {
412
               if( centers[0]==Y ) cen0 = y;
413
          else if( centers[0]==X ) cen0 = x;
414
          else                     cen0 = centers[0];
415
416
               if( centers[1]==Y ) cen1 = y;
417
          else if( centers[1]==X ) cen1 = x;
418
          else                     cen1 = centers[1];
419
420
               if( centers[2]==Y ) cen2 = y;
421
          else if( centers[2]==X ) cen2 = x;
422
          else                     cen2 = centers[2];
423
424 e6cf7283 Leszek Koltunski
          CENTERS[index] = new float[] {cen0,cen1,cen2};
425 3f3ff476 Leszek Koltunski
          }
426
        }
427
      }
428
429 fb52fae9 Leszek Koltunski
    return CENTERS;
430
    }
431
432
///////////////////////////////////////////////////////////////////////////////////////////////////
433
434 3e605536 Leszek Koltunski
  Static4D getQuat(int cubit, int numLayers)
435 fb52fae9 Leszek Koltunski
    {
436 d92030e4 Leszek Koltunski
    int numCorners = getNumCorners();
437
    int numEdges   = getNumEdges(numLayers);
438 3f3ff476 Leszek Koltunski
439
    if( cubit<numCorners )
440
      {
441
      switch(cubit)
442
        {
443
        case  0: return QUATS[0];                          //  unit quat
444
        case  1: return new Static4D( SQ2/2,0,0,SQ2/2);    //  90 along X
445
        case  2: return new Static4D(-SQ2/2,0,0,SQ2/2);    // -90 along X
446
        case  3: return QUATS[1];                          // 180 along X
447
        case  4: return new Static4D(0, SQ2/2,0,SQ2/2);    //  90 along Y
448
        case  5: return QUATS[2];                          // 180 along Y
449
        case  6: return QUATS[3];                          // 180 along Z
450
        case  7: return new Static4D(SQ2/2,0,-SQ2/2,0);    // 180 along (SQ2/2,0,-SQ2/2)
451
        }
452
      }
453
    else if( cubit<numCorners+numEdges )
454
      {
455 d92030e4 Leszek Koltunski
      int edge = (cubit-numCorners)/(numLayers-2);
456 3f3ff476 Leszek Koltunski
457
      switch(edge)
458
        {
459
        case  0: return QUATS[ 0];
460
        case  1: return QUATS[ 5];
461
        case  2: return QUATS[ 3];
462
        case  3: return QUATS[11];
463
        case  4: return QUATS[ 4];
464
        case  5: return QUATS[ 7];
465
        case  6: return QUATS[ 9];
466
        case  7: return QUATS[10];
467
        case  8: return QUATS[ 2];
468
        case  9: return QUATS[ 8];
469
        case 10: return QUATS[ 1];
470
        case 11: return QUATS[ 6];
471
        }
472
      }
473
    else
474 fb52fae9 Leszek Koltunski
      {
475 d92030e4 Leszek Koltunski
      int center = (cubit-numCorners-numEdges)/getNumCentersPerFace(numLayers);
476 3f3ff476 Leszek Koltunski
477
      switch(center)
478
        {
479
        case 0: return new Static4D(0,-SQ2/2,0,SQ2/2);    // -90 along Y
480
        case 1: return new Static4D(0, SQ2/2,0,SQ2/2);    //  90 along Y
481
        case 2: return new Static4D( SQ2/2,0,0,SQ2/2);    //  90 along X
482
        case 3: return new Static4D(-SQ2/2,0,0,SQ2/2);    // -90 along X
483
        case 4: return QUATS[0];                          //  unit quaternion
484
        case 5: return QUATS[1];                          // 180 along X
485
        }
486 fb52fae9 Leszek Koltunski
      }
487
488
    return null;
489
    }
490
491
///////////////////////////////////////////////////////////////////////////////////////////////////
492
493 8655f3fe Leszek Koltunski
  ObjectShape getObjectShape(int cubit, int numLayers)
494 fb52fae9 Leszek Koltunski
    {
495 8655f3fe Leszek Koltunski
    int variant = getCubitVariant(cubit,numLayers);
496 fb52fae9 Leszek Koltunski
497 8655f3fe Leszek Koltunski
    if( variant==0 )
498 fb52fae9 Leszek Koltunski
      {
499 8655f3fe Leszek Koltunski
      int N = numLayers==2 ? 7:5;
500
      int E1= numLayers==2 ? 3:2;
501
      int E2= numLayers==2 ? 5:3;
502 3e605536 Leszek Koltunski
      float[][] bands     = new float[][] { {0.028f,35,0.16f,0.7f,N,E1,E1}, {0.000f, 0,1.00f,0.0f,3,1,E2} };
503 8655f3fe Leszek Koltunski
      int[] bandIndices   = new int[] { 0,0,0,1,1,1 };
504
      float[][] corners   = new float[][] { {0.08f,0.15f}, {0.08f,0.20f} };
505
      int[] cornerIndices = new int[] { 1,1,1,0,0 };
506
      float[][] centers   = new float[][] { {-0.25f, -0.25f, -0.25f} };
507
      int[] centerIndices = new int[] { 0,0,0,-1,0 };
508
      return new ObjectShape(VERTICES_CORNER,VERT_INDEXES_CORNER,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
509 fb52fae9 Leszek Koltunski
      }
510 8655f3fe Leszek Koltunski
    else if( variant==1 )
511 3f3ff476 Leszek Koltunski
      {
512 8655f3fe Leszek Koltunski
      int N = numLayers==2 ? 7:5;
513
      int E = numLayers==2 ? 5:2;
514 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} };
515 8655f3fe Leszek Koltunski
      int[] bandIndices   = new int[] { 0,0,1,1 };
516
      float[][] corners   = new float[][] { {0.07f,0.20f}, {0.02f,0.30f} };
517
      int[] cornerIndices = new int[] { 0,0,1,1 };
518
      float[][] centers   = new float[][] { {0.0f, -0.25f, -0.25f} };
519
      int[] centerIndices = new int[] { 0,0,0,0 };
520
      return new ObjectShape(VERTICES_EDGE,VERT_INDEXES_EDGE,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
521 3f3ff476 Leszek Koltunski
      }
522 fb52fae9 Leszek Koltunski
    else
523
      {
524 8655f3fe Leszek Koltunski
      int N = numLayers==2 ? 7:6;
525
      int E = numLayers==2 ? 3:1;
526 3e605536 Leszek Koltunski
      float[][] bands     = new float[][] { {0.051f,35,SQ2/8,0.9f,N,E,E}, {0.000f,0,1,0.0f,3,0,0} };
527 8655f3fe Leszek Koltunski
      int[] bandIndices   = new int[] { 0,1,1,1,1 };
528
      float[][] corners   = new float[][] { {0.06f,0.10f} };
529
      int[] cornerIndices = new int[] { 0,0,0,0,0 };
530
      float[][] centers   = new float[][] { {0,0,-0.2f} };
531
      int[] centerIndices = new int[] { 0,0,0,0,-1 };
532
      return new ObjectShape(VERTICES_FACE,VERT_INDEXES_FACE,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
533
      }
534
    }
535
536
///////////////////////////////////////////////////////////////////////////////////////////////////
537
538 3e605536 Leszek Koltunski
  int getNumCubitVariants(int numLayers)
539 8655f3fe Leszek Koltunski
    {
540
    return 3;
541
    }
542
543
///////////////////////////////////////////////////////////////////////////////////////////////////
544
545
  int getCubitVariant(int cubit, int numLayers)
546
    {
547
    int numCorners = getNumCorners();
548
    if( cubit<numCorners ) return 0;
549
    int numEdges = getNumEdges(numLayers);
550
    return cubit<numCorners+numEdges ? 1:2;
551
    }
552
553 fb52fae9 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
554
555 d92030e4 Leszek Koltunski
  int getFaceColor(int cubit, int cubitface, int numLayers)
556 fb52fae9 Leszek Koltunski
    {
557 d92030e4 Leszek Koltunski
    int numCorners = getNumCorners();
558
    int numEdges   = getNumEdges(numLayers);
559 3f3ff476 Leszek Koltunski
560
    if( cubit<numCorners )
561
      {
562
      return mCornerMap[cubit][cubitface];
563
      }
564
    else if( cubit<numCorners+numEdges )
565
      {
566 d92030e4 Leszek Koltunski
      int edge = (cubit-numCorners)/(numLayers-2);
567 3f3ff476 Leszek Koltunski
      return mEdgeMap[edge][cubitface];
568
      }
569
    else
570
      {
571 d92030e4 Leszek Koltunski
      int center = (cubit-numCorners-numEdges)/getNumCentersPerFace(numLayers);
572 3f3ff476 Leszek Koltunski
      return mCenterMap[center][cubitface];
573
      }
574 fb52fae9 Leszek Koltunski
    }
575
576
///////////////////////////////////////////////////////////////////////////////////////////////////
577
578 9c06394a Leszek Koltunski
  int getColor(int face)
579 fb52fae9 Leszek Koltunski
    {
580 9c06394a Leszek Koltunski
    return FACE_COLORS[face];
581
    }
582 eab9d8f8 Leszek Koltunski
583 9c06394a Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
584 ae755eda Leszek Koltunski
585 9c06394a Leszek Koltunski
  ObjectSticker retSticker(int face)
586
    {
587
    return mStickers[face/NUM_FACES];
588 fb52fae9 Leszek Koltunski
    }
589
590
///////////////////////////////////////////////////////////////////////////////////////////////////
591
592
  float returnMultiplier()
593
    {
594
    return 2.0f;
595
    }
596
597
///////////////////////////////////////////////////////////////////////////////////////////////////
598
// PUBLIC API
599
600
  public Static3D[] getRotationAxis()
601
    {
602
    return ROT_AXIS;
603
    }
604
605
///////////////////////////////////////////////////////////////////////////////////////////////////
606
607 925ed78f Leszek Koltunski
  public int[] getBasicAngle()
608 fb52fae9 Leszek Koltunski
    {
609 925ed78f Leszek Koltunski
    return BASIC_ANGLE;
610 fb52fae9 Leszek Koltunski
    }
611
612
///////////////////////////////////////////////////////////////////////////////////////////////////
613
614 01b2ef5a Leszek Koltunski
  public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles)
615 fb52fae9 Leszek Koltunski
    {
616 9f171eba Leszek Koltunski
    if( curr==0 )
617 fb52fae9 Leszek Koltunski
      {
618 01b2ef5a Leszek Koltunski
      mCurrState     = 0;
619
      mIndexExcluded =-1;
620 fb52fae9 Leszek Koltunski
      }
621
622 01b2ef5a Leszek Koltunski
    int total = mStates[mCurrState].getTotal(mIndexExcluded);
623
    int random= rnd.nextInt(total);
624
    int[] info= mStates[mCurrState].getInfo(random,mIndexExcluded);
625 fb52fae9 Leszek Koltunski
626 01b2ef5a Leszek Koltunski
    scramble[curr][0] = info[0];
627
    scramble[curr][1] = info[1];
628
    scramble[curr][2] = info[2];
629
630
    mCurrState     = info[3];
631
    mIndexExcluded = info[0];
632 fb52fae9 Leszek Koltunski
    }
633
634 6fd4a72c Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
635
636
  public int getObjectName(int numLayers)
637
    {
638
    switch(numLayers)
639
      {
640
      case 2: return R.string.skew2;
641
      case 3: return R.string.skew3;
642
      }
643
    return R.string.skew2;
644
    }
645
646
///////////////////////////////////////////////////////////////////////////////////////////////////
647
648
  public int getInventor(int numLayers)
649
    {
650
    switch(numLayers)
651
      {
652
      case 2: return R.string.skew2_inventor;
653
      case 3: return R.string.skew3_inventor;
654
      }
655
    return R.string.skew2_inventor;
656
    }
657
658
///////////////////////////////////////////////////////////////////////////////////////////////////
659
660
  public int getComplexity(int numLayers)
661
    {
662
    switch(numLayers)
663
      {
664 d5ca9927 Leszek Koltunski
      case 2: return 4;
665
      case 3: return 8;
666 6fd4a72c Leszek Koltunski
      }
667
    return 5;
668
    }
669 fb52fae9 Leszek Koltunski
}