Revision af0de0af
Added by Leszek Koltunski about 4 years ago
| src/main/java/org/distorted/objects/TwistyKilominx.java | ||
|---|---|---|
| 34 | 34 |  | 
| 35 | 35 | public class TwistyKilominx extends TwistyMinx | 
| 36 | 36 | {
 | 
| 37 | private static final int[] mCenterFaceMap = new int[] | |
| 37 | private int[] mCenterFaceMap; | |
| 38 |  | |
| 39 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 40 |  | |
| 41 | TwistyKilominx(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh, | |
| 42 | DistortedEffects effects, int[][] moves, Resources res, int scrWidth) | |
| 43 |     {
 | |
| 44 | super(size, size, quat, texture, mesh, effects, moves, ObjectList.KILO, res, scrWidth); | |
| 45 | } | |
| 46 |  | |
| 47 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 48 |  | |
| 49 | void initializeCenterFaceMap() | |
| 50 |     {
 | |
| 51 | mCenterFaceMap = new int[] | |
| 38 | 52 |       {
 | 
| 39 | 53 | 0,0,0,0,1, | 
| 40 | 54 | 1,0,1,1,0, | 
| ... | ... | |
| 49 | 63 | 2,1,0,1,2, | 
| 50 | 64 | 2,2,2,2,2 | 
| 51 | 65 | }; | 
| 52 |  | |
| 53 | private static final float CENTER_CORR = 0.87f; | |
| 54 |  | |
| 55 | private static final float[][] STICKERS = new float[][] | |
| 56 |       {
 | |
| 57 |         { -0.36616942f, -0.36327124f, 0.5f, -0.36327124f, 0.23233888f, 0.4605048f, -0.36616942f, 0.26603764f },
 | |
| 58 |         { -0.36327127f, -0.5f, 0.36327127f, -0.26393202f, 0.36327127f, 0.5f, -0.36327127f, 0.26393202f },
 | |
| 59 |         { -0.3249197f, -0.39442718f, 0.3249197f, -0.39442718f, 0.3249197f, 0.5f, -0.3249197f, 0.2888544f }
 | |
| 60 | }; | |
| 61 |  | |
| 62 | static | |
| 63 |     {
 | |
| 64 | final float C = 1.14f; // make the 'center' sticker artificially larger, so that we paint | |
| 65 | // over the area in the center of the face. | |
| 66 |  | |
| 67 | STICKERS[0][0] *= C; | |
| 68 | STICKERS[0][1] *= C; | |
| 69 | STICKERS[0][2] *= C; | |
| 70 | STICKERS[0][3] *= C; | |
| 71 | STICKERS[0][4] *= C; | |
| 72 | STICKERS[0][5] *= C; | |
| 73 | STICKERS[0][6] *= C; | |
| 74 | STICKERS[0][7] *= C; | |
| 75 |  | |
| 76 | STICKERS[0][2] *= CENTER_CORR; | |
| 77 | STICKERS[0][3] *= CENTER_CORR; | |
| 78 | } | |
| 79 |  | |
| 80 | private static final ObjectSticker[] mStickers; | |
| 81 | static | |
| 82 |     {
 | |
| 83 | mStickers = new ObjectSticker[STICKERS.length]; | |
| 84 |  | |
| 85 | float R = 0.10f; | |
| 86 |     final float[][] radii = { {R,R,R,R},{R,R,R,R},{R,R,R,R} };
 | |
| 87 |     final float[] strokes = { 0.20f, 0.11f, 0.10f };
 | |
| 88 |  | |
| 89 | for(int s=0; s<STICKERS.length; s++) | |
| 90 |       {
 | |
| 91 | mStickers[s] = new ObjectSticker(STICKERS[s],null,radii[s],strokes[s]); | |
| 92 | } | |
| 93 | } | |
| 94 |  | |
| 95 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 96 |  | |
| 97 | TwistyKilominx(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh, | |
| 98 | DistortedEffects effects, int[][] moves, Resources res, int scrWidth) | |
| 99 |     {
 | |
| 100 | super(size, size, quat, texture, mesh, effects, moves, ObjectList.KILO, res, scrWidth); | |
| 101 | 66 | } | 
| 102 | 67 |  | 
| 103 | 68 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| ... | ... | |
| 169 | 134 |  | 
| 170 | 135 | private void computeBasicCornerVectors(int corner) | 
| 171 | 136 |     {
 | 
| 172 | Static4D quat = QUATS[QUAT_CORNER_INDICES[corner]]; | |
| 137 | if( mQuatCornerIndices==null ) initializeQuatIndices(); | |
| 138 | if( mQuats==null ) initializeQuats(); | |
| 139 | if( mCurrCornerV==null || mBasicCornerV==null ) initializeCornerV(); | |
| 140 |  | |
| 141 | Static4D quat = mQuats[mQuatCornerIndices[corner]]; | |
| 173 | 142 |  | 
| 174 | 143 | mCurrCornerV[0] = QuatHelper.rotateVectorByQuat(mBasicCornerV[0],quat); | 
| 175 | 144 | mCurrCornerV[1] = QuatHelper.rotateVectorByQuat(mBasicCornerV[1],quat); | 
| ... | ... | |
| 180 | 149 |  | 
| 181 | 150 | private float[] computeCorner(int numCubitsPerCorner, int numLayers, int corner, int part) | 
| 182 | 151 |     {
 | 
| 152 | if( mCorners==null ) initializeCorners(); | |
| 153 | if( mCurrCornerV==null || mBasicCornerV==null ) initializeCornerV(); | |
| 154 |  | |
| 183 | 155 | float D = numLayers/3.0f; | 
| 184 |     float[] corn = CORNERS[corner];
 | |
| 156 |     float[] corn = mCorners[corner];
 | |
| 185 | 157 |  | 
| 186 | 158 | if( part==0 ) | 
| 187 | 159 |       {
 | 
| ... | ... | |
| 212 | 184 |  | 
| 213 | 185 | private float[] computeCenter(int numLayers, int center, int part) | 
| 214 | 186 |     {
 | 
| 187 | if( mCenterCoords==null ) initializeCenterCoords(); | |
| 188 | if( mCorners ==null ) initializeCorners(); | |
| 189 | if( mCenterMap ==null ) initializeCenterMap(); | |
| 190 |  | |
| 215 | 191 | int corner = mCenterMap[center][part]; | 
| 216 | 192 | float[] cent = mCenterCoords[center]; | 
| 217 |     float[] corn = CORNERS[corner];
 | |
| 193 |     float[] corn = mCorners[corner];
 | |
| 218 | 194 | float D = numLayers/3.0f; | 
| 219 | 195 | float F = 1.0f - (2.0f*numLayers-6.0f)/(numLayers-1)*COS54*COS54; | 
| 220 | 196 |  | 
| ... | ... | |
| 238 | 214 |  | 
| 239 | 215 | private float[] computeEdge(int numLayers, int edge, int part) | 
| 240 | 216 |     {
 | 
| 217 | if( mCenterCoords==null ) initializeCenterCoords(); | |
| 218 | if( mCorners==null ) initializeCorners(); | |
| 219 | if( mEdgeMap==null ) initializeEdgeMap(); | |
| 220 |  | |
| 241 | 221 | float D = numLayers/3.0f; | 
| 242 |     float[] c1 = CORNERS[ mEdgeMap[edge][0] ];
 | |
| 243 |     float[] c2 = CORNERS[ mEdgeMap[edge][1] ];
 | |
| 222 |     float[] c1 = mCorners[ mEdgeMap[edge][0] ];
 | |
| 223 |     float[] c2 = mCorners[ mEdgeMap[edge][1] ];
 | |
| 244 | 224 |  | 
| 245 | 225 | int leftRight = 2*(part%2) -1; | 
| 246 | 226 | part /= 2; | 
| ... | ... | |
| 284 | 264 |  | 
| 285 | 265 | float[][] getCubitPositions(int numLayers) | 
| 286 | 266 |     {
 | 
| 287 | if( numLayers<5 ) return CORNERS; | |
| 267 | if( mCorners==null ) initializeCorners(); | |
| 268 | if( numLayers<5 ) return mCorners; | |
| 288 | 269 |  | 
| 289 | 270 | int numCubitsPerCorner = numCubitsPerCorner(numLayers); | 
| 290 | 271 | int numCubitsPerEdge = numCubitsPerEdge(numLayers); | 
| ... | ... | |
| 327 | 308 |  | 
| 328 | 309 | private int getQuat(int cubit, int numCubitsPerCorner, int numCubitsPerEdge) | 
| 329 | 310 |     {
 | 
| 311 | if( mQuatCornerIndices==null || mQuatEdgeIndices==null ) initializeQuatIndices(); | |
| 312 | if( mCenterMap==null ) initializeCenterMap(); | |
| 313 |  | |
| 330 | 314 | if( cubit < NUM_CORNERS*numCubitsPerCorner ) | 
| 331 | 315 |       {
 | 
| 332 | 316 | int corner = cubit/numCubitsPerCorner; | 
| 333 |       return QUAT_CORNER_INDICES[corner];
 | |
| 317 |       return mQuatCornerIndices[corner];
 | |
| 334 | 318 | } | 
| 335 | 319 |  | 
| 336 | 320 | if( cubit < NUM_CORNERS*numCubitsPerCorner + NUM_EDGES*numCubitsPerEdge ) | 
| 337 | 321 |       {
 | 
| 338 | 322 | int edge = (cubit-NUM_CORNERS*numCubitsPerCorner)/numCubitsPerEdge; | 
| 339 |       return QUAT_EDGE_INDICES[edge];
 | |
| 323 |       return mQuatEdgeIndices[edge];
 | |
| 340 | 324 | } | 
| 341 | 325 |  | 
| 342 | 326 | if( numCubitsPerCorner==0 ) | 
| 343 | 327 |       {
 | 
| 344 |       return QUAT_CORNER_INDICES[cubit];
 | |
| 328 |       return mQuatCornerIndices[cubit];
 | |
| 345 | 329 | } | 
| 346 | 330 | else | 
| 347 | 331 |       {
 | 
| ... | ... | |
| 351 | 335 | int index= cubit%numCubitsPerCenter; | 
| 352 | 336 | int corner=mCenterMap[face][index]; | 
| 353 | 337 |  | 
| 354 |       return QUAT_CORNER_INDICES[corner];
 | |
| 338 |       return mQuatCornerIndices[corner];
 | |
| 355 | 339 | } | 
| 356 | 340 | } | 
| 357 | 341 |  | 
| ... | ... | |
| 537 | 521 |  | 
| 538 | 522 | Static4D getQuat(int cubit, int numLayers) | 
| 539 | 523 |     {
 | 
| 524 | if( mQuats==null ) initializeQuats(); | |
| 540 | 525 | int numCubitsPerCorner = numCubitsPerCorner(numLayers); | 
| 541 | 526 | int numCubitsPerEdge = numCubitsPerEdge(numLayers); | 
| 542 | 527 |  | 
| 543 |     return QUATS[getQuat(cubit,numCubitsPerCorner,numCubitsPerEdge)];
 | |
| 528 |     return mQuats[getQuat(cubit,numCubitsPerCorner,numCubitsPerEdge)];
 | |
| 544 | 529 | } | 
| 545 | 530 |  | 
| 546 | 531 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| ... | ... | |
| 581 | 566 |  | 
| 582 | 567 | int getCornerColor(int cubit, int cubitface, int numLayers, int numCubitsPerCorner) | 
| 583 | 568 |     {
 | 
| 569 | if( mCornerFaceMap==null ) initializeCornerFaceMap(); | |
| 584 | 570 | if( cubitface<0 || cubitface>2 ) return NUM_TEXTURES; | 
| 585 | 571 |  | 
| 586 | 572 | int part = cubit % numCubitsPerCorner; | 
| ... | ... | |
| 627 | 613 |  | 
| 628 | 614 | int part = edge % numCubitsPerEdge; | 
| 629 | 615 | int variant = edge / numCubitsPerEdge; | 
| 616 | if( mEdgeMap==null ) initializeEdgeMap(); | |
| 630 | 617 |  | 
| 631 | 618 | part /=2; | 
| 632 | 619 |  | 
| ... | ... | |
| 637 | 624 |  | 
| 638 | 625 | int getCenterColor(int center, int cubitface, int numLayers) | 
| 639 | 626 |     {
 | 
| 640 | if( numLayers==3 ) | |
| 627 | if( mCenterFaceMap==null ) initializeCenterFaceMap(); | |
| 628 | if( mCornerFaceMap==null ) initializeCornerFaceMap(); | |
| 629 |  | |
| 630 | if( numLayers==3 ) | |
| 641 | 631 |       {
 | 
| 642 | 632 | return cubitface>=0 && cubitface<3 ? mCornerFaceMap[center][cubitface] : NUM_TEXTURES; | 
| 643 | 633 | } | 
| ... | ... | |
| 679 | 669 |  | 
| 680 | 670 | ObjectSticker retSticker(int face) | 
| 681 | 671 |     {
 | 
| 672 | if( mStickers==null ) | |
| 673 |       {
 | |
| 674 | float[][] STICKERS = new float[][] | |
| 675 |         {
 | |
| 676 |           { -0.36616942f, -0.36327124f, 0.5f, -0.36327124f, 0.23233888f, 0.4605048f, -0.36616942f, 0.26603764f },
 | |
| 677 |           { -0.36327127f, -0.5f, 0.36327127f, -0.26393202f, 0.36327127f, 0.5f, -0.36327127f, 0.26393202f },
 | |
| 678 |           { -0.3249197f, -0.39442718f, 0.3249197f, -0.39442718f, 0.3249197f, 0.5f, -0.3249197f, 0.2888544f }
 | |
| 679 | }; | |
| 680 |  | |
| 681 | float CENTER_CORR = 0.87f; | |
| 682 | float C = 1.14f; // make the 'center' sticker artificially larger, so that we paint over the area in the center of the face. | |
| 683 |  | |
| 684 | STICKERS[0][0] *= C; | |
| 685 | STICKERS[0][1] *= C; | |
| 686 | STICKERS[0][2] *= C; | |
| 687 | STICKERS[0][3] *= C; | |
| 688 | STICKERS[0][4] *= C; | |
| 689 | STICKERS[0][5] *= C; | |
| 690 | STICKERS[0][6] *= C; | |
| 691 | STICKERS[0][7] *= C; | |
| 692 |  | |
| 693 | STICKERS[0][2] *= CENTER_CORR; | |
| 694 | STICKERS[0][3] *= CENTER_CORR; | |
| 695 |  | |
| 696 | mStickers = new ObjectSticker[STICKERS.length]; | |
| 697 |  | |
| 698 | float R = 0.10f; | |
| 699 |       final float[][] radii = { {R,R,R,R},{R,R,R,R},{R,R,R,R} };
 | |
| 700 |       final float[] strokes = { 0.20f, 0.11f, 0.10f };
 | |
| 701 |  | |
| 702 | for(int s=0; s<STICKERS.length; s++) | |
| 703 |         {
 | |
| 704 | mStickers[s] = new ObjectSticker(STICKERS[s],null,radii[s],strokes[s]); | |
| 705 | } | |
| 706 | } | |
| 707 |  | |
| 682 | 708 | return mStickers[getStickerIndex(face)]; | 
| 683 | 709 | } | 
| 684 | 710 |  | 
| src/main/java/org/distorted/objects/TwistyMegaminx.java | ||
|---|---|---|
| 35 | 35 | public class TwistyMegaminx extends TwistyMinx | 
| 36 | 36 | {
 | 
| 37 | 37 | static final float MEGA_D = 0.04f; | 
| 38 | private int[] mQuatCenterIndices; | |
| 38 | 39 |  | 
| 39 | private static final int[] QUAT_CENTER_INDICES = | |
| 40 |       {
 | |
| 41 | 16, 18, 22, 1, 20, 13, 14, 15, 0, 12, 2, 3 | |
| 42 | }; | |
| 40 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 43 | 41 |  | 
| 44 | private static final float[][] STICKERS = new float[][] | |
| 45 |       {
 | |
| 46 |         { -0.36327127f, -0.5f, 0.36327127f, -0.26393202f, 0.36327127f, 0.5f, -0.36327127f, 0.26393202f },
 | |
| 47 |         { -0.5f, -0.0914315f, 0.5f, -0.4163512f, 0.5f, 0.4163512f, -0.5f, 0.0914315f },
 | |
| 48 |         { -0.49233657f, -0.18006028f, 0.49233657f, -0.5f, 0.49233657f, 0.5f, -0.49233657f, 0.18006028f },
 | |
| 49 |         { -0.3002273f, -0.30490047f, 0.3002273f, -0.5f, 0.3002273f, 0.5f, -0.3002273f, 0.30490047f },
 | |
| 50 |         { -0.29389262f, 0.4045085f, -0.47552824f, -0.1545085f, 0.0f, -0.5f, 0.47552824f, -0.1545085f, 0.29389262f, 0.4045085f }
 | |
| 51 | }; | |
| 52 |  | |
| 53 | private static final ObjectSticker[] mStickers; | |
| 54 | static | |
| 42 | TwistyMegaminx(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh, | |
| 43 | DistortedEffects effects, int[][] moves, Resources res, int scrWidth) | |
| 55 | 44 |     {
 | 
| 56 | mStickers = new ObjectSticker[STICKERS.length]; | |
| 57 |  | |
| 58 | final float R0 = 0.08f; | |
| 59 | final float R1 = 0.12f; | |
| 60 | final float R2 = 0.12f; | |
| 61 | final float R3 = 0.08f; | |
| 62 | final float R4 = 0.10f; | |
| 63 |     final float[][] radii = { {R0,R0,R0,R0},{R1,R1,R1,R1},{R2,R2,R2,R2},{R3,R3,R3,R3},{R4,R4,R4,R4,R4} };
 | |
| 64 |     final float[] strokes = { 0.10f,0.12f,0.12f,0.08f,0.07f };
 | |
| 65 |  | |
| 66 | for(int s=0; s<STICKERS.length; s++) | |
| 67 |       {
 | |
| 68 | mStickers[s] = new ObjectSticker(STICKERS[s],null,radii[s],strokes[s]); | |
| 69 | } | |
| 45 | super(size, size, quat, texture, mesh, effects, moves, ObjectList.MEGA, res, scrWidth); | |
| 70 | 46 | } | 
| 71 | 47 |  | 
| 72 | 48 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 73 | 49 |  | 
| 74 | TwistyMegaminx(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh, | |
| 75 | DistortedEffects effects, int[][] moves, Resources res, int scrWidth) | |
| 50 | private void initializeCenterIndices() | |
| 76 | 51 |     {
 | 
| 77 |     super(size, size, quat, texture, mesh, effects, moves, ObjectList.MEGA, res, scrWidth);
 | |
| 52 |     mQuatCenterIndices = new int[] { 16, 18, 22,  1, 20, 13, 14, 15,  0, 12,  2,  3 };
 | |
| 78 | 53 | } | 
| 79 | 54 |  | 
| 80 | 55 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| ... | ... | |
| 144 | 119 |  | 
| 145 | 120 | private float[] computeCenter(int center, int numLayers) | 
| 146 | 121 |     {
 | 
| 122 | if( mCenterCoords==null ) initializeCenterCoords(); | |
| 147 | 123 | float[] coords = mCenterCoords[center]; | 
| 148 | 124 | float A = numLayers/3.0f; | 
| 149 | 125 |  | 
| ... | ... | |
| 156 | 132 |  | 
| 157 | 133 | private void computeBasicCornerVectors(int corner) | 
| 158 | 134 |     {
 | 
| 159 | Static4D quat = QUATS[QUAT_CORNER_INDICES[corner]]; | |
| 135 | if( mQuatCornerIndices==null ) initializeQuatIndices(); | |
| 136 | if( mQuats==null ) initializeQuats(); | |
| 137 | if( mCurrCornerV==null || mBasicCornerV==null ) initializeCornerV(); | |
| 138 |  | |
| 139 | Static4D quat = mQuats[mQuatCornerIndices[corner]]; | |
| 160 | 140 |  | 
| 161 | 141 | mCurrCornerV[0] = QuatHelper.rotateVectorByQuat(mBasicCornerV[0],quat); | 
| 162 | 142 | mCurrCornerV[1] = QuatHelper.rotateVectorByQuat(mBasicCornerV[1],quat); | 
| ... | ... | |
| 167 | 147 |  | 
| 168 | 148 | private float[] computeCorner(int numCubitsPerCorner, int numLayers, int corner, int part) | 
| 169 | 149 |     {
 | 
| 150 | if( mCorners==null ) initializeCorners(); | |
| 151 | if( mCurrCornerV==null || mBasicCornerV==null ) initializeCornerV(); | |
| 152 |  | |
| 170 | 153 | float D = numLayers/3.0f; | 
| 171 |     float[] corn = CORNERS[corner];
 | |
| 154 |     float[] corn = mCorners[corner];
 | |
| 172 | 155 |  | 
| 173 | 156 | if( part==0 ) | 
| 174 | 157 |       {
 | 
| ... | ... | |
| 207 | 190 |  | 
| 208 | 191 | private float[] computeEdge(int numLayers, int edge, int part) | 
| 209 | 192 |     {
 | 
| 210 | float D = numLayers/3.0f; | |
| 193 | if( mCenterCoords==null ) initializeCenterCoords(); | |
| 194 | if( mCorners==null ) initializeCorners(); | |
| 195 | if( mEdgeMap==null ) initializeEdgeMap(); | |
| 211 | 196 |  | 
| 212 | float[] c1 = CORNERS[ mEdgeMap[edge][0] ]; | |
| 213 | float[] c2 = CORNERS[ mEdgeMap[edge][1] ]; | |
| 197 | float D = numLayers/3.0f; | |
| 198 | float[] c1 = mCorners[ mEdgeMap[edge][0] ]; | |
| 199 | float[] c2 = mCorners[ mEdgeMap[edge][1] ]; | |
| 214 | 200 | float x = D * (c1[0]+c2[0]) / 2; | 
| 215 | 201 | float y = D * (c1[1]+c2[1]) / 2; | 
| 216 | 202 | float z = D * (c1[2]+c2[2]) / 2; | 
| ... | ... | |
| 277 | 263 |  | 
| 278 | 264 | private int getQuat(int cubit, int numCubitsPerCorner, int numCubitsPerEdge) | 
| 279 | 265 |     {
 | 
| 266 | if( mQuatCornerIndices==null || mQuatEdgeIndices==null ) initializeQuatIndices(); | |
| 267 | if( mQuatCenterIndices==null ) initializeCenterIndices(); | |
| 268 |  | |
| 280 | 269 | if( cubit < NUM_CORNERS*numCubitsPerCorner ) | 
| 281 | 270 |       {
 | 
| 282 | 271 | int corner = cubit/numCubitsPerCorner; | 
| 283 |       return QUAT_CORNER_INDICES[corner];
 | |
| 272 |       return mQuatCornerIndices[corner];
 | |
| 284 | 273 | } | 
| 285 | 274 |  | 
| 286 | 275 | if( cubit < NUM_CORNERS*numCubitsPerCorner + NUM_EDGES*numCubitsPerEdge ) | 
| 287 | 276 |       {
 | 
| 288 | 277 | int edge = (cubit-NUM_CORNERS*numCubitsPerCorner)/numCubitsPerEdge; | 
| 289 |       return QUAT_EDGE_INDICES[edge];
 | |
| 278 |       return mQuatEdgeIndices[edge];
 | |
| 290 | 279 | } | 
| 291 | 280 |  | 
| 292 | 281 | int center = cubit - NUM_CORNERS*numCubitsPerCorner - NUM_EDGES*numCubitsPerEdge; | 
| 293 |     return QUAT_CENTER_INDICES[center];
 | |
| 282 |     return mQuatCenterIndices[center];
 | |
| 294 | 283 | } | 
| 295 | 284 |  | 
| 296 | 285 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| ... | ... | |
| 443 | 432 | } | 
| 444 | 433 | } | 
| 445 | 434 |  | 
| 446 |  | |
| 447 | 435 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 448 | 436 |  | 
| 449 | 437 | Static4D getQuat(int cubit, int numLayers) | 
| 450 | 438 |     {
 | 
| 439 | if( mQuats==null ) initializeQuats(); | |
| 451 | 440 | int numCubitsPerCorner = numCubitsPerCorner(numLayers); | 
| 452 | 441 | int numCubitsPerEdge = numCubitsPerEdge(numLayers); | 
| 453 | 442 |  | 
| 454 |     return QUATS[getQuat(cubit,numCubitsPerCorner,numCubitsPerEdge)];
 | |
| 443 |     return mQuats[getQuat(cubit,numCubitsPerCorner,numCubitsPerEdge)];
 | |
| 455 | 444 | } | 
| 456 | 445 |  | 
| 457 | 446 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| ... | ... | |
| 491 | 480 |  | 
| 492 | 481 | int getCornerColor(int cubit, int cubitface, int numLayers, int numCubitsPerCorner) | 
| 493 | 482 |     {
 | 
| 483 | if( mCornerFaceMap==null ) initializeCornerFaceMap(); | |
| 494 | 484 | if( cubitface<0 || cubitface>2 ) return NUM_TEXTURES; | 
| 495 | 485 |  | 
| 496 | 486 | int part = cubit % numCubitsPerCorner; | 
| ... | ... | |
| 537 | 527 |  | 
| 538 | 528 | int part = edge % numCubitsPerEdge; | 
| 539 | 529 | int variant = edge / numCubitsPerEdge; | 
| 530 | if( mEdgeMap==null ) initializeEdgeMap(); | |
| 540 | 531 |  | 
| 541 | 532 | return (part==0 || cubitface==((part+1)%2)) ? mEdgeMap[variant][cubitface+2] + ((part+3)/2)*NUM_FACES : NUM_TEXTURES; | 
| 542 | 533 | } | 
| ... | ... | |
| 582 | 573 |  | 
| 583 | 574 | ObjectSticker retSticker(int face) | 
| 584 | 575 |     {
 | 
| 576 | if( mStickers==null ) | |
| 577 |       {
 | |
| 578 | float[][] STICKERS = new float[][] | |
| 579 |         {
 | |
| 580 |           { -0.36327127f, -0.5f, 0.36327127f, -0.26393202f, 0.36327127f, 0.5f, -0.36327127f, 0.26393202f },
 | |
| 581 |           { -0.5f, -0.0914315f, 0.5f, -0.4163512f, 0.5f, 0.4163512f, -0.5f, 0.0914315f },
 | |
| 582 |           { -0.49233657f, -0.18006028f, 0.49233657f, -0.5f, 0.49233657f, 0.5f, -0.49233657f, 0.18006028f },
 | |
| 583 |           { -0.3002273f, -0.30490047f, 0.3002273f, -0.5f, 0.3002273f, 0.5f, -0.3002273f, 0.30490047f },
 | |
| 584 |           { -0.29389262f, 0.4045085f, -0.47552824f, -0.1545085f, 0.0f, -0.5f, 0.47552824f, -0.1545085f, 0.29389262f, 0.4045085f }
 | |
| 585 | }; | |
| 586 |  | |
| 587 | mStickers = new ObjectSticker[STICKERS.length]; | |
| 588 |  | |
| 589 | final float R0 = 0.08f; | |
| 590 | final float R1 = 0.12f; | |
| 591 | final float R2 = 0.12f; | |
| 592 | final float R3 = 0.08f; | |
| 593 | final float R4 = 0.10f; | |
| 594 |       final float[][] radii = { {R0,R0,R0,R0},{R1,R1,R1,R1},{R2,R2,R2,R2},{R3,R3,R3,R3},{R4,R4,R4,R4,R4} };
 | |
| 595 |       final float[] strokes = { 0.10f,0.12f,0.12f,0.08f,0.07f };
 | |
| 596 |  | |
| 597 | for(int s=0; s<STICKERS.length; s++) | |
| 598 |         {
 | |
| 599 | mStickers[s] = new ObjectSticker(STICKERS[s],null,radii[s],strokes[s]); | |
| 600 | } | |
| 601 | } | |
| 602 |  | |
| 585 | 603 | return mStickers[getStickerIndex(face)]; | 
| 586 | 604 | } | 
| 587 | 605 |  | 
| src/main/java/org/distorted/objects/TwistyMinx.java | ||
|---|---|---|
| 21 | 21 |  | 
| 22 | 22 | import android.content.res.Resources; | 
| 23 | 23 |  | 
| 24 | import org.distorted.helpers.ObjectSticker; | |
| 24 | 25 | import org.distorted.helpers.ScrambleState; | 
| 25 | 26 | import org.distorted.library.main.DistortedEffects; | 
| 26 | 27 | import org.distorted.library.main.DistortedTexture; | 
| ... | ... | |
| 60 | 61 | new Static3D( SIN54/LEN, 0 , -C2/LEN ) | 
| 61 | 62 | }; | 
| 62 | 63 |  | 
| 63 |   private static final int[] BASIC_ANGLE = new int[] { 5,5,5,5,5,5 };
 | |
| 64 |  | |
| 65 | 64 | static final int MINX_LGREEN = 0xff53aa00; | 
| 66 | 65 | static final int MINX_PINK = 0xfffd7ab7; | 
| 67 | 66 | static final int MINX_SANDY = 0xffefd48b; | 
| ... | ... | |
| 82 | 81 | MINX_DBLUE , MINX_DYELLOW, MINX_WHITE , MINX_GREY | 
| 83 | 82 | }; | 
| 84 | 83 |  | 
| 85 |   private static final int[] mFaceMap = new int[] {8,10,3,7,1,11,9,2,4,0,5,6};
 | |
| 84 | private int mCurrState; | |
| 85 | private int mIndexExcluded; | |
| 86 | private ScrambleState[] mStates; | |
| 87 | private int[][] mScrambleTable; | |
| 88 | private int[] mNumOccurences; | |
| 89 | private int[] mBasicAngle; | |
| 90 | private int[] mFaceMap; | |
| 91 | Static4D[] mQuats; | |
| 92 | float[][] mCenterCoords; | |
| 93 | float[][] mCorners; | |
| 94 | int[][] mCornerFaceMap; | |
| 95 | int[] mQuatEdgeIndices; | |
| 96 | int[] mQuatCornerIndices; | |
| 97 | int[][] mEdgeMap; | |
| 98 | int[][] mCenterMap; | |
| 99 | Static4D[] mBasicCornerV, mCurrCornerV; | |
| 100 | ObjectSticker[] mStickers; | |
| 86 | 101 |  | 
| 87 | // All 60 legal rotation quats of a Minx | |
| 88 | static final Static4D[] QUATS = new Static4D[] | |
| 89 |          {
 | |
| 90 | new Static4D( 0.0f, 0.0f, 0.0f, 1.0f ), //0 | |
| 91 | new Static4D( 1.0f, 0.0f, 0.0f, 0.0f ), | |
| 92 | new Static4D( 0.0f, 1.0f, 0.0f, 0.0f ), | |
| 93 | new Static4D( 0.0f, 0.0f, 1.0f, 0.0f ), | |
| 94 |  | |
| 95 | new Static4D( 0.5f, 0.5f, 0.5f, 0.5f ), //4 | |
| 96 | new Static4D( 0.5f, 0.5f, -0.5f, 0.5f ), | |
| 97 | new Static4D( 0.5f, -0.5f, 0.5f, 0.5f ), | |
| 98 | new Static4D( 0.5f, -0.5f, -0.5f, 0.5f ), | |
| 99 | new Static4D( -0.5f, 0.5f, 0.5f, 0.5f ), | |
| 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 |  | |
| 104 | new Static4D( 0.5f, SIN54, SIN18, 0.0f ), // 12 | |
| 105 | new Static4D( 0.5f, SIN54,-SIN18, 0.0f ), | |
| 106 | new Static4D( 0.5f,-SIN54, SIN18, 0.0f ), | |
| 107 | new Static4D( 0.5f,-SIN54,-SIN18, 0.0f ), | |
| 108 | new Static4D( SIN18, 0.5f, SIN54, 0.0f ), | |
| 109 | new Static4D( SIN18, 0.5f,-SIN54, 0.0f ), | |
| 110 | new Static4D(-SIN18, 0.5f, SIN54, 0.0f ), | |
| 111 | new Static4D(-SIN18, 0.5f,-SIN54, 0.0f ), | |
| 112 | new Static4D( SIN54, SIN18, 0.5f, 0.0f ), | |
| 113 | new Static4D( SIN54,-SIN18, 0.5f, 0.0f ), | |
| 114 | new Static4D(-SIN54, SIN18, 0.5f, 0.0f ), | |
| 115 | new Static4D(-SIN54,-SIN18, 0.5f, 0.0f ), | |
| 116 |  | |
| 117 | new Static4D( 0.0f, SIN18, SIN54, 0.5f ), //24 | |
| 118 | new Static4D( 0.0f, SIN18,-SIN54, 0.5f ), | |
| 119 | new Static4D( 0.0f,-SIN18, SIN54, 0.5f ), | |
| 120 | new Static4D( 0.0f,-SIN18,-SIN54, 0.5f ), | |
| 121 | new Static4D( SIN18, SIN54, 0.0f, 0.5f ), | |
| 122 | new Static4D( SIN18,-SIN54, 0.0f, 0.5f ), | |
| 123 | new Static4D(-SIN18, SIN54, 0.0f, 0.5f ), | |
| 124 | new Static4D(-SIN18,-SIN54, 0.0f, 0.5f ), | |
| 125 | new Static4D( SIN54, 0.0f, SIN18, 0.5f ), | |
| 126 | new Static4D( SIN54, 0.0f,-SIN18, 0.5f ), | |
| 127 | new Static4D(-SIN54, 0.0f, SIN18, 0.5f ), | |
| 128 | new Static4D(-SIN54, 0.0f,-SIN18, 0.5f ), | |
| 129 |  | |
| 130 | new Static4D( 0.0f, SIN54, 0.5f, SIN18 ), //36 | |
| 131 | new Static4D( 0.0f, SIN54, -0.5f, SIN18 ), | |
| 132 | new Static4D( 0.0f,-SIN54, 0.5f, SIN18 ), | |
| 133 | new Static4D( 0.0f,-SIN54, -0.5f, SIN18 ), | |
| 134 | new Static4D( 0.5f, 0.0f, SIN54, SIN18 ), | |
| 135 | new Static4D( 0.5f, 0.0f,-SIN54, SIN18 ), | |
| 136 | new Static4D( -0.5f, 0.0f, SIN54, SIN18 ), | |
| 137 | new Static4D( -0.5f, 0.0f,-SIN54, SIN18 ), | |
| 138 | new Static4D( SIN54, 0.5f, 0.0f, SIN18 ), | |
| 139 | new Static4D( SIN54, -0.5f, 0.0f, SIN18 ), | |
| 140 | new Static4D(-SIN54, 0.5f, 0.0f, SIN18 ), | |
| 141 | new Static4D(-SIN54, -0.5f, 0.0f, SIN18 ), | |
| 142 |  | |
| 143 | new Static4D( 0.0f, 0.5f, SIN18, SIN54 ), //48 | |
| 144 | new Static4D( 0.0f, 0.5f,-SIN18, SIN54 ), | |
| 145 | new Static4D( 0.0f, -0.5f, SIN18, SIN54 ), | |
| 146 | new Static4D( 0.0f, -0.5f,-SIN18, SIN54 ), | |
| 147 | new Static4D( 0.5f, SIN18, 0.0f, SIN54 ), | |
| 148 | new Static4D( 0.5f,-SIN18, 0.0f, SIN54 ), | |
| 149 | new Static4D( -0.5f, SIN18, 0.0f, SIN54 ), | |
| 150 | new Static4D( -0.5f,-SIN18, 0.0f, SIN54 ), | |
| 151 | new Static4D( SIN18, 0.0f, 0.5f, SIN54 ), | |
| 152 | new Static4D( SIN18, 0.0f, -0.5f, SIN54 ), | |
| 153 | new Static4D(-SIN18, 0.0f, 0.5f, SIN54 ), | |
| 154 | new Static4D(-SIN18, 0.0f, -0.5f, SIN54 ), | |
| 155 | }; | |
| 102 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 156 | 103 |  | 
| 157 | // Coordinates of all 20 corners of a Minx | |
| 158 | static final float[][] CORNERS = new float[][] | |
| 159 |          {
 | |
| 160 |              {  0.0f,  0.5f,    C2},
 | |
| 161 |              {  0.0f,  0.5f,   -C2},
 | |
| 162 |              {  0.0f, -0.5f,    C2},
 | |
| 163 |              {  0.0f, -0.5f,   -C2},
 | |
| 164 |              {    C2,  0.0f,  0.5f},
 | |
| 165 |              {    C2,  0.0f, -0.5f},
 | |
| 166 |              {   -C2,  0.0f,  0.5f},
 | |
| 167 |              {   -C2,  0.0f, -0.5f},
 | |
| 168 |              {  0.5f,    C2,  0.0f},
 | |
| 169 |              {  0.5f,   -C2,  0.0f},
 | |
| 170 |              { -0.5f,    C2,  0.0f},
 | |
| 171 |              { -0.5f,   -C2,  0.0f},
 | |
| 172 |              { SIN54, SIN54, SIN54},
 | |
| 173 |              { SIN54, SIN54,-SIN54},
 | |
| 174 |              { SIN54,-SIN54, SIN54},
 | |
| 175 |              { SIN54,-SIN54,-SIN54},
 | |
| 176 |              {-SIN54, SIN54, SIN54},
 | |
| 177 |              {-SIN54, SIN54,-SIN54},
 | |
| 178 |              {-SIN54,-SIN54, SIN54},
 | |
| 179 |              {-SIN54,-SIN54,-SIN54},
 | |
| 180 | }; | |
| 104 | TwistyMinx(int numLayers, int realSize, Static4D quat, DistortedTexture texture, MeshSquare mesh, | |
| 105 | DistortedEffects effects, int[][] moves, ObjectList obj, Resources res, int scrWidth) | |
| 106 |     {
 | |
| 107 | super(numLayers, realSize, quat, texture, mesh, effects, moves, obj, res, scrWidth); | |
| 181 | 108 |  | 
| 182 | static final int[][] mCornerFaceMap = | |
| 183 |          {
 | |
| 184 |            {  0, 1, 8 },
 | |
| 185 |            {  6, 5,10 },
 | |
| 186 |            {  1, 0,11 },
 | |
| 187 |            {  5, 6, 3 },
 | |
| 188 |            {  0, 9, 4 },
 | |
| 189 |            {  5, 4, 9 },
 | |
| 190 |            {  7, 1, 2 },
 | |
| 191 |            {  2, 6, 7 },
 | |
| 192 |            { 10, 9, 8 },
 | |
| 193 |            {  4, 3,11 },
 | |
| 194 |            {  7,10, 8 },
 | |
| 195 |            {  3, 2,11 },
 | |
| 196 |            {  0, 8, 9 },
 | |
| 197 |            {  9,10, 5 },
 | |
| 198 |            {  0, 4,11 },
 | |
| 199 |            {  4, 5, 3 },
 | |
| 200 |            {  1, 7, 8 },
 | |
| 201 |            {  7, 6,10 },
 | |
| 202 |            {  2, 1,11 },
 | |
| 203 |            {  6, 2, 3 },
 | |
| 204 | }; | |
| 109 | initializeScrambleStates(numLayers); | |
| 110 | } | |
| 205 | 111 |  | 
| 206 | static final int[] QUAT_EDGE_INDICES = | |
| 207 |       {
 | |
| 208 | 56, 40, 43, 59, 0, 19, 9, 54, 58, 49, | |
| 209 | 48, 24, 52, 4, 16, 32, 20, 11, 21, 35 , | |
| 210 | 37, 30, 8, 28, 36, 44, 1, 46, 12, 47 | |
| 211 | }; | |
| 212 | 112 |  | 
| 113 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 213 | 114 |  | 
| 214 | static final int[] QUAT_CORNER_INDICES = | |
| 215 |       {
 | |
| 216 | 0, 2, 3, 1, 40, 31, 41, 30, 39, 35, | |
| 217 | 36, 34, 56, 32, 43, 21, 48, 28, 42, 23 | |
| 218 | }; | |
| 115 | void initializeCornerV() | |
| 116 |     {
 | |
| 117 | mBasicCornerV = new Static4D[3]; | |
| 118 | mCurrCornerV = new Static4D[3]; | |
| 119 |  | |
| 120 | mBasicCornerV[0] = new Static4D( (SQ5+1)*0.125f, (SQ5-1)*0.125f, -0.250f, 0.0f ); | |
| 121 | mBasicCornerV[1] = new Static4D(-(SQ5+1)*0.125f, (SQ5-1)*0.125f, -0.250f, 0.0f ); | |
| 122 | mBasicCornerV[2] = new Static4D( 0, -0.500f, 0.0f, 0.0f ); | |
| 123 | } | |
| 124 |  | |
| 125 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 126 | // the five vertices that form a given face. Order: the same as colors of the faces in TwistyMinx. | |
| 127 |  | |
| 128 | void initializeCenterMap() | |
| 129 |     {
 | |
| 130 | mCenterMap = new int[][] | |
| 131 |          {
 | |
| 132 |            { 0, 12,  4, 14,  2},
 | |
| 133 |            { 0,  2, 18,  6, 16},
 | |
| 134 |            { 6, 18, 11, 19,  7},
 | |
| 135 |            { 3, 15,  9, 11, 19},
 | |
| 136 |            { 4,  5, 15,  9, 14},
 | |
| 137 |            { 1, 13,  5, 15,  3},
 | |
| 138 |            { 1,  3, 19,  7, 17},
 | |
| 139 |            {10, 16,  6,  7, 17},
 | |
| 140 |            { 0, 12,  8, 10, 16},
 | |
| 141 |            { 8, 13,  5,  4, 12},
 | |
| 142 |            { 1, 13,  8, 10, 17},
 | |
| 143 |            { 2, 14,  9, 11, 18},
 | |
| 144 | }; | |
| 145 | } | |
| 219 | 146 |  | 
| 220 | // the quadruple ( corner1, corner2, face1, face2 ) defining an edge. | |
| 221 | // In fact the 2 corners already define it, the faces only provide easy | |
| 222 | // way to get to know the colors. Order: arbitrary. Face1 arbitrarily on | |
| 223 | // the 'left' or right of vector corner1 --> corner2, according to Quat. | |
| 224 | static final int[][] mEdgeMap = | |
| 147 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 148 | // the quadruple ( corner1, corner2, face1, face2 ) defining an edge. | |
| 149 | // In fact the 2 corners already define it, the faces only provide easy | |
| 150 | // way to get to know the colors. Order: arbitrary. Face1 arbitrarily on | |
| 151 | // the 'left' or right of vector corner1 --> corner2, according to Quat. | |
| 152 |  | |
| 153 | void initializeEdgeMap() | |
| 154 |     {
 | |
| 155 | mEdgeMap = new int[][] | |
| 225 | 156 |          {
 | 
| 226 | 157 |            {  0, 12,  0,  8}, //0
 | 
| 227 | 158 |            { 12,  4,  0,  9},
 | 
| ... | ... | |
| 254 | 185 |            {  1, 13, 10,  5},
 | 
| 255 | 186 |            {  3, 15,  5,  3},
 | 
| 256 | 187 | }; | 
| 188 | } | |
| 257 | 189 |  | 
| 258 | // the five vertices that form a given face. Order: the same as colors | |
| 259 | // of the faces in TwistyMinx. | |
| 260 | static final int[][] mCenterMap = | |
| 261 |          {
 | |
| 262 |            { 0, 12,  4, 14,  2},
 | |
| 263 |            { 0,  2, 18,  6, 16},
 | |
| 264 |            { 6, 18, 11, 19,  7},
 | |
| 265 |            { 3, 15,  9, 11, 19},
 | |
| 266 |            { 4,  5, 15,  9, 14},
 | |
| 267 |            { 1, 13,  5, 15,  3},
 | |
| 268 |            { 1,  3, 19,  7, 17},
 | |
| 269 |            {10, 16,  6,  7, 17},
 | |
| 270 |            { 0, 12,  8, 10, 16},
 | |
| 271 |            { 8, 13,  5,  4, 12},
 | |
| 272 |            { 1, 13,  8, 10, 17},
 | |
| 273 |            { 2, 14,  9, 11, 18},
 | |
| 274 | }; | |
| 275 |  | |
| 276 | static final float[][] mCenterCoords = new float[NUM_CENTERS][3]; | |
| 190 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 277 | 191 |  | 
| 278 |   static
 | |
| 192 |   void initializeQuatIndices()
 | |
| 279 | 193 |     {
 | 
| 280 |     for(int center=0; center<NUM_CENTERS; center++)
 | |
| 194 |     mQuatEdgeIndices = new int[]
 | |
| 281 | 195 |       {
 | 
| 282 | int[] map = mCenterMap[center]; | |
| 196 | 56, 40, 43, 59, 0, 19, 9, 54, 58, 49, | |
| 197 | 48, 24, 52, 4, 16, 32, 20, 11, 21, 35, | |
| 198 | 37, 30, 8, 28, 36, 44, 1, 46, 12, 47 | |
| 199 | }; | |
| 200 | mQuatCornerIndices = new int[] | |
| 201 |       {
 | |
| 202 | 0, 2, 3, 1, 40, 31, 41, 30, 39, 35, | |
| 203 | 36, 34, 56, 32, 43, 21, 48, 28, 42, 23 | |
| 204 | }; | |
| 205 | } | |
| 283 | 206 |  | 
| 284 | float x = CORNERS[map[0]][0] + | |
| 285 | CORNERS[map[1]][0] + | |
| 286 | CORNERS[map[2]][0] + | |
| 287 | CORNERS[map[3]][0] + | |
| 288 | CORNERS[map[4]][0] ; | |
| 207 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 289 | 208 |  | 
| 290 | float y = CORNERS[map[0]][1] + | |
| 291 | CORNERS[map[1]][1] + | |
| 292 | CORNERS[map[2]][1] + | |
| 293 | CORNERS[map[3]][1] + | |
| 294 | CORNERS[map[4]][1] ; | |
| 209 | void initializeCornerFaceMap() | |
| 210 |     {
 | |
| 211 | mCornerFaceMap = new int[][] | |
| 212 |          {
 | |
| 213 |            {  0, 1, 8 },
 | |
| 214 |            {  6, 5,10 },
 | |
| 215 |            {  1, 0,11 },
 | |
| 216 |            {  5, 6, 3 },
 | |
| 217 |            {  0, 9, 4 },
 | |
| 218 |            {  5, 4, 9 },
 | |
| 219 |            {  7, 1, 2 },
 | |
| 220 |            {  2, 6, 7 },
 | |
| 221 |            { 10, 9, 8 },
 | |
| 222 |            {  4, 3,11 },
 | |
| 223 |            {  7,10, 8 },
 | |
| 224 |            {  3, 2,11 },
 | |
| 225 |            {  0, 8, 9 },
 | |
| 226 |            {  9,10, 5 },
 | |
| 227 |            {  0, 4,11 },
 | |
| 228 |            {  4, 5, 3 },
 | |
| 229 |            {  1, 7, 8 },
 | |
| 230 |            {  7, 6,10 },
 | |
| 231 |            {  2, 1,11 },
 | |
| 232 |            {  6, 2, 3 },
 | |
| 233 | }; | |
| 234 | } | |
| 295 | 235 |  | 
| 296 | float z = CORNERS[map[0]][2] + | |
| 297 | CORNERS[map[1]][2] + | |
| 298 | CORNERS[map[2]][2] + | |
| 299 | CORNERS[map[3]][2] + | |
| 300 | CORNERS[map[4]][2] ; | |
| 236 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 301 | 237 |  | 
| 302 | mCenterCoords[center][0] = x/5; | |
| 303 | mCenterCoords[center][1] = y/5; | |
| 304 | mCenterCoords[center][2] = z/5; | |
| 305 | } | |
| 238 | void initializeQuats() | |
| 239 |     {
 | |
| 240 | mQuats = new Static4D[] | |
| 241 |          {
 | |
| 242 | new Static4D( 0.0f, 0.0f, 0.0f, 1.0f ), //0 | |
| 243 | new Static4D( 1.0f, 0.0f, 0.0f, 0.0f ), | |
| 244 | new Static4D( 0.0f, 1.0f, 0.0f, 0.0f ), | |
| 245 | new Static4D( 0.0f, 0.0f, 1.0f, 0.0f ), | |
| 246 |  | |
| 247 | new Static4D( 0.5f, 0.5f, 0.5f, 0.5f ), //4 | |
| 248 | new Static4D( 0.5f, 0.5f, -0.5f, 0.5f ), | |
| 249 | new Static4D( 0.5f, -0.5f, 0.5f, 0.5f ), | |
| 250 | new Static4D( 0.5f, -0.5f, -0.5f, 0.5f ), | |
| 251 | new Static4D( -0.5f, 0.5f, 0.5f, 0.5f ), | |
| 252 | new Static4D( -0.5f, 0.5f, -0.5f, 0.5f ), | |
| 253 | new Static4D( -0.5f, -0.5f, 0.5f, 0.5f ), | |
| 254 | new Static4D( -0.5f, -0.5f, -0.5f, 0.5f ), | |
| 255 |  | |
| 256 | new Static4D( 0.5f, SIN54, SIN18, 0.0f ), // 12 | |
| 257 | new Static4D( 0.5f, SIN54,-SIN18, 0.0f ), | |
| 258 | new Static4D( 0.5f,-SIN54, SIN18, 0.0f ), | |
| 259 | new Static4D( 0.5f,-SIN54,-SIN18, 0.0f ), | |
| 260 | new Static4D( SIN18, 0.5f, SIN54, 0.0f ), | |
| 261 | new Static4D( SIN18, 0.5f,-SIN54, 0.0f ), | |
| 262 | new Static4D(-SIN18, 0.5f, SIN54, 0.0f ), | |
| 263 | new Static4D(-SIN18, 0.5f,-SIN54, 0.0f ), | |
| 264 | new Static4D( SIN54, SIN18, 0.5f, 0.0f ), | |
| 265 | new Static4D( SIN54,-SIN18, 0.5f, 0.0f ), | |
| 266 | new Static4D(-SIN54, SIN18, 0.5f, 0.0f ), | |
| 267 | new Static4D(-SIN54,-SIN18, 0.5f, 0.0f ), | |
| 268 |  | |
| 269 | new Static4D( 0.0f, SIN18, SIN54, 0.5f ), //24 | |
| 270 | new Static4D( 0.0f, SIN18,-SIN54, 0.5f ), | |
| 271 | new Static4D( 0.0f,-SIN18, SIN54, 0.5f ), | |
| 272 | new Static4D( 0.0f,-SIN18,-SIN54, 0.5f ), | |
| 273 | new Static4D( SIN18, SIN54, 0.0f, 0.5f ), | |
| 274 | new Static4D( SIN18,-SIN54, 0.0f, 0.5f ), | |
| 275 | new Static4D(-SIN18, SIN54, 0.0f, 0.5f ), | |
| 276 | new Static4D(-SIN18,-SIN54, 0.0f, 0.5f ), | |
| 277 | new Static4D( SIN54, 0.0f, SIN18, 0.5f ), | |
| 278 | new Static4D( SIN54, 0.0f,-SIN18, 0.5f ), | |
| 279 | new Static4D(-SIN54, 0.0f, SIN18, 0.5f ), | |
| 280 | new Static4D(-SIN54, 0.0f,-SIN18, 0.5f ), | |
| 281 |  | |
| 282 | new Static4D( 0.0f, SIN54, 0.5f, SIN18 ), //36 | |
| 283 | new Static4D( 0.0f, SIN54, -0.5f, SIN18 ), | |
| 284 | new Static4D( 0.0f,-SIN54, 0.5f, SIN18 ), | |
| 285 | new Static4D( 0.0f,-SIN54, -0.5f, SIN18 ), | |
| 286 | new Static4D( 0.5f, 0.0f, SIN54, SIN18 ), | |
| 287 | new Static4D( 0.5f, 0.0f,-SIN54, SIN18 ), | |
| 288 | new Static4D( -0.5f, 0.0f, SIN54, SIN18 ), | |
| 289 | new Static4D( -0.5f, 0.0f,-SIN54, SIN18 ), | |
| 290 | new Static4D( SIN54, 0.5f, 0.0f, SIN18 ), | |
| 291 | new Static4D( SIN54, -0.5f, 0.0f, SIN18 ), | |
| 292 | new Static4D(-SIN54, 0.5f, 0.0f, SIN18 ), | |
| 293 | new Static4D(-SIN54, -0.5f, 0.0f, SIN18 ), | |
| 294 |  | |
| 295 | new Static4D( 0.0f, 0.5f, SIN18, SIN54 ), //48 | |
| 296 | new Static4D( 0.0f, 0.5f,-SIN18, SIN54 ), | |
| 297 | new Static4D( 0.0f, -0.5f, SIN18, SIN54 ), | |
| 298 | new Static4D( 0.0f, -0.5f,-SIN18, SIN54 ), | |
| 299 | new Static4D( 0.5f, SIN18, 0.0f, SIN54 ), | |
| 300 | new Static4D( 0.5f,-SIN18, 0.0f, SIN54 ), | |
| 301 | new Static4D( -0.5f, SIN18, 0.0f, SIN54 ), | |
| 302 | new Static4D( -0.5f,-SIN18, 0.0f, SIN54 ), | |
| 303 | new Static4D( SIN18, 0.0f, 0.5f, SIN54 ), | |
| 304 | new Static4D( SIN18, 0.0f, -0.5f, SIN54 ), | |
| 305 | new Static4D(-SIN18, 0.0f, 0.5f, SIN54 ), | |
| 306 | new Static4D(-SIN18, 0.0f, -0.5f, SIN54 ), | |
| 307 | }; | |
| 306 | 308 | } | 
| 307 | 309 |  | 
| 308 | static final Static4D[] mBasicCornerV, mCurrCornerV; | |
| 310 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 311 | // Coordinates of all 20 corners of a Minx | |
| 309 | 312 |  | 
| 310 |   static
 | |
| 313 |   void initializeCorners()
 | |
| 311 | 314 |     {
 | 
| 312 | mBasicCornerV = new Static4D[3]; | |
| 313 | mCurrCornerV = new Static4D[3]; | |
| 314 |  | |
| 315 | mBasicCornerV[0] = new Static4D( (SQ5+1)*0.125f, (SQ5-1)*0.125f, -0.250f, 0.0f ); | |
| 316 | mBasicCornerV[1] = new Static4D(-(SQ5+1)*0.125f, (SQ5-1)*0.125f, -0.250f, 0.0f ); | |
| 317 | mBasicCornerV[2] = new Static4D( 0, -0.500f, 0.0f, 0.0f ); | |
| 315 | mCorners = new float[][] | |
| 316 |          {
 | |
| 317 |              {  0.0f,  0.5f,    C2},
 | |
| 318 |              {  0.0f,  0.5f,   -C2},
 | |
| 319 |              {  0.0f, -0.5f,    C2},
 | |
| 320 |              {  0.0f, -0.5f,   -C2},
 | |
| 321 |              {    C2,  0.0f,  0.5f},
 | |
| 322 |              {    C2,  0.0f, -0.5f},
 | |
| 323 |              {   -C2,  0.0f,  0.5f},
 | |
| 324 |              {   -C2,  0.0f, -0.5f},
 | |
| 325 |              {  0.5f,    C2,  0.0f},
 | |
| 326 |              {  0.5f,   -C2,  0.0f},
 | |
| 327 |              { -0.5f,    C2,  0.0f},
 | |
| 328 |              { -0.5f,   -C2,  0.0f},
 | |
| 329 |              { SIN54, SIN54, SIN54},
 | |
| 330 |              { SIN54, SIN54,-SIN54},
 | |
| 331 |              { SIN54,-SIN54, SIN54},
 | |
| 332 |              { SIN54,-SIN54,-SIN54},
 | |
| 333 |              {-SIN54, SIN54, SIN54},
 | |
| 334 |              {-SIN54, SIN54,-SIN54},
 | |
| 335 |              {-SIN54,-SIN54, SIN54},
 | |
| 336 |              {-SIN54,-SIN54,-SIN54},
 | |
| 337 | }; | |
| 318 | 338 | } | 
| 319 | 339 |  | 
| 320 | private int mCurrState; | |
| 321 | private int mIndexExcluded; | |
| 322 | private ScrambleState[] mStates; | |
| 323 | private int[][] mScrambleTable; | |
| 324 | private int[] mNumOccurences; | |
| 325 |  | |
| 326 | 340 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 327 | 341 |  | 
| 328 | TwistyMinx(int numLayers, int realSize, Static4D quat, DistortedTexture texture, MeshSquare mesh, | |
| 329 | DistortedEffects effects, int[][] moves, ObjectList obj, Resources res, int scrWidth) | |
| 342 | void initializeCenterCoords() | |
| 330 | 343 |     {
 | 
| 331 | super(numLayers, realSize, quat, texture, mesh, effects, moves, obj, res, scrWidth); | |
| 344 | if( mCorners==null ) initializeCorners(); | |
| 345 | if( mCenterMap==null ) initializeCenterMap(); | |
| 332 | 346 |  | 
| 333 | initializeScrambleStates(numLayers); | |
| 347 | mCenterCoords = new float[NUM_CENTERS][3]; | |
| 348 |  | |
| 349 | for(int center=0; center<NUM_CENTERS; center++) | |
| 350 |       {
 | |
| 351 | int[] map = mCenterMap[center]; | |
| 352 |  | |
| 353 | float x = mCorners[map[0]][0] + | |
| 354 | mCorners[map[1]][0] + | |
| 355 | mCorners[map[2]][0] + | |
| 356 | mCorners[map[3]][0] + | |
| 357 | mCorners[map[4]][0] ; | |
| 358 |  | |
| 359 | float y = mCorners[map[0]][1] + | |
| 360 | mCorners[map[1]][1] + | |
| 361 | mCorners[map[2]][1] + | |
| 362 | mCorners[map[3]][1] + | |
| 363 | mCorners[map[4]][1] ; | |
| 364 |  | |
| 365 | float z = mCorners[map[0]][2] + | |
| 366 | mCorners[map[1]][2] + | |
| 367 | mCorners[map[2]][2] + | |
| 368 | mCorners[map[3]][2] + | |
| 369 | mCorners[map[4]][2] ; | |
| 370 |  | |
| 371 | mCenterCoords[center][0] = x/5; | |
| 372 | mCenterCoords[center][1] = y/5; | |
| 373 | mCenterCoords[center][2] = z/5; | |
| 374 | } | |
| 334 | 375 | } | 
| 335 | 376 |  | 
| 336 | 377 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| ... | ... | |
| 463 | 504 |  | 
| 464 | 505 | int[] getSolvedQuats(int cubit, int numLayers) | 
| 465 | 506 |     {
 | 
| 507 | if( mQuats==null ) initializeQuats(); | |
| 508 |     if( mFaceMap==null ) mFaceMap = new int[] {8,10,3,7,1,11,9,2,4,0,5,6};
 | |
| 466 | 509 | int status = retCubitSolvedStatus(cubit,numLayers); | 
| 467 |     return status<0 ? null : buildSolvedQuats(MovementMinx.FACE_AXIS[mFaceMap[status]],QUATS);
 | |
| 510 |     return status<0 ? null : buildSolvedQuats(MovementMinx.FACE_AXIS[mFaceMap[status]],mQuats);
 | |
| 468 | 511 | } | 
| 469 | 512 |  | 
| 470 | 513 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 471 | 514 |  | 
| 472 | 515 | Static4D[] getQuats() | 
| 473 | 516 |     {
 | 
| 474 | return QUATS; | |
| 517 | if( mQuats==null ) initializeQuats(); | |
| 518 | return mQuats; | |
| 475 | 519 | } | 
| 476 | 520 |  | 
| 477 | 521 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| ... | ... | |
| 569 | 613 |  | 
| 570 | 614 | public int[] getBasicAngle() | 
| 571 | 615 |     {
 | 
| 572 | return BASIC_ANGLE; | |
| 616 |     if( mBasicAngle ==null ) mBasicAngle = new int[] { 5,5,5,5,5,5 };
 | |
| 617 | return mBasicAngle; | |
| 573 | 618 | } | 
| 574 | 619 | } | 
| src/main/java/org/distorted/objects/TwistyObject.java | ||
|---|---|---|
| 271 | 271 | int sizeIndex = ObjectList.getSizeIndex(list.ordinal(),mNumLayers); | 
| 272 | 272 | int resourceID= list.getResourceIDs()[sizeIndex]; | 
| 273 | 273 |  | 
| 274 | if( resourceID!=0 ) | |
| 274 |     if( false ) // resourceID!=0 )
 | |
| 275 | 275 |       {
 | 
| 276 | 276 | InputStream is = res.openRawResource(resourceID); | 
| 277 | 277 | DataInputStream dos = new DataInputStream(is); | 
Also available in: Unified diff
Remove statics from the Minx classes.