Project

General

Profile

« Previous | Next » 

Revision 9c2f0c91

Added by Leszek Koltunski about 4 years ago

Rename some classes.

View differences:

src/main/java/org/distorted/dialogs/RubikDialogNewRecord.java
38 38

  
39 39
import org.distorted.main.R;
40 40
import org.distorted.main.RubikActivity;
41
import org.distorted.objects.RubikObjectList;
41
import org.distorted.objects.ObjectList;
42 42
import org.distorted.scores.RubikScores;
43 43
import org.distorted.states.RubikState;
44 44
import org.distorted.states.RubikStatePlay;
......
105 105
          RubikStatePlay play = (RubikStatePlay) RubikState.PLAY.getStateClass();
106 106
          int object = play.getObject();
107 107
          int size   = play.getSize();
108
          int sizeIndex = RubikObjectList.getSizeIndex(object,size);
108
          int sizeIndex = ObjectList.getSizeIndex(object,size);
109 109

  
110
          bundle.putInt("tab", RubikObjectList.pack(object,sizeIndex) );
110
          bundle.putInt("tab", ObjectList.pack(object,sizeIndex) );
111 111
          bundle.putBoolean("submitting", true);
112 112

  
113 113
          RubikDialogScores scoresDiag = new RubikDialogScores();
src/main/java/org/distorted/dialogs/RubikDialogPattern.java
41 41

  
42 42
import org.distorted.main.R;
43 43
import org.distorted.main.RubikActivity;
44
import org.distorted.objects.RubikObjectList;
44
import org.distorted.objects.ObjectList;
45 45
import org.distorted.patterns.RubikPatternList;
46 46

  
47 47
///////////////////////////////////////////////////////////////////////////////////////////////////
......
94 94

  
95 95
    for(int i=0; i< RubikPatternList.NUM_OBJECTS; i++)
96 96
      {
97
      RubikObjectList list = RubikPatternList.getObject(i);
97
      ObjectList list = RubikPatternList.getObject(i);
98 98
      int size             = RubikPatternList.getSize(i);
99
      int sizeIndex        = RubikObjectList.getSizeIndex(list.ordinal(),size);
99
      int sizeIndex        = ObjectList.getSizeIndex(list.ordinal(),size);
100 100
      int iconID           = list.getIconIDs()[sizeIndex];
101 101

  
102 102
      ImageView imageView = new ImageView(act);
src/main/java/org/distorted/dialogs/RubikDialogPatternView.java
28 28

  
29 29
import org.distorted.main.R;
30 30
import org.distorted.main.RubikActivity;
31
import org.distorted.objects.RubikObjectList;
31
import org.distorted.objects.ObjectList;
32 32
import org.distorted.patterns.RubikPattern;
33 33
import org.distorted.patterns.RubikPatternList;
34 34
import org.distorted.states.RubikState;
......
94 94
        RubikPattern pattern = RubikPattern.getInstance();
95 95
        int[][] moves = pattern.reInitialize(mTab, groupPosition, childPosition);
96 96

  
97
        RubikObjectList list = RubikPatternList.getObject(mTab);
97
        ObjectList list = RubikPatternList.getObject(mTab);
98 98
        int size             = RubikPatternList.getSize(mTab);
99 99

  
100 100
        ract.setupObject(list, size, moves);
src/main/java/org/distorted/dialogs/RubikDialogScores.java
41 41

  
42 42
import org.distorted.main.R;
43 43
import org.distorted.main.RubikActivity;
44
import org.distorted.objects.RubikObjectList;
44
import org.distorted.objects.ObjectList;
45 45

  
46 46
///////////////////////////////////////////////////////////////////////////////////////////////////
47 47

  
......
104 104
    tabLayout.setupWithViewPager(viewPager);
105 105

  
106 106
    viewPager.setCurrentItem(curTab);
107
    RubikObjectList list;
107
    ObjectList list;
108 108

  
109
    for (int object=0; object<RubikObjectList.NUM_OBJECTS; object++)
109
    for (int object = 0; object< ObjectList.NUM_OBJECTS; object++)
110 110
      {
111
      list = RubikObjectList.getObject(object);
111
      list = ObjectList.getObject(object);
112 112
      int[] iconID = list.getIconIDs();
113 113
      int len = list.getSizes().length;
114 114

  
115 115
      for(int size=0; size<len; size++)
116 116
        {
117
        int t = RubikObjectList.pack(object,size);
117
        int t = ObjectList.pack(object,size);
118 118
        ImageView imageView = new ImageView(act);
119 119
        imageView.setImageResource(iconID[size]);
120 120
        TabLayout.Tab tab = tabLayout.getTabAt(t);
src/main/java/org/distorted/dialogs/RubikDialogScoresPagerAdapter.java
32 32

  
33 33
import org.distorted.scores.RubikScores;
34 34
import org.distorted.scores.RubikScoresDownloader;
35
import org.distorted.objects.RubikObjectList;
35
import org.distorted.objects.ObjectList;
36 36

  
37 37
///////////////////////////////////////////////////////////////////////////////////////////////////
38 38

  
......
108 108

  
109 109
    for(int i=0; i<mNumTabs; i++)
110 110
      {
111
      int object   = RubikObjectList.unpackObject(i);
112
      int sizeIndex= RubikObjectList.unpackSizeIndex(i);
113
      maxTab[i]    = RubikObjectList.getMaxLevel(object, sizeIndex);
111
      int object   = ObjectList.unpackObject(i);
112
      int sizeIndex= ObjectList.unpackSizeIndex(i);
113
      maxTab[i]    = ObjectList.getMaxLevel(object, sizeIndex);
114 114
      toDoTab[i]   = 0;
115 115

  
116 116
      toDo += maxTab[i];
......
200 200
    {
201 201
    mAct = act;
202 202
    mDialog = diag;
203
    mNumTabs = RubikObjectList.getTotal();
203
    mNumTabs = ObjectList.getTotal();
204 204
    mViews = new RubikDialogScoresView[mNumTabs];
205 205
    mViewPager = viewPager;
206 206
    mIsSubmitting = isSubmitting;
src/main/java/org/distorted/dialogs/RubikDialogScoresView.java
33 33

  
34 34
import org.distorted.main.R;
35 35
import org.distorted.main.RubikActivity;
36
import org.distorted.objects.RubikObjectList;
36
import org.distorted.objects.ObjectList;
37 37
import org.distorted.scores.RubikScores;
38 38

  
39 39
import static org.distorted.scores.RubikScoresDownloader.MAX_PLACES;
......
88 88
    Resources res = act.getResources();
89 89
    String packageName = act.getPackageName();
90 90

  
91
    int object   = RubikObjectList.unpackObject(tab);
92
    int sizeIndex= RubikObjectList.unpackSizeIndex(tab);
91
    int object   = ObjectList.unpackObject(tab);
92
    int sizeIndex= ObjectList.unpackSizeIndex(tab);
93 93
    RubikScores scores = RubikScores.getInstance();
94 94

  
95 95
    boolean inserted = false;
src/main/java/org/distorted/dialogs/RubikDialogSetName.java
40 40

  
41 41
import org.distorted.main.R;
42 42
import org.distorted.main.RubikActivity;
43
import org.distorted.objects.RubikObjectList;
43
import org.distorted.objects.ObjectList;
44 44
import org.distorted.scores.RubikScores;
45 45
import org.distorted.states.RubikState;
46 46
import org.distorted.states.RubikStatePlay;
......
148 148

  
149 149
          int object = play.getObject();
150 150
          int size   = play.getSize();
151
          int sizeIndex = RubikObjectList.getSizeIndex(object,size);
151
          int sizeIndex = ObjectList.getSizeIndex(object,size);
152 152

  
153 153
          Bundle bundle = new Bundle();
154
          bundle.putInt("tab", RubikObjectList.pack(object,sizeIndex) );
154
          bundle.putInt("tab", ObjectList.pack(object,sizeIndex) );
155 155
          bundle.putBoolean("submitting", true);
156 156

  
157 157
          RubikDialogScores scores = new RubikDialogScores();
src/main/java/org/distorted/effects/objectchange/ObjectChangeEffect.java
25 25
import org.distorted.library.main.DistortedScreen;
26 26
import org.distorted.library.message.EffectListener;
27 27
import org.distorted.main.RubikPreRender;
28
import org.distorted.objects.RubikObject;
28
import org.distorted.objects.TwistyObject;
29 29

  
30 30
import java.lang.reflect.Method;
31 31

  
......
73 73
  private int[] mEffectFinished;
74 74
  private boolean[] mPhaseActive;
75 75

  
76
  RubikObject[] mObject;
76
  TwistyObject[] mObject;
77 77
  DistortedScreen mScreen;
78 78
  Effect[][] mCubeEffects;
79 79
  int[][] mCubeEffectPosition;
......
93 93
    mNodeEffectPosition = new int[NUM_PHASES][];
94 94
    mCubeEffects        = new Effect[NUM_PHASES][];
95 95
    mNodeEffects        = new Effect[NUM_PHASES][];
96
    mObject             = new RubikObject[NUM_PHASES];
96
    mObject             = new TwistyObject[NUM_PHASES];
97 97
    }
98 98

  
99 99
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/effects/scramble/ScrambleEffect.java
25 25
import org.distorted.library.main.DistortedScreen;
26 26
import org.distorted.library.message.EffectListener;
27 27
import org.distorted.main.RubikPreRender;
28
import org.distorted.objects.RubikObject;
28
import org.distorted.objects.TwistyObject;
29 29

  
30 30
import java.lang.reflect.Method;
31 31
import java.util.Random;
......
74 74
  private Random mRnd;
75 75
  private int mBasicAngle;
76 76

  
77
  RubikObject mObject;
77
  TwistyObject mObject;
78 78
  Effect[] mNodeEffects;
79 79
  int[] mNodeEffectPosition;
80 80
  Effect[] mCubeEffects;
src/main/java/org/distorted/effects/solve/SolveEffect.java
25 25
import org.distorted.library.main.DistortedScreen;
26 26
import org.distorted.library.message.EffectListener;
27 27
import org.distorted.main.RubikPreRender;
28
import org.distorted.objects.RubikObject;
28
import org.distorted.objects.TwistyObject;
29 29

  
30 30
import java.lang.reflect.Method;
31 31

  
......
69 69
  private int[] mCubeEffectNumber, mNodeEffectNumber;
70 70
  private int mPhase;
71 71

  
72
  RubikObject mObject;
72
  TwistyObject mObject;
73 73
  DistortedScreen mScreen;
74 74
  Effect[][] mCubeEffects;
75 75
  int[][] mCubeEffectPosition;
src/main/java/org/distorted/effects/win/WinEffect.java
25 25
import org.distorted.library.main.DistortedScreen;
26 26
import org.distorted.library.message.EffectListener;
27 27
import org.distorted.main.RubikPreRender;
28
import org.distorted.objects.RubikObject;
28
import org.distorted.objects.TwistyObject;
29 29

  
30 30
import java.lang.reflect.Method;
31 31

  
......
67 67
  private int mEffectReturned;
68 68
  private int mCubeEffectNumber, mNodeEffectNumber;
69 69

  
70
  RubikObject mObject;
70
  TwistyObject mObject;
71 71
  DistortedScreen mScreen;
72 72
  Effect[] mCubeEffects;
73 73
  int[] mCubeEffectPosition;
src/main/java/org/distorted/main/RubikActivity.java
37 37
import org.distorted.effects.BaseEffect;
38 38
import org.distorted.library.main.DistortedLibrary;
39 39

  
40
import org.distorted.objects.RubikObject;
40
import org.distorted.objects.TwistyObject;
41 41
import org.distorted.scores.RubikScores;
42 42
import org.distorted.scores.RubikScoresDownloader;
43
import org.distorted.objects.RubikObjectList;
43
import org.distorted.objects.ObjectList;
44 44
import org.distorted.states.RubikState;
45 45
import org.distorted.states.RubikStatePlay;
46 46

  
......
219 219
      int object = play.getObject();
220 220
      int size   = play.getSize();
221 221

  
222
      if( object>=0 && object<RubikObjectList.NUM_OBJECTS )
222
      if( object>=0 && object< ObjectList.NUM_OBJECTS )
223 223
        {
224
        RubikObjectList obj = RubikObjectList.getObject(object);
224
        ObjectList obj = ObjectList.getObject(object);
225 225
        int[] sizes = obj.getSizes();
226
        int sizeIndex = RubikObjectList.getSizeIndex(object,size);
226
        int sizeIndex = ObjectList.getSizeIndex(object,size);
227 227

  
228 228
        if( sizeIndex>=0 && sizeIndex<sizes.length )
229 229
          {
......
234 234

  
235 235
      if( !success )
236 236
        {
237
        RubikObjectList obj = RubikObjectList.getObject(RubikStatePlay.DEF_OBJECT);
237
        ObjectList obj = ObjectList.getObject(RubikStatePlay.DEF_OBJECT);
238 238
        int s = RubikStatePlay.DEF_SIZE;
239 239

  
240 240
        play.setObjectAndSize(this,obj,s);
......
334 334

  
335 335
///////////////////////////////////////////////////////////////////////////////////////////////////
336 336

  
337
    public RubikObject getObject()
337
    public TwistyObject getObject()
338 338
      {
339 339
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
340 340
      RubikPreRender pre = view.getPreRender();
......
365 365

  
366 366
///////////////////////////////////////////////////////////////////////////////////////////////////
367 367

  
368
    public void changeObject(RubikObjectList newObject, int newSize, boolean reportChange)
368
    public void changeObject(ObjectList newObject, int newSize, boolean reportChange)
369 369
      {
370 370
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
371 371
      RubikPreRender pre = view.getPreRender();
372 372

  
373 373
      if( reportChange )
374 374
        {
375
        RubikObject oldObject = pre.getObject();
376
        RubikObjectList oldList = oldObject.getObjectList();
375
        TwistyObject oldObject = pre.getObject();
376
        ObjectList oldList = oldObject.getObjectList();
377 377
        int oldSize = oldObject.getSize();
378 378
        float fps = view.getRenderer().getFPS();
379 379
        fps = (int)(fps+0.5f);
......
410 410

  
411 411
///////////////////////////////////////////////////////////////////////////////////////////////////
412 412

  
413
    public void setupObject(RubikObjectList object, int size, int[][] moves)
413
    public void setupObject(ObjectList object, int size, int[][] moves)
414 414
      {
415 415
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
416 416
      RubikPreRender pre = view.getPreRender();
src/main/java/org/distorted/main/RubikPreRender.java
28 28
import org.distorted.dialogs.RubikDialogSolved;
29 29
import org.distorted.effects.BaseEffect;
30 30
import org.distorted.library.message.EffectListener;
31
import org.distorted.objects.RubikObject;
32
import org.distorted.objects.RubikObjectList;
31
import org.distorted.objects.TwistyObject;
32
import org.distorted.objects.ObjectList;
33 33
import org.distorted.scores.RubikScores;
34 34
import org.distorted.states.RubikState;
35 35
import org.distorted.states.RubikStateSolving;
......
49 49
                  mInitializeObject, mSetTextureMap, mResetAllTextureMaps;
50 50
  private boolean mCanRotate, mCanPlay;
51 51
  private boolean mIsSolved;
52
  private RubikObjectList mNextObject;
52
  private ObjectList mNextObject;
53 53
  private int mNextSize;
54 54
  private long mRotationFinishedID;
55 55
  private long[] mEffectID;
......
58 58
  private int mScreenWidth, mScreenHeight;
59 59
  private SharedPreferences mPreferences;
60 60
  private int[][] mNextMoves;
61
  private RubikObject mOldObject, mNewObject;
61
  private TwistyObject mOldObject, mNewObject;
62 62
  private int mScrambleObjectNum;
63 63
  private int mAddRotationAxis, mAddRotationRowBitmap, mAddRotationAngle;
64 64
  private long mAddRotationDuration;
......
97 97

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

  
100
  private void createObjectNow(RubikObjectList object, int size, int[][] moves)
100
  private void createObjectNow(ObjectList object, int size, int[][] moves)
101 101
    {
102 102
    boolean firstTime = (mNewObject==null);
103 103

  
......
366 366

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

  
369
  void changeObject(RubikObjectList object, int size)
369
  void changeObject(ObjectList object, int size)
370 370
    {
371 371
    if( size>0 )
372 372
      {
......
378 378

  
379 379
///////////////////////////////////////////////////////////////////////////////////////////////////
380 380

  
381
  void setupObject(RubikObjectList object, int size, int[][] moves)
381
  void setupObject(ObjectList object, int size, int[][] moves)
382 382
    {
383 383
    if( size>0 )
384 384
      {
......
492 492

  
493 493
///////////////////////////////////////////////////////////////////////////////////////////////////
494 494

  
495
  public RubikObject getObject()
495
  public TwistyObject getObject()
496 496
    {
497 497
    return mNewObject;
498 498
    }
499 499

  
500 500
///////////////////////////////////////////////////////////////////////////////////////////////////
501 501

  
502
  public RubikObject getOldObject()
502
  public TwistyObject getOldObject()
503 503
    {
504 504
    return mOldObject;
505 505
    }
src/main/java/org/distorted/main/RubikSurfaceView.java
32 32

  
33 33
import org.distorted.library.type.Static2D;
34 34
import org.distorted.library.type.Static4D;
35
import org.distorted.objects.RubikObject;
35
import org.distorted.objects.TwistyObject;
36 36
import org.distorted.objects.Movement;
37 37
import org.distorted.solvers.SolverMain;
38 38
import org.distorted.states.RubikState;
......
328 328
              mLastCubitFace = mMovement.getTouchedFace();
329 329
              float[] point = mMovement.getTouchedPoint3D();
330 330
              int color = solver.getCurrentColor();
331
              RubikObject object = mPreRender.getObject();
331
              TwistyObject object = mPreRender.getObject();
332 332
              mLastCubit = object.getCubit(point);
333 333
              mPreRender.setTextureMap( mLastCubit, mLastCubitFace, color );
334 334
              mLastCubitColor = SolverMain.cubitIsLocked(object.getObjectList(), object.getSize(), mLastCubit);
......
389 389
        float distQuot = mInitDistance<0 ? 1.0f : distNow/ mInitDistance;
390 390
        mInitDistance = distNow;
391 391

  
392
        RubikObject object = mPreRender.getObject();
392
        TwistyObject object = mPreRender.getObject();
393 393
        if( object!=null ) object.setObjectRatio(distQuot);
394 394
        }
395 395
      else
......
463 463
      Static4D rotatedTouchPoint2= rotateVectorByInvertedQuat(touchPoint2, mQuat);
464 464

  
465 465
      Static2D res = mMovement.newRotation(rotatedTouchPoint2);
466
      RubikObject object = mPreRender.getObject();
466
      TwistyObject object = mPreRender.getObject();
467 467

  
468 468
      mCurrentAxis = (int)res.get0();
469 469
      float offset = res.get1();
src/main/java/org/distorted/objects/Cubit.java
31 31
  {
32 32
  private final Static3D mOrigPosition;
33 33

  
34
  private RubikObject mParent;
34
  private TwistyObject mParent;
35 35
  private Static3D mCurrentPosition;
36 36
  private int mNumAxis;
37 37

  
......
40 40

  
41 41
///////////////////////////////////////////////////////////////////////////////////////////////////
42 42

  
43
  Cubit(RubikObject parent, Static3D position)
43
  Cubit(TwistyObject parent, Static3D position)
44 44
    {
45 45
    float x = position.get0();
46 46
    float y = position.get1();
......
167 167
      {
168 168
      row = (int)(mRotationRow[axis]+0.5f);
169 169
      result += (1<<(row+accumulativeShift));
170
      accumulativeShift += RubikObjectList.MAX_OBJECT_SIZE;
170
      accumulativeShift += ObjectList.MAX_OBJECT_SIZE;
171 171
      }
172 172

  
173 173
    return result;
src/main/java/org/distorted/objects/Movement.java
240 240

  
241 241
  public boolean faceTouched(Static4D rotatedTouchPoint, Static4D rotatedCamera)
242 242
    {
243
    float objectRatio = RubikObject.getObjectRatio();
243
    float objectRatio = TwistyObject.getObjectRatio();
244 244

  
245 245
    mPoint[0]  = rotatedTouchPoint.get0()/objectRatio;
246 246
    mPoint[1]  = rotatedTouchPoint.get1()/objectRatio;
......
267 267

  
268 268
  public Static2D newRotation(Static4D rotatedTouchPoint)
269 269
    {
270
    float objectRatio = RubikObject.getObjectRatio();
270
    float objectRatio = TwistyObject.getObjectRatio();
271 271

  
272 272
    mPoint[0] = rotatedTouchPoint.get0()/objectRatio;
273 273
    mPoint[1] = rotatedTouchPoint.get1()/objectRatio;
src/main/java/org/distorted/objects/MovementCube.java
25 25
{
26 26
  MovementCube()
27 27
    {
28
    super(RubikCube.ROT_AXIS, RubikCube.FACE_AXIS, 0.5f, 0.5f);
28
    super(TwistyCube.ROT_AXIS, TwistyCube.FACE_AXIS, 0.5f, 0.5f);
29 29
    }
30 30

  
31 31
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/MovementDiamond.java
25 25
{
26 26
  MovementDiamond()
27 27
    {
28
    super(RubikDiamond.ROT_AXIS, RubikDiamond.FACE_AXIS, 0.25f, 0.25f);
28
    super(TwistyDiamond.ROT_AXIS, TwistyDiamond.FACE_AXIS, 0.25f, 0.25f);
29 29
    }
30 30

  
31 31
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/MovementDino.java
25 25
{
26 26
  MovementDino()
27 27
    {
28
    super(RubikDino.ROT_AXIS, RubikDino.FACE_AXIS, 0.5f, 0.5f);
28
    super(TwistyDino.ROT_AXIS, TwistyDino.FACE_AXIS, 0.5f, 0.5f);
29 29
    }
30 30

  
31 31
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/MovementHelicopter.java
25 25
{
26 26
  MovementHelicopter()
27 27
    {
28
    super(RubikHelicopter.ROT_AXIS, RubikHelicopter.FACE_AXIS, 0.166f, 0.166f);
28
    super(TwistyHelicopter.ROT_AXIS, TwistyHelicopter.FACE_AXIS, 0.166f, 0.166f);
29 29
    }
30 30

  
31 31
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/MovementPyraminx.java
30 30

  
31 31
  MovementPyraminx()
32 32
    {
33
    super(RubikPyraminx.ROT_AXIS, RubikPyraminx.FACE_AXIS, SQ6/12, SQ3/6);
33
    super(TwistyPyraminx.ROT_AXIS, TwistyPyraminx.FACE_AXIS, SQ6/12, SQ3/6);
34 34
    }
35 35

  
36 36
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/MovementSkewb.java
25 25
{
26 26
  MovementSkewb()
27 27
    {
28
    super(RubikSkewb.ROT_AXIS, RubikSkewb.FACE_AXIS, 0.25f, 0.25f);
28
    super(TwistySkewb.ROT_AXIS, TwistySkewb.FACE_AXIS, 0.25f, 0.25f);
29 29
    }
30 30

  
31 31
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/ObjectList.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
package org.distorted.objects;
21

  
22
import android.content.res.Resources;
23

  
24
import org.distorted.library.main.DistortedEffects;
25
import org.distorted.library.main.DistortedTexture;
26
import org.distorted.library.mesh.MeshSquare;
27
import org.distorted.library.type.Static4D;
28
import org.distorted.main.R;
29
import org.distorted.main.RubikActivity;
30

  
31
import java.lang.reflect.Field;
32

  
33
///////////////////////////////////////////////////////////////////////////////////////////////////
34

  
35
public enum ObjectList
36
  {
37
  CUBE (
38
         new int[][] {
39
                       {2 , 12, R.raw.cube2, R.drawable.ui_small_cube2, R.drawable.ui_medium_cube2, R.drawable.ui_big_cube2, R.drawable.ui_huge_cube2} ,
40
                       {3 , 16, R.raw.cube3, R.drawable.ui_small_cube3, R.drawable.ui_medium_cube3, R.drawable.ui_big_cube3, R.drawable.ui_huge_cube3} ,
41
                       {4 , 20, R.raw.cube4, R.drawable.ui_small_cube4, R.drawable.ui_medium_cube4, R.drawable.ui_big_cube4, R.drawable.ui_huge_cube4} ,
42
                       {5 , 24, R.raw.cube5, R.drawable.ui_small_cube5, R.drawable.ui_medium_cube5, R.drawable.ui_big_cube5, R.drawable.ui_huge_cube5}
43
                     },
44
         TwistyCube.class,
45
         new MovementCube(),
46
         0
47
       ),
48

  
49
  PYRA (
50
         new int[][] {
51
                       {3 , 10, R.raw.pyra3, R.drawable.ui_small_pyra3, R.drawable.ui_medium_pyra3, R.drawable.ui_big_pyra3, R.drawable.ui_huge_pyra3} ,
52
                       {4 , 15, R.raw.pyra4, R.drawable.ui_small_pyra4, R.drawable.ui_medium_pyra4, R.drawable.ui_big_pyra4, R.drawable.ui_huge_pyra4} ,
53
                       {5 , 20, R.raw.pyra5, R.drawable.ui_small_pyra5, R.drawable.ui_medium_pyra5, R.drawable.ui_big_pyra5, R.drawable.ui_huge_pyra5}
54
                     },
55
         TwistyPyraminx.class,
56
         new MovementPyraminx(),
57
         1
58
       ),
59

  
60
  DIAM (
61
         new int[][] {
62
                       {2 , 10, R.raw.dino, R.drawable.ui_small_dino, R.drawable.ui_medium_dino, R.drawable.ui_big_dino, R.drawable.ui_huge_dino} ,
63
                     },
64
         TwistyDiamond.class,
65
         new MovementDiamond(),
66
         1
67
       ),
68

  
69
  DINO (
70
         new int[][] {
71
                       {3 , 10, R.raw.dino, R.drawable.ui_small_dino, R.drawable.ui_medium_dino, R.drawable.ui_big_dino, R.drawable.ui_huge_dino} ,
72
                     },
73
         TwistyDino6.class,
74
         new MovementDino(),
75
         2
76
       ),
77

  
78
  DIN4 (
79
         new int[][] {
80
                       {3 ,  7, R.raw.dino, R.drawable.ui_small_din4, R.drawable.ui_medium_din4, R.drawable.ui_big_din4, R.drawable.ui_huge_din4} ,
81
                     },
82
         TwistyDino4.class,
83
         new MovementDino(),
84
         2
85
       ),
86

  
87
  SKEW (
88
         new int[][] {
89
                       {2 , 11, R.raw.skewb, R.drawable.ui_small_skewb, R.drawable.ui_medium_skewb, R.drawable.ui_big_skewb, R.drawable.ui_huge_skewb} ,
90
                     },
91
         TwistySkewb.class,
92
         new MovementSkewb(),
93
         2
94
       ),
95

  
96
  HELI (
97
         new int[][] {
98
                       {3 , 18, R.raw.heli, R.drawable.ui_small_heli, R.drawable.ui_medium_heli, R.drawable.ui_big_heli, R.drawable.ui_huge_heli} ,
99
                     },
100
         TwistyHelicopter.class,
101
         new MovementHelicopter(),
102
         2
103
       ),
104
  ;
105

  
106
  public static final int NUM_OBJECTS = values().length;
107
  public static final int MAX_NUM_OBJECTS;
108
  public static final int MAX_LEVEL;
109
  public static final int MAX_OBJECT_SIZE;
110

  
111
  private final int[] mObjectSizes, mMaxLevels, mSmallIconIDs, mMediumIconIDs, mBigIconIDs, mHugeIconIDs, mResourceIDs;
112
  private final Class<? extends TwistyObject> mObjectClass;
113
  private final Movement mObjectMovementClass;
114
  private final int mColumn, mNumSizes;
115

  
116
  private static final ObjectList[] objects;
117
  private static int mNumAll;
118
  private static int[] mIndices;
119
  private static int mColCount, mRowCount;
120

  
121
  static
122
    {
123
    mNumAll = 0;
124
    int num, i = 0;
125
    objects = new ObjectList[NUM_OBJECTS];
126
    int maxNum  = Integer.MIN_VALUE;
127
    int maxLevel= Integer.MIN_VALUE;
128
    int maxSize = Integer.MIN_VALUE;
129

  
130
    for(ObjectList object: ObjectList.values())
131
      {
132
      objects[i] = object;
133
      i++;
134
      num = object.mObjectSizes.length;
135
      mNumAll += num;
136
      if( num> maxNum ) maxNum = num;
137

  
138
      for(int j=0; j<num; j++)
139
        {
140
        if( object.mMaxLevels[j] > maxLevel ) maxLevel = object.mMaxLevels[j];
141
        if( object.mObjectSizes[j] > maxSize) maxSize  = object.mObjectSizes[j];
142
        }
143
      }
144

  
145
    MAX_NUM_OBJECTS = maxNum;
146
    MAX_LEVEL       = maxLevel;
147
    MAX_OBJECT_SIZE = maxSize;
148
    }
149

  
150
///////////////////////////////////////////////////////////////////////////////////////////////////
151

  
152
  private static void setUpColAndRow()
153
    {
154
    mIndices = new int[NUM_OBJECTS];
155
    mColCount= 0;
156

  
157
    for(int obj=0; obj<NUM_OBJECTS; obj++)
158
      {
159
      mIndices[obj] = objects[obj].mColumn;
160
      if( mIndices[obj]>=mColCount ) mColCount = mIndices[obj]+1;
161
      }
162

  
163
    mRowCount = 0;
164

  
165
    for(int col=0; col<mColCount; col++)
166
      {
167
      int numObjects = computeNumObjectsInColumn(col);
168
      if( numObjects>mRowCount ) mRowCount = numObjects;
169
      }
170
    }
171

  
172
///////////////////////////////////////////////////////////////////////////////////////////////////
173

  
174
  private static int computeNumObjectsInColumn(int column)
175
    {
176
    int num=0;
177

  
178
    for(int object=0; object<NUM_OBJECTS; object++)
179
      {
180
      if( objects[object].mColumn == column )
181
        {
182
        num += objects[object].mNumSizes;
183
        }
184
      }
185

  
186
    return num;
187
    }
188

  
189
///////////////////////////////////////////////////////////////////////////////////////////////////
190

  
191
  public static int getColumnCount()
192
    {
193
    if( mIndices==null ) setUpColAndRow();
194

  
195
    return mColCount;
196
    }
197

  
198
///////////////////////////////////////////////////////////////////////////////////////////////////
199

  
200
  public static int getRowCount()
201
    {
202
    if( mIndices==null ) setUpColAndRow();
203

  
204
    return mRowCount;
205
    }
206

  
207
///////////////////////////////////////////////////////////////////////////////////////////////////
208

  
209
  public static int[] getIndices()
210
    {
211
    if( mIndices==null ) setUpColAndRow();
212

  
213
    return mIndices;
214
    }
215

  
216
///////////////////////////////////////////////////////////////////////////////////////////////////
217

  
218
  public static ObjectList getObject(int ordinal)
219
    {
220
    return ordinal>=0 && ordinal<NUM_OBJECTS ? objects[ordinal] : CUBE;
221
    }
222

  
223
///////////////////////////////////////////////////////////////////////////////////////////////////
224

  
225
  public static int pack(int object, int sizeIndex)
226
    {
227
    int ret = 0;
228
    for(int i=0; i<object; i++) ret += objects[i].mObjectSizes.length;
229

  
230
    return ret+sizeIndex;
231
    }
232

  
233
///////////////////////////////////////////////////////////////////////////////////////////////////
234

  
235
  public static int unpackSizeIndex(int number)
236
    {
237
    int num;
238

  
239
    for(int i=0; i<NUM_OBJECTS; i++)
240
      {
241
      num = objects[i].mObjectSizes.length;
242
      if( number<num ) return number;
243
      number -= num;
244
      }
245

  
246
    return -1;
247
    }
248

  
249
///////////////////////////////////////////////////////////////////////////////////////////////////
250

  
251
  public static int unpackObject(int number)
252
    {
253
    int num;
254

  
255
    for(int i=0; i<NUM_OBJECTS; i++)
256
      {
257
      num = objects[i].mObjectSizes.length;
258
      if( number<num ) return i;
259
      number -= num;
260
      }
261

  
262
    return -1;
263
    }
264

  
265
///////////////////////////////////////////////////////////////////////////////////////////////////
266

  
267
  public static int unpackObjectFromString(String obj)
268
    {
269
    int u = obj.indexOf('_');
270
    int l = obj.length();
271

  
272
    if( u>0 )
273
      {
274
      String name = obj.substring(0,u);
275
      int size = Integer.parseInt( obj.substring(u+1,l) );
276

  
277
      for(int i=0; i<NUM_OBJECTS; i++)
278
        {
279
        if( objects[i].name().equals(name) )
280
          {
281
          int sizeIndex = getSizeIndex(i,size);
282
          return pack(i,sizeIndex);
283
          }
284
        }
285
      }
286

  
287
    return -1;
288
    }
289

  
290
///////////////////////////////////////////////////////////////////////////////////////////////////
291

  
292
  public static String getObjectList()
293
    {
294
    String name;
295
    StringBuilder list = new StringBuilder();
296
    int len;
297
    int[] sizes;
298

  
299
    for(int i=0; i<NUM_OBJECTS; i++)
300
      {
301
      sizes = objects[i].mObjectSizes;
302
      len   = sizes.length;
303
      name  = objects[i].name();
304

  
305
      for(int j=0; j<len; j++)
306
        {
307
        if( i>0 || j>0 ) list.append(',');
308
        list.append(name);
309
        list.append('_');
310
        list.append(sizes[j]);
311
        }
312
      }
313

  
314
    return list.toString();
315
    }
316

  
317
///////////////////////////////////////////////////////////////////////////////////////////////////
318

  
319
  public static int getTotal()
320
    {
321
    return mNumAll;
322
    }
323

  
324
///////////////////////////////////////////////////////////////////////////////////////////////////
325

  
326
  public static int getMaxLevel(int ordinal, int sizeIndex)
327
    {
328
    if( ordinal>=0 && ordinal<NUM_OBJECTS )
329
      {
330
      int num = objects[ordinal].mObjectSizes.length;
331
      return sizeIndex>=0 && sizeIndex<num ? objects[ordinal].mMaxLevels[sizeIndex] : 0;
332
      }
333

  
334
    return 0;
335
    }
336

  
337
///////////////////////////////////////////////////////////////////////////////////////////////////
338

  
339
  public static int getOrdinal(String name)
340
    {
341
    for(int i=0; i<NUM_OBJECTS; i++)
342
      {
343
      if(objects[i].name().equals(name)) return i;
344
      }
345

  
346
    return -1;
347
    }
348

  
349
///////////////////////////////////////////////////////////////////////////////////////////////////
350

  
351
  public static int getSizeIndex(int ordinal, int size)
352
    {
353
    if( ordinal>=0 && ordinal<NUM_OBJECTS )
354
      {
355
      int[] sizes = objects[ordinal].getSizes();
356
      int len = sizes.length;
357

  
358
      for(int i=0; i<len; i++)
359
        {
360
        if( sizes[i]==size ) return i;
361
        }
362
      }
363

  
364
    return -1;
365
    }
366

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

  
369
  public static int[] retFaceColors(ObjectList object)
370
    {
371
    Field field;
372
    int[] faceColors=null;
373

  
374
    try
375
      {
376
      field = object.mObjectClass.getDeclaredField("FACE_COLORS");
377
      field.setAccessible(true);
378
      Object obj = field.get(null);
379
      faceColors = (int[]) obj;
380
      }
381
    catch(NoSuchFieldException ex)
382
      {
383
      android.util.Log.e("RubikObjectList", object.mObjectClass.getSimpleName()+": no such field exception getting field: "+ex.getMessage());
384
      }
385
    catch(IllegalAccessException ex)
386
      {
387
      android.util.Log.e("RubikObjectList", object.mObjectClass.getSimpleName()+": illegal access exception getting field: "+ex.getMessage());
388
      }
389

  
390
    return faceColors;
391
    }
392

  
393
///////////////////////////////////////////////////////////////////////////////////////////////////
394

  
395
  ObjectList(int[][] info, Class<? extends TwistyObject> object , Movement movement, int column)
396
    {
397
    mNumSizes = info.length;
398

  
399
    mObjectSizes  = new int[mNumSizes];
400
    mMaxLevels    = new int[mNumSizes];
401
    mResourceIDs  = new int[mNumSizes];
402
    mSmallIconIDs = new int[mNumSizes];
403
    mMediumIconIDs= new int[mNumSizes];
404
    mBigIconIDs   = new int[mNumSizes];
405
    mHugeIconIDs  = new int[mNumSizes];
406

  
407
    for(int i=0; i<mNumSizes; i++)
408
      {
409
      mObjectSizes[i]  = info[i][0];
410
      mMaxLevels[i]    = info[i][1];
411
      mResourceIDs[i]  = info[i][2];
412
      mSmallIconIDs[i] = info[i][3];
413
      mMediumIconIDs[i]= info[i][4];
414
      mBigIconIDs[i]   = info[i][5];
415
      mHugeIconIDs[i]  = info[i][6];
416
      }
417

  
418
    mObjectClass         = object;
419
    mObjectMovementClass = movement;
420
    mColumn              = column;
421
    }
422

  
423
///////////////////////////////////////////////////////////////////////////////////////////////////
424

  
425
  public int[] getSizes()
426
    {
427
    return mObjectSizes;
428
    }
429

  
430
///////////////////////////////////////////////////////////////////////////////////////////////////
431

  
432
  public int[] getMaxLevels()
433
    {
434
    return mMaxLevels;
435
    }
436

  
437
///////////////////////////////////////////////////////////////////////////////////////////////////
438

  
439
  public int[] getIconIDs()
440
    {
441
    int size = RubikActivity.getDrawableSize();
442

  
443
    switch(size)
444
      {
445
      case 0 : return mSmallIconIDs;
446
      case 1 : return mMediumIconIDs;
447
      case 2 : return mBigIconIDs;
448
      default: return mHugeIconIDs;
449
      }
450
    }
451

  
452
///////////////////////////////////////////////////////////////////////////////////////////////////
453

  
454
  public int[] getResourceIDs()
455
    {
456
    return mResourceIDs;
457
    }
458

  
459
///////////////////////////////////////////////////////////////////////////////////////////////////
460

  
461
  public int getNumVariants()
462
    {
463
    return mObjectSizes.length;
464
    }
465

  
466
///////////////////////////////////////////////////////////////////////////////////////////////////
467

  
468
  public TwistyObject create(int size, Static4D quat, int[][] moves, Resources res, int scrWidth)
469
    {
470
    DistortedTexture texture = new DistortedTexture();
471
    DistortedEffects effects = new DistortedEffects();
472
    MeshSquare mesh          = new MeshSquare(20,20);   // mesh of the node, not of the cubits
473

  
474
    switch(ordinal())
475
      {
476
      case 0: return new TwistyCube(size, quat, texture, mesh, effects, moves, res, scrWidth);
477
      case 1: return new TwistyPyraminx(size, quat, texture, mesh, effects, moves, res, scrWidth);
478
      case 2: return new TwistyDiamond(size, quat, texture, mesh, effects, moves, res, scrWidth);
479
      case 3: return new TwistyDino6(size, quat, texture, mesh, effects, moves, res, scrWidth);
480
      case 4: return new TwistyDino4(size, quat, texture, mesh, effects, moves, res, scrWidth);
481
      case 5: return new TwistySkewb(size, quat, texture, mesh, effects, moves, res, scrWidth);
482
      case 6: return new TwistyHelicopter(size, quat, texture, mesh, effects, moves, res, scrWidth);
483
      }
484

  
485
    return null;
486
    }
487

  
488
///////////////////////////////////////////////////////////////////////////////////////////////////
489

  
490
  public Movement getObjectMovementClass()
491
    {
492
    return mObjectMovementClass;
493
    }
494
  }
src/main/java/org/distorted/objects/RubikCube.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
import android.graphics.Canvas;
24
import android.graphics.Paint;
25

  
26
import org.distorted.library.effect.VertexEffectDeform;
27
import org.distorted.library.effect.VertexEffectMove;
28
import org.distorted.library.effect.VertexEffectRotate;
29
import org.distorted.library.main.DistortedEffects;
30
import org.distorted.library.main.DistortedTexture;
31
import org.distorted.library.mesh.MeshBase;
32
import org.distorted.library.mesh.MeshJoined;
33
import org.distorted.library.mesh.MeshPolygon;
34
import org.distorted.library.mesh.MeshSquare;
35
import org.distorted.library.type.Static1D;
36
import org.distorted.library.type.Static3D;
37
import org.distorted.library.type.Static4D;
38
import org.distorted.main.RubikSurfaceView;
39

  
40
import java.util.Random;
41

  
42
import static org.distorted.effects.scramble.ScrambleEffect.START_AXIS;
43

  
44
///////////////////////////////////////////////////////////////////////////////////////////////////
45

  
46
class RubikCube extends RubikObject
47
{
48
  static final float SQ2 = (float)Math.sqrt(2);
49

  
50
  // the three rotation axis of a RubikCube. Must be normalized.
51
  static final Static3D[] ROT_AXIS = new Static3D[]
52
         {
53
           new Static3D(1,0,0),
54
           new Static3D(0,1,0),
55
           new Static3D(0,0,1)
56
         };
57

  
58
  // the six axis that determine the faces
59
  static final Static3D[] FACE_AXIS = new Static3D[]
60
         {
61
           new Static3D(1,0,0), new Static3D(-1,0,0),
62
           new Static3D(0,1,0), new Static3D(0,-1,0),
63
           new Static3D(0,0,1), new Static3D(0,0,-1)
64
         };
65

  
66
  private static final int[] FACE_COLORS = new int[]
67
         {
68
           COLOR_YELLOW, COLOR_WHITE,
69
           COLOR_BLUE  , COLOR_GREEN,
70
           COLOR_RED   , COLOR_BROWN
71
         };
72

  
73
  // All legal rotation quats of a RubikCube of any size.
74
  // Here's how to compute this:
75
  // 1) compute how many rotations there are (RubikCube of any size = 24)
76
  // 2) take the AXIS, angles of rotation (90 in RubikCube's case) compute the basic quaternions
77
  // (i.e. rotations of 1 basic angle along each of the axis) and from there start semi-randomly
78
  // multiplying them and eventually you'll find all (24) legal rotations.
79
  // Example program in C, res/raw/compute_quats.c , is included.
80
  private static final Static4D[] QUATS = new Static4D[]
81
         {
82
         new Static4D(  0.0f,   0.0f,   0.0f,   1.0f),
83
         new Static4D(  1.0f,   0.0f,   0.0f,   0.0f),
84
         new Static4D(  0.0f,   1.0f,   0.0f,   0.0f),
85
         new Static4D(  0.0f,   0.0f,   1.0f,   0.0f),
86

  
87
         new Static4D( SQ2/2,  SQ2/2,  0.0f ,   0.0f),
88
         new Static4D( SQ2/2, -SQ2/2,  0.0f ,   0.0f),
89
         new Static4D( SQ2/2,   0.0f,  SQ2/2,   0.0f),
90
         new Static4D(-SQ2/2,   0.0f,  SQ2/2,   0.0f),
91
         new Static4D( SQ2/2,   0.0f,   0.0f,  SQ2/2),
92
         new Static4D( SQ2/2,   0.0f,   0.0f, -SQ2/2),
93
         new Static4D(  0.0f,  SQ2/2,  SQ2/2,   0.0f),
94
         new Static4D(  0.0f,  SQ2/2, -SQ2/2,   0.0f),
95
         new Static4D(  0.0f,  SQ2/2,   0.0f,  SQ2/2),
96
         new Static4D(  0.0f,  SQ2/2,   0.0f, -SQ2/2),
97
         new Static4D(  0.0f,   0.0f,  SQ2/2,  SQ2/2),
98
         new Static4D(  0.0f,   0.0f,  SQ2/2, -SQ2/2),
99

  
100
         new Static4D(  0.5f,   0.5f,   0.5f,   0.5f),
101
         new Static4D(  0.5f,   0.5f,  -0.5f,   0.5f),
102
         new Static4D(  0.5f,   0.5f,  -0.5f,  -0.5f),
103
         new Static4D(  0.5f,  -0.5f,   0.5f,  -0.5f),
104
         new Static4D( -0.5f,  -0.5f,  -0.5f,   0.5f),
105
         new Static4D( -0.5f,   0.5f,  -0.5f,  -0.5f),
106
         new Static4D( -0.5f,   0.5f,   0.5f,  -0.5f),
107
         new Static4D( -0.5f,   0.5f,   0.5f,   0.5f)
108
         };
109

  
110
  private static MeshBase[] mMeshes;
111

  
112
///////////////////////////////////////////////////////////////////////////////////////////////////
113

  
114
  RubikCube(int size, Static4D quat, DistortedTexture texture,
115
            MeshSquare mesh, DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
116
    {
117
    super(size, 60, quat, texture, mesh, effects, moves, RubikObjectList.CUBE, res, scrWidth);
118
    }
119

  
120
///////////////////////////////////////////////////////////////////////////////////////////////////
121
// paint the square with upper-right corner at (left,top) and side length 'side' with texture
122
// for face 'face'.
123

  
124
  void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top, int side)
125
    {
126
    final float R = side*0.10f;
127
    final float M = side*0.05f;
128

  
129
    paint.setColor(FACE_COLORS[face]);
130
    canvas.drawRoundRect( left+M, top+M, left+side-M, top+side-M, R, R, paint);
131
    }
132

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

  
135
  Static3D[] getCubitPositions(int size)
136
    {
137
    int numCubits = size>1 ? 6*size*size - 12*size + 8 : 1;
138
    Static3D[] tmp = new Static3D[numCubits];
139

  
140
    float diff = 0.5f*(size-1);
141
    int currentPosition = 0;
142

  
143
    for(int x = 0; x<size; x++)
144
      for(int y = 0; y<size; y++)
145
        for(int z = 0; z<size; z++)
146
          if( x==0 || x==size-1 || y==0 || y==size-1 || z==0 || z==size-1 )
147
            {
148
            tmp[currentPosition++] = new Static3D(x-diff,y-diff,z-diff);
149
            }
150

  
151
    return tmp;
152
    }
153

  
154
///////////////////////////////////////////////////////////////////////////////////////////////////
155

  
156
  Static4D[] getQuats()
157
    {
158
    return QUATS;
159
    }
160

  
161
///////////////////////////////////////////////////////////////////////////////////////////////////
162

  
163
  boolean shouldResetTextureMaps()
164
    {
165
    return false;
166
    }
167

  
168
///////////////////////////////////////////////////////////////////////////////////////////////////
169

  
170
  int getNumFaces()
171
    {
172
    return FACE_COLORS.length;
173
    }
174

  
175
///////////////////////////////////////////////////////////////////////////////////////////////////
176

  
177
  float getBasicStep()
178
    {
179
    return 1.0f;
180
    }
181

  
182
///////////////////////////////////////////////////////////////////////////////////////////////////
183

  
184
  int getNumStickerTypes()
185
    {
186
    return 1;
187
    }
188

  
189
///////////////////////////////////////////////////////////////////////////////////////////////////
190

  
191
  int getNumCubitFaces()
192
    {
193
    return FACE_COLORS.length;
194
    }
195

  
196
///////////////////////////////////////////////////////////////////////////////////////////////////
197

  
198
  float getScreenRatio()
199
    {
200
    return 0.5f;
201
    }
202

  
203
///////////////////////////////////////////////////////////////////////////////////////////////////
204

  
205
  int getFaceColor(int cubit, int cubitface, int size)
206
    {
207
    boolean belongs = isOnFace(cubit, cubitface/2, cubitface%2==0 ? size-1:0 );
208
    return belongs ? cubitface : NUM_FACES;
209
    }
210

  
211
///////////////////////////////////////////////////////////////////////////////////////////////////
212

  
213
  MeshBase createCubitMesh(int cubit)
214
    {
215
    int size   = getSize();
216
    int ordinal= RubikObjectList.CUBE.ordinal();
217
    int index  = RubikObjectList.getSizeIndex(ordinal,size);
218
    float[] bands;
219
    float D = 0.027f;
220
    float E = 0.5f-D;
221
    float[] vertices = { -E,-E, +E,-E, +E,+E, -E,+E };
222
    int extraI, extraV;
223

  
224
    switch(size)
225
      {
226
      case 2 : bands = new float[] { 1.0f    ,-D,
227
                                     1.0f-D/2,-D*0.55f,
228
                                     1.0f-D  ,-D*0.25f,
229
                                     1.0f-2*D, 0.0f,
230
                                     0.50f, 0.040f,
231
                                     0.0f, 0.048f };
232
               extraI = 2;
233
               extraV = 2;
234
               break;
235
      case 3 : bands = new float[] { 1.0f    ,-D,
236
                                     1.0f-D*1.2f,-D*0.55f,
237
                                     1.0f-2*D, 0.0f,
238
                                     0.50f, 0.040f,
239
                                     0.0f, 0.048f };
240
               extraI = 2;
241
               extraV = 2;
242
               break;
243
      case 4 : bands = new float[] { 1.0f    ,-D,
244
                                     1.0f-D*1.2f,-D*0.55f,
245
                                     1.0f-2*D, 0.0f,
246
                                     0.50f, 0.040f,
247
                                     0.0f, 0.048f };
248
               extraI = 1;
249
               extraV = 2;
250
               break;
251
      default: bands = new float[] { 1.0f    ,-D,
252
                                     1.0f-2*D, 0.0f,
253
                                     0.50f, 0.025f,
254
                                     0.0f, 0.030f };
255
               extraI = 1;
256
               extraV = 1;
257
               break;
258
      }
259

  
260
    return createCubitMesh(index,vertices,bands,extraI,extraV);
261
    }
262

  
263
///////////////////////////////////////////////////////////////////////////////////////////////////
264

  
265
  MeshBase createCubitMesh(int index, float[] vertices, float[] bands, int extraI, int extraV)
266
    {
267
    if( mMeshes==null )
268
      {
269
      mMeshes = new MeshBase[RubikObjectList.CUBE.getNumVariants()];
270
      }
271

  
272
    if( mMeshes[index]==null )
273
      {
274
      final int MESHES=6;
275
      int association = 1;
276
      MeshBase[] meshes = new MeshPolygon[MESHES];
277
      meshes[0] = new MeshPolygon(vertices,bands,extraI,extraV);
278
      meshes[0].setEffectAssociation(0,association,0);
279

  
280
      for(int i=1; i<MESHES; i++)
281
        {
282
        association <<=1;
283
        meshes[i] = meshes[0].copy(true);
284
        meshes[i].setEffectAssociation(0,association,0);
285
        }
286

  
287
      mMeshes[index] = new MeshJoined(meshes);
288

  
289
      Static3D axisY   = new Static3D(0,1,0);
290
      Static3D axisX   = new Static3D(1,0,0);
291
      Static3D center  = new Static3D(0,0,0);
292
      Static1D angle90 = new Static1D(90);
293
      Static1D angle180= new Static1D(180);
294
      Static1D angle270= new Static1D(270);
295

  
296
      float d1 = 1.0f;
297
      float d2 =-0.05f;
298
      float d3 = 0.12f;
299

  
300
      Static3D dCen0 = new Static3D( d1*(+0.5f), d1*(+0.5f), d1*(+0.5f) );
301
      Static3D dCen1 = new Static3D( d1*(+0.5f), d1*(+0.5f), d1*(-0.5f) );
302
      Static3D dCen2 = new Static3D( d1*(+0.5f), d1*(-0.5f), d1*(+0.5f) );
303
      Static3D dCen3 = new Static3D( d1*(+0.5f), d1*(-0.5f), d1*(-0.5f) );
304
      Static3D dCen4 = new Static3D( d1*(-0.5f), d1*(+0.5f), d1*(+0.5f) );
305
      Static3D dCen5 = new Static3D( d1*(-0.5f), d1*(+0.5f), d1*(-0.5f) );
306
      Static3D dCen6 = new Static3D( d1*(-0.5f), d1*(-0.5f), d1*(+0.5f) );
307
      Static3D dCen7 = new Static3D( d1*(-0.5f), d1*(-0.5f), d1*(-0.5f) );
308

  
309
      Static3D dVec0 = new Static3D( d2*(+0.5f), d2*(+0.5f), d2*(+0.5f) );
310
      Static3D dVec1 = new Static3D( d2*(+0.5f), d2*(+0.5f), d2*(-0.5f) );
311
      Static3D dVec2 = new Static3D( d2*(+0.5f), d2*(-0.5f), d2*(+0.5f) );
312
      Static3D dVec3 = new Static3D( d2*(+0.5f), d2*(-0.5f), d2*(-0.5f) );
313
      Static3D dVec4 = new Static3D( d2*(-0.5f), d2*(+0.5f), d2*(+0.5f) );
314
      Static3D dVec5 = new Static3D( d2*(-0.5f), d2*(+0.5f), d2*(-0.5f) );
315
      Static3D dVec6 = new Static3D( d2*(-0.5f), d2*(-0.5f), d2*(+0.5f) );
316
      Static3D dVec7 = new Static3D( d2*(-0.5f), d2*(-0.5f), d2*(-0.5f) );
317

  
318
      Static4D dReg  = new Static4D(0,0,0,d3);
319
      Static1D dRad  = new Static1D(1);
320

  
321
      VertexEffectMove   effect0 = new VertexEffectMove(new Static3D(0,0,+0.5f));
322
      effect0.setMeshAssociation(63,-1);  // all 6 sides
323
      VertexEffectRotate effect1 = new VertexEffectRotate( angle180, axisX, center );
324
      effect1.setMeshAssociation(32,-1);  // back
325
      VertexEffectRotate effect2 = new VertexEffectRotate( angle90 , axisX, center );
326
      effect2.setMeshAssociation( 8,-1);  // bottom
327
      VertexEffectRotate effect3 = new VertexEffectRotate( angle270, axisX, center );
328
      effect3.setMeshAssociation( 4,-1);  // top
329
      VertexEffectRotate effect4 = new VertexEffectRotate( angle270, axisY, center );
330
      effect4.setMeshAssociation( 2,-1);  // left
331
      VertexEffectRotate effect5 = new VertexEffectRotate( angle90 , axisY, center );
332
      effect5.setMeshAssociation( 1,-1);  // right
333

  
334
      VertexEffectDeform effect6 = new VertexEffectDeform(dVec0, dRad, dCen0, dReg);
335
      VertexEffectDeform effect7 = new VertexEffectDeform(dVec1, dRad, dCen1, dReg);
336
      VertexEffectDeform effect8 = new VertexEffectDeform(dVec2, dRad, dCen2, dReg);
337
      VertexEffectDeform effect9 = new VertexEffectDeform(dVec3, dRad, dCen3, dReg);
338
      VertexEffectDeform effect10= new VertexEffectDeform(dVec4, dRad, dCen4, dReg);
339
      VertexEffectDeform effect11= new VertexEffectDeform(dVec5, dRad, dCen5, dReg);
340
      VertexEffectDeform effect12= new VertexEffectDeform(dVec6, dRad, dCen6, dReg);
341
      VertexEffectDeform effect13= new VertexEffectDeform(dVec7, dRad, dCen7, dReg);
342

  
343
      mMeshes[index].apply(effect0);
344
      mMeshes[index].apply(effect1);
345
      mMeshes[index].apply(effect2);
346
      mMeshes[index].apply(effect3);
347
      mMeshes[index].apply(effect4);
348
      mMeshes[index].apply(effect5);
349
      mMeshes[index].apply(effect6);
350
      mMeshes[index].apply(effect7);
351
      mMeshes[index].apply(effect8);
352
      mMeshes[index].apply(effect9);
353
      mMeshes[index].apply(effect10);
354
      mMeshes[index].apply(effect11);
355
      mMeshes[index].apply(effect12);
356
      mMeshes[index].apply(effect13);
357

  
358
      mMeshes[index].mergeEffComponents();
359
      }
360

  
361
    return mMeshes[index].copy(true);
362
    }
363

  
364
///////////////////////////////////////////////////////////////////////////////////////////////////
365

  
366
  float returnMultiplier()
367
    {
368
    return getSize();
369
    }
370

  
371
///////////////////////////////////////////////////////////////////////////////////////////////////
372

  
373
  float[] getRowChances()
374
    {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff