| 53 |
53 |
|
| 54 |
54 |
private static final int POST_ROTATION_MILLISEC = 500;
|
| 55 |
55 |
private final int NUM_CUBITS;
|
| 56 |
|
private int mRotRow;
|
|
56 |
private int mRotRowBitmap;
|
| 57 |
57 |
private int mRotAxis;
|
| 58 |
58 |
private Static3D[] mOrigPos;
|
| 59 |
59 |
private Static3D mScale, mNodeScale;
|
| ... | ... | |
| 190 |
190 |
|
| 191 |
191 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 192 |
192 |
|
| 193 |
|
private boolean belongsToRotation( int cubit, int axis, int row)
|
|
193 |
private boolean belongsToRotation( int cubit, int axis, int rowBitmap)
|
| 194 |
194 |
{
|
| 195 |
|
return ((int)(mCubits[cubit].mRotationRow[axis]+0.5f))==row;
|
|
195 |
int cubitRow = (int)(mCubits[cubit].mRotationRow[axis]+0.5f);
|
|
196 |
return ((1<<cubitRow)&rowBitmap)!=0;
|
| 196 |
197 |
}
|
| 197 |
198 |
|
| 198 |
199 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| ... | ... | |
| 221 |
222 |
|
| 222 |
223 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 223 |
224 |
// TODO
|
|
225 |
// rotV : 0 --> VECTX, 1--> VECTY, 2 --> VECTZ
|
|
226 |
// rotRC: 01010 --> move the 2nd and 4th layer
|
|
227 |
// rotA : counterclockwise by rotA*90 degrees
|
| 224 |
228 |
|
| 225 |
229 |
private boolean scheduleMultiRotation(int rotV, int rotRC, int rotA)
|
| 226 |
230 |
{
|
| ... | ... | |
| 433 |
437 |
|
| 434 |
438 |
for(int i=0; i<NUM_CUBITS; i++)
|
| 435 |
439 |
{
|
| 436 |
|
if( belongsToRotation(i,mRotAxis,mRotRow) )
|
|
440 |
if( belongsToRotation(i,mRotAxis,mRotRowBitmap) )
|
| 437 |
441 |
{
|
| 438 |
442 |
if( first )
|
| 439 |
443 |
{
|
| ... | ... | |
| 506 |
510 |
return;
|
| 507 |
511 |
}
|
| 508 |
512 |
|
| 509 |
|
mRotAxis = axis;
|
| 510 |
|
mRotRow = row;
|
|
513 |
mRotAxis = axis;
|
|
514 |
mRotRowBitmap = (1<<row);
|
| 511 |
515 |
|
| 512 |
516 |
mRotationAngleStatic.set0(0.0f);
|
| 513 |
517 |
|
| 514 |
518 |
for(int i=0; i<NUM_CUBITS; i++)
|
| 515 |
|
if( belongsToRotation(i,mRotAxis,mRotRow) )
|
|
519 |
if( belongsToRotation(i,mRotAxis,mRotRowBitmap) )
|
| 516 |
520 |
{
|
| 517 |
521 |
mCubits[i].beginNewRotation(axis);
|
| 518 |
522 |
}
|
| ... | ... | |
| 520 |
524 |
|
| 521 |
525 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 522 |
526 |
|
| 523 |
|
public long addNewRotation( int axis, int row, int angle, long durationMillis, EffectListener listener )
|
|
527 |
public long addNewRotation( int axis, int rowBitmap, int angle, long durationMillis, EffectListener listener )
|
| 524 |
528 |
{
|
| 525 |
529 |
long effectID=0;
|
| 526 |
530 |
boolean first = true;
|
| 527 |
531 |
|
| 528 |
|
mRotAxis = axis;
|
| 529 |
|
mRotRow = row;
|
|
532 |
mRotAxis = axis;
|
|
533 |
mRotRowBitmap = rowBitmap;
|
| 530 |
534 |
|
| 531 |
535 |
mRotationAngleStatic.set0(0.0f);
|
| 532 |
536 |
|
| 533 |
537 |
for(int i=0; i<NUM_CUBITS; i++)
|
| 534 |
|
if( belongsToRotation(i,mRotAxis,mRotRow) )
|
|
538 |
if( belongsToRotation(i,mRotAxis,mRotRowBitmap) )
|
| 535 |
539 |
{
|
| 536 |
540 |
mCubits[i].addNewRotation(axis,durationMillis,angle);
|
| 537 |
541 |
|
| ... | ... | |
| 553 |
557 |
Static4D quat = null;
|
| 554 |
558 |
|
| 555 |
559 |
for(int i=0; i<NUM_CUBITS; i++)
|
| 556 |
|
if( belongsToRotation(i,mRotAxis,mRotRow) )
|
|
560 |
if( belongsToRotation(i,mRotAxis,mRotRowBitmap) )
|
| 557 |
561 |
{
|
| 558 |
562 |
if( first )
|
| 559 |
563 |
{
|
| ... | ... | |
| 575 |
579 |
int a2=move.charAt(2)-'0';
|
| 576 |
580 |
int a3=move.charAt(3)-'0';
|
| 577 |
581 |
|
| 578 |
|
int rotVector = (10*a1+a2)/32; // 0 --> VECTX, 1--> VECTY, 2 --> VECTZ
|
| 579 |
|
int rotBitmap = (10*a1+a2)%32; // 01010 --> move the 2nd and 4th layer
|
| 580 |
|
int rotAngle = 2-a3; // counterclockwise by rotAngle*90 degrees
|
|
582 |
int rotVector = (10*a1+a2)/32;
|
|
583 |
int rotBitmap = (10*a1+a2)%32;
|
|
584 |
int rotAngle = 2-a3;
|
| 581 |
585 |
|
| 582 |
586 |
return scheduleMultiRotation(rotVector, rotBitmap, rotAngle);
|
| 583 |
587 |
}
|
extend the RubikObject API to make it possible to add rotations of multiple rows simultaneously (all along the same axis of course!)