Revision 9ba7f3f6
Added by Leszek Koltunski over 1 year ago
src/main/java/org/distorted/objectlib/objects/TwistyMorphix.java | ||
---|---|---|
17 | 17 |
import org.distorted.objectlib.helpers.ObjectSignature; |
18 | 18 |
import org.distorted.objectlib.helpers.ObjectVertexEffects; |
19 | 19 |
import org.distorted.objectlib.main.InitData; |
20 |
import org.distorted.objectlib.scrambling.ScrambleState; |
|
21 | 20 |
import org.distorted.objectlib.main.ObjectType; |
22 | 21 |
import org.distorted.objectlib.shape.ShapeTetrahedron; |
23 | 22 |
import org.distorted.objectlib.touchcontrol.TouchControlTetrahedron; |
... | ... | |
43 | 42 |
new Static3D( SQ2/2, 0.0f,-SQ2/2), |
44 | 43 |
}; |
45 | 44 |
|
46 |
private ScrambleState[] mStates;
|
|
45 |
private int[][] mEdges;
|
|
47 | 46 |
private int[][] mBasicAngle; |
48 | 47 |
private float[][] mCuts; |
49 | 48 |
private float[][] mCenters; |
... | ... | |
73 | 72 |
} |
74 | 73 |
|
75 | 74 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
76 |
// same as in cubes |
|
77 | 75 |
|
78 |
public ScrambleState[] getScrambleStates()
|
|
76 |
private void insertSection(int[] table, int startIndex, int size, int startAlg, int state)
|
|
79 | 77 |
{ |
80 |
if( mStates==null ) |
|
78 |
for(int i=0; i<size; i++) |
|
79 |
{ |
|
80 |
table[2*(i+startIndex) ] = startAlg +i; |
|
81 |
table[2*(i+startIndex)+1] = state; |
|
82 |
} |
|
83 |
} |
|
84 |
|
|
85 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
86 |
|
|
87 |
private int[] createEdge(int sizeX, int sizeY, int sizeZ, int stateX, int stateY, int stateZ) |
|
88 |
{ |
|
89 |
int num = 0; |
|
90 |
if( stateX>=0 ) num += (3*sizeX); |
|
91 |
if( stateY>=0 ) num += (3*sizeY); |
|
92 |
if( stateZ>=0 ) num += (3*sizeZ); |
|
93 |
|
|
94 |
int[] ret = new int[2*num]; |
|
95 |
|
|
96 |
if( stateX>=0 ) |
|
97 |
{ |
|
98 |
insertSection(ret,0,3*sizeX,0,stateX); |
|
99 |
if( stateY>=0 ) |
|
100 |
{ |
|
101 |
insertSection(ret,3*sizeX,3*sizeY,3*sizeX,stateY); |
|
102 |
if( stateZ>=0 ) insertSection(ret,3*sizeX+3*sizeY,3*sizeZ,3*sizeX+3*sizeY,stateZ); |
|
103 |
} |
|
104 |
else |
|
105 |
{ |
|
106 |
insertSection(ret,3*sizeX,3*sizeZ,3*sizeX+3*sizeY,stateZ); |
|
107 |
} |
|
108 |
} |
|
109 |
else |
|
110 |
{ |
|
111 |
if( stateY>=0 ) |
|
112 |
{ |
|
113 |
insertSection(ret,0,3*sizeY,3*sizeX,stateY); |
|
114 |
if( stateZ>=0 ) insertSection(ret,3*sizeY,3*sizeZ,3*sizeX+3*sizeY,stateZ); |
|
115 |
} |
|
116 |
else |
|
117 |
{ |
|
118 |
insertSection(ret,0,3*sizeZ,3*sizeX+3*sizeY,stateZ); |
|
119 |
} |
|
120 |
} |
|
121 |
|
|
122 |
return ret; |
|
123 |
} |
|
124 |
|
|
125 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
126 |
// same as in a non-flat cuboids |
|
127 |
|
|
128 |
public int[][] getScrambleEdges() |
|
129 |
{ |
|
130 |
if( mEdges==null ) |
|
81 | 131 |
{ |
82 | 132 |
int[] numLayers = getNumLayers(); |
83 |
int[][] m = new int[16][]; |
|
84 |
for(int i=1; i<16; i++) m[i] = createEdges(numLayers[0],i); |
|
85 | 133 |
|
86 |
mStates = new ScrambleState[] |
|
134 |
int X = numLayers[0]; |
|
135 |
int Y = numLayers[1]; |
|
136 |
int Z = numLayers[2]; |
|
137 |
|
|
138 |
mEdges = new int[][] |
|
87 | 139 |
{ |
88 |
new ScrambleState( new int[][] { m[ 1], m[ 2], m[ 3] } ), // 0
|
|
89 |
new ScrambleState( new int[][] { null, m[ 4], m[ 5] } ), // x
|
|
90 |
new ScrambleState( new int[][] { m[ 6], null, m[ 7] } ), // y
|
|
91 |
new ScrambleState( new int[][] { m[ 8], m[ 8], null } ), // z
|
|
92 |
new ScrambleState( new int[][] { m[10], null, m[ 7] } ), // xy
|
|
93 |
new ScrambleState( new int[][] { m[11], m[ 9], null } ), // xz
|
|
94 |
new ScrambleState( new int[][] { null, m[12], m[ 5] } ), // yx
|
|
95 |
new ScrambleState( new int[][] { m[ 8], m[13], null } ), // yz
|
|
96 |
new ScrambleState( new int[][] { null, m[ 4], m[14] } ), // zx
|
|
97 |
new ScrambleState( new int[][] { m[ 6], null, m[15] } ), // zy
|
|
98 |
new ScrambleState( new int[][] { null, null, m[ 5] } ), // xyx
|
|
99 |
new ScrambleState( new int[][] { null, m[ 4], null } ), // xzx
|
|
100 |
new ScrambleState( new int[][] { null, null, m[ 7] } ), // yxy
|
|
101 |
new ScrambleState( new int[][] { m[ 6], null, null } ), // yzy
|
|
102 |
new ScrambleState( new int[][] { null, m[ 9], null } ), // zxz
|
|
103 |
new ScrambleState( new int[][] { m[ 8], null, null } ), // zyz
|
|
140 |
createEdge(X,Y,Z, 1, 2, 3), // 0 0
|
|
141 |
createEdge(X,Y,Z,-1, 4, 5), // 1 x
|
|
142 |
createEdge(X,Y,Z, 6,-1, 7), // 2 y
|
|
143 |
createEdge(X,Y,Z, 8, 9,-1), // 3 z
|
|
144 |
createEdge(X,Y,Z,10,-1, 7), // 4 xy
|
|
145 |
createEdge(X,Y,Z,11, 9,-1), // 5 xz
|
|
146 |
createEdge(X,Y,Z,-1,12, 5), // 6 yx
|
|
147 |
createEdge(X,Y,Z, 8,13,-1), // 7 yz
|
|
148 |
createEdge(X,Y,Z,-1, 4,14), // 8 zx
|
|
149 |
createEdge(X,Y,Z, 6,-1,15), // 9 zy
|
|
150 |
createEdge(X,Y,Z,-1,-1, 5), // 10 xyx
|
|
151 |
createEdge(X,Y,Z,-1, 4,-1), // 11 xzx
|
|
152 |
createEdge(X,Y,Z,-1,-1, 7), // 12 yxy
|
|
153 |
createEdge(X,Y,Z, 6,-1,-1), // 13 yzy
|
|
154 |
createEdge(X,Y,Z,-1, 9,-1), // 14 zxz
|
|
155 |
createEdge(X,Y,Z, 8,-1,-1), // 15 zyz
|
|
104 | 156 |
}; |
105 | 157 |
} |
106 | 158 |
|
107 |
return mStates;
|
|
159 |
return mEdges;
|
|
108 | 160 |
} |
109 | 161 |
|
110 | 162 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Move scrambling to a new model where there are spearete scrambling 'algorithms' and 'edges' of the scrambling graph.
Now each edge can contain a whole algorithm, i.e. a sequence of moves leading from state to state, which permits construction of scrambling for more complicated bandaged objects such as the AI cube.
Unchecked as of yet, probably still a lot of bugs.