Project

General

Profile

« Previous | Next » 

Revision 925ed78f

Added by Leszek Koltunski over 3 years ago

Make it possible for an object to have different 'basicAngles' along each of its axis.

View differences:

src/main/java/org/distorted/effects/scramble/ScrambleEffect.java
70 70
  private int mNumDoubleScramblesLeft, mNumScramblesLeft;
71 71
  private long mDurationSingleTurn;
72 72
  private final Random mRnd;
73
  private int mBasicAngle;
73
  private int[] mBasicAngle;
74 74
  private boolean mRotReady, mPluginReady;
75 75

  
76 76
  TwistyObject mObject;
......
149 149
        android.util.Log.e("effect", "ERROR: "+mNumDoubleScramblesLeft);
150 150
        }
151 151

  
152
      mController.addRotation(this, axis, rowBitmap, angle*(360/mBasicAngle), durationMillis);
152
      mController.addRotation(this, axis, rowBitmap, angle*(360/mBasicAngle[axis]), durationMillis);
153 153

  
154 154
      mNumScrambles++;
155 155
      }
src/main/java/org/distorted/main/RubikSurfaceView.java
397 397
    private void finishRotation()
398 398
      {
399 399
      computeCurrentSpeedInInchesPerSecond();
400
      int angle = mPreRender.getObject().computeNearestAngle(mCurrentAngle, mCurrRotSpeed);
400
      int angle = mPreRender.getObject().computeNearestAngle(mCurrentAxis,mCurrentAngle, mCurrRotSpeed);
401 401
      mPreRender.finishRotation(angle);
402 402
      mPreRender.rememberMove(mCurrentAxis,mCurrentRow,angle);
403 403

  
src/main/java/org/distorted/objects/TwistyBandagedAbstract.java
52 52
           new Static3D(0,0,1)
53 53
         };
54 54

  
55
  private static final int[] BASIC_ANGLE = new int[] { 4,4,4 };
56

  
55 57
  private static final int[] FACE_COLORS = new int[]
56 58
         {
57 59
           COLOR_YELLOW, COLOR_WHITE,
......
545 547

  
546 548
///////////////////////////////////////////////////////////////////////////////////////////////////
547 549

  
548
  public int getBasicAngle()
550
  public int[] getBasicAngle()
549 551
    {
550
    return 4;
552
    return BASIC_ANGLE;
551 553
    }
552 554

  
553 555
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyCube.java
47 47
           new Static3D(0,0,1)
48 48
         };
49 49

  
50
  private static final int[] BASIC_ANGLE = new int[] { 4,4,4 };
51

  
50 52
  private static final int[] FACE_COLORS = new int[]
51 53
         {
52 54
           COLOR_YELLOW, COLOR_WHITE,
......
287 289

  
288 290
///////////////////////////////////////////////////////////////////////////////////////////////////
289 291

  
290
  public int getBasicAngle()
292
  public int[] getBasicAngle()
291 293
    {
292
    return 4;
294
    return BASIC_ANGLE;
293 295
    }
294 296

  
295 297
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyDiamond.java
51 51
           new Static3D(     0,-SQ3/3,+SQ6/3)
52 52
         };
53 53

  
54
  private static final int[] BASIC_ANGLE = new int[] { 3,3,3,3 };
55

  
54 56
  private static final int[] FACE_COLORS = new int[]
55 57
         {
56 58
           COLOR_ORANGE, COLOR_VIOLET,
......
510 512

  
511 513
///////////////////////////////////////////////////////////////////////////////////////////////////
512 514

  
513
  public int getBasicAngle()
515
  public int[] getBasicAngle()
514 516
    {
515
    return 3;
517
    return BASIC_ANGLE;
516 518
    }
517 519

  
518 520
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyDino.java
46 46
           new Static3D(+SQ3/3,-SQ3/3,-SQ3/3)
47 47
         };
48 48

  
49
  private static final int[] BASIC_ANGLE = new int[] { 3,3,3,3 };
50

  
49 51
  private static final int[] FACE_COLORS = new int[]
50 52
         {
51 53
           COLOR_YELLOW, COLOR_WHITE,
......
236 238

  
237 239
///////////////////////////////////////////////////////////////////////////////////////////////////
238 240

  
239
  public int getBasicAngle()
241
  public int[] getBasicAngle()
240 242
    {
241
    return 3;
243
    return BASIC_ANGLE;
242 244
    }
243 245

  
244 246
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyHelicopter.java
53 53
           new Static3D(-SQ2/2, -SQ2/2,      0)
54 54
         };
55 55

  
56
  private static final int[] BASIC_ANGLE = new int[] { 2,2,2,2,2,2 };
57

  
56 58
  private static final int[] FACE_COLORS = new int[]
57 59
         {
58 60
           COLOR_YELLOW, COLOR_WHITE,
......
403 405

  
404 406
///////////////////////////////////////////////////////////////////////////////////////////////////
405 407

  
406
  public int getBasicAngle()
408
  public int[] getBasicAngle()
407 409
    {
408
    return 2;
410
    return BASIC_ANGLE;
409 411
    }
410 412

  
411 413
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyIvy.java
63 63
           new Static3D(+SQ3/3,-SQ3/3,-SQ3/3)
64 64
         };
65 65

  
66
  private static final int[] BASIC_ANGLE = new int[] { 3,3,3,3 };
67

  
66 68
  private static final int[] FACE_COLORS = new int[]
67 69
         {
68 70
           COLOR_YELLOW, COLOR_WHITE,
......
426 428

  
427 429
///////////////////////////////////////////////////////////////////////////////////////////////////
428 430

  
429
  public int getBasicAngle()
431
  public int[] getBasicAngle()
430 432
    {
431
    return 3;
433
    return BASIC_ANGLE;
432 434
    }
433 435

  
434 436
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyMinx.java
61 61
           new Static3D( SIN54/LEN,    0     ,   -C2/LEN )
62 62
         };
63 63

  
64
  private static final int[] BASIC_ANGLE = new int[] { 5,5,5,5,5,5 };
65

  
64 66
  static final int MINX_LGREEN = 0xff53aa00;
65 67
  static final int MINX_PINK   = 0xfffd7ab7;
66 68
  static final int MINX_SANDY  = 0xffefd48b;
......
450 452

  
451 453
///////////////////////////////////////////////////////////////////////////////////////////////////
452 454

  
453
  public int getBasicAngle()
455
  public int[] getBasicAngle()
454 456
    {
455
    return 5;
457
    return BASIC_ANGLE;
456 458
    }
457 459

  
458 460
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyObject.java
370 370
      {
371 371
      Static4D quat;
372 372
      int index, axis, rowBitmap, angle;
373
      int corr = (360/getBasicAngle());
373
      int[] basic = getBasicAngle();
374 374

  
375 375
      for(int[] move: moves)
376 376
        {
377 377
        axis     = move[0];
378 378
        rowBitmap= move[1];
379
        angle    = move[2]*corr;
379
        angle    = move[2]*(360/basic[axis]);
380 380
        quat     = makeQuaternion(axis,angle);
381 381

  
382 382
        for(int j=0; j<NUM_CUBITS; j++)
......
914 914

  
915 915
///////////////////////////////////////////////////////////////////////////////////////////////////
916 916

  
917
  public int computeNearestAngle(float angle, float speed)
917
  public int computeNearestAngle(int axis, float angle, float speed)
918 918
    {
919
    final int NEAREST = 360/getBasicAngle();
919
    final int NEAREST = 360/getBasicAngle()[axis];
920 920

  
921 921
    int tmp = (int)((angle+NEAREST/2)/NEAREST);
922 922
    if( angle< -(NEAREST*0.5) ) tmp-=1;
......
961 961
  abstract float returnMultiplier();
962 962
  abstract float[] getCuts(int numLayers);
963 963
  abstract boolean shouldResetTextureMaps();
964
  abstract Static3D[] getRotationAxis();
964 965

  
965 966
  public abstract boolean isSolved();
966
  public abstract Static3D[] getRotationAxis();
967
  public abstract int getBasicAngle();
967
  public abstract int[] getBasicAngle();
968 968
  public abstract String retObjectString();
969 969
  public abstract void randomizeNewScramble(int[][] scramble, Random rnd, int numScramble);
970 970
  public abstract int getObjectName(int numLayers);
src/main/java/org/distorted/objects/TwistyPyraminx.java
47 47
           new Static3D(-SQ6/3,+SQ3/3,     0),
48 48
         };
49 49

  
50
  private static final int[] BASIC_ANGLE = new int[] { 3,3,3,3 };
51

  
50 52
  private static final int[] FACE_COLORS = new int[]
51 53
         {
52 54
           COLOR_GREEN , COLOR_YELLOW,
......
377 379

  
378 380
///////////////////////////////////////////////////////////////////////////////////////////////////
379 381

  
380
  public int getBasicAngle()
382
  public int[] getBasicAngle()
381 383
    {
382
    return 3;
384
    return BASIC_ANGLE;
383 385
    }
384 386

  
385 387
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyRedi.java
51 51
           new Static3D(+SQ3/3,-SQ3/3,-SQ3/3)
52 52
         };
53 53

  
54
  private static final int[] BASIC_ANGLE = new int[] { 3,3,3,3 };
55

  
54 56
  private static final int[] FACE_COLORS = new int[]
55 57
         {
56 58
           COLOR_YELLOW, COLOR_WHITE,
......
416 418

  
417 419
///////////////////////////////////////////////////////////////////////////////////////////////////
418 420

  
419
  public int getBasicAngle()
421
  public int[] getBasicAngle()
420 422
    {
421
    return 3;
423
    return BASIC_ANGLE;
422 424
    }
423 425

  
424 426
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyRex.java
60 60
           new Static3D(+SQ3/3,-SQ3/3,-SQ3/3)
61 61
         };
62 62

  
63
  private static final int[] BASIC_ANGLE = new int[] { 3,3,3,3 };
64

  
63 65
  private static final int[] FACE_COLORS = new int[]
64 66
         {
65 67
           COLOR_YELLOW, COLOR_WHITE,
......
591 593

  
592 594
///////////////////////////////////////////////////////////////////////////////////////////////////
593 595

  
594
  public int getBasicAngle()
596
  public int[] getBasicAngle()
595 597
    {
596
    return 3;
598
    return BASIC_ANGLE;
597 599
    }
598 600

  
599 601
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistySkewb.java
51 51
           new Static3D(+SQ3/3,-SQ3/3,-SQ3/3)
52 52
         };
53 53

  
54
  private static final int[] BASIC_ANGLE = new int[] { 3,3,3,3 };
55

  
54 56
  private static final int[] FACE_COLORS = new int[]
55 57
         {
56 58
           COLOR_YELLOW, COLOR_WHITE,
......
611 613

  
612 614
///////////////////////////////////////////////////////////////////////////////////////////////////
613 615

  
614
  public int getBasicAngle()
616
  public int[] getBasicAngle()
615 617
    {
616
    return 3;
618
    return BASIC_ANGLE;
617 619
    }
618 620

  
619 621
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistySquare1.java
50 50
      new Static3D(COS15,0,SIN15)
51 51
    };
52 52

  
53
  private static final int[] BASIC_ANGLE = new int[] { 12,2 };
54

  
53 55
  private static final int[] FACE_COLORS = new int[]
54 56
    {
55 57
      COLOR_YELLOW, COLOR_WHITE,
......
454 456
    }
455 457

  
456 458
///////////////////////////////////////////////////////////////////////////////////////////////////
457
// TODO
458 459

  
459
  public int getBasicAngle()
460
  public int[] getBasicAngle()
460 461
    {
461
    return 4;
462
    return BASIC_ANGLE;
462 463
    }
463 464

  
464 465
///////////////////////////////////////////////////////////////////////////////////////////////////
......
472 473
      }
473 474
    else
474 475
      {
475
      int newVector = rnd.nextInt(NUM_AXIS -1);
476
      int newVector = rnd.nextInt(NUM_AXIS-1);
476 477
      scramble[num][0] = (newVector>=scramble[num-1][0] ? newVector+1 : newVector);
477 478
      }
478 479

  
src/main/java/org/distorted/objects/TwistyUltimate.java
69 69
           new Static3D( 0,C,-B)
70 70
         };
71 71

  
72
  private static final int[] BASIC_ANGLE = new int[] { 3,3,3,3 };
73

  
72 74
  private static final int[] FACE_COLORS = new int[]
73 75
         {
74 76
           MINX_LGREEN, MINX_PINK   , MINX_SANDY , MINX_LBLUE,
......
434 436

  
435 437
///////////////////////////////////////////////////////////////////////////////////////////////////
436 438

  
437
  public int getBasicAngle()
439
  public int[] getBasicAngle()
438 440
    {
439
    return 3;
441
    return BASIC_ANGLE;
440 442
    }
441 443

  
442 444
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/patterns/RubikPattern.java
265 265
          }
266 266
        else
267 267
          {
268
          int axis     = moves[curMove-1][0];
269
		      int rowBitmap= moves[curMove-1][1];
270
		      int bareAngle= moves[curMove-1][2];
271
          int angle    = bareAngle*(360/pre.getObject().getBasicAngle());
272
          int numRot   = Math.abs(bareAngle);
268
          int axis      = moves[curMove-1][0];
269
		      int rowBitmap = moves[curMove-1][1];
270
		      int bareAngle = moves[curMove-1][2];
271
		      int basicAngle= pre.getObject().getBasicAngle()[axis];
272
          int angle     = bareAngle*(360/basicAngle);
273
          int numRot    = Math.abs(bareAngle);
273 274

  
274 275
          if( angle!=0 )
275 276
            {
......
305 306
          }
306 307
        else
307 308
          {
308
          int axis     = moves[curMove][0];
309
		      int rowBitmap= moves[curMove][1];
310
		      int bareAngle= moves[curMove][2];
311
          int angle    = bareAngle*(360/pre.getObject().getBasicAngle());
312
          int numRot   = Math.abs(bareAngle);
309
          int axis      = moves[curMove][0];
310
		      int rowBitmap = moves[curMove][1];
311
		      int bareAngle = moves[curMove][2];
312
		      int basicAngle= pre.getObject().getBasicAngle()[axis];
313
          int angle     = bareAngle*(360/basicAngle);
314
          int numRot    = Math.abs(bareAngle);
313 315

  
314 316
          if( angle!=0 )
315 317
            {
src/main/java/org/distorted/screens/RubikScreenBase.java
70 70
        int axis  = move.mAxis;
71 71
        int row   = (1<<move.mRow);
72 72
        int angle = move.mAngle;
73
        int numRot= Math.abs(angle*object.getBasicAngle()/360);
73
        int basic = object.getBasicAngle()[axis];
74
        int numRot= Math.abs(angle*basic/360);
74 75

  
75 76
        if( angle!=0 )
76 77
          {
src/main/java/org/distorted/screens/RubikScreenSolution.java
197 197
        }
198 198
      else
199 199
        {
200
        int axis     = mMoves[mCurrMove-1][0];
201
		    int rowBitmap= mMoves[mCurrMove-1][1];
202
		    int bareAngle= mMoves[mCurrMove-1][2];
203
        int angle    = bareAngle*(360/pre.getObject().getBasicAngle());
204
        int numRot   = Math.abs(bareAngle);
200
        int axis      = mMoves[mCurrMove-1][0];
201
		    int rowBitmap = mMoves[mCurrMove-1][1];
202
		    int bareAngle = mMoves[mCurrMove-1][2];
203
		    int basicAngle= pre.getObject().getBasicAngle()[axis];
204
        int angle     = bareAngle*(360/basicAngle);
205
        int numRot    = Math.abs(bareAngle);
205 206

  
206 207
        if( angle!=0 )
207 208
          {
......
235 236
        }
236 237
      else
237 238
        {
238
        int axis     = mMoves[mCurrMove][0];
239
		    int rowBitmap= mMoves[mCurrMove][1];
240
		    int bareAngle= mMoves[mCurrMove][2];
241
        int angle    = bareAngle*(360/pre.getObject().getBasicAngle());
242
        int numRot   = Math.abs(bareAngle);
239
        int axis      = mMoves[mCurrMove][0];
240
		    int rowBitmap = mMoves[mCurrMove][1];
241
		    int bareAngle = mMoves[mCurrMove][2];
242
        int basicAngle= pre.getObject().getBasicAngle()[axis];
243
        int angle     = bareAngle*(360/basicAngle);
244
        int numRot    = Math.abs(bareAngle);
243 245

  
244 246
        if( angle!=0 )
245 247
          {
src/main/java/org/distorted/tutorials/TutorialState.java
74 74
        int axis  = move.mAxis;
75 75
        int row   = (1<<move.mRow);
76 76
        int angle = move.mAngle;
77
        int numRot= Math.abs(angle*object.getBasicAngle()/360);
77
        int basic = object.getBasicAngle()[axis];
78
        int numRot= Math.abs(angle*basic/360);
78 79

  
79 80
        if( angle!=0 )
80 81
          {
src/main/java/org/distorted/tutorials/TutorialSurfaceView.java
366 366
    private void finishRotation()
367 367
      {
368 368
      computeCurrentSpeedInInchesPerSecond();
369
      int angle = mPreRender.getObject().computeNearestAngle(mCurrentAngle, mCurrRotSpeed);
369
      int angle = mPreRender.getObject().computeNearestAngle(mCurrentAxis,mCurrentAngle, mCurrRotSpeed);
370 370
      mPreRender.finishRotation(angle);
371 371

  
372 372
      if( angle!=0 )

Also available in: Unified diff