Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyMegaminx.java @ 7ba38dd4

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
import static org.distorted.objectlib.main.Movement12.COS54;
23
import static org.distorted.objectlib.main.Movement12.SIN54;
24
25
import android.content.res.Resources;
26
27 ecf3d6e3 Leszek Koltunski
import org.distorted.library.type.Static3D;
28 29b82486 Leszek Koltunski
import org.distorted.library.type.Static4D;
29 a706f8e0 Leszek Koltunski
import org.distorted.library.main.QuatHelper;
30 29b82486 Leszek Koltunski
31
import org.distorted.objectlib.R;
32 8592461c Leszek Koltunski
import org.distorted.objectlib.main.ObjectControl;
33 8005e762 Leszek Koltunski
import org.distorted.objectlib.main.ObjectType;
34 198c5bf0 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectShape;
35
import org.distorted.objectlib.helpers.ObjectSticker;
36 29b82486 Leszek Koltunski
37
///////////////////////////////////////////////////////////////////////////////////////////////////
38
39
public class TwistyMegaminx extends TwistyMinx
40
{
41
  static final float MEGA_D = 0.04f;
42
  private int[] mQuatCenterIndices;
43
44
///////////////////////////////////////////////////////////////////////////////////////////////////
45
46 7ba38dd4 Leszek Koltunski
  public TwistyMegaminx(int[] numL, Static4D quat, Static3D move, Resources res)
47 29b82486 Leszek Koltunski
    {
48 7ba38dd4 Leszek Koltunski
    super(numL, quat, move, res);
49 29b82486 Leszek Koltunski
    }
50
51
///////////////////////////////////////////////////////////////////////////////////////////////////
52
53
  private void initializeCenterIndices()
54
    {
55
    mQuatCenterIndices = new int[] { 16, 18, 22,  1, 20, 13, 14, 15,  0, 12,  2,  3 };
56
    }
57
58
///////////////////////////////////////////////////////////////////////////////////////////////////
59
60
  private int numCubitsPerCorner(int numLayers)
61
    {
62
    return 3*((numLayers-1)/2)*((numLayers-3)/2) + 1;
63
    }
64
65
///////////////////////////////////////////////////////////////////////////////////////////////////
66
67
  private int numCubitsPerEdge(int numLayers)
68
    {
69
    return numLayers-2;
70
    }
71
72 4e1dc313 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
73
74 a57e6870 Leszek Koltunski
  protected int getResource(int[] numLayers)
75 4e1dc313 Leszek Koltunski
    {
76 a57e6870 Leszek Koltunski
    switch(numLayers[0])
77 4e1dc313 Leszek Koltunski
      {
78 55fa6993 Leszek Koltunski
      case 3: return R.raw.mega_3;
79
      case 5: return R.raw.mega_5;
80 4e1dc313 Leszek Koltunski
      }
81
82
    return 0;
83
    }
84
85 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
86
87 1bb09f88 Leszek Koltunski
  public int getNumStickerTypes(int[] numLayers)
88 29b82486 Leszek Koltunski
    {
89 a57e6870 Leszek Koltunski
    return (numLayers[0]+3)/2;
90 29b82486 Leszek Koltunski
    }
91
92
///////////////////////////////////////////////////////////////////////////////////////////////////
93
94 7bbfc84f Leszek Koltunski
  public float[][] getCuts(int[] numLayers)
95 29b82486 Leszek Koltunski
    {
96 a57e6870 Leszek Koltunski
    return genericGetCuts(numLayers[0],0.5f-MEGA_D);
97 29b82486 Leszek Koltunski
    }
98
99
///////////////////////////////////////////////////////////////////////////////////////////////////
100
101
  private float[] computeCenter(int center, int numLayers)
102
    {
103
    if( mCenterCoords==null ) initializeCenterCoords();
104
    float[] coords = mCenterCoords[center];
105
    float A = 0.33f*numLayers;
106
107
    return new float[] { A*coords[0], A*coords[1], A*coords[2] };
108
    }
109
110
///////////////////////////////////////////////////////////////////////////////////////////////////
111
// Fill out mCurrCorner{X,Y,Z} by applying appropriate Quat to mBasicCorner{X,Y,Z}
112
// Appropriate one: QUATS[QUAT_INDICES[corner]].
113
114
  private void computeBasicCornerVectors(int corner)
115
    {
116
    if( mQuatCornerIndices==null ) initializeQuatIndices();
117
    if( mQuats==null ) initializeQuats();
118
    if( mCurrCornerV==null || mBasicCornerV==null ) initializeCornerV();
119
120
    Static4D quat = mQuats[mQuatCornerIndices[corner]];
121
122
    mCurrCornerV[0] = QuatHelper.rotateVectorByQuat(mBasicCornerV[0],quat);
123
    mCurrCornerV[1] = QuatHelper.rotateVectorByQuat(mBasicCornerV[1],quat);
124
    mCurrCornerV[2] = QuatHelper.rotateVectorByQuat(mBasicCornerV[2],quat);
125
    }
126
127
///////////////////////////////////////////////////////////////////////////////////////////////////
128
129
  private float[] computeCorner(int numCubitsPerCorner, int numLayers, int corner, int part)
130
    {
131
    if( mCorners==null ) initializeCorners();
132
    if( mCurrCornerV==null || mBasicCornerV==null ) initializeCornerV();
133
134
    float D = numLayers/3.0f;
135
    float[] corn = mCorners[corner];
136
137
    if( part==0 )
138
      {
139
      return new float[] { corn[0]*D, corn[1]*D, corn[2]*D };
140
      }
141
    else
142
      {
143
      float E = 2.0f*D*(0.5f-MEGA_D)/(0.5f*(numLayers-1));
144
      int N = (numCubitsPerCorner-1)/3;
145
      int block = (part-1) % N;
146
      int index = (part-1) / N;
147
      Static4D pri = mCurrCornerV[index];
148
      Static4D sec = mCurrCornerV[(index+2)%3];
149
150
      int layers= (numLayers-3)/2;
151
      int multP = (block % layers) + 1;
152
      int multS = (block / layers);
153
154
      return new float[] {
155
                          corn[0]*D + (pri.get0()*multP + sec.get0()*multS)*E,
156
                          corn[1]*D + (pri.get1()*multP + sec.get1()*multS)*E,
157
                          corn[2]*D + (pri.get2()*multP + sec.get2()*multS)*E
158
                         };
159
      }
160
    }
161
162
///////////////////////////////////////////////////////////////////////////////////////////////////
163
164
  private int computeEdgeType(int cubit, int numCubitsPerCorner, int numCubitsPerEdge)
165
    {
166
    int part = (cubit - NUM_CORNERS*numCubitsPerCorner) % numCubitsPerEdge;
167
    return (part+1)/2;
168
    }
169
170
///////////////////////////////////////////////////////////////////////////////////////////////////
171
172
  private float[] computeEdge(int numLayers, int edge, int part)
173
    {
174
    if( mCenterCoords==null ) initializeCenterCoords();
175
    if( mCorners==null ) initializeCorners();
176
    if( mEdgeMap==null ) initializeEdgeMap();
177
178
    float D = numLayers/3.0f;
179
    float[] c1 = mCorners[ mEdgeMap[edge][0] ];
180
    float[] c2 = mCorners[ mEdgeMap[edge][1] ];
181
    float x = D * (c1[0]+c2[0]) / 2;
182
    float y = D * (c1[1]+c2[1]) / 2;
183
    float z = D * (c1[2]+c2[2]) / 2;
184
185
    if( part==0 )
186
      {
187
      return new float[] { x, y, z };
188
      }
189
    else
190
      {
191
      int mult = (part+1)/2;
192
      int dir  = (part+1)%2;
193
      float[] center = mCenterCoords[ mEdgeMap[edge][dir+2] ];
194
195
      float vX = D*center[0] - x;
196
      float vY = D*center[1] - y;
197
      float vZ = D*center[2] - z;
198
199
      float A = 3*mult*D*(0.5f-MEGA_D)*COS18/((numLayers-1)*0.5f);
200
      A /= (float)Math.sqrt(vX*vX+vY*vY+vZ*vZ);
201
202
      return new float[] { x+A*vX, y+A*vY, z+A*vZ };
203
      }
204
    }
205
206
///////////////////////////////////////////////////////////////////////////////////////////////////
207
208 7b832206 Leszek Koltunski
  public float[][] getCubitPositions(int[] numLayers)
209 29b82486 Leszek Koltunski
    {
210 a57e6870 Leszek Koltunski
    int numL = numLayers[0];
211
    int numCubitsPerCorner = numCubitsPerCorner(numL);
212
    int numCubitsPerEdge   = numCubitsPerEdge(numL);
213 29b82486 Leszek Koltunski
    int numCubits = NUM_CORNERS*numCubitsPerCorner + NUM_EDGES*numCubitsPerEdge + NUM_CENTERS;
214
    int index=0;
215
216
    final float[][] CENTERS = new float[numCubits][];
217
218
    for(int corner=0; corner<NUM_CORNERS; corner++)
219
      {
220
      computeBasicCornerVectors(corner);
221
222
      for(int part=0; part<numCubitsPerCorner; part++, index++)
223
        {
224 a57e6870 Leszek Koltunski
        CENTERS[index] = computeCorner(numCubitsPerCorner,numL,corner,part);
225 29b82486 Leszek Koltunski
        }
226
      }
227
228
    for(int edge=0; edge<NUM_EDGES; edge++)
229
      {
230
      for(int part=0; part<numCubitsPerEdge; part++, index++)
231
        {
232 a57e6870 Leszek Koltunski
        CENTERS[index] = computeEdge(numL, edge, part );
233 29b82486 Leszek Koltunski
        }
234
      }
235
236
    for(int center=0; center<NUM_CENTERS; center++, index++)
237
      {
238 a57e6870 Leszek Koltunski
      CENTERS[index] = computeCenter(center, numL);
239 29b82486 Leszek Koltunski
      }
240
241
    return CENTERS;
242
    }
243
244
///////////////////////////////////////////////////////////////////////////////////////////////////
245
246
  private int getQuat(int cubit, int numCubitsPerCorner, int numCubitsPerEdge)
247
    {
248
    if( mQuatCornerIndices==null || mQuatEdgeIndices==null ) initializeQuatIndices();
249
    if( mQuatCenterIndices==null ) initializeCenterIndices();
250
251
    if( cubit < NUM_CORNERS*numCubitsPerCorner )
252
      {
253
      int corner = cubit/numCubitsPerCorner;
254
      return mQuatCornerIndices[corner];
255
      }
256
257
    if( cubit < NUM_CORNERS*numCubitsPerCorner + NUM_EDGES*numCubitsPerEdge )
258
      {
259
      int edge = (cubit-NUM_CORNERS*numCubitsPerCorner)/numCubitsPerEdge;
260
      return mQuatEdgeIndices[edge];
261
      }
262
263
    int center = cubit - NUM_CORNERS*numCubitsPerCorner - NUM_EDGES*numCubitsPerEdge;
264
    return mQuatCenterIndices[center];
265
    }
266
267
///////////////////////////////////////////////////////////////////////////////////////////////////
268
269 e30c522a Leszek Koltunski
  public ObjectShape getObjectShape(int variant)
270 29b82486 Leszek Koltunski
    {
271 e30c522a Leszek Koltunski
    int[] numLayers = getNumLayers();
272 29b82486 Leszek Koltunski
    int numVariants = getNumCubitVariants(numLayers);
273 e30c522a Leszek Koltunski
    int numL        = numLayers[0];
274 29b82486 Leszek Koltunski
275
    if( variant==0 )
276
      {
277 a57e6870 Leszek Koltunski
      float width = numL*(0.5f-MEGA_D)/(0.5f*(numL-1));
278 29b82486 Leszek Koltunski
      float A = (2*SQ3/3)*SIN54;
279
      float B = 0.4f;
280
      double X = width*COS18*SIN_HALFD;
281
      double Y = width*SIN18;
282
      double Z = width*COS18*COS_HALFD;
283 a57e6870 Leszek Koltunski
      int N = numL==3 ? 1:0;
284 29b82486 Leszek Koltunski
285
      double[][] vertices = new double[][]
286
        {
287
            { 0.0, 0.0      , 0.0 },
288
            {   X,   Y      ,  -Z },
289
            { 0.0, 2*Y      ,-2*Z },
290
            {  -X,   Y      ,  -Z },
291
            { 0.0, 0.0-width, 0.0 },
292
            {   X,   Y-width,  -Z },
293
            { 0.0, 2*Y-width,-2*Z },
294
            {  -X,   Y-width,  -Z },
295
        };
296
297
      int[][] vertIndexes = new int[][]
298
        {
299
            {4,5,1,0},
300
            {7,4,0,3},
301
            {0,1,2,3},
302
            {4,5,6,7},
303
            {6,5,1,2},
304
            {7,6,2,3}
305
        };
306
307
      float[][] bands    = new float[][]
308
        {
309
         {0.04f,34,0.3f,0.2f, 3, N, 0},
310
         {0.00f, 0,0.0f,0.0f, 2, N, 0}
311
        };
312
313
      int[] bandIndices   = new int[] { 0,0,0,1,1,1};
314
      float[][] corners   = new float[][] { {0.04f,0.10f} };
315
      int[] cornerIndices = new int[] { 0,-1,-1,-1,-1,-1,-1,-1 };
316
      float[][] centers   = new float[][] { {0.0f, -(float)Math.sqrt(1-A*A)*B,-A*B} };
317
      int[] centerIndices = new int[] { 0,-1,-1,-1,-1,-1,-1,-1 };
318
319
      return new ObjectShape(vertices,vertIndexes,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
320
      }
321
    if( variant<numVariants-1 )
322
      {
323 e30c522a Leszek Koltunski
      int type = variant-1;
324 a57e6870 Leszek Koltunski
      float height= numL*(0.5f-MEGA_D)*COS18/((numL-1)*0.5f);
325
      float width = numL*2*MEGA_D + 2*type*height*SIN18/COS18;
326 29b82486 Leszek Koltunski
327
      double W = width/2;
328
      double X = height*SIN_HALFD;
329
      double Y = height*SIN18/COS18;
330
      double Z = height*COS_HALFD;
331
332
      double[][] vertices = new double[][]
333
        {
334
            { 0.0,   W   , 0.0 },
335
            {   X, W+Y   ,  -Z },
336
            { 0.0, W+2*Y ,-2*Z },
337
            {  -X, W+Y   ,  -Z },
338
            { 0.0,  -W   , 0.0 },
339
            {   X,-W-Y   ,  -Z },
340
            { 0.0,-W-2*Y ,-2*Z },
341
            {  -X,-W-Y   ,  -Z },
342
        };
343
344
      int[][] vertIndexes = new int[][]
345
        {
346
            {4,5,1,0},
347
            {7,4,0,3},
348
            {7,6,2,3},
349
            {6,5,1,2},
350
            {0,1,2,3},
351
            {4,5,6,7}
352
        };
353
354 a57e6870 Leszek Koltunski
      int N = numL<=5 ? 5 : 3;
355 29b82486 Leszek Koltunski
356 a57e6870 Leszek Koltunski
      float[][] bands = new float[][]
357 29b82486 Leszek Koltunski
        {
358
         {0.04f,34,0.2f,0.2f,N,0,0},
359
         {0.00f, 0,0.3f,0.2f,2,0,0}
360
        };
361
      int[] bandIndices   = new int[] { 0,0,1,1,1,1};
362
      float[][] corners   = new float[][] { {0.04f,0.10f} };
363
      int[] cornerIndices = new int[] { -1,-1,-1,-1, -1,-1,-1,-1 };
364
      float[][] centers   = new float[][] { {0.0f, 0.0f, (float)(-2*Z)} };
365
      int[] centerIndices = new int[] { -1,-1,-1,-1, -1,-1,-1,-1 };
366
367
      return new ObjectShape(vertices,vertIndexes,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
368
      }
369
    else
370
      {
371 a57e6870 Leszek Koltunski
      float width = 2*numL*(MEGA_D+(0.5f-MEGA_D)*SIN18);
372 29b82486 Leszek Koltunski
      final double V = 0.83;   // ??
373
      final double ANGLE = V*Math.PI;
374
      final double cosA  = Math.cos(ANGLE);
375
      final double sinA  = Math.sin(ANGLE);
376
377
      float R  = 0.5f*width/COS54;
378
      float X1 = R*COS54;
379
      float Y1 = R*SIN54;
380
      float X2 = R*COS18;
381
      float Y2 = R*SIN18;
382
383
      double[][] vertices = new double[][]
384
        {
385
          {-X1,+Y1*sinA, Y1*cosA},
386
          {-X2,-Y2*sinA,-Y2*cosA},
387
          {0.0f,-R*sinA, -R*cosA},
388
          {+X2,-Y2*sinA,-Y2*cosA},
389
          {+X1,+Y1*sinA, Y1*cosA}
390
        };
391
392
      int[][] vertIndexes = new int[][]
393
        {
394
          {0,1,2,3,4},
395
          {0,1,2,3,4}
396
        };
397
398 a57e6870 Leszek Koltunski
      int N = numL==3 ? 4 : 3;
399 29b82486 Leszek Koltunski
400
      float[][] bands = new float[][]
401
        {
402
         {0.04f,45, R/3,0.2f,N,0,0},
403
         {0.00f, 0, R/3,0.2f,2,0,0}
404
        };
405
406
      int[] bandIndices   = new int[] { 0,1 };
407
      float[][] corners   = new float[][] { {0.04f,0.10f} };
408
      int[] cornerIndices = new int[] { -1,-1,-1,-1, -1 };
409
      float[][] centers   = new float[][] { {0.0f, 0.0f, 0.0f} };
410
      int[] centerIndices = new int[] { -1,-1,-1,-1, -1 };
411
412
      return new ObjectShape(vertices,vertIndexes,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
413
      }
414
    }
415
416
///////////////////////////////////////////////////////////////////////////////////////////////////
417
418 7b832206 Leszek Koltunski
  public Static4D getQuat(int cubit, int[] numLayers)
419 29b82486 Leszek Koltunski
    {
420
    if( mQuats==null ) initializeQuats();
421 a57e6870 Leszek Koltunski
422
    int numL = numLayers[0];
423
    int numCubitsPerCorner = numCubitsPerCorner(numL);
424
    int numCubitsPerEdge   = numCubitsPerEdge(numL);
425 29b82486 Leszek Koltunski
426
    return mQuats[getQuat(cubit,numCubitsPerCorner,numCubitsPerEdge)];
427
    }
428
429
///////////////////////////////////////////////////////////////////////////////////////////////////
430
431 e30c522a Leszek Koltunski
  public int getNumCubitVariants(int[] numLayers)
432 29b82486 Leszek Koltunski
    {
433 a57e6870 Leszek Koltunski
    switch(numLayers[0])
434 61aa85e4 Leszek Koltunski
      {
435
      case 3: return 3;
436
      case 5: return 4;
437
      }
438 29b82486 Leszek Koltunski
439 61aa85e4 Leszek Koltunski
    return 3;
440 29b82486 Leszek Koltunski
    }
441
442
///////////////////////////////////////////////////////////////////////////////////////////////////
443
444 e30c522a Leszek Koltunski
  public int getCubitVariant(int cubit, int[] numLayers)
445 29b82486 Leszek Koltunski
    {
446 a57e6870 Leszek Koltunski
    int numL = numLayers[0];
447
    int numCubitsPerCorner = numCubitsPerCorner(numL);
448 29b82486 Leszek Koltunski
449
    if( cubit<NUM_CORNERS*numCubitsPerCorner ) return 0;
450
451 a57e6870 Leszek Koltunski
    int numCubitsPerEdge = numCubitsPerEdge(numL);
452 29b82486 Leszek Koltunski
453
    if( cubit<NUM_CORNERS*numCubitsPerCorner + NUM_EDGES*numCubitsPerEdge )
454
      {
455
      int type = computeEdgeType(cubit,numCubitsPerCorner,numCubitsPerEdge);
456
      return type+1;
457
      }
458
459 61aa85e4 Leszek Koltunski
    return getNumCubitVariants(numLayers)-1;
460 29b82486 Leszek Koltunski
    }
461
462
///////////////////////////////////////////////////////////////////////////////////////////////////
463
464
  int getCornerColor(int cubit, int cubitface, int numLayers, int numCubitsPerCorner)
465
    {
466
    if( mCornerFaceMap==null ) initializeCornerFaceMap();
467 a75ae1ee Leszek Koltunski
    if( cubitface<0 || cubitface>2 ) return -1;
468 29b82486 Leszek Koltunski
469
    int part  = cubit % numCubitsPerCorner;
470
    int corner= cubit / numCubitsPerCorner;
471
472
    if( part==0 )
473
      {
474
      return mCornerFaceMap[corner][cubitface];
475
      }
476
    else
477
      {
478
      int N = (numCubitsPerCorner-1)/3;
479
      int block = (part-1) % N;
480
      int index = (part-1) / N;
481
482
      if( block< (numLayers-3)/2 )
483
        {
484
        switch(index)
485
          {
486 a75ae1ee Leszek Koltunski
          case 0: return cubitface==1 ? -1 : mCornerFaceMap[corner][cubitface];
487
          case 1: return cubitface==0 ? -1 : mCornerFaceMap[corner][cubitface];
488
          case 2: return cubitface==2 ? -1 : mCornerFaceMap[corner][cubitface];
489 29b82486 Leszek Koltunski
          }
490
        }
491
      else
492
        {
493
        switch(index)
494
          {
495 a75ae1ee Leszek Koltunski
          case 0: return cubitface==0 ? mCornerFaceMap[corner][cubitface] : -1;
496
          case 1: return cubitface==2 ? mCornerFaceMap[corner][cubitface] : -1;
497
          case 2: return cubitface==1 ? mCornerFaceMap[corner][cubitface] : -1;
498 29b82486 Leszek Koltunski
          }
499
        }
500
      }
501
502
    return NUM_TEXTURES;
503
    }
504
505
///////////////////////////////////////////////////////////////////////////////////////////////////
506
507
  int getEdgeColor(int edge, int cubitface, int numCubitsPerEdge)
508
    {
509 a75ae1ee Leszek Koltunski
    if( cubitface<0 || cubitface>1 ) return -1;
510 29b82486 Leszek Koltunski
511
    int part    = edge % numCubitsPerEdge;
512
    int variant = edge / numCubitsPerEdge;
513
    if( mEdgeMap==null ) initializeEdgeMap();
514
515 a75ae1ee Leszek Koltunski
    return (part==0 || cubitface==((part+1)%2)) ? mEdgeMap[variant][cubitface+2] : -1;
516 29b82486 Leszek Koltunski
    }
517
518
///////////////////////////////////////////////////////////////////////////////////////////////////
519
520 43a4ccff Leszek Koltunski
  int getCenterColor(int center, int cubitface)
521 29b82486 Leszek Koltunski
    {
522 a75ae1ee Leszek Koltunski
    return cubitface>0 ? -1 : center;
523 29b82486 Leszek Koltunski
    }
524
525
///////////////////////////////////////////////////////////////////////////////////////////////////
526
527 a75ae1ee Leszek Koltunski
  public int getCubitFaceColor(int cubit, int face, int[] numLayers)
528 29b82486 Leszek Koltunski
    {
529 a57e6870 Leszek Koltunski
    int numL = numLayers[0];
530
    int numCubitsPerCorner = numCubitsPerCorner(numL);
531
    int numCubitsPerEdge   = numCubitsPerEdge(numL);
532 29b82486 Leszek Koltunski
533
    if( cubit < NUM_CORNERS*numCubitsPerCorner )
534
      {
535 a75ae1ee Leszek Koltunski
      return getCornerColor(cubit,face,numL,numCubitsPerCorner);
536 29b82486 Leszek Koltunski
      }
537
    else if( cubit<NUM_CORNERS*numCubitsPerCorner + NUM_EDGES*numCubitsPerEdge )
538
      {
539
      int edge = cubit - NUM_CORNERS*numCubitsPerCorner;
540 a75ae1ee Leszek Koltunski
      return getEdgeColor(edge,face,numCubitsPerEdge);
541 29b82486 Leszek Koltunski
      }
542
    else
543
      {
544
      int center = cubit-NUM_CORNERS*numCubitsPerCorner-NUM_EDGES*numCubitsPerEdge;
545 a75ae1ee Leszek Koltunski
      return getCenterColor( center, face );
546
      }
547
    }
548
549
///////////////////////////////////////////////////////////////////////////////////////////////////
550
551
  public int getVariantFaceColor(int variant, int face, int[] numLayers)
552
    {
553
    if( variant==0 ) return 0;
554
    else
555
      {
556
      if( variant==getNumCubitVariants(numLayers)-1 ) return 1;
557
      else return variant+1;
558 29b82486 Leszek Koltunski
      }
559
    }
560
561
///////////////////////////////////////////////////////////////////////////////////////////////////
562
563 1bb09f88 Leszek Koltunski
  public ObjectSticker retSticker(int sticker)
564 29b82486 Leszek Koltunski
    {
565
    if( mStickers==null )
566
      {
567 43a4ccff Leszek Koltunski
      float[][] STICKERS;
568
      int[] numLayers = getNumLayers();
569
      int numL = numLayers[0];
570
571
      if( numL==3 )
572 29b82486 Leszek Koltunski
        {
573 43a4ccff Leszek Koltunski
        STICKERS = new float[][]
574
          {
575
            { -0.36327127f, -0.5f, 0.36327127f, -0.26393202f, 0.36327127f, 0.5f, -0.36327127f, 0.26393202f },
576
            { -0.29389262f, 0.4045085f, -0.47552824f, -0.1545085f, 0.0f, -0.5f, 0.47552824f, -0.1545085f, 0.29389262f, 0.4045085f },
577
            { -0.5f, -0.0914315f, 0.5f, -0.4163512f, 0.5f, 0.4163512f, -0.5f, 0.0914315f }
578
          };
579
        }
580
      else
581
        {
582
        STICKERS = new float[][]
583
          {
584
            { -0.36327127f, -0.5f, 0.36327127f, -0.26393202f, 0.36327127f, 0.5f, -0.36327127f, 0.26393202f },
585
            { -0.29389262f, 0.4045085f, -0.47552824f, -0.1545085f, 0.0f, -0.5f, 0.47552824f, -0.1545085f, 0.29389262f, 0.4045085f },
586
            { -0.49233657f, -0.18006028f, 0.49233657f, -0.5f, 0.49233657f, 0.5f, -0.49233657f, 0.18006028f },
587
            { -0.3002273f, -0.30490047f, 0.3002273f, -0.5f, 0.3002273f, 0.5f, -0.3002273f, 0.30490047f }
588
          };
589
        }
590 29b82486 Leszek Koltunski
591
      mStickers = new ObjectSticker[STICKERS.length];
592
593
      final float R0 = 0.08f;
594 43a4ccff Leszek Koltunski
      final float R1 = 0.10f;
595 29b82486 Leszek Koltunski
      final float R2 = 0.12f;
596
      final float R3 = 0.08f;
597 43a4ccff Leszek Koltunski
598
      final float[][] radii = { {R0,R0,R0,R0},{R1,R1,R1,R1,R1},{R2,R2,R2,R2},{R3,R3,R3,R3} };
599
      float[] strokes = { 0.10f,0.065f,0.12f,0.08f };
600 8592461c Leszek Koltunski
601
      if( ObjectControl.isInIconMode() )
602
        {
603 43a4ccff Leszek Koltunski
        float mult = numL==3 ? 1.5f : 2.2f;
604 8592461c Leszek Koltunski
605
        strokes[0]*=mult;
606
        strokes[1]*=mult;
607
        strokes[2]*=mult;
608
        strokes[3]*=mult;
609
        strokes[4]*=mult;
610
        }
611 29b82486 Leszek Koltunski
612
      for(int s=0; s<STICKERS.length; s++)
613
        {
614
        mStickers[s] = new ObjectSticker(STICKERS[s],null,radii[s],strokes[s]);
615
        }
616
      }
617
618 1bb09f88 Leszek Koltunski
    return mStickers[sticker];
619 29b82486 Leszek Koltunski
    }
620
621 61aa85e4 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
622
623 a57e6870 Leszek Koltunski
  public ObjectType intGetObjectType(int[] numLayers)
624 61aa85e4 Leszek Koltunski
    {
625 a57e6870 Leszek Koltunski
    switch(numLayers[0])
626 61aa85e4 Leszek Koltunski
      {
627 8005e762 Leszek Koltunski
      case 3: return ObjectType.MEGA_3;
628
      case 5: return ObjectType.MEGA_5;
629 61aa85e4 Leszek Koltunski
      }
630
631 8005e762 Leszek Koltunski
    return ObjectType.MEGA_3;
632 61aa85e4 Leszek Koltunski
    }
633
634 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
635
636 a57e6870 Leszek Koltunski
  public int getObjectName(int[] numLayers)
637 29b82486 Leszek Koltunski
    {
638 a57e6870 Leszek Koltunski
    int numL = numLayers[0];
639
640
    if( numL==3 ) return R.string.minx3;
641
    if( numL==5 ) return R.string.minx5;
642 29b82486 Leszek Koltunski
643
    return 0;
644
    }
645
646
///////////////////////////////////////////////////////////////////////////////////////////////////
647
648 a57e6870 Leszek Koltunski
  public int getInventor(int[] numLayers)
649 29b82486 Leszek Koltunski
    {
650 a57e6870 Leszek Koltunski
    int numL = numLayers[0];
651
652
    if( numL==3 ) return R.string.minx3_inventor;
653
    if( numL==5 ) return R.string.minx5_inventor;
654 29b82486 Leszek Koltunski
655
    return 0;
656
    }
657
658 59c20632 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
659
660
  public int getYearOfInvention(int[] numLayers)
661
    {
662
    switch(numLayers[0])
663
      {
664
      case 3: return 1982;
665
      case 5: return 2006;
666
      }
667
    return 1982;
668
    }
669
670 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
671
672 a57e6870 Leszek Koltunski
  public int getComplexity(int[] numLayers)
673 29b82486 Leszek Koltunski
    {
674 a57e6870 Leszek Koltunski
    int numL = numLayers[0];
675
676
    if( numL==3 ) return 7;
677
    if( numL==5 ) return 9;
678 29b82486 Leszek Koltunski
679 a57e6870 Leszek Koltunski
    return 9;
680 29b82486 Leszek Koltunski
    }
681
}