Project

General

Profile

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

magiccube / src / main / java / org / distorted / objects / TwistyBandagedAbstract.java @ be56193c

1 4c0a6d97 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2021 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
import android.graphics.Canvas;
24
import android.graphics.Paint;
25
26 749ef882 Leszek Koltunski
import org.distorted.helpers.FactoryCubit;
27
import org.distorted.helpers.FactorySticker;
28 4c0a6d97 Leszek Koltunski
import org.distorted.library.effect.MatrixEffectQuaternion;
29 be56193c Leszek Koltunski
import org.distorted.library.effect.VertexEffect;
30
import org.distorted.library.effect.VertexEffectMove;
31
import org.distorted.library.effect.VertexEffectRotate;
32
import org.distorted.library.effect.VertexEffectScale;
33 4c0a6d97 Leszek Koltunski
import org.distorted.library.main.DistortedEffects;
34
import org.distorted.library.main.DistortedTexture;
35
import org.distorted.library.mesh.MeshBase;
36 be56193c Leszek Koltunski
import org.distorted.library.mesh.MeshJoined;
37
import org.distorted.library.mesh.MeshPolygon;
38 4c0a6d97 Leszek Koltunski
import org.distorted.library.mesh.MeshSquare;
39 be56193c Leszek Koltunski
import org.distorted.library.type.Static1D;
40 4c0a6d97 Leszek Koltunski
import org.distorted.library.type.Static3D;
41
import org.distorted.library.type.Static4D;
42
43
///////////////////////////////////////////////////////////////////////////////////////////////////
44
45 538ee7a6 Leszek Koltunski
abstract class TwistyBandagedAbstract extends TwistyObject
46 4c0a6d97 Leszek Koltunski
{
47
  // the three rotation axis of a 3x3 Cube. Must be normalized.
48
  static final Static3D[] ROT_AXIS = new Static3D[]
49
         {
50
           new Static3D(1,0,0),
51
           new Static3D(0,1,0),
52
           new Static3D(0,0,1)
53
         };
54
55
  private static final int[] FACE_COLORS = new int[]
56
         {
57
           COLOR_YELLOW, COLOR_WHITE,
58
           COLOR_BLUE  , COLOR_GREEN,
59
           COLOR_RED   , COLOR_ORANGE
60
         };
61
62
  private static final Static4D[] QUATS = new Static4D[]
63
         {
64
         new Static4D(  0.0f,   0.0f,   0.0f,   1.0f),
65
         new Static4D(  1.0f,   0.0f,   0.0f,   0.0f),
66
         new Static4D(  0.0f,   1.0f,   0.0f,   0.0f),
67
         new Static4D(  0.0f,   0.0f,   1.0f,   0.0f),
68
69
         new Static4D( SQ2/2,  SQ2/2,  0.0f ,   0.0f),
70
         new Static4D( SQ2/2, -SQ2/2,  0.0f ,   0.0f),
71
         new Static4D( SQ2/2,   0.0f,  SQ2/2,   0.0f),
72
         new Static4D(-SQ2/2,   0.0f,  SQ2/2,   0.0f),
73
         new Static4D( SQ2/2,   0.0f,   0.0f,  SQ2/2),
74
         new Static4D( SQ2/2,   0.0f,   0.0f, -SQ2/2),
75
         new Static4D(  0.0f,  SQ2/2,  SQ2/2,   0.0f),
76
         new Static4D(  0.0f,  SQ2/2, -SQ2/2,   0.0f),
77
         new Static4D(  0.0f,  SQ2/2,   0.0f,  SQ2/2),
78
         new Static4D(  0.0f,  SQ2/2,   0.0f, -SQ2/2),
79
         new Static4D(  0.0f,   0.0f,  SQ2/2,  SQ2/2),
80
         new Static4D(  0.0f,   0.0f,  SQ2/2, -SQ2/2),
81
82
         new Static4D(  0.5f,   0.5f,   0.5f,   0.5f),
83
         new Static4D(  0.5f,   0.5f,  -0.5f,   0.5f),
84
         new Static4D(  0.5f,   0.5f,  -0.5f,  -0.5f),
85
         new Static4D(  0.5f,  -0.5f,   0.5f,  -0.5f),
86
         new Static4D( -0.5f,  -0.5f,  -0.5f,   0.5f),
87
         new Static4D( -0.5f,   0.5f,  -0.5f,  -0.5f),
88
         new Static4D( -0.5f,   0.5f,   0.5f,  -0.5f),
89
         new Static4D( -0.5f,   0.5f,   0.5f,   0.5f)
90
         };
91
92 538ee7a6 Leszek Koltunski
  private static final Static4D[] INIT_QUATS = new Static4D[]
93 4c0a6d97 Leszek Koltunski
        {
94
        new Static4D(  0.0f,   0.0f,   0.0f,   1.0f),  // NULL
95 538ee7a6 Leszek Koltunski
        new Static4D( SQ2/2,   0.0f,   0.0f, -SQ2/2),  // X
96
        new Static4D(  0.0f,  SQ2/2,   0.0f, -SQ2/2),  // Y
97
        new Static4D(  0.0f,   0.0f,  SQ2/2, -SQ2/2),  // Z
98
        new Static4D( -0.5f,  +0.5f,  -0.5f,  +0.5f),  // ZX
99
        new Static4D( +0.5f,  +0.5f,  +0.5f,  -0.5f),  // YX
100
        };
101
102
  private static final int[][] mDimensions = new int[][]
103
        {
104
         {1,1,1},  // has to be X>=Z>=Y so that all
105
         {2,1,1},  // the faces are horizontal
106
         {3,1,1},
107
         {2,1,2},
108
         {2,2,2}
109 4c0a6d97 Leszek Koltunski
        };
110
111 538ee7a6 Leszek Koltunski
  private static final int[][] mStickerDimensions = new int[][]
112
        {
113
         {1,1},  // dimensions of the faces of
114
         {2,1},  // the cuboids defined above
115
         {3,1},
116
         {2,2}
117
        };
118
119
  private static final int[][] mFaceMap = new int[][] // cubitface=2 when rotated by
120
    {                                                 // quatIndex=1 gets moved to
121
        {0,0,5,2,4,2},                                // position mFaceMap[2][1]
122
        {1,1,4,3,5,3},
123
        {2,4,2,1,1,4},
124
        {3,5,3,0,0,5},
125
        {4,3,0,4,3,0},
126
        {5,2,1,5,2,1}
127
    };
128
129
  private static final int[][] mAxisMap = new int[][] // axis=1 when rotated by
130
    {                                                 // quatIndex=2 gets moved to
131
        {0,0,2,1,2,1},                                // axis mAxisMap[1][2]
132
        {1,2,1,0,0,2},
133
        {2,1,0,2,1,0}
134
    };
135
136
  private static final int NUM_STICKERS = mStickerDimensions.length;
137
138 4c0a6d97 Leszek Koltunski
  private static MeshBase[] mMeshes;
139
140
///////////////////////////////////////////////////////////////////////////////////////////////////
141
142 538ee7a6 Leszek Koltunski
  TwistyBandagedAbstract(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
143
                         DistortedEffects effects, int[][] moves, ObjectList list, Resources res, int scrWidth)
144 4c0a6d97 Leszek Koltunski
    {
145
    super(size, size, quat, texture, mesh, effects, moves, list, res, scrWidth);
146
    }
147
148
///////////////////////////////////////////////////////////////////////////////////////////////////
149
150 68ce0d53 Leszek Koltunski
  abstract float[][] getPositions();
151
  abstract int[] getQuatIndices();
152
153
///////////////////////////////////////////////////////////////////////////////////////////////////
154
155
  int getCubitVariant(int cubit)
156
    {
157
    float[][] pos = getPositions();
158
159
    if( cubit>=0 && cubit< pos.length )
160
      {
161
      int numPoints = pos[cubit].length/3;
162 10cd5579 Leszek Koltunski
      return numPoints==8 ? 4 : numPoints-1;
163 68ce0d53 Leszek Koltunski
      }
164
165
    return 1;
166
    }
167
168
///////////////////////////////////////////////////////////////////////////////////////////////////
169
170
  int getNumCubits()
171
    {
172
    return getPositions().length;
173
    }
174
175
///////////////////////////////////////////////////////////////////////////////////////////////////
176
177
  float[] getCubitPosition(int cubit)
178
    {
179
    float[][] pos = getPositions();
180
181
    return ( cubit>=0 && cubit< pos.length ) ? pos[cubit] : null;
182
    }
183
184
///////////////////////////////////////////////////////////////////////////////////////////////////
185
186 10cd5579 Leszek Koltunski
  private int getQuatIndex(int cubit)
187 68ce0d53 Leszek Koltunski
    {
188
    int[] indices = getQuatIndices();
189
190
    return ( cubit>=0 && cubit< indices.length ) ? indices[cubit] : 0;
191
    }
192 4c0a6d97 Leszek Koltunski
193 be56193c Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
194
195
  private float[] createVertices(int A, int B)
196
    {
197
    float E = 0.5f / Math.max(A,B);
198
    return new float[] { -A*E,-B*E, +A*E,-B*E, +A*E,+B*E, -A*E,+B*E };
199
    }
200
201
///////////////////////////////////////////////////////////////////////////////////////////////////
202
203
  private MeshBase createCuboid(int[] dimensions)
204
    {
205
    FactoryCubit factory = FactoryCubit.getInstance();
206
207
    int X = dimensions[0];
208
    int Y = dimensions[1];
209
    int Z = dimensions[2];
210
211
    float[] verticesXY = createVertices(X,Y);
212
    float[] verticesXZ = createVertices(X,Z);
213
    float[] verticesYZ = createVertices(Z,Y);
214
215
    float defHeight = 0.048f;
216
217
    float[] bandsX = factory.computeBands( defHeight/X,65,0.25f,0.5f,5);
218
    float[] bandsY = factory.computeBands( defHeight/Y,65,0.25f,0.5f,5);
219
    float[] bandsZ = factory.computeBands( defHeight/Z,65,0.25f,0.5f,5);
220
221
    MeshBase[] meshes = new MeshPolygon[6];
222
223
    meshes[0] = new MeshPolygon(verticesYZ,bandsX,1,2);
224
    meshes[0].setEffectAssociation(0,1,0);
225
    meshes[1] = meshes[0].copy(true);
226
    meshes[1].setEffectAssociation(0,2,0);
227
    meshes[2] = new MeshPolygon(verticesXZ,bandsY,1,2);
228
    meshes[2].setEffectAssociation(0,4,0);
229
    meshes[3] = meshes[2].copy(true);
230
    meshes[3].setEffectAssociation(0,8,0);
231
    meshes[4] = new MeshPolygon(verticesXY,bandsZ,1,2);
232
    meshes[4].setEffectAssociation(0,16,0);
233
    meshes[5] = meshes[4].copy(true);
234
    meshes[5].setEffectAssociation(0,32,0);
235
236
    return new MeshJoined(meshes);
237
    }
238
239
///////////////////////////////////////////////////////////////////////////////////////////////////
240
241
  private VertexEffect[] createCuboidEffects(int[] dimensions)
242
    {
243
    float X = dimensions[0];
244
    float Y = dimensions[1];
245
    float Z = dimensions[2];
246
247
    float MAX_XY = Math.max(X,Y);
248
    float MAX_XZ = Math.max(X,Z);
249
    float MAX_YZ = Math.max(Z,Y);
250
251
    Static1D angle = new Static1D(90);
252
    Static3D move  = new Static3D( 0.0f, 0.0f, 0.5f);
253
    Static3D axisX = new Static3D( 1.0f, 0.0f, 0.0f);
254
    Static3D axisY = new Static3D( 0.0f, 1.0f, 0.0f);
255
    Static3D center= new Static3D( 0.0f, 0.0f, 0.0f);
256
257
    Static3D scale3 = new Static3D(MAX_XY,MAX_XY,+Z);
258
    Static3D scale4 = new Static3D(MAX_XY,MAX_XY,-Z);
259
    Static3D scale5 = new Static3D(MAX_XZ,+Y,MAX_XZ);
260
    Static3D scale6 = new Static3D(MAX_XZ,-Y,MAX_XZ);
261
    Static3D scale7 = new Static3D(+X,MAX_YZ,MAX_YZ);
262
    Static3D scale8 = new Static3D(-X,MAX_YZ,MAX_YZ);
263
264
    VertexEffect[] effect = new VertexEffect[9];
265
266
    effect[0] = new VertexEffectMove(move);
267
    effect[1] = new VertexEffectRotate(angle, axisX, center);
268
    effect[2] = new VertexEffectRotate(angle, axisY, center);
269
    effect[3] = new VertexEffectScale(scale3);
270
    effect[4] = new VertexEffectScale(scale4);
271
    effect[5] = new VertexEffectScale(scale5);
272
    effect[6] = new VertexEffectScale(scale6);
273
    effect[7] = new VertexEffectScale(scale7);
274
    effect[8] = new VertexEffectScale(scale8);
275
276
    effect[1].setMeshAssociation(12,-1);  // meshes 2,3
277
    effect[2].setMeshAssociation( 3,-1);  // meshes 0,1
278
    effect[3].setMeshAssociation(16,-1);  // mesh 4
279
    effect[4].setMeshAssociation(32,-1);  // mesh 5
280
    effect[5].setMeshAssociation( 8,-1);  // mesh 3
281
    effect[6].setMeshAssociation( 4,-1);  // mesh 2
282
    effect[7].setMeshAssociation( 1,-1);  // mesh 0
283
    effect[8].setMeshAssociation( 2,-1);  // mesh 1
284
285
    return effect;
286
    }
287
288
///////////////////////////////////////////////////////////////////////////////////////////////////
289
290
  private MeshBase createCuboidMesh(int[] dimensions)
291
    {
292
    MeshBase mesh = createCuboid(dimensions);
293
    VertexEffect[] effects = createCuboidEffects(dimensions);
294
    for( VertexEffect effect : effects ) mesh.apply(effect);
295
296
    int X = dimensions[0];
297
    int Y = dimensions[1];
298
    int Z = dimensions[2];
299
300
    float strength = 0.04f;
301
    float radius   = 0.15f;
302
303
    Static3D[] vertices = new Static3D[1];
304
    Static3D center;
305
    FactoryCubit factory = FactoryCubit.getInstance();
306
307
    vertices[0] = new Static3D(+0.5f*X,+0.5f*Y,+0.5f*Z);
308
    center = new Static3D(+0.5f*(X-1),+0.5f*(Y-1),+0.5f*(Z-1));
309
    factory.roundCorners(mesh, center, vertices, strength, radius);
310
311
    vertices[0] = new Static3D(+0.5f*X,+0.5f*Y,-0.5f*Z);
312
    center = new Static3D(+0.5f*(X-1),+0.5f*(Y-1),-0.5f*(Z-1));
313
    factory.roundCorners(mesh, center, vertices, strength, radius);
314
315
    vertices[0] = new Static3D(+0.5f*X,-0.5f*Y,+0.5f*Z);
316
    center = new Static3D(+0.5f*(X-1),-0.5f*(Y-1),+0.5f*(Z-1));
317
    factory.roundCorners(mesh, center, vertices, strength, radius);
318
319
    vertices[0] = new Static3D(+0.5f*X,-0.5f*Y,-0.5f*Z);
320
    center = new Static3D(+0.5f*(X-1),-0.5f*(Y-1),-0.5f*(Z-1));
321
    factory.roundCorners(mesh, center, vertices, strength, radius);
322
323
    vertices[0] = new Static3D(-0.5f*X,+0.5f*Y,+0.5f*Z);
324
    center = new Static3D(-0.5f*(X-1),+0.5f*(Y-1),+0.5f*(Z-1));
325
    factory.roundCorners(mesh, center, vertices, strength, radius);
326
327
    vertices[0] = new Static3D(-0.5f*X,+0.5f*Y,-0.5f*Z);
328
    center = new Static3D(-0.5f*(X-1),+0.5f*(Y-1),-0.5f*(Z-1));
329
    factory.roundCorners(mesh, center, vertices, strength, radius);
330
331
    vertices[0] = new Static3D(-0.5f*X,-0.5f*Y,+0.5f*Z);
332
    center = new Static3D(-0.5f*(X-1),-0.5f*(Y-1),+0.5f*(Z-1));
333
    factory.roundCorners(mesh, center, vertices, strength, radius);
334
335
    vertices[0] = new Static3D(-0.5f*X,-0.5f*Y,-0.5f*Z);
336
    center = new Static3D(-0.5f*(X-1),-0.5f*(Y-1),-0.5f*(Z-1));
337
    factory.roundCorners(mesh, center, vertices, strength, radius);
338
339
    mesh.mergeEffComponents();
340
341
    return mesh;
342
    }
343
344 4c0a6d97 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
345
346
  MeshBase createCubitMesh(int cubit, int numLayers)
347
    {
348
    if( mMeshes==null )
349
      {
350 538ee7a6 Leszek Koltunski
      int LEN = mDimensions.length;
351
      mMeshes = new MeshBase[LEN];
352 4c0a6d97 Leszek Koltunski
353 538ee7a6 Leszek Koltunski
      for(int i=0; i<LEN; i++)
354
        {
355 be56193c Leszek Koltunski
        mMeshes[i] = createCuboidMesh(mDimensions[i]);
356 538ee7a6 Leszek Koltunski
        }
357 4c0a6d97 Leszek Koltunski
      }
358
359 538ee7a6 Leszek Koltunski
    int variant = getCubitVariant(cubit);
360 4c0a6d97 Leszek Koltunski
    MeshBase mesh = mMeshes[variant].copy(true);
361
    MatrixEffectQuaternion quat = new MatrixEffectQuaternion( INIT_QUATS[getQuatIndex(cubit)], new Static3D(0,0,0) );
362
    mesh.apply(quat,0xffffffff,0);
363
364
    return mesh;
365
    }
366
367
///////////////////////////////////////////////////////////////////////////////////////////////////
368
369
  void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top)
370
    {
371
    int numFaces = FACE_COLORS.length;
372
    int stickerType = face/numFaces;
373 538ee7a6 Leszek Koltunski
    int color = face%numFaces;
374
    float X = mStickerDimensions[stickerType][0];
375
    float Y = mStickerDimensions[stickerType][1];
376
    float MAX = Math.max(X,Y);
377
    float R = 0.10f / MAX;
378
    float S = 0.08f / MAX;
379
    X /= (2*MAX);
380
    Y /= (2*MAX);
381 4c0a6d97 Leszek Koltunski
382
    float[] vertices = { -X,-Y, +X,-Y, +X,+Y, -X,+Y};
383
384
    FactorySticker factory = FactorySticker.getInstance();
385 538ee7a6 Leszek Koltunski
    factory.drawRoundedPolygon(canvas, paint, left, top, vertices, S, FACE_COLORS[color], R);
386 4c0a6d97 Leszek Koltunski
    }
387
388
///////////////////////////////////////////////////////////////////////////////////////////////////
389
390 e6cf7283 Leszek Koltunski
  float[][] getCubitPositions(int size)
391 4c0a6d97 Leszek Koltunski
    {
392
    int numCubits = getNumCubits();
393 e6cf7283 Leszek Koltunski
    float[][] tmp = new float[numCubits][];
394 4c0a6d97 Leszek Koltunski
395
    for(int cubit=0; cubit<numCubits; cubit++)
396
      {
397 e6cf7283 Leszek Koltunski
      tmp[cubit] = getCubitPosition(cubit);
398 4c0a6d97 Leszek Koltunski
      }
399
400
    return tmp;
401
    }
402
403
///////////////////////////////////////////////////////////////////////////////////////////////////
404
405
  Static4D[] getQuats()
406
    {
407
    return QUATS;
408
    }
409
410
///////////////////////////////////////////////////////////////////////////////////////////////////
411
412
  boolean shouldResetTextureMaps()
413
    {
414
    return false;
415
    }
416
417
///////////////////////////////////////////////////////////////////////////////////////////////////
418
419
  int getNumFaces()
420
    {
421
    return FACE_COLORS.length;
422
    }
423
424
///////////////////////////////////////////////////////////////////////////////////////////////////
425
426
  float[] getCuts(int numLayers)
427
    {
428
    float[] cuts = new float[numLayers-1];
429
430
    for(int i=0; i<numLayers-1; i++)
431
      {
432
      cuts[i] = (2-numLayers)*0.5f + i;
433
      }
434
435
    return cuts;
436
    }
437
438
///////////////////////////////////////////////////////////////////////////////////////////////////
439
440
  int getNumStickerTypes(int numLayers)
441
    {
442 538ee7a6 Leszek Koltunski
    return NUM_STICKERS;
443 4c0a6d97 Leszek Koltunski
    }
444
445
///////////////////////////////////////////////////////////////////////////////////////////////////
446
447
  int getNumCubitFaces()
448
    {
449
    return FACE_COLORS.length;
450
    }
451
452
///////////////////////////////////////////////////////////////////////////////////////////////////
453
454
  float getScreenRatio()
455
    {
456
    return 0.5f;
457
    }
458
459
///////////////////////////////////////////////////////////////////////////////////////////////////
460
461 538ee7a6 Leszek Koltunski
  private int retStickerIndex(int horzSize, int vertSize)
462 4c0a6d97 Leszek Koltunski
    {
463 538ee7a6 Leszek Koltunski
    switch(horzSize)
464 4c0a6d97 Leszek Koltunski
      {
465 538ee7a6 Leszek Koltunski
      case 1: return 0;
466
      case 2: return vertSize==1 ? 1:3;
467
      case 3: return 2;
468 4c0a6d97 Leszek Koltunski
      }
469
470 538ee7a6 Leszek Koltunski
    return 0;
471
    }
472 4c0a6d97 Leszek Koltunski
473 538ee7a6 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
474
475
  private int getStickerIndex(int cubitface, int[] dim)
476
    {
477 4c0a6d97 Leszek Koltunski
    switch(cubitface)
478
      {
479 538ee7a6 Leszek Koltunski
      case 0: case 1: return retStickerIndex(dim[2],dim[1]);
480
      case 2: case 3: return retStickerIndex(dim[0],dim[2]);
481
      case 4: case 5: return retStickerIndex(dim[0],dim[1]);
482 4c0a6d97 Leszek Koltunski
      }
483
484 538ee7a6 Leszek Koltunski
    return 0;
485
    }
486
487
///////////////////////////////////////////////////////////////////////////////////////////////////
488
489
  int getFaceColor(int cubit, int cubitface, int numLayers)
490
    {
491
    int variant      = getCubitVariant(cubit);
492
    int[] dim        = mDimensions[variant];
493
    float[] pos      = getCubitPosition(cubit);
494
    int stickerIndex = getStickerIndex(cubitface,dim);
495
    int quatIndex    = getQuatIndex(cubit);
496
    int face         = mFaceMap[cubitface][quatIndex];
497
    int multiplier   = (face%2)==0 ? 1:-1;
498
    int posIndex     = face/2;
499
    int dimIndex     = mAxisMap[posIndex][quatIndex];
500 92ec91b9 Leszek Koltunski
501
    float position = 0.0f;
502
    int len = pos.length/3;
503
    for(int i=0; i<len; i++) position += pos[3*i+posIndex];
504
    position /= len;
505
506
    boolean reaches  = multiplier*position + dim[dimIndex]*0.5f > (numLayers-1)*0.5f;
507 538ee7a6 Leszek Koltunski
508 f0450fcc Leszek Koltunski
    return reaches ? stickerIndex*NUM_FACES + face : NUM_STICKERS*NUM_FACES;
509 4c0a6d97 Leszek Koltunski
    }
510
511 ce366b42 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
512
513
  int computeBitmapFromRow(int rowBitmap, int axis)
514
    {
515
    int bitmap, initBitmap=0;
516
517
    while( initBitmap!=rowBitmap )
518
      {
519
      initBitmap = rowBitmap;
520
521
      for(int cubit=0; cubit<NUM_CUBITS; cubit++)
522
        {
523
        bitmap = CUBITS[cubit].mRotationRow[axis];
524
        if( (rowBitmap & bitmap) != 0 ) rowBitmap |= bitmap;
525
        }
526
      }
527
528
    return rowBitmap;
529
    }
530
531 4c0a6d97 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
532
533
  float returnMultiplier()
534
    {
535
    return getNumLayers();
536
    }
537
538
///////////////////////////////////////////////////////////////////////////////////////////////////
539
540
  float[] getRowChances(int numLayers)
541
    {
542
    float[] chances = new float[numLayers];
543
544
    for(int i=0; i<numLayers; i++)
545
      {
546
      chances[i] = (i+1.0f) / numLayers;
547
      }
548
549
    return chances;
550
    }
551
552
///////////////////////////////////////////////////////////////////////////////////////////////////
553
// PUBLIC API
554
555
  public Static3D[] getRotationAxis()
556
    {
557
    return ROT_AXIS;
558
    }
559
560
///////////////////////////////////////////////////////////////////////////////////////////////////
561
562
  public int getBasicAngle()
563
    {
564
    return 4;
565
    }
566
567
///////////////////////////////////////////////////////////////////////////////////////////////////
568
569
  public boolean isSolved()
570
    {
571
    int index = CUBITS[0].mQuatIndex;
572
573
    for(int i=1; i<NUM_CUBITS; i++)
574
      {
575 722b2512 Leszek Koltunski
      if( thereIsVisibleDifference(CUBITS[i], index) ) return false;
576 4c0a6d97 Leszek Koltunski
      }
577
578
    return true;
579
    }
580
581
///////////////////////////////////////////////////////////////////////////////////////////////////
582 538ee7a6 Leszek Koltunski
// only needed for solvers - there are no Bandaged solvers ATM)
583 4c0a6d97 Leszek Koltunski
584
  public String retObjectString()
585
    {
586
    return "";
587
    }
588
}