Revision 91792184
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objects/TwistyJing.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 TwistyJing extends TwistyObject |
... | ... | |
55 | 53 |
// the length of the edge of the whole tetrahedron. |
56 | 54 |
// keep < 0.25. |
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 int[] mRotQuat; |
65 | 59 |
private Static4D[] mQuats; |
... | ... | |
73 | 67 |
DistortedEffects effects, int[][] moves, Resources res, int scrWidth) |
74 | 68 |
{ |
75 | 69 |
super(size, size, quat, texture, mesh, effects, moves, ObjectList.JING, res, scrWidth); |
70 |
} |
|
76 | 71 |
|
77 |
int[] tmp = {0,-1,0, 0,1,0, 1,-1,0, 1,1,0 };
|
|
72 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
78 | 73 |
|
79 |
mStates = new ScrambleState[] |
|
74 |
ScrambleState[] getScrambleStates() |
|
75 |
{ |
|
76 |
if( mStates==null ) |
|
80 | 77 |
{ |
81 |
new ScrambleState( new int[][] {tmp,tmp,tmp,tmp} ) |
|
82 |
}; |
|
78 |
int[] tmp = {0,-1,0, 0,1,0, 1,-1,0, 1,1,0 }; |
|
79 |
|
|
80 |
mStates = new ScrambleState[] |
|
81 |
{ |
|
82 |
new ScrambleState( new int[][] {tmp,tmp,tmp,tmp} ) |
|
83 |
}; |
|
84 |
} |
|
85 |
|
|
86 |
return mStates; |
|
83 | 87 |
} |
84 | 88 |
|
85 | 89 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
408 | 412 |
return getNumLayers()/(SQ6/3); |
409 | 413 |
} |
410 | 414 |
|
411 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
412 |
|
|
413 |
private void initializeScrambling() |
|
414 |
{ |
|
415 |
int numLayers = getNumLayers(); |
|
416 |
|
|
417 |
if( mScrambleTable ==null ) |
|
418 |
{ |
|
419 |
mScrambleTable = new int[NUM_AXIS][numLayers]; |
|
420 |
} |
|
421 |
if( mNumOccurences ==null ) |
|
422 |
{ |
|
423 |
int max=0; |
|
424 |
|
|
425 |
for (ScrambleState mState : mStates) |
|
426 |
{ |
|
427 |
int tmp = mState.getTotal(-1); |
|
428 |
if (max < tmp) max = tmp; |
|
429 |
} |
|
430 |
|
|
431 |
mNumOccurences = new int[max]; |
|
432 |
} |
|
433 |
|
|
434 |
for(int i=0; i<NUM_AXIS; i++) |
|
435 |
for(int j=0; j<numLayers; j++) mScrambleTable[i][j] = 0; |
|
436 |
} |
|
437 |
|
|
438 | 415 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
439 | 416 |
// PUBLIC API |
440 | 417 |
|
441 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles) |
|
442 |
{ |
|
443 |
if( curr==0 ) |
|
444 |
{ |
|
445 |
mCurrState = 0; |
|
446 |
mIndexExcluded =-1; |
|
447 |
initializeScrambling(); |
|
448 |
} |
|
449 |
|
|
450 |
int[] info= mStates[mCurrState].getRandom(rnd, mIndexExcluded, mScrambleTable, mNumOccurences); |
|
451 |
|
|
452 |
scramble[curr][0] = info[0]; |
|
453 |
scramble[curr][1] = info[1]; |
|
454 |
scramble[curr][2] = info[2]; |
|
455 |
|
|
456 |
mCurrState = info[3]; |
|
457 |
mIndexExcluded = info[0]; |
|
458 |
} |
|
459 |
|
|
460 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
461 |
|
|
462 | 418 |
public Static3D[] getRotationAxis() |
463 | 419 |
{ |
464 | 420 |
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')