Revision 91792184
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objects/TwistyRex.java | ||
---|---|---|
31 | 31 |
import org.distorted.library.type.Static4D; |
32 | 32 |
import org.distorted.main.R; |
33 | 33 |
|
34 |
import java.util.Random; |
|
35 |
|
|
36 | 34 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
37 | 35 |
|
38 | 36 |
public class TwistyRex extends TwistyObject |
... | ... | |
55 | 53 |
|
56 | 54 |
public static final float REX_D = 0.2f; |
57 | 55 |
|
58 |
private int mCurrState; |
|
59 |
private int mIndexExcluded; |
|
60 |
private final ScrambleState[] mStates; |
|
61 |
private int[][] mScrambleTable; |
|
62 |
private int[] mNumOccurences; |
|
56 |
private ScrambleState[] mStates; |
|
63 | 57 |
private int[] mBasicAngle; |
64 | 58 |
private Static4D[] mQuats; |
65 | 59 |
private int[][] mFaceMap; |
... | ... | |
71 | 65 |
DistortedEffects effects, int[][] moves, Resources res, int scrWidth) |
72 | 66 |
{ |
73 | 67 |
super(size, size, quat, texture, mesh, effects, moves, ObjectList.REX, res, scrWidth); |
68 |
} |
|
74 | 69 |
|
75 |
int[] tmp = {0,-1,0, 0,1,0, 2,-1,0, 2,1,0 };
|
|
70 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
76 | 71 |
|
77 |
mStates = new ScrambleState[] |
|
72 |
ScrambleState[] getScrambleStates() |
|
73 |
{ |
|
74 |
if( mStates==null ) |
|
78 | 75 |
{ |
79 |
new ScrambleState( new int[][] {tmp,tmp,tmp,tmp} ) |
|
80 |
}; |
|
76 |
int[] tmp = {0,-1,0, 0,1,0, 2,-1,0, 2,1,0 }; |
|
77 |
|
|
78 |
mStates = new ScrambleState[] |
|
79 |
{ |
|
80 |
new ScrambleState( new int[][] {tmp,tmp,tmp,tmp} ) |
|
81 |
}; |
|
82 |
} |
|
83 |
|
|
84 |
return mStates; |
|
81 | 85 |
} |
82 | 86 |
|
83 | 87 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
486 | 490 |
return 2.0f; |
487 | 491 |
} |
488 | 492 |
|
489 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
490 |
|
|
491 |
private void initializeScrambling() |
|
492 |
{ |
|
493 |
int numLayers = getNumLayers(); |
|
494 |
|
|
495 |
if( mScrambleTable ==null ) |
|
496 |
{ |
|
497 |
mScrambleTable = new int[NUM_AXIS][numLayers]; |
|
498 |
} |
|
499 |
if( mNumOccurences ==null ) |
|
500 |
{ |
|
501 |
int max=0; |
|
502 |
|
|
503 |
for (ScrambleState mState : mStates) |
|
504 |
{ |
|
505 |
int tmp = mState.getTotal(-1); |
|
506 |
if (max < tmp) max = tmp; |
|
507 |
} |
|
508 |
|
|
509 |
mNumOccurences = new int[max]; |
|
510 |
} |
|
511 |
|
|
512 |
for(int i=0; i<NUM_AXIS; i++) |
|
513 |
for(int j=0; j<numLayers; j++) mScrambleTable[i][j] = 0; |
|
514 |
} |
|
515 |
|
|
516 | 493 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
517 | 494 |
// PUBLIC API |
518 | 495 |
|
519 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles) |
|
520 |
{ |
|
521 |
if( curr==0 ) |
|
522 |
{ |
|
523 |
mCurrState = 0; |
|
524 |
mIndexExcluded =-1; |
|
525 |
initializeScrambling(); |
|
526 |
} |
|
527 |
|
|
528 |
int[] info= mStates[mCurrState].getRandom(rnd, mIndexExcluded, mScrambleTable, mNumOccurences); |
|
529 |
|
|
530 |
scramble[curr][0] = info[0]; |
|
531 |
scramble[curr][1] = info[1]; |
|
532 |
scramble[curr][2] = info[2]; |
|
533 |
|
|
534 |
mCurrState = info[3]; |
|
535 |
mIndexExcluded = info[0]; |
|
536 |
} |
|
537 |
|
|
538 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
539 |
|
|
540 | 496 |
public Static3D[] getRotationAxis() |
541 | 497 |
{ |
542 | 498 |
return ROT_AXIS; |
Also available in: Unified diff
Make object scrambling abstract (well, almost - with exception of Square-1 - this theoretically could also be done the generic way, but this would require almost 20000 'ScrambleStates')