Revision 59c20632
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objectlib/objects/TwistyCuboid.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.objectlib.objects; |
21 | 21 |
|
22 |
import static org.distorted.objectlib.main.Movement.MOVEMENT_SHAPECHANGE; |
|
22 | 23 |
import static org.distorted.objectlib.main.Movement.TYPE_NOT_SPLIT; |
23 | 24 |
|
24 | 25 |
import android.content.res.Resources; |
... | ... | |
30 | 31 |
import org.distorted.library.type.Static4D; |
31 | 32 |
|
32 | 33 |
import org.distorted.objectlib.R; |
33 |
import org.distorted.objectlib.main.Movement; |
|
34 | 34 |
import org.distorted.objectlib.main.MovementC; |
35 | 35 |
import org.distorted.objectlib.main.ObjectControl; |
36 | 36 |
import org.distorted.objectlib.main.ObjectType; |
... | ... | |
50 | 50 |
new Static3D(0,0,1) |
51 | 51 |
}; |
52 | 52 |
|
53 |
private static final int[][][] ENABLED = new int[][][] |
|
54 |
{ |
|
55 |
{{1,2}},{{1,2}},{{0,2}},{{0,2}},{{0,1}},{{0,1}}, |
|
56 |
}; |
|
57 |
|
|
58 | 53 |
private ScrambleState[] mStates; |
59 | 54 |
private Static4D[] mQuats; |
60 | 55 |
private float[][] mCuts; |
61 |
private boolean[][] mLayerRotatable; |
|
62 | 56 |
private int[] mBasicAngle; |
63 | 57 |
private ObjectSticker[] mStickers; |
64 |
private Movement mMovement; |
|
65 | 58 |
|
66 | 59 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
67 | 60 |
|
... | ... | |
564 | 557 |
|
565 | 558 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
566 | 559 |
|
567 |
private void getLayerRotatable(int[] numLayers)
|
|
560 |
public boolean[][] getLayerRotatable(int[] numLayers)
|
|
568 | 561 |
{ |
569 |
if( mLayerRotatable==null ) |
|
570 |
{ |
|
571 |
int numAxis = ROT_AXIS.length; |
|
572 |
mLayerRotatable = new boolean[numAxis][]; |
|
562 |
int numAxis = ROT_AXIS.length; |
|
563 |
boolean[][] layerRotatable = new boolean[numAxis][]; |
|
573 | 564 |
|
574 |
for(int i=0; i<numAxis; i++) |
|
575 |
{ |
|
576 |
mLayerRotatable[i] = new boolean[numLayers[i]]; |
|
577 |
for(int j=0; j<numLayers[i]; j++) mLayerRotatable[i][j] = true; |
|
578 |
} |
|
565 |
for(int i=0; i<numAxis; i++) |
|
566 |
{ |
|
567 |
layerRotatable[i] = new boolean[numLayers[i]]; |
|
568 |
for(int j=0; j<numLayers[i]; j++) layerRotatable[i][j] = true; |
|
579 | 569 |
} |
580 |
} |
|
581 |
|
|
582 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
583 | 570 |
|
584 |
protected int getSolvedFunctionIndex() |
|
585 |
{ |
|
586 |
return 0; |
|
571 |
return layerRotatable; |
|
587 | 572 |
} |
588 | 573 |
|
589 | 574 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
590 | 575 |
|
591 |
protected int getNumStickerTypes(int[] numLayers)
|
|
576 |
public int getMovementType()
|
|
592 | 577 |
{ |
593 |
return 1;
|
|
578 |
return MOVEMENT_SHAPECHANGE;
|
|
594 | 579 |
} |
595 | 580 |
|
596 | 581 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
597 | 582 |
|
598 |
protected int getNumCubitFaces()
|
|
583 |
public int getMovementSplit()
|
|
599 | 584 |
{ |
600 |
return 6;
|
|
585 |
return TYPE_NOT_SPLIT;
|
|
601 | 586 |
} |
602 | 587 |
|
603 | 588 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
604 |
// PUBLIC API |
|
605 | 589 |
|
606 |
public Static3D[] getRotationAxis()
|
|
590 |
public int[][][] getEnabled()
|
|
607 | 591 |
{ |
608 |
return ROT_AXIS; |
|
592 |
return new int[][][] |
|
593 |
{ |
|
594 |
{{1,2}},{{1,2}},{{0,2}},{{0,2}},{{0,1}},{{0,1}}, |
|
595 |
}; |
|
609 | 596 |
} |
610 | 597 |
|
611 | 598 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
612 | 599 |
|
613 |
public Movement getMovement()
|
|
600 |
public float[] getDist3D(int[] numLayers)
|
|
614 | 601 |
{ |
615 |
if( mMovement==null ) |
|
616 |
{ |
|
617 |
int[] numLayers = getNumLayers(); |
|
618 |
if( mCuts==null ) getCuts(numLayers); |
|
619 |
getLayerRotatable(numLayers); |
|
620 |
float avg = (numLayers[0]+numLayers[1]+numLayers[2])/3.0f; |
|
602 |
float avg = (numLayers[0]+numLayers[1]+numLayers[2])/3.0f; |
|
621 | 603 |
|
622 |
float[] dist3D =
|
|
604 |
return new float[]
|
|
623 | 605 |
{ |
624 | 606 |
0.5f*numLayers[0]/avg, |
625 | 607 |
0.5f*numLayers[0]/avg, |
... | ... | |
628 | 610 |
0.5f*numLayers[2]/avg, |
629 | 611 |
0.5f*numLayers[2]/avg, |
630 | 612 |
}; |
613 |
} |
|
631 | 614 |
|
632 |
mMovement = new MovementC(ROT_AXIS,mCuts,mLayerRotatable,avg,TYPE_NOT_SPLIT,ENABLED,dist3D); |
|
633 |
} |
|
634 |
return mMovement; |
|
615 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
616 |
|
|
617 |
public int getSolvedFunctionIndex() |
|
618 |
{ |
|
619 |
return 0; |
|
620 |
} |
|
621 |
|
|
622 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
623 |
|
|
624 |
protected int getNumStickerTypes(int[] numLayers) |
|
625 |
{ |
|
626 |
return 1; |
|
627 |
} |
|
628 |
|
|
629 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
630 |
|
|
631 |
protected int getNumCubitFaces() |
|
632 |
{ |
|
633 |
return 6; |
|
634 |
} |
|
635 |
|
|
636 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
637 |
// PUBLIC API |
|
638 |
|
|
639 |
public Static3D[] getRotationAxis() |
|
640 |
{ |
|
641 |
return ROT_AXIS; |
|
635 | 642 |
} |
636 | 643 |
|
637 | 644 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
705 | 712 |
return R.string.cube3_inventor; |
706 | 713 |
} |
707 | 714 |
|
715 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
716 |
|
|
717 |
public int getYearOfInvention(int[] numLayers) |
|
718 |
{ |
|
719 |
switch(numLayers[0]) |
|
720 |
{ |
|
721 |
case 2: return 1970; |
|
722 |
case 3: return 1974; |
|
723 |
case 4: return 1981; |
|
724 |
case 5: return 1981; |
|
725 |
} |
|
726 |
return 1974; |
|
727 |
} |
|
728 |
|
|
708 | 729 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
709 | 730 |
|
710 | 731 |
public int getComplexity(int[] numLayers) |
Also available in: Unified diff
Reorg for writing the JSON