Project

General

Profile

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

magiccube / src / main / java / org / distorted / objects / TwistySkewb.java @ a480ee80

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