Revision 5a20f7a1
Added by Leszek Koltunski almost 2 years ago
src/main/java/org/distorted/objectlib/main/Cubit.java | ||
---|---|---|
216 | 216 |
mRowOffset[0] = mTmp[0]; |
217 | 217 |
mRowOffset[1] = mTmp[1]; |
218 | 218 |
mRowOffset[2] = mTmp[2]; |
219 |
mParent.setRotationRowOffset(mCurrentPuzzleFace,mRowOffset); |
|
220 | 219 |
} |
221 | 220 |
} |
222 | 221 |
|
... | ... | |
271 | 270 |
return mRowOffset; |
272 | 271 |
} |
273 | 272 |
|
273 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
274 |
|
|
275 |
public int getPuzzleFace() |
|
276 |
{ |
|
277 |
return mCurrentPuzzleFace; |
|
278 |
} |
|
279 |
|
|
274 | 280 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
275 | 281 |
|
276 | 282 |
public int getRotRow(int axisIndex) |
src/main/java/org/distorted/objectlib/main/ObjectType.java | ||
---|---|---|
33 | 33 |
|
34 | 34 |
public enum ObjectType |
35 | 35 |
{ |
36 |
CRA1_2 ( TwistyCrazy2x2.class , 16, R.drawable.cra1_3, true, new InitData(new int[] {2,2,2}, TwistyCrazy2x2.CIRCLE )), |
|
37 |
|
|
36 | 38 |
CUBE_2 ( TwistyCuboid.class , 12, R.drawable.cube_2, true, new InitData(new int[] {2,2,2})), |
37 | 39 |
CUBE_3 ( TwistyCuboid.class , 17, R.drawable.cube_3, true, new InitData(new int[] {3,3,3})), |
38 | 40 |
CUBE_4 ( TwistyCuboid.class , 24, R.drawable.cube_4, true, new InitData(new int[] {4,4,4})), |
... | ... | |
79 | 81 |
SKEW_3 ( TwistySkewb.class , 21, R.drawable.skew_3, true, new InitData(new int[] {3,3,3,3})), |
80 | 82 |
CONT_2 ( TwistyContainer.class , 12, R.drawable.cont_2, true, new InitData(new int[] {2,2,2,2})), |
81 | 83 |
|
82 |
CRA1_2 ( TwistyCrazy2x2.class , 16, R.drawable.cra1_3, true, new InitData(new int[] {2,2,2}, TwistyCrazy2x2.CIRCLE )), |
|
84 |
|
|
83 | 85 |
CRA1_3 ( TwistyCrazy3x3.class , 22, R.drawable.cra1_3, true, new InitData(new int[] {3,3,3}, TwistyCrazy3x3.CRAZY )), |
84 | 86 |
CRA2_3 ( TwistyCrazy3x3.class , 22, R.drawable.cra1_3, true, new InitData(new int[] {3,3,3}, TwistyCrazy3x3.MERCURY)), |
85 | 87 |
CRA3_3 ( TwistyCrazy3x3.class , 22, R.drawable.cra1_3, true, new InitData(new int[] {3,3,3}, TwistyCrazy3x3.VENUS )), |
src/main/java/org/distorted/objectlib/main/TwistyObject.java | ||
---|---|---|
154 | 154 |
private float[][] mRowOffsets; |
155 | 155 |
private boolean[] mBelongs; |
156 | 156 |
private float[] mTmp; |
157 |
private int mNumPuzzleFaces; |
|
157 | 158 |
|
158 | 159 |
//////////////////// SOLVED1 //////////////////////// |
159 | 160 |
|
... | ... | |
198 | 199 |
mObjectQuats = getQuats(); |
199 | 200 |
mNumQuats = mObjectQuats.length; |
200 | 201 |
mOrigPos = getCubitPositions(mNumLayers); |
201 |
mRowOffsets = createInitRowOffsets(); |
|
202 |
mNumPuzzleFaces = getNumFaces(); |
|
203 |
mRowOffsets = new float[mNumPuzzleFaces][3]; |
|
202 | 204 |
mTmp = new float[4]; |
203 | 205 |
|
204 | 206 |
int numAxis = mAxis.length; |
... | ... | |
1149 | 1151 |
if( mBelongs[j] ) mCubits[j].rotateCubit(quat); |
1150 | 1152 |
} |
1151 | 1153 |
|
1154 |
recomputeFaceOffsets(); |
|
1155 |
|
|
1152 | 1156 |
for(int j=0; j<mNumCubits; j++) |
1153 | 1157 |
{ |
1154 | 1158 |
if( mBelongs[j] ) |
... | ... | |
1351 | 1355 |
if( mBelongs[i] ) mCubits[i].rotateCubit(quat); |
1352 | 1356 |
} |
1353 | 1357 |
|
1358 |
recomputeFaceOffsets(); |
|
1359 |
|
|
1354 | 1360 |
for(int i=0; i<mNumCubits; i++) |
1355 | 1361 |
{ |
1356 | 1362 |
if( mBelongs[i] ) |
... | ... | |
1366 | 1372 |
} |
1367 | 1373 |
} |
1368 | 1374 |
|
1375 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1376 |
|
|
1377 |
private void recomputeFaceOffsets() |
|
1378 |
{ |
|
1379 |
for(int i=0; i<mNumPuzzleFaces; i++) |
|
1380 |
{ |
|
1381 |
mRowOffsets[i][0] =0; |
|
1382 |
mRowOffsets[i][1] =0; |
|
1383 |
mRowOffsets[i][2] =0; |
|
1384 |
} |
|
1385 |
|
|
1386 |
for(int i=0; i<mNumCubits; i++) |
|
1387 |
if( mCubits[i].getType()==Cubit.TYPE_DECIDER ) |
|
1388 |
{ |
|
1389 |
float[] offset = mCubits[i].getOffset(); |
|
1390 |
int face = mCubits[i].getPuzzleFace(); |
|
1391 |
mRowOffsets[face][0] = offset[0]; |
|
1392 |
mRowOffsets[face][1] = offset[1]; |
|
1393 |
mRowOffsets[face][2] = offset[2]; |
|
1394 |
} |
|
1395 |
} |
|
1396 |
|
|
1369 | 1397 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
1370 | 1398 |
|
1371 | 1399 |
long finishRotationNow(EffectListener listener, int nearestAngleInDegrees) |
... | ... | |
1929 | 1957 |
return 0; |
1930 | 1958 |
} |
1931 | 1959 |
|
1932 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1933 |
|
|
1934 |
public float[][] createInitRowOffsets() |
|
1935 |
{ |
|
1936 |
return new float[getNumFaces()][3]; |
|
1937 |
} |
|
1938 |
|
|
1939 | 1960 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
1940 | 1961 |
|
1941 | 1962 |
public TouchControl getTouchControl() |
src/main/java/org/distorted/objectlib/objects/TwistyCrazy2x2.java | ||
---|---|---|
43 | 43 |
public static final int CIRCLE = 0x29; |
44 | 44 |
|
45 | 45 |
private static final float DIAMETER_RATIO = 0.60f; |
46 |
private static final float DIFF = 0.3f; |
|
47 | 46 |
private static final int NUMBER_CORNER_SEGMENTS = 4; |
48 | 47 |
|
49 | 48 |
static final Static3D[] ROT_AXIS = new Static3D[] |
... | ... | |
75 | 74 |
final float A = 0.50000f; |
76 | 75 |
final float B = 0.45424f; |
77 | 76 |
final float C = 0.11830f; |
77 |
final float D = 0.01000f; |
|
78 | 78 |
|
79 | 79 |
mStickerCoords = new float[][] |
80 | 80 |
{ |
81 | 81 |
{ B, A,-A, A,-A,-B,-C,-B, B, C }, |
82 |
{ -A, A,-A,-A, A,-A } |
|
82 |
{ -A, A,-A,-A, A,-A }, |
|
83 |
{ -D,-D, D,-D, D, D } |
|
83 | 84 |
}; |
84 | 85 |
} |
85 | 86 |
|
... | ... | |
88 | 89 |
@Override |
89 | 90 |
public int getCubitRotationType(int cubit) |
90 | 91 |
{ |
91 |
return cubit<8 ? Cubit.TYPE_NORMAL : Cubit.TYPE_FOLLOWER;
|
|
92 |
return cubit<8 ? Cubit.TYPE_NORMAL : ( cubit<32 ? Cubit.TYPE_FOLLOWER : Cubit.TYPE_DECIDER );
|
|
92 | 93 |
} |
93 | 94 |
|
94 | 95 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
95 | 96 |
|
96 | 97 |
@Override |
97 |
public float[][] createInitRowOffsets()
|
|
98 |
public float[] getCubitRowOffset(int cubitIndex)
|
|
98 | 99 |
{ |
99 | 100 |
if( mOffsets==null ) |
100 | 101 |
{ |
101 |
int param = getInitData().getParam(); |
|
102 |
float[] tmp = new float[] {0,0,0}; |
|
103 |
int numCubits = mPositions.length; |
|
104 |
mOffsets = new float[numCubits][]; |
|
102 | 105 |
|
103 |
int R = (param>>5)&0x1;
|
|
104 |
int L = (param>>4)&0x1;
|
|
105 |
int U = (param>>3)&0x1;
|
|
106 |
int D = (param>>2)&0x1;
|
|
107 |
int F = (param>>1)&0x1;
|
|
108 |
int B = (param )&0x1;
|
|
109 |
|
|
110 |
float OFF = 1.5f*DIFF;
|
|
111 |
|
|
112 |
mOffsets = new float[][] { {-OFF*R,0,0},{+OFF*L,0,0},{0,-OFF*U,0},{0,+OFF*D,0},{0,0,-OFF*F},{0,0,+OFF*B} };
|
|
106 |
for(int i=0; i<numCubits; i++)
|
|
107 |
{
|
|
108 |
switch(i)
|
|
109 |
{
|
|
110 |
case 32: mOffsets[i] = new float[] {1,0,0}; break;
|
|
111 |
case 33: mOffsets[i] = new float[] {0,1,0}; break;
|
|
112 |
case 34: mOffsets[i] = new float[] {0,0,-1};break; |
|
113 |
default: mOffsets[i] = tmp;
|
|
114 |
} |
|
115 |
}
|
|
113 | 116 |
} |
114 | 117 |
|
115 |
return mOffsets; |
|
118 |
return mOffsets[cubitIndex];
|
|
116 | 119 |
} |
117 | 120 |
|
118 | 121 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
195 | 198 |
{ |
196 | 199 |
if( mPositions==null ) |
197 | 200 |
{ |
201 |
final float D = 1.02f; |
|
202 |
final float E = 0.50f; |
|
203 |
|
|
198 | 204 |
mPositions = new float[][] |
199 | 205 |
{ |
200 | 206 |
{ 0.5f, 0.5f, 0.5f}, |
... | ... | |
206 | 212 |
{-0.5f,-0.5f, 0.5f}, |
207 | 213 |
{-0.5f,-0.5f,-0.5f}, |
208 | 214 |
|
209 |
{ 0.5f, 0.5f, DIFF}, |
|
210 |
{ 0.5f, 0.5f,-DIFF}, |
|
211 |
{ 0.5f,-0.5f, DIFF}, |
|
212 |
{ 0.5f,-0.5f,-DIFF}, |
|
213 |
{-0.5f, 0.5f, DIFF}, |
|
214 |
{-0.5f, 0.5f,-DIFF}, |
|
215 |
{-0.5f,-0.5f, DIFF}, |
|
216 |
{-0.5f,-0.5f,-DIFF}, |
|
217 |
{ 0.5f, DIFF, 0.5f}, |
|
218 |
{ 0.5f,-DIFF, 0.5f}, |
|
219 |
{ 0.5f, DIFF,-0.5f}, |
|
220 |
{ 0.5f,-DIFF,-0.5f}, |
|
221 |
{-0.5f, DIFF, 0.5f}, |
|
222 |
{-0.5f,-DIFF, 0.5f}, |
|
223 |
{-0.5f, DIFF,-0.5f}, |
|
224 |
{-0.5f,-DIFF,-0.5f}, |
|
225 |
{ DIFF, 0.5f, 0.5f}, |
|
226 |
{-DIFF, 0.5f, 0.5f}, |
|
227 |
{ DIFF, 0.5f,-0.5f}, |
|
228 |
{-DIFF, 0.5f,-0.5f}, |
|
229 |
{ DIFF,-0.5f, 0.5f}, |
|
230 |
{-DIFF,-0.5f, 0.5f}, |
|
231 |
{ DIFF,-0.5f,-0.5f}, |
|
232 |
{-DIFF,-0.5f,-0.5f}, |
|
215 |
{ 0.5f, 0.5f, E}, |
|
216 |
{ 0.5f, 0.5f,-E}, |
|
217 |
{ 0.5f,-0.5f, E}, |
|
218 |
{ 0.5f,-0.5f,-E}, |
|
219 |
{-0.5f, 0.5f, E}, |
|
220 |
{-0.5f, 0.5f,-E}, |
|
221 |
{-0.5f,-0.5f, E}, |
|
222 |
{-0.5f,-0.5f,-E}, |
|
223 |
{ 0.5f, E, 0.5f}, |
|
224 |
{ 0.5f,-E, 0.5f}, |
|
225 |
{ 0.5f, E,-0.5f}, |
|
226 |
{ 0.5f,-E,-0.5f}, |
|
227 |
{-0.5f, E, 0.5f}, |
|
228 |
{-0.5f,-E, 0.5f}, |
|
229 |
{-0.5f, E,-0.5f}, |
|
230 |
{-0.5f,-E,-0.5f}, |
|
231 |
{ E, 0.5f, 0.5f}, |
|
232 |
{-E, 0.5f, 0.5f}, |
|
233 |
{ E, 0.5f,-0.5f}, |
|
234 |
{-E, 0.5f,-0.5f}, |
|
235 |
{ E,-0.5f, 0.5f}, |
|
236 |
{-E,-0.5f, 0.5f}, |
|
237 |
{ E,-0.5f,-0.5f}, |
|
238 |
{-E,-0.5f,-0.5f}, |
|
239 |
|
|
240 |
{-D ,-0.5f, 0.5f}, |
|
241 |
{-0.5f, -D, 0.5f}, |
|
242 |
{-0.5f,-0.5f, D} |
|
233 | 243 |
}; |
234 | 244 |
} |
235 | 245 |
|
... | ... | |
241 | 251 |
public Static4D getCubitQuats(int cubit, int[] numLayers) |
242 | 252 |
{ |
243 | 253 |
if( mQuatIndex==null ) mQuatIndex = new int[] { 0,1,17,22,4,5,8,19, |
244 |
0,18,7,2, 9,5,8,19, 13,3,1,22, 14,23,15,11, 21,4,6,10, 17,20,12,16 }; |
|
254 |
0,18,7,2, 9,5,8,19, 13,3,1,22, 14,23,15,11, 21,4,6,10, 17,20,12,16, |
|
255 |
0, 0, 0 }; |
|
245 | 256 |
return mObjectQuats[mQuatIndex[cubit]]; |
246 | 257 |
} |
247 | 258 |
|
... | ... | |
397 | 408 |
|
398 | 409 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
399 | 410 |
|
400 |
private ObjectShape getSmallCircleShape(float D)
|
|
411 |
private ObjectShape getSmallCircleShape() |
|
401 | 412 |
{ |
413 |
final float D = 0.02f; |
|
402 | 414 |
final float H = DIAMETER_RATIO-0.5f; |
403 | 415 |
final float INIT_ALPHA = 0; |
404 | 416 |
final float STEP_CORNER= (float)((Math.PI/2)/NUMBER_CORNER_SEGMENTS); |
... | ... | |
457 | 469 |
return new ObjectShape(vertices,indices); |
458 | 470 |
} |
459 | 471 |
|
472 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
473 |
|
|
474 |
private ObjectShape getDeciderShape() |
|
475 |
{ |
|
476 |
final float A = 0.5f; |
|
477 |
float[][] vertices = new float[][] { {-A,-A,0},{A,-A,0},{A,A,0} }; |
|
478 |
int[][] indices = new int[][] { {0,1,2} }; |
|
479 |
|
|
480 |
return new ObjectShape(vertices,indices); |
|
481 |
} |
|
482 |
|
|
460 | 483 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
461 | 484 |
|
462 | 485 |
public ObjectShape getObjectShape(int variant) |
... | ... | |
464 | 487 |
switch(variant) |
465 | 488 |
{ |
466 | 489 |
case 0: return getCornerShape(); |
467 |
case 1: return getSmallCircleShape(0.52f-DIFF); |
|
490 |
case 1: return getSmallCircleShape(); |
|
491 |
case 2: return getDeciderShape(); |
|
468 | 492 |
} |
469 | 493 |
|
470 | 494 |
return null; |
... | ... | |
493 | 517 |
for(int i=4; i<NUM_VERTICES; i++) indices[i] = -1; |
494 | 518 |
return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null); |
495 | 519 |
} |
496 |
else |
|
520 |
else if( variant==1 )
|
|
497 | 521 |
{ |
498 | 522 |
float h1 = isInIconMode() ? 0.001f : 0.02f; |
499 | 523 |
float[][] bands = { {h1,45,0.2f,0.4f,5,0,0}, {0.001f,1,0.3f,0.5f,3,0,0}, {0.001f,1,0.3f,0.5f,2,0,0} }; |
... | ... | |
511 | 535 |
indices[0] = indices[1] = indices[2] = 0; |
512 | 536 |
return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null); |
513 | 537 |
} |
538 |
else |
|
539 |
{ |
|
540 |
float h1 = 0.001f; |
|
541 |
float[][] bands = { {h1,1,0.2f,0.4f,2,0,0} }; |
|
542 |
int[] bandIndices = new int[] {0}; |
|
543 |
float[][] corners = { {0.02f,0.09f} }; |
|
544 |
float[][] centers = { { 0.0f, 0.0f, 0.0f } }; |
|
545 |
int[] indices = new int[] {-1,-1,-1}; |
|
546 |
return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null); |
|
547 |
} |
|
514 | 548 |
} |
515 | 549 |
|
516 | 550 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
517 | 551 |
|
518 | 552 |
public int getNumCubitVariants(int[] numLayers) |
519 | 553 |
{ |
520 |
return 2;
|
|
554 |
return 3;
|
|
521 | 555 |
} |
522 | 556 |
|
523 | 557 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
524 | 558 |
|
525 | 559 |
public int getCubitVariant(int cubit, int[] numLayers) |
526 | 560 |
{ |
527 |
return cubit<8 ? 0:1;
|
|
561 |
return cubit<8 ? 0 : (cubit<32 ? 1:2);
|
|
528 | 562 |
} |
529 | 563 |
|
530 | 564 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
546 | 580 |
public float[][] getStickerAngles() |
547 | 581 |
{ |
548 | 582 |
float D = (float)(Math.PI/4); |
549 |
return new float[][] { { 0,0,0,-D,0 },{ 0,0,D } }; |
|
583 |
return new float[][] { { 0,0,0,-D,0 },{ 0,0,D },{0,0,0} };
|
|
550 | 584 |
} |
551 | 585 |
|
552 | 586 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
617 | 651 |
public String[][] getTutorials() |
618 | 652 |
{ |
619 | 653 |
return new String[][] { |
620 |
{"gb","7xUE8ond_Mg","Crazy 3x3x3 Cube Tutorial","SuperAntoniovivaldi"}, |
|
621 |
{"vn","N_AWJjHzqk0","Circle Crazy 3x3 Tutorial","VĂN CÔNG TÙNG"}, |
|
654 |
{"gb","DKLIQghl66c","Circle 2x2 Demonstration","SuperAntoniovivaldi"}, |
|
655 |
{"es","Wq9lwfDfg4E","Resolucion Del 2X2 Crazy","RUBIKworld"}, |
|
656 |
{"br","K4bFs4BFdXc","Tutorial Crazy 2x2 de Sengso","Manzacuber"}, |
|
622 | 657 |
}; |
623 | 658 |
} |
624 | 659 |
} |
Also available in: Unified diff
Progress with Circle 2x2.