Project

General

Profile

« Previous | Next » 

Revision abf36986

Added by Leszek Koltunski about 3 years ago

Add Mirror Cube 2x2 and 3x3.

View differences:

src/main/java/org/distorted/objects/ObjectList.java
246 246
         60
247 247
       ),
248 248

  
249
  MIRR (
250
         new int[][] {
251
                       {2 , 12, 12, 0, R.drawable.ui_small_cube2, R.drawable.ui_medium_cube2, R.drawable.ui_big_cube2, R.drawable.ui_huge_cube2} ,
252
                       {3 , 16, 17, 0, R.drawable.ui_small_cube3, R.drawable.ui_medium_cube3, R.drawable.ui_big_cube3, R.drawable.ui_huge_cube3} ,
253
                     },
254
         TwistyMirror.class,
255
         new MovementCube(),
256
         7,
257
         60
258
       ),
249 259
  ;
250 260

  
251 261
  public static final int NUM_OBJECTS = values().length;
......
673 683
      case 17: return new TwistyBandagedEvil  (size, quat, texture, mesh, effects, moves, res, scrWidth);
674 684
      case 18: return new TwistySquare1       (size, quat, texture, mesh, effects, moves, res, scrWidth);
675 685
      case 19: return new TwistySquare2       (size, quat, texture, mesh, effects, moves, res, scrWidth);
686
      case 20: return new TwistyMirror        (size, quat, texture, mesh, effects, moves, res, scrWidth);
676 687
      }
677 688

  
678 689
    return null;
src/main/java/org/distorted/objects/TwistyBandagedAbstract.java
296 296
        }
297 297
      }
298 298

  
299
    return mStickers[face/NUM_FACES];
299
    return mStickers[face/NUM_FACE_COLORS];
300 300
    }
301 301

  
302 302
///////////////////////////////////////////////////////////////////////////////////////////////////
......
331 331

  
332 332
///////////////////////////////////////////////////////////////////////////////////////////////////
333 333

  
334
  int getNumFaces()
334
  int getNumFaceColors()
335 335
    {
336 336
    return FACE_COLORS.length;
337 337
    }
......
450 450

  
451 451
    boolean reaches  = multiplier*position + dim[dimIndex]*0.5f > (numLayers-1)*0.5f;
452 452

  
453
    return reaches ? stickerIndex*NUM_FACES + face : NUM_TEXTURES;
453
    return reaches ? stickerIndex*NUM_FACE_COLORS + face : NUM_TEXTURES;
454 454
    }
455 455

  
456 456
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyCube.java
252 252
      mStickers[0] = new ObjectSticker(STICKERS[0],null,radii,stroke );
253 253
      }
254 254

  
255
    return mStickers[face/NUM_FACES];
255
    return mStickers[face/NUM_FACE_COLORS];
256 256
    }
257 257

  
258 258
///////////////////////////////////////////////////////////////////////////////////////////////////
......
293 293

  
294 294
///////////////////////////////////////////////////////////////////////////////////////////////////
295 295

  
296
  int getNumFaces()
296
  int getNumFaceColors()
297 297
    {
298 298
    return FACE_COLORS.length;
299 299
    }
src/main/java/org/distorted/objects/TwistyDiamond.java
144 144

  
145 145
///////////////////////////////////////////////////////////////////////////////////////////////////
146 146

  
147
  int getNumFaces()
147
  int getNumFaceColors()
148 148
    {
149 149
    return FACE_COLORS.length;
150 150
    }
......
502 502
      mStickers[0]  = new ObjectSticker(STICKERS[0],null,radii,stroke);
503 503
      }
504 504

  
505
    return mStickers[face/NUM_FACES];
505
    return mStickers[face/NUM_FACE_COLORS];
506 506
    }
507 507

  
508 508
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyDino.java
102 102

  
103 103
///////////////////////////////////////////////////////////////////////////////////////////////////
104 104

  
105
  int getNumFaces()
105
  int getNumFaceColors()
106 106
    {
107 107
    return FACE_COLORS.length;
108 108
    }
......
213 213
      mStickers[0]  = new ObjectSticker(STICKERS[0],null,radii,stroke);
214 214
      }
215 215

  
216
    return mStickers[face/NUM_FACES];
216
    return mStickers[face/NUM_FACE_COLORS];
217 217
    }
218 218

  
219 219
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyHelicopter.java
166 166

  
167 167
///////////////////////////////////////////////////////////////////////////////////////////////////
168 168

  
169
  int getNumFaces()
169
  int getNumFaceColors()
170 170
    {
171 171
    return FACE_COLORS.length;
172 172
    }
......
417 417
      mStickers[0] = new ObjectSticker(STICKERS[0],null,radii,stroke);
418 418
      }
419 419

  
420
    return mStickers[face/NUM_FACES];
420
    return mStickers[face/NUM_FACE_COLORS];
421 421
    }
422 422

  
423 423
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyIvy.java
142 142

  
143 143
///////////////////////////////////////////////////////////////////////////////////////////////////
144 144

  
145
  int getNumFaces()
145
  int getNumFaceColors()
146 146
    {
147 147
    return FACE_COLORS.length;
148 148
    }
......
448 448
      for(int s=0; s<NUM_STICKERS; s++) mStickers[s] = new ObjectSticker(STICKERS[s], angles[s],radii[s],strokes[s]);
449 449
      }
450 450

  
451
    return mStickers[face/NUM_FACES];
451
    return mStickers[face/NUM_FACE_COLORS];
452 452
    }
453 453

  
454 454
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyJing.java
156 156

  
157 157
///////////////////////////////////////////////////////////////////////////////////////////////////
158 158

  
159
  int getNumFaces()
159
  int getNumFaceColors()
160 160
    {
161 161
    return FACE_COLORS.length;
162 162
    }
......
401 401
        }
402 402
      }
403 403

  
404
    return mStickers[face/NUM_FACES];
404
    return mStickers[face/NUM_FACE_COLORS];
405 405
    }
406 406

  
407 407
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyKilominx.java
617 617

  
618 618
    part /=2;
619 619

  
620
    return (part==0 || cubitface==((part+1)%2)) ? mEdgeMap[variant][cubitface+2] + ((part+3)/2)*NUM_FACES : NUM_TEXTURES;
620
    return (part==0 || cubitface==((part+1)%2)) ? mEdgeMap[variant][cubitface+2] + ((part+3)/2)*NUM_FACE_COLORS : NUM_TEXTURES;
621 621
    }
622 622

  
623 623
///////////////////////////////////////////////////////////////////////////////////////////////////
......
632 632
      return cubitface>=0 && cubitface<3 ? mCornerFaceMap[center][cubitface] : NUM_TEXTURES;
633 633
      }
634 634

  
635
    return cubitface==mCenterFaceMap[center] ? center/5 + NUM_FACES*(numLayers-1)/2 : NUM_TEXTURES;
635
    return cubitface==mCenterFaceMap[center] ? center/5 + NUM_FACE_COLORS*(numLayers-1)/2 : NUM_TEXTURES;
636 636
    }
637 637

  
638 638
///////////////////////////////////////////////////////////////////////////////////////////////////
......
712 712

  
713 713
  private int getStickerIndex(int face)
714 714
    {
715
    int variant = face/NUM_FACES;
715
    int variant = face/NUM_FACE_COLORS;
716 716
    int numLayers = getNumLayers();
717 717

  
718 718
    if( variant == (numLayers-1)/2 || numLayers==3 ) return 0;
src/main/java/org/distorted/objects/TwistyMegaminx.java
529 529
    int variant = edge / numCubitsPerEdge;
530 530
    if( mEdgeMap==null ) initializeEdgeMap();
531 531

  
532
    return (part==0 || cubitface==((part+1)%2)) ? mEdgeMap[variant][cubitface+2] + ((part+3)/2)*NUM_FACES : NUM_TEXTURES;
532
    return (part==0 || cubitface==((part+1)%2)) ? mEdgeMap[variant][cubitface+2] + ((part+3)/2)*NUM_FACE_COLORS : NUM_TEXTURES;
533 533
    }
534 534

  
535 535
///////////////////////////////////////////////////////////////////////////////////////////////////
536 536

  
537 537
  int getCenterColor(int center, int cubitface, int numLayers)
538 538
    {
539
    return cubitface>0 ? NUM_TEXTURES : center + NUM_FACES*(numLayers+1)/2;
539
    return cubitface>0 ? NUM_TEXTURES : center + NUM_FACE_COLORS*(numLayers+1)/2;
540 540
    }
541 541

  
542 542
///////////////////////////////////////////////////////////////////////////////////////////////////
......
607 607

  
608 608
  private int getStickerIndex(int face)
609 609
    {
610
    int variant = face/NUM_FACES;
610
    int variant = face/NUM_FACE_COLORS;
611 611

  
612 612
    if( variant==0 ) return 0;
613 613

  
src/main/java/org/distorted/objects/TwistyMinx.java
524 524

  
525 525
///////////////////////////////////////////////////////////////////////////////////////////////////
526 526

  
527
  int getNumFaces()
527
  int getNumFaceColors()
528 528
    {
529 529
    return FACE_COLORS.length;
530 530
    }
src/main/java/org/distorted/objects/TwistyMirror.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 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
import org.distorted.helpers.ObjectShape;
25
import org.distorted.helpers.ObjectSticker;
26
import org.distorted.helpers.ScrambleState;
27
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
import org.distorted.main.R;
33

  
34
///////////////////////////////////////////////////////////////////////////////////////////////////
35

  
36
class TwistyMirror extends TwistyObject
37
{
38
  static final Static3D[] ROT_AXIS = new Static3D[]
39
         {
40
           new Static3D(1,0,0),
41
           new Static3D(0,1,0),
42
           new Static3D(0,0,1)
43
         };
44

  
45
  private static final int[] FACE_COLORS = new int[] { COLOR_WHITE };
46
  private static final float DX = 0.10f;
47
  private static final float DY = 0.16f;
48
  private static final float DZ = 0.22f;
49

  
50
  private ScrambleState[] mStates;
51
  private Static4D[] mQuats;
52
  private int[] mBasicAngle;
53
  private ObjectSticker[] mStickers;
54
  private float[][] mPositions;
55

  
56
///////////////////////////////////////////////////////////////////////////////////////////////////
57

  
58
  TwistyMirror(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
59
               DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
60
    {
61
    super(size, size, quat, texture, mesh, effects, moves, ObjectList.MIRR, res, scrWidth);
62
    }
63

  
64
///////////////////////////////////////////////////////////////////////////////////////////////////
65

  
66
  ScrambleState[] getScrambleStates()
67
    {
68
    if( mStates==null )
69
      {
70
      int size = getNumLayers();
71
      int[][] m = new int[16][];
72
      for(int i=1; i<16; i++) m[i] = createEdges(size,i);
73

  
74
      mStates = new ScrambleState[]
75
        {
76
        new ScrambleState( new int[][] { m[ 1], m[ 2], m[ 3] } ),  // 0
77
        new ScrambleState( new int[][] {  null, m[ 4], m[ 5] } ),  // x
78
        new ScrambleState( new int[][] { m[ 6],  null, m[ 7] } ),  // y
79
        new ScrambleState( new int[][] { m[ 8], m[ 8],  null } ),  // z
80
        new ScrambleState( new int[][] { m[10],  null, m[ 7] } ),  // xy
81
        new ScrambleState( new int[][] { m[11], m[ 9],  null } ),  // xz
82
        new ScrambleState( new int[][] {  null, m[12], m[ 5] } ),  // yx
83
        new ScrambleState( new int[][] { m[ 8], m[13],  null } ),  // yz
84
        new ScrambleState( new int[][] {  null, m[ 4], m[14] } ),  // zx
85
        new ScrambleState( new int[][] { m[ 6],  null, m[15] } ),  // zy
86
        new ScrambleState( new int[][] {  null,  null, m[ 5] } ),  // xyx
87
        new ScrambleState( new int[][] {  null, m[ 4],  null } ),  // xzx
88
        new ScrambleState( new int[][] {  null,  null, m[ 7] } ),  // yxy
89
        new ScrambleState( new int[][] { m[ 6],  null,  null } ),  // yzy
90
        new ScrambleState( new int[][] {  null, m[ 9],  null } ),  // zxz
91
        new ScrambleState( new int[][] { m[ 8],  null,  null } ),  // zyz
92
        };
93
      }
94

  
95
    return mStates;
96
    }
97

  
98
///////////////////////////////////////////////////////////////////////////////////////////////////
99

  
100
  private int[] createEdges(int size, int vertex)
101
    {
102
    int[] ret = new int[9*size];
103

  
104
    for(int l=0; l<size; l++)
105
      {
106
      ret[9*l  ] = l;
107
      ret[9*l+1] =-1;
108
      ret[9*l+2] = vertex;
109
      ret[9*l+3] = l;
110
      ret[9*l+4] = 1;
111
      ret[9*l+5] = vertex;
112
      ret[9*l+6] = l;
113
      ret[9*l+7] = 2;
114
      ret[9*l+8] = vertex;
115
      }
116

  
117
    return ret;
118
    }
119

  
120
///////////////////////////////////////////////////////////////////////////////////////////////////
121

  
122
  private void initializeQuats()
123
    {
124
    mQuats = new Static4D[]
125
         {
126
         new Static4D(  0.0f,   0.0f,   0.0f,   1.0f),
127
         new Static4D(  1.0f,   0.0f,   0.0f,   0.0f),
128
         new Static4D(  0.0f,   1.0f,   0.0f,   0.0f),
129
         new Static4D(  0.0f,   0.0f,   1.0f,   0.0f),
130

  
131
         new Static4D( SQ2/2,  SQ2/2,  0.0f ,   0.0f),
132
         new Static4D( SQ2/2, -SQ2/2,  0.0f ,   0.0f),
133
         new Static4D( SQ2/2,   0.0f,  SQ2/2,   0.0f),
134
         new Static4D(-SQ2/2,   0.0f,  SQ2/2,   0.0f),
135
         new Static4D( SQ2/2,   0.0f,   0.0f,  SQ2/2),
136
         new Static4D( SQ2/2,   0.0f,   0.0f, -SQ2/2),
137
         new Static4D(  0.0f,  SQ2/2,  SQ2/2,   0.0f),
138
         new Static4D(  0.0f,  SQ2/2, -SQ2/2,   0.0f),
139
         new Static4D(  0.0f,  SQ2/2,   0.0f,  SQ2/2),
140
         new Static4D(  0.0f,  SQ2/2,   0.0f, -SQ2/2),
141
         new Static4D(  0.0f,   0.0f,  SQ2/2,  SQ2/2),
142
         new Static4D(  0.0f,   0.0f,  SQ2/2, -SQ2/2),
143

  
144
         new Static4D(  0.5f,   0.5f,   0.5f,   0.5f),
145
         new Static4D(  0.5f,   0.5f,  -0.5f,   0.5f),
146
         new Static4D(  0.5f,   0.5f,  -0.5f,  -0.5f),
147
         new Static4D(  0.5f,  -0.5f,   0.5f,  -0.5f),
148
         new Static4D( -0.5f,  -0.5f,  -0.5f,   0.5f),
149
         new Static4D( -0.5f,   0.5f,  -0.5f,  -0.5f),
150
         new Static4D( -0.5f,   0.5f,   0.5f,  -0.5f),
151
         new Static4D( -0.5f,   0.5f,   0.5f,   0.5f)
152
         };
153
    }
154

  
155
///////////////////////////////////////////////////////////////////////////////////////////////////
156
// we cannot do this the standard, automatic way because there's only 1 color in the FACE_COLORS
157
// table and retCubitSolvedStatus() always returns -1,-1 or 0.
158

  
159
  int[] getSolvedQuats(int cubit, int numLayers)
160
    {
161
    if( numLayers==3 )
162
      {
163
      switch(cubit)
164
        {
165
        case  4:
166
        case 21: return new int[] {1,8,9};
167
        case 10:
168
        case 15: return new int[] {2,12,13};
169
        case 12:
170
        case 13: return new int[] {3,14,15};
171
        }
172
      }
173

  
174
    return null;
175
    }
176

  
177
///////////////////////////////////////////////////////////////////////////////////////////////////
178

  
179
  int getFaceColor(int cubit, int cubitface, int numLayers)
180
    {
181
    if( numLayers==2 )
182
      {
183
      switch(cubitface)
184
        {
185
        case 0: if( cubit==4 ) return 11;
186
                if( cubit==5 ) return 10;
187
                if( cubit==6 ) return  9;
188
                if( cubit==7 ) return  8;
189
                return NUM_TEXTURES;
190
        case 1: if( cubit==0 ) return 11;
191
                if( cubit==1 ) return 10;
192
                if( cubit==2 ) return  9;
193
                if( cubit==3 ) return  8;
194
                return NUM_TEXTURES;
195
        case 2: if( cubit==3 ) return  4;
196
                if( cubit==7 ) return  5;
197
                if( cubit==2 ) return  6;
198
                if( cubit==6 ) return  7;
199
                return NUM_TEXTURES;
200
        case 3: if( cubit==1 ) return  4;
201
                if( cubit==5 ) return  5;
202
                if( cubit==0 ) return  6;
203
                if( cubit==4 ) return  7;
204
                return NUM_TEXTURES;
205
        case 4: if( cubit==3 ) return  0;
206
                if( cubit==7 ) return  1;
207
                if( cubit==1 ) return  2;
208
                if( cubit==5 ) return  3;
209
                return NUM_TEXTURES;
210
        case 5: if( cubit==2 ) return  0;
211
                if( cubit==6 ) return  1;
212
                if( cubit==0 ) return  2;
213
                if( cubit==4 ) return  3;
214
                return NUM_TEXTURES;
215
        }
216
      }
217
    if( numLayers==3 )
218
      {
219
      switch(cubitface)
220
        {
221
        case 0: if( cubit==17 ) return 24;
222
                if( cubit==18 ) return 23;
223
                if( cubit==19 ) return 22;
224
                if( cubit==20 ) return 21;
225
                if( cubit==21 ) return  0;
226
                if( cubit==22 ) return 20;
227
                if( cubit==23 ) return 19;
228
                if( cubit==24 ) return 18;
229
                if( cubit==25 ) return 17;
230
                return NUM_TEXTURES;
231
        case 1: if( cubit== 0 ) return 24;
232
                if( cubit== 1 ) return 23;
233
                if( cubit== 2 ) return 22;
234
                if( cubit== 3 ) return 21;
235
                if( cubit== 4 ) return  0;
236
                if( cubit== 5 ) return 20;
237
                if( cubit== 6 ) return 19;
238
                if( cubit== 7 ) return 18;
239
                if( cubit== 8 ) return 17;
240
                return NUM_TEXTURES;
241
        case 2: if( cubit== 6 ) return 14;
242
                if( cubit==14 ) return  2; // theoretically should have been 15, but this must have gotten collapsed in the Factory
243
                if( cubit==23 ) return 16;
244
                if( cubit== 7 ) return 12;
245
                if( cubit==15 ) return  0;
246
                if( cubit==24 ) return 13;
247
                if( cubit== 8 ) return  9;
248
                if( cubit==16 ) return  6; // ditto, theoretically 10
249
                if( cubit==25 ) return 11;
250
                return NUM_TEXTURES;
251
        case 3: if( cubit== 0 ) return 14;
252
                if( cubit== 9 ) return  2; // ditto, theoretically 15
253
                if( cubit==17 ) return 16;
254
                if( cubit== 1 ) return 12;
255
                if( cubit==10 ) return  0;
256
                if( cubit==18 ) return 13;
257
                if( cubit== 2 ) return  9;
258
                if( cubit==11 ) return  6; // ditto, theoretically 10
259
                if( cubit==19 ) return 11;
260
                return NUM_TEXTURES;
261
        case 4: if( cubit== 8 ) return  1;
262
                if( cubit==16 ) return  2;
263
                if( cubit==25 ) return  3;
264
                if( cubit== 5 ) return  4;
265
                if( cubit==13 ) return  0;
266
                if( cubit==22 ) return  5;
267
                if( cubit== 2 ) return  6;
268
                if( cubit==11 ) return  7;
269
                if( cubit==19 ) return  8;
270
                return NUM_TEXTURES;
271
        case 5: if( cubit== 6 ) return  1;
272
                if( cubit==14 ) return  2;
273
                if( cubit==23 ) return  3;
274
                if( cubit== 3 ) return  4;
275
                if( cubit==12 ) return  0;
276
                if( cubit==20 ) return  5;
277
                if( cubit== 0 ) return  6;
278
                if( cubit== 9 ) return  7;
279
                if( cubit==17 ) return  8;
280
                return NUM_TEXTURES;
281
        }
282
      }
283

  
284
    return 0;
285
    }
286

  
287
///////////////////////////////////////////////////////////////////////////////////////////////////
288

  
289
  private float returnStroke(float x, float y)
290
    {
291
    return 0.08f/(Math.max(x,y));
292
    }
293

  
294
///////////////////////////////////////////////////////////////////////////////////////////////////
295

  
296
  private float[] generateStrokes()
297
    {
298
    int num = getNumLayers();
299
    final float A = 0.08f;
300

  
301
    if( num==2 )
302
      {
303
      return new float[] {
304
                           returnStroke(1-DX,1-DY),
305
                           returnStroke(1+DX,1-DY),
306
                           returnStroke(1-DX,1+DY),
307
                           returnStroke(1+DX,1+DY),
308
                           returnStroke(1-DX,1-DZ),
309
                           returnStroke(1+DX,1-DZ),
310
                           returnStroke(1-DX,1+DZ),
311
                           returnStroke(1+DX,1+DZ),
312
                           returnStroke(1-DZ,1-DY),
313
                           returnStroke(1+DZ,1-DY),
314
                           returnStroke(1-DZ,1+DY),
315
                           returnStroke(1+DZ,1+DY),
316

  
317
                           A/(1-DX), A/(1+DX), A/(1+DY), A/(1+DY),
318
                           A/(1-DX), A/(1+DX), A/(1+DZ), A/(1+DZ),
319
                           A/(1-DY), A/(1+DY), A/(1+DZ), A/(1+DZ),
320
                         };
321
      }
322
    else
323
      {
324
      return new float[] {
325
                           returnStroke(1   ,1   ),
326

  
327
                           returnStroke(1-DX,1-DY),
328
                           returnStroke(1   ,1-DY),
329
                           returnStroke(1+DX,1-DY),
330
                           returnStroke(1-DX,1   ),
331
                           returnStroke(1+DX,1   ),
332
                           returnStroke(1-DX,1+DY),
333
                           returnStroke(1   ,1+DY),
334
                           returnStroke(1+DX,1+DY),
335

  
336
                           returnStroke(1-DX,1-DZ),
337
                           returnStroke(1   ,1-DZ),
338
                           returnStroke(1+DX,1-DZ),
339
                           returnStroke(1-DX,1   ),
340
                           returnStroke(1+DX,1   ),
341
                           returnStroke(1-DX,1+DZ),
342
                           returnStroke(1   ,1+DZ),
343
                           returnStroke(1+DX,1+DZ),
344

  
345
                           returnStroke(1-DZ,1-DY),
346
                           returnStroke(1   ,1-DY),
347
                           returnStroke(1+DZ,1-DY),
348
                           returnStroke(1-DZ,1   ),
349
                           returnStroke(1+DZ,1   ),
350
                           returnStroke(1-DZ,1+DY),
351
                           returnStroke(1   ,1+DY),
352
                           returnStroke(1+DZ,1+DY),
353
                         };
354
      }
355
    }
356

  
357
///////////////////////////////////////////////////////////////////////////////////////////////////
358

  
359
  private float[] returnSticker(float x, float y)
360
    {
361
      float H = 0.5f;
362

  
363
      if( x<y ) { float D=H*x/y; return new float[] {-D,-H,+D,-H,+D,+H,-D,+H}; }
364
      else      { float D=H*y/x; return new float[] {-H,-D,+H,-D,+H,+D,-H,+D}; }
365
    }
366

  
367
///////////////////////////////////////////////////////////////////////////////////////////////////
368

  
369
  private float[][] generateStickers()
370
    {
371
    int num = getNumLayers();
372

  
373
    if( num==2 )
374
      {
375
      return new float[][]
376
          {
377
              returnSticker(1-DX,1-DY),
378
              returnSticker(1+DX,1-DY),
379
              returnSticker(1-DX,1+DY),
380
              returnSticker(1+DX,1+DY),
381
              returnSticker(1-DX,1-DZ),
382
              returnSticker(1+DX,1-DZ),
383
              returnSticker(1-DX,1+DZ),
384
              returnSticker(1+DX,1+DZ),
385
              returnSticker(1-DZ,1-DY),
386
              returnSticker(1+DZ,1-DY),
387
              returnSticker(1-DZ,1+DY),
388
              returnSticker(1+DZ,1+DY),
389
          };
390
      }
391
    else
392
      {
393
      return new float[][]
394
          {
395
              returnSticker(1   ,1   ),
396

  
397
              returnSticker(1-DX,1-DY),
398
              returnSticker(1   ,1-DY),
399
              returnSticker(1+DX,1-DY),
400
              returnSticker(1-DX,1   ),
401
              returnSticker(1+DX,1   ),
402
              returnSticker(1-DX,1+DY),
403
              returnSticker(1   ,1+DY),
404
              returnSticker(1+DX,1+DY),
405

  
406
              returnSticker(1-DX,1-DZ),
407
              returnSticker(1   ,1-DZ),
408
              returnSticker(1+DX,1-DZ),
409
              returnSticker(1-DX,1   ),
410
              returnSticker(1+DX,1   ),
411
              returnSticker(1-DX,1+DZ),
412
              returnSticker(1   ,1+DZ),
413
              returnSticker(1+DX,1+DZ),
414

  
415
              returnSticker(1-DZ,1-DY),
416
              returnSticker(1   ,1-DY),
417
              returnSticker(1+DZ,1-DY),
418
              returnSticker(1-DZ,1   ),
419
              returnSticker(1+DZ,1   ),
420
              returnSticker(1-DZ,1+DY),
421
              returnSticker(1   ,1+DY),
422
              returnSticker(1+DZ,1+DY),
423
          };
424
      }
425
    }
426

  
427
///////////////////////////////////////////////////////////////////////////////////////////////////
428

  
429
  ObjectSticker retSticker(int face)
430
    {
431
    if( mStickers==null )
432
      {
433
      final float[][] STICKERS = generateStickers();
434
      final float[] STROKES = generateStrokes();
435
      final int NUM_STICKERS = STICKERS.length;
436
      final float radius = 0.10f;
437
      final float[] radii = {radius,radius,radius,radius};
438
      mStickers = new ObjectSticker[NUM_STICKERS];
439

  
440
      for(int i=0; i<NUM_STICKERS; i++)
441
        {
442
        mStickers[i] = new ObjectSticker(STICKERS[i],null,radii,STROKES[i]);
443
        }
444
      }
445

  
446
    return mStickers[face/NUM_FACE_COLORS];
447
    }
448

  
449
///////////////////////////////////////////////////////////////////////////////////////////////////
450

  
451
  int getNumStickerTypes(int numLayers)
452
    {
453
    return numLayers==2 ? 12 : 25;
454
    }
455

  
456
///////////////////////////////////////////////////////////////////////////////////////////////////
457

  
458
  private int getRow(int cubit, int numLayers, int dim)
459
    {
460
    return (int)(mPositions[cubit][dim] + 0.5f*(numLayers-1));
461
    }
462

  
463
///////////////////////////////////////////////////////////////////////////////////////////////////
464

  
465
  ObjectShape getObjectShape(int cubit, int numLayers)
466
    {
467
    int extraI, extraV, num;
468
    float height;
469

  
470
    switch(numLayers)
471
      {
472
      case 2 : num = 6; extraI = 2; extraV = 2; height = 0.045f; break;
473
      case 3 : num = 5; extraI = 2; extraV = 2; height = 0.045f; break;
474
      case 4 : num = 5; extraI = 1; extraV = 1; height = 0.045f; break;
475
      default: num = 5; extraI = 0; extraV = 0; height = 0.045f; break;
476
      }
477

  
478
    int xrow = getRow(cubit,numLayers,0);
479
    int yrow = getRow(cubit,numLayers,1);
480
    int zrow = getRow(cubit,numLayers,2);
481

  
482
    float XL = -0.5f + (xrow==          0 ? DX : 0);
483
    float XR = +0.5f + (xrow==numLayers-1 ? DX : 0);
484
    float YL = -0.5f - (yrow==          0 ? DY : 0);
485
    float YR = +0.5f - (yrow==numLayers-1 ? DY : 0);
486
    float ZL = -0.5f - (zrow==          0 ? DZ : 0);
487
    float ZR = +0.5f - (zrow==numLayers-1 ? DZ : 0);
488

  
489
    double[][] vertices = new double[][]
490
          {
491
              { XR, YR, ZR },
492
              { XR, YR, ZL },
493
              { XR, YL, ZR },
494
              { XR, YL, ZL },
495
              { XL, YR, ZR },
496
              { XL, YR, ZL },
497
              { XL, YL, ZR },
498
              { XL, YL, ZL },
499
          };
500

  
501
    int[][] vert_indices = new int[][]
502
          {
503
              {2,3,1,0},
504
              {7,6,4,5},
505
              {4,0,1,5},
506
              {7,3,2,6},
507
              {6,2,0,4},
508
              {3,7,5,1}
509
          };
510

  
511
    float[][] bands     = new float[][] { {height,35,0.5f,0.7f,num,extraI,extraV} };
512
    int[] bandIndices   = new int[] { 0,0,0,0,0,0};
513
    float[][] corners   = new float[][] { {0.036f,0.12f} };
514
    int[] cornerIndices = new int[] { 0,0,0,0,0,0,0,0 };
515
    float[][] centers   = new float[][] { {0.0f, 0.0f, 0.0f} };
516
    int[] centerIndices = new int[] { 0,0,0,0,0,0,0,0 };
517

  
518
    return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
519
    }
520

  
521
///////////////////////////////////////////////////////////////////////////////////////////////////
522

  
523
  Static4D getQuat(int cubit, int numLayers)
524
    {
525
    if( mQuats ==null ) initializeQuats();
526
    return mQuats[0];
527
    }
528

  
529
///////////////////////////////////////////////////////////////////////////////////////////////////
530

  
531
  int getNumCubitVariants(int numLayers)
532
    {
533
    return 6*numLayers*numLayers - 12*numLayers + 8;
534
    }
535

  
536
///////////////////////////////////////////////////////////////////////////////////////////////////
537

  
538
  int getCubitVariant(int cubit, int numLayers)
539
    {
540
    return cubit;
541
    }
542

  
543
///////////////////////////////////////////////////////////////////////////////////////////////////
544

  
545
  int getColor(int face)
546
    {
547
    return FACE_COLORS[face];
548
    }
549

  
550
///////////////////////////////////////////////////////////////////////////////////////////////////
551

  
552
  float[][] getCubitPositions(int numLayers)
553
    {
554
    if( mPositions==null )
555
      {
556
      int numCubits = numLayers>1 ? 6*numLayers*numLayers - 12*numLayers + 8 : 1;
557
      mPositions = new float[numCubits][];
558

  
559
      float diff = 0.5f*(numLayers-1);
560
      int currentPosition = 0;
561

  
562
      for(int x = 0; x<numLayers; x++)
563
        for(int y = 0; y<numLayers; y++)
564
          for(int z = 0; z<numLayers; z++)
565
            if( x==0 || x==numLayers-1 || y==0 || y==numLayers-1 || z==0 || z==numLayers-1 )
566
              {
567
              mPositions[currentPosition++] = new float[] {x-diff,y-diff,z-diff};
568
              }
569
      }
570

  
571
    return mPositions;
572
    }
573

  
574
///////////////////////////////////////////////////////////////////////////////////////////////////
575

  
576
  Static4D[] getQuats()
577
    {
578
    if( mQuats ==null ) initializeQuats();
579
    return mQuats;
580
    }
581

  
582
///////////////////////////////////////////////////////////////////////////////////////////////////
583

  
584
  boolean shouldResetTextureMaps()
585
    {
586
    return false;
587
    }
588

  
589
///////////////////////////////////////////////////////////////////////////////////////////////////
590

  
591
  int getNumFaceColors()
592
    {
593
    return FACE_COLORS.length;
594
    }
595

  
596
///////////////////////////////////////////////////////////////////////////////////////////////////
597

  
598
  float[][] getCuts(int numLayers)
599
    {
600
    float[][] cuts = new float[3][numLayers-1];
601

  
602
    for(int i=0; i<numLayers-1; i++)
603
      {
604
      float cut = (2-numLayers)*0.5f + i;
605
      cuts[0][i] = cut;
606
      cuts[1][i] = cut;
607
      cuts[2][i] = cut;
608
      }
609

  
610
    return cuts;
611
    }
612

  
613
///////////////////////////////////////////////////////////////////////////////////////////////////
614

  
615
  int getSolvedFunctionIndex()
616
    {
617
    return 0;
618
    }
619

  
620
///////////////////////////////////////////////////////////////////////////////////////////////////
621

  
622
  int getNumCubitFaces()
623
    {
624
    return 6;
625
    }
626

  
627
///////////////////////////////////////////////////////////////////////////////////////////////////
628

  
629
  float getScreenRatio()
630
    {
631
    return 0.5f;
632
    }
633

  
634
///////////////////////////////////////////////////////////////////////////////////////////////////
635

  
636
  float returnMultiplier()
637
    {
638
    return getNumLayers();
639
    }
640

  
641
///////////////////////////////////////////////////////////////////////////////////////////////////
642
// PUBLIC API
643

  
644
  public Static3D[] getRotationAxis()
645
    {
646
    return ROT_AXIS;
647
    }
648

  
649
///////////////////////////////////////////////////////////////////////////////////////////////////
650

  
651
  public int[] getBasicAngle()
652
    {
653
    if( mBasicAngle==null ) mBasicAngle = new int[] { 4,4,4 };
654
    return mBasicAngle;
655
    }
656

  
657
///////////////////////////////////////////////////////////////////////////////////////////////////
658

  
659
  public int getObjectName(int numLayers)
660
    {
661
    switch(numLayers)
662
      {
663
      case 2: return R.string.mirr2;
664
      case 3: return R.string.mirr3;
665
      }
666
    return R.string.mirr3;
667
    }
668

  
669
///////////////////////////////////////////////////////////////////////////////////////////////////
670

  
671
  public int getInventor(int numLayers)
672
    {
673
    switch(numLayers)
674
      {
675
      case 2: return R.string.mirr2_inventor;
676
      case 3: return R.string.mirr3_inventor;
677
      }
678
    return R.string.mirr3_inventor;
679
    }
680

  
681
///////////////////////////////////////////////////////////////////////////////////////////////////
682

  
683
  public int getComplexity(int numLayers)
684
    {
685
    switch(numLayers)
686
      {
687
      case 2: return 5;
688
      case 3: return 7;
689
      }
690
    return 7;
691
    }
692
}
src/main/java/org/distorted/objects/TwistyObject.java
91 91
  MeshBase[] mMeshes;
92 92
  final Static4D[] OBJECT_QUATS;
93 93
  final Cubit[] CUBITS;
94
  final int NUM_FACES;
94
  final int NUM_FACE_COLORS;
95 95
  final int NUM_TEXTURES;
96 96
  final int NUM_CUBITS;
97 97
  final int NUM_AXIS;
......
163 163

  
164 164
    OBJECT_QUATS = getQuats();
165 165
    NUM_CUBITS  = mOrigPos.length;
166
    NUM_FACES = getNumFaces();
167
    NUM_TEXTURES = getNumStickerTypes(mNumLayers)*NUM_FACES;
166
    NUM_FACE_COLORS = getNumFaceColors();
167
    NUM_TEXTURES = getNumStickerTypes(mNumLayers)*NUM_FACE_COLORS;
168 168
    NUM_AXIS = mAxis.length;
169 169
    NUM_QUATS = OBJECT_QUATS.length;
170 170

  
......
378 378
      if( color<NUM_TEXTURES )
379 379
        {
380 380
        numNonBlack++;
381
        nonBlackIndex = color%NUM_FACES;
381
        nonBlackIndex = color%NUM_FACE_COLORS;
382 382
        }
383 383
      }
384 384

  
......
872 872

  
873 873
  public int getCubitFaceColorIndex(int cubit, int face)
874 874
    {
875
    Static4D texMap = mMesh.getTextureMap(NUM_FACES*cubit + face);
875
    Static4D texMap = mMesh.getTextureMap(NUM_FACE_COLORS*cubit + face);
876 876

  
877 877
    int x = (int)(texMap.get0()/texMap.get2());
878 878
    int y = (int)(texMap.get1()/texMap.get3());
......
906 906
        {
907 907
        if( face>=NUM_TEXTURES ) break;
908 908
        ObjectSticker sticker = retSticker(face);
909
        factory.drawRoundedPolygon(canvas, paint, col*TEXTURE_HEIGHT, row*TEXTURE_HEIGHT, getColor(face%NUM_FACES), sticker);
909
        factory.drawRoundedPolygon(canvas, paint, col*TEXTURE_HEIGHT, row*TEXTURE_HEIGHT, getColor(face%NUM_FACE_COLORS), sticker);
910 910
        face++;
911 911
        }
912 912

  
......
1285 1285
  abstract float getScreenRatio();
1286 1286
  abstract float[][] getCubitPositions(int numLayers);
1287 1287
  abstract Static4D[] getQuats();
1288
  abstract int getNumFaces();
1288
  abstract int getNumFaceColors();
1289 1289
  abstract int getNumStickerTypes(int numLayers);
1290 1290
  abstract int getNumCubitFaces();
1291 1291
  abstract ObjectSticker retSticker(int face);
src/main/java/org/distorted/objects/TwistyPyraminx.java
203 203

  
204 204
///////////////////////////////////////////////////////////////////////////////////////////////////
205 205

  
206
  int getNumFaces()
206
  int getNumFaceColors()
207 207
    {
208 208
    return FACE_COLORS.length;
209 209
    }
......
272 272

  
273 273
  private int faceColor(int cubit, int axis)
274 274
    {
275
    return CUBITS[cubit].mRotationRow[axis] == 1 ? axis : NUM_FACES;
275
    return CUBITS[cubit].mRotationRow[axis] == 1 ? axis : NUM_TEXTURES;
276 276
    }
277 277

  
278 278
///////////////////////////////////////////////////////////////////////////////////////////////////
......
287 287
        case 2: return faceColor(cubit,1);
288 288
        case 5: return faceColor(cubit,3);
289 289
        case 7: return faceColor(cubit,2);
290
        default:return NUM_FACES;
290
        default:return NUM_TEXTURES;
291 291
        }
292 292
      }
293 293
    else
294 294
      {
295
      return cubitface<NUM_FACES ? faceColor(cubit,cubitface) : NUM_FACES;
295
      return cubitface<NUM_TEXTURES ? faceColor(cubit,cubitface) : NUM_TEXTURES;
296 296
      }
297 297
    }
298 298

  
......
375 375
      mStickers[0] = new ObjectSticker(STICKERS[0],null,radii,stroke);
376 376
      }
377 377

  
378
    return mStickers[face/NUM_FACES];
378
    return mStickers[face/NUM_FACE_COLORS];
379 379
    }
380 380

  
381 381
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyRedi.java
139 139

  
140 140
///////////////////////////////////////////////////////////////////////////////////////////////////
141 141

  
142
  int getNumFaces()
142
  int getNumFaceColors()
143 143
    {
144 144
    return FACE_COLORS.length;
145 145
    }
......
413 413
        }
414 414
      }
415 415

  
416
    return mStickers[face/NUM_FACES];
416
    return mStickers[face/NUM_FACE_COLORS];
417 417
    }
418 418

  
419 419
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyRex.java
132 132

  
133 133
///////////////////////////////////////////////////////////////////////////////////////////////////
134 134

  
135
  int getNumFaces()
135
  int getNumFaceColors()
136 136
    {
137 137
    return FACE_COLORS.length;
138 138
    }
......
480 480
        }
481 481
      }
482 482

  
483
    return mStickers[face/NUM_FACES];
483
    return mStickers[face/NUM_FACE_COLORS];
484 484
    }
485 485

  
486 486
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistySkewb.java
152 152

  
153 153
///////////////////////////////////////////////////////////////////////////////////////////////////
154 154

  
155
  int getNumFaces()
155
  int getNumFaceColors()
156 156
    {
157 157
    return FACE_COLORS.length;
158 158
    }
......
553 553
        }
554 554
      }
555 555

  
556
    return mStickers[face/NUM_FACES];
556
    return mStickers[face/NUM_FACE_COLORS];
557 557
    }
558 558

  
559 559
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistySquare.java
122 122

  
123 123
///////////////////////////////////////////////////////////////////////////////////////////////////
124 124

  
125
  int getNumFaces()
125
  int getNumFaceColors()
126 126
    {
127 127
    return FACE_COLORS.length;
128 128
    }
src/main/java/org/distorted/objects/TwistySquare1.java
241 241
        }
242 242
      }
243 243

  
244
    return mStickers[face/NUM_FACES];
244
    return mStickers[face/NUM_FACE_COLORS];
245 245
    }
246 246

  
247 247
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistySquare2.java
247 247
        }
248 248
      }
249 249

  
250
    return mStickers[face/NUM_FACES];
250
    return mStickers[face/NUM_FACE_COLORS];
251 251
    }
252 252

  
253 253
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyUltimate.java
357 357
        }
358 358
      }
359 359

  
360
    return mStickers[face/NUM_FACES];
360
    return mStickers[face/NUM_FACE_COLORS];
361 361
    }
362 362

  
363 363
///////////////////////////////////////////////////////////////////////////////////////////////////
......
391 391

  
392 392
///////////////////////////////////////////////////////////////////////////////////////////////////
393 393

  
394
  int getNumFaces()
394
  int getNumFaceColors()
395 395
    {
396 396
    return FACE_COLORS.length;
397 397
    }
src/main/java/org/distorted/screens/RubikScreenSolver.java
55 55
  private int[] mFaceColors;
56 56
  private int mNumFaces;
57 57
  private float mBitmapSize;
58

  
59
  private ObjectList mCurrentObject;
60
  private int mCurrentObjectSize;
61

  
62 58
  private WeakReference<RubikActivity> mWeakAct;
63 59

  
64 60
///////////////////////////////////////////////////////////////////////////////////////////////////
......
79 75
    int sizeH = (int)(width*RubikActivity.SOLVER_BMP_H_SIZE);
80 76

  
81 77
    mBitmapSize = Math.min(sizeV,sizeH);
82

  
83 78
    mWeakAct = new WeakReference<>(act);
84

  
85 79
    mSolving = false;
86 80

  
87
    mCurrentObject     = ImplementedSolversList.getObject(0);
88
    mCurrentObjectSize = ImplementedSolversList.getObjectSize(0);
81
    ObjectList currentObject= ImplementedSolversList.getObject(0);
82
    int currentObjectSize   = ImplementedSolversList.getObjectSize(0);
89 83

  
90
    act.setupObject(mCurrentObject, mCurrentObjectSize, null);
84
    act.setupObject(currentObject, currentObjectSize, null);
91 85
    RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
92
    play.setObjectAndSize(act, mCurrentObject, mCurrentObjectSize);
86
    play.setObjectAndSize(act, currentObject, currentObjectSize);
93 87

  
94
    mFaceColors = ObjectList.retFaceColors(mCurrentObject);
88
    mFaceColors = ObjectList.retFaceColors(currentObject);
95 89
    mNumFaces   = mFaceColors!=null ? mFaceColors.length : 0;
96 90

  
97 91
    // TOP ////////////////////////////
src/main/res/values/strings.xml
100 100
    <string name="squa1" translatable="false">Square-1</string>
101 101
    <string name="squa2" translatable="false">Square-2</string>
102 102
    <string name="jing"  translatable="false">Jing Pyraminx</string>
103
    <string name="mirr2"  translatable="false">Mirror Cube</string>
104
    <string name="mirr3"  translatable="false">Pocket Mirror</string>
103 105

  
104 106
    <string name="bandaged_fused"  translatable="false">Fused Cube</string>
105 107
    <string name="bandaged_2bar"   translatable="false">2Bar Cube</string>
......
132 134
    <string name="squa1_inventor" translatable="false">Vojtech Kopsky, Harel Hrsel, 1999</string>
133 135
    <string name="squa2_inventor" translatable="false">David Litwin, 1995</string>
134 136
    <string name="jing_inventor"  translatable="false">Tony Fisher, 1991</string>
137
    <string name="mirr2_inventor" translatable="false">Thomas de Bruin, 2007</string>
138
    <string name="mirr3_inventor" translatable="false">Hidetoshi Takeji, 2006</string>
135 139

  
136 140
    <string name="bandaged_fused_inventor"  translatable="false">who knows</string>
137 141
    <string name="bandaged_2bar_inventor"   translatable="false">who knows</string>

Also available in: Unified diff