1 |
68f6046c
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2020 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
|
|
// This file is part of Magic Cube. //
|
5 |
|
|
// //
|
6 |
|
|
// Magic Cube is free software: you can redistribute it and/or modify //
|
7 |
|
|
// it under the terms of the GNU General Public License as published by //
|
8 |
|
|
// the Free Software Foundation, either version 2 of the License, or //
|
9 |
|
|
// (at your option) any later version. //
|
10 |
|
|
// //
|
11 |
|
|
// Magic Cube is distributed in the hope that it will be useful, //
|
12 |
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
13 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
14 |
|
|
// GNU General Public License for more details. //
|
15 |
|
|
// //
|
16 |
|
|
// You should have received a copy of the GNU General Public License //
|
17 |
|
|
// along with Magic Cube. If not, see <http://www.gnu.org/licenses/>. //
|
18 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19 |
|
|
|
20 |
|
|
package org.distorted.objects;
|
21 |
|
|
|
22 |
|
|
import android.content.res.Resources;
|
23 |
|
|
|
24 |
2077dd18
|
Leszek Koltunski
|
import org.distorted.helpers.ObjectShape;
|
25 |
9c06394a
|
Leszek Koltunski
|
import org.distorted.helpers.ObjectSticker;
|
26 |
cda32fc1
|
Leszek Koltunski
|
import org.distorted.helpers.ScrambleState;
|
27 |
68f6046c
|
Leszek Koltunski
|
import org.distorted.library.main.DistortedEffects;
|
28 |
|
|
import org.distorted.library.main.DistortedTexture;
|
29 |
|
|
import org.distorted.library.mesh.MeshSquare;
|
30 |
|
|
import org.distorted.library.type.Static3D;
|
31 |
|
|
import org.distorted.library.type.Static4D;
|
32 |
6fd4a72c
|
Leszek Koltunski
|
import org.distorted.main.R;
|
33 |
68f6046c
|
Leszek Koltunski
|
|
34 |
|
|
import java.util.Random;
|
35 |
|
|
|
36 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
37 |
|
|
|
38 |
|
|
public class TwistyRedi extends TwistyObject
|
39 |
|
|
{
|
40 |
1dd8d3af
|
Leszek Koltunski
|
// the four rotation axis of a Redi. Must be normalized.
|
41 |
68f6046c
|
Leszek Koltunski
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
42 |
|
|
{
|
43 |
|
|
new Static3D(+SQ3/3,+SQ3/3,+SQ3/3),
|
44 |
|
|
new Static3D(+SQ3/3,+SQ3/3,-SQ3/3),
|
45 |
|
|
new Static3D(+SQ3/3,-SQ3/3,+SQ3/3),
|
46 |
|
|
new Static3D(+SQ3/3,-SQ3/3,-SQ3/3)
|
47 |
|
|
};
|
48 |
|
|
|
49 |
|
|
private static final int[] FACE_COLORS = new int[]
|
50 |
|
|
{
|
51 |
|
|
COLOR_YELLOW, COLOR_WHITE,
|
52 |
|
|
COLOR_BLUE , COLOR_GREEN,
|
53 |
323b217c
|
Leszek Koltunski
|
COLOR_RED , COLOR_ORANGE
|
54 |
68f6046c
|
Leszek Koltunski
|
};
|
55 |
|
|
|
56 |
1dd8d3af
|
Leszek Koltunski
|
private static final int FACES_PER_CUBIT =9;
|
57 |
9c06394a
|
Leszek Koltunski
|
|
58 |
cda32fc1
|
Leszek Koltunski
|
private int mCurrState;
|
59 |
|
|
private int mIndexExcluded;
|
60 |
|
|
private final ScrambleState[] mStates;
|
61 |
|
|
private int[][] mScrambleTable;
|
62 |
|
|
private int[] mNumOccurences;
|
63 |
1dd8d3af
|
Leszek Koltunski
|
private int[] mBasicAngle;
|
64 |
|
|
private Static4D[] mQuats;
|
65 |
|
|
private float[][] mCenters;
|
66 |
|
|
private int[][] mFaceMap;
|
67 |
|
|
private ObjectSticker[] mStickers;
|
68 |
cda32fc1
|
Leszek Koltunski
|
|
69 |
68f6046c
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
70 |
|
|
|
71 |
|
|
TwistyRedi(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
|
72 |
|
|
DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
|
73 |
|
|
{
|
74 |
db875721
|
Leszek Koltunski
|
super(size, size, quat, texture, mesh, effects, moves, ObjectList.REDI, res, scrWidth);
|
75 |
cda32fc1
|
Leszek Koltunski
|
|
76 |
|
|
mStates = new ScrambleState[]
|
77 |
|
|
{
|
78 |
|
|
new ScrambleState( new int[][] { {0,1,1,0,-1,1, 2,1,2,2,-1,2},{0,1,3,0,-1,3, 2,1,4,2,-1,4},{0,1,5,0,-1,5, 2,1,6,2,-1,6},{0,1,7,0,-1,7, 2,1,8,2,-1,8} } ),
|
79 |
|
|
new ScrambleState( new int[][] { { },{0,1,3,0,-1,3 },{0,1,5,0,-1,5, },{ 2,1,8,2,-1,8} } ),
|
80 |
|
|
new ScrambleState( new int[][] { { },{ 2,1,4,2,-1,4},{ 2,1,6,2,-1,6},{0,1,7,0,-1,7 } } ),
|
81 |
|
|
new ScrambleState( new int[][] { {0,1,1,0,-1,1 },{ },{ 2,1,6,2,-1,6},{0,1,7,0,-1,7 } } ),
|
82 |
|
|
new ScrambleState( new int[][] { { 2,1,2,2,-1,2},{ },{0,1,5,0,-1,5, },{ 2,1,8,2,-1,8} } ),
|
83 |
|
|
new ScrambleState( new int[][] { {0,1,1,0,-1,1 },{ 2,1,4,2,-1,4},{ },{0,1,7,0,-1,7 } } ),
|
84 |
|
|
new ScrambleState( new int[][] { { 2,1,2,2,-1,2},{0,1,3,0,-1,3 },{ },{ 2,1,8,2,-1,8} } ),
|
85 |
|
|
new ScrambleState( new int[][] { { 2,1,2,2,-1,2},{0,1,3,0,-1,3 },{0,1,5,0,-1,5, },{ } } ),
|
86 |
|
|
new ScrambleState( new int[][] { {0,1,1,0,-1,1 },{ 2,1,4,2,-1,4},{ 2,1,6,2,-1,6},{ } } ),
|
87 |
|
|
};
|
88 |
68f6046c
|
Leszek Koltunski
|
}
|
89 |
|
|
|
90 |
1dd8d3af
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
91 |
|
|
|
92 |
|
|
private void initializeQuats()
|
93 |
|
|
{
|
94 |
|
|
mQuats = new Static4D[]
|
95 |
|
|
{
|
96 |
|
|
new Static4D( 0.0f, 0.0f, 0.0f, 1.0f ),
|
97 |
|
|
new Static4D( 1.0f, 0.0f, 0.0f, 0.0f ),
|
98 |
|
|
new Static4D( 0.0f, 1.0f, 0.0f, 0.0f ),
|
99 |
|
|
new Static4D( 0.0f, 0.0f, 1.0f, 0.0f ),
|
100 |
|
|
|
101 |
|
|
new Static4D( 0.5f, 0.5f, 0.5f, 0.5f ),
|
102 |
|
|
new Static4D( 0.5f, 0.5f, 0.5f, -0.5f ),
|
103 |
|
|
new Static4D( 0.5f, 0.5f, -0.5f, 0.5f ),
|
104 |
|
|
new Static4D( 0.5f, 0.5f, -0.5f, -0.5f ),
|
105 |
|
|
new Static4D( 0.5f, -0.5f, 0.5f, 0.5f ),
|
106 |
|
|
new Static4D( 0.5f, -0.5f, 0.5f, -0.5f ),
|
107 |
|
|
new Static4D( 0.5f, -0.5f, -0.5f, 0.5f ),
|
108 |
|
|
new Static4D( 0.5f, -0.5f, -0.5f, -0.5f )
|
109 |
|
|
};
|
110 |
|
|
}
|
111 |
|
|
|
112 |
a480ee80
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
113 |
|
|
|
114 |
|
|
int[] getSolvedQuats(int cubit, int numLayers)
|
115 |
|
|
{
|
116 |
1dd8d3af
|
Leszek Koltunski
|
if( mQuats==null ) initializeQuats();
|
117 |
a480ee80
|
Leszek Koltunski
|
int status = retCubitSolvedStatus(cubit,numLayers);
|
118 |
1dd8d3af
|
Leszek Koltunski
|
return status<0 ? null : buildSolvedQuats(MovementRedi.FACE_AXIS[status],mQuats);
|
119 |
a480ee80
|
Leszek Koltunski
|
}
|
120 |
|
|
|
121 |
68f6046c
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
122 |
|
|
|
123 |
|
|
float getScreenRatio()
|
124 |
|
|
{
|
125 |
|
|
return 0.50f;
|
126 |
|
|
}
|
127 |
|
|
|
128 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
129 |
|
|
|
130 |
|
|
Static4D[] getQuats()
|
131 |
|
|
{
|
132 |
1dd8d3af
|
Leszek Koltunski
|
if( mQuats==null ) initializeQuats();
|
133 |
|
|
return mQuats;
|
134 |
68f6046c
|
Leszek Koltunski
|
}
|
135 |
|
|
|
136 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
137 |
|
|
|
138 |
|
|
int getNumFaces()
|
139 |
|
|
{
|
140 |
|
|
return FACE_COLORS.length;
|
141 |
|
|
}
|
142 |
|
|
|
143 |
169219a7
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
144 |
|
|
|
145 |
|
|
int getSolvedFunctionIndex()
|
146 |
|
|
{
|
147 |
|
|
return 0;
|
148 |
|
|
}
|
149 |
|
|
|
150 |
68f6046c
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
151 |
|
|
|
152 |
|
|
boolean shouldResetTextureMaps()
|
153 |
|
|
{
|
154 |
|
|
return false;
|
155 |
|
|
}
|
156 |
|
|
|
157 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
158 |
|
|
|
159 |
a64e07d0
|
Leszek Koltunski
|
int getNumStickerTypes(int numLayers)
|
160 |
68f6046c
|
Leszek Koltunski
|
{
|
161 |
1dd8d3af
|
Leszek Koltunski
|
return 2;
|
162 |
68f6046c
|
Leszek Koltunski
|
}
|
163 |
|
|
|
164 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
165 |
|
|
|
166 |
e6734aa9
|
Leszek Koltunski
|
float[][] getCuts(int size)
|
167 |
68f6046c
|
Leszek Koltunski
|
{
|
168 |
668423be
|
Leszek Koltunski
|
float C = +SQ3/3 +0.05f;
|
169 |
|
|
float[] cut = new float[] {-C,+C};
|
170 |
e6734aa9
|
Leszek Koltunski
|
return new float[][] { cut,cut,cut,cut };
|
171 |
68f6046c
|
Leszek Koltunski
|
}
|
172 |
|
|
|
173 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
174 |
|
|
|
175 |
|
|
int getNumCubitFaces()
|
176 |
|
|
{
|
177 |
|
|
return FACES_PER_CUBIT;
|
178 |
|
|
}
|
179 |
|
|
|
180 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
181 |
|
|
|
182 |
e6cf7283
|
Leszek Koltunski
|
float[][] getCubitPositions(int size)
|
183 |
68f6046c
|
Leszek Koltunski
|
{
|
184 |
1dd8d3af
|
Leszek Koltunski
|
if( mCenters==null )
|
185 |
|
|
{
|
186 |
|
|
final float DIST_CORNER = 1.0f;
|
187 |
|
|
final float DIST_EDGE = 1.5f;
|
188 |
|
|
|
189 |
|
|
mCenters = new float[][]
|
190 |
|
|
{
|
191 |
|
|
{ DIST_CORNER, DIST_CORNER, DIST_CORNER },
|
192 |
|
|
{ DIST_CORNER, DIST_CORNER,-DIST_CORNER },
|
193 |
|
|
{ DIST_CORNER,-DIST_CORNER, DIST_CORNER },
|
194 |
|
|
{ DIST_CORNER,-DIST_CORNER,-DIST_CORNER },
|
195 |
|
|
{-DIST_CORNER, DIST_CORNER, DIST_CORNER },
|
196 |
|
|
{-DIST_CORNER, DIST_CORNER,-DIST_CORNER },
|
197 |
|
|
{-DIST_CORNER,-DIST_CORNER, DIST_CORNER },
|
198 |
|
|
{-DIST_CORNER,-DIST_CORNER,-DIST_CORNER },
|
199 |
|
|
|
200 |
|
|
{ 0.0f, DIST_EDGE, DIST_EDGE },
|
201 |
|
|
{ DIST_EDGE, 0.0f, DIST_EDGE },
|
202 |
|
|
{ 0.0f,-DIST_EDGE, DIST_EDGE },
|
203 |
|
|
{-DIST_EDGE, 0.0f, DIST_EDGE },
|
204 |
|
|
{ DIST_EDGE, DIST_EDGE, 0.0f },
|
205 |
|
|
{ DIST_EDGE,-DIST_EDGE, 0.0f },
|
206 |
|
|
{-DIST_EDGE,-DIST_EDGE, 0.0f },
|
207 |
|
|
{-DIST_EDGE, DIST_EDGE, 0.0f },
|
208 |
|
|
{ 0.0f, DIST_EDGE,-DIST_EDGE },
|
209 |
|
|
{ DIST_EDGE, 0.0f,-DIST_EDGE },
|
210 |
|
|
{ 0.0f,-DIST_EDGE,-DIST_EDGE },
|
211 |
|
|
{-DIST_EDGE, 0.0f,-DIST_EDGE }
|
212 |
|
|
};
|
213 |
|
|
}
|
214 |
|
|
|
215 |
|
|
return mCenters;
|
216 |
68f6046c
|
Leszek Koltunski
|
}
|
217 |
|
|
|
218 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
219 |
|
|
|
220 |
2077dd18
|
Leszek Koltunski
|
ObjectShape getObjectShape(int cubit, int numLayers)
|
221 |
|
|
{
|
222 |
|
|
int variant = getCubitVariant(cubit,numLayers);
|
223 |
|
|
|
224 |
|
|
if( variant==0 )
|
225 |
|
|
{
|
226 |
1dd8d3af
|
Leszek Koltunski
|
double[][] vertices = new double[][]
|
227 |
|
|
{
|
228 |
|
|
{ 0.0f, 0.0f, 0.0f },
|
229 |
|
|
{-0.5f, 0.5f, 0.5f },
|
230 |
|
|
{-0.5f,-0.5f, 0.5f },
|
231 |
|
|
{ 0.5f, 0.5f, 0.5f },
|
232 |
|
|
{ 0.5f,-0.5f, 0.5f },
|
233 |
|
|
{ 0.5f, 0.5f,-0.5f },
|
234 |
|
|
{ 0.5f,-0.5f,-0.5f },
|
235 |
|
|
{-0.5f, 0.5f,-0.5f },
|
236 |
|
|
};
|
237 |
|
|
|
238 |
|
|
int[][] vert_indices = new int[][]
|
239 |
|
|
{
|
240 |
|
|
{ 2,4,3,1 },
|
241 |
|
|
{ 1,3,5,7 },
|
242 |
|
|
{ 4,6,5,3 },
|
243 |
|
|
|
244 |
|
|
{ 2,4,0 },
|
245 |
|
|
{ 5,7,0 },
|
246 |
|
|
{ 4,6,0 },
|
247 |
|
|
{ 7,1,0 },
|
248 |
|
|
{ 1,2,0 },
|
249 |
|
|
{ 6,5,0 }
|
250 |
|
|
};
|
251 |
|
|
|
252 |
668423be
|
Leszek Koltunski
|
float[][] bands = new float[][] { {0.06f,35,0.5f,0.7f,5,2,2}, {0.01f,35,0.2f,0.4f,5,2,2} };
|
253 |
2077dd18
|
Leszek Koltunski
|
int[] bandIndices = new int[] { 0,0,0,1,1,1,1,1,1 };
|
254 |
|
|
float[][] corners = new float[][] { {0.06f,0.12f} };
|
255 |
|
|
int[] cornerIndices = new int[] { -1,0,-1,0,0,0,-1,-1 };
|
256 |
|
|
float[][] centers = new float[][] { { 0.0f, 0.0f, 0.0f} };
|
257 |
|
|
int[] centerIndices = new int[] { -1,0,-1,0,0,0,-1,-1 };
|
258 |
1dd8d3af
|
Leszek Koltunski
|
return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
259 |
2077dd18
|
Leszek Koltunski
|
}
|
260 |
|
|
else
|
261 |
|
|
{
|
262 |
1dd8d3af
|
Leszek Koltunski
|
double[][] vertices = new double[][]
|
263 |
|
|
{
|
264 |
|
|
{-0.5f, 0.0f, 0.0f},
|
265 |
|
|
{ 0.5f, 0.0f, 0.0f},
|
266 |
|
|
{-0.5f,-1.0f, 0.0f},
|
267 |
|
|
{ 0.5f,-1.0f, 0.0f},
|
268 |
|
|
{ 0.0f,-1.5f, 0.0f},
|
269 |
|
|
{-0.5f, 0.0f,-1.0f},
|
270 |
|
|
{ 0.5f, 0.0f,-1.0f},
|
271 |
|
|
{ 0.0f, 0.0f,-1.5f},
|
272 |
|
|
};
|
273 |
|
|
|
274 |
|
|
int[][] vert_indices = new int[][]
|
275 |
|
|
{
|
276 |
|
|
{ 0,2,4,3,1 },
|
277 |
|
|
{ 0,1,6,7,5 },
|
278 |
|
|
{ 1,3,6 },
|
279 |
|
|
{ 0,2,5 },
|
280 |
|
|
{ 4,7,6,3 },
|
281 |
|
|
{ 4,7,5,2 }
|
282 |
|
|
};
|
283 |
|
|
|
284 |
668423be
|
Leszek Koltunski
|
float[][] bands = new float[][] { {0.038f,35,0.250f,0.7f,7,2,2}, {0.020f,35,0.125f,0.2f,3,1,2}, {0.020f,35,0.125f,0.2f,3,1,1} };
|
285 |
2077dd18
|
Leszek Koltunski
|
int[] bandIndices = new int[] { 0,0,1,1,2,2 };
|
286 |
|
|
float[][] corners = new float[][] { {0.06f,0.20f} };
|
287 |
|
|
int[] cornerIndices = new int[] { 0,0,-1,-1,-1,-1,-1,-1 };
|
288 |
|
|
float[][] centers = new float[][] { { 0.0f,-0.75f,-0.75f} };
|
289 |
|
|
int[] centerIndices = new int[] { 0,0,-1,-1,-1,-1,-1,-1 };
|
290 |
1dd8d3af
|
Leszek Koltunski
|
return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
291 |
2077dd18
|
Leszek Koltunski
|
}
|
292 |
|
|
}
|
293 |
|
|
|
294 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
295 |
|
|
|
296 |
3e605536
|
Leszek Koltunski
|
Static4D getQuat(int cubit, int numLayers)
|
297 |
68f6046c
|
Leszek Koltunski
|
{
|
298 |
1dd8d3af
|
Leszek Koltunski
|
if( mQuats==null ) initializeQuats();
|
299 |
|
|
|
300 |
68f6046c
|
Leszek Koltunski
|
switch(cubit)
|
301 |
|
|
{
|
302 |
1dd8d3af
|
Leszek Koltunski
|
case 0: return mQuats[0]; // unit quat
|
303 |
68f6046c
|
Leszek Koltunski
|
case 1: return new Static4D( SQ2/2,0,0,SQ2/2); // 90 along X
|
304 |
|
|
case 2: return new Static4D(-SQ2/2,0,0,SQ2/2); // -90 along X
|
305 |
1dd8d3af
|
Leszek Koltunski
|
case 3: return mQuats[1]; // 180 along X
|
306 |
68f6046c
|
Leszek Koltunski
|
case 4: return new Static4D(0, SQ2/2,0,SQ2/2); // 90 along Y
|
307 |
1dd8d3af
|
Leszek Koltunski
|
case 5: return mQuats[2]; // 180 along Y
|
308 |
|
|
case 6: return mQuats[3]; // 180 along Z
|
309 |
68f6046c
|
Leszek Koltunski
|
case 7: return new Static4D(SQ2/2,0,-SQ2/2,0); // 180 along (SQ2/2,0,-SQ2/2)
|
310 |
|
|
|
311 |
1dd8d3af
|
Leszek Koltunski
|
case 8: return mQuats[0];
|
312 |
|
|
case 9: return mQuats[5];
|
313 |
|
|
case 10: return mQuats[3];
|
314 |
|
|
case 11: return mQuats[11];
|
315 |
|
|
case 12: return mQuats[4];
|
316 |
|
|
case 13: return mQuats[7];
|
317 |
|
|
case 14: return mQuats[9];
|
318 |
|
|
case 15: return mQuats[10];
|
319 |
|
|
case 16: return mQuats[2];
|
320 |
|
|
case 17: return mQuats[8];
|
321 |
|
|
case 18: return mQuats[1];
|
322 |
|
|
case 19: return mQuats[6];
|
323 |
68f6046c
|
Leszek Koltunski
|
}
|
324 |
|
|
|
325 |
|
|
return null;
|
326 |
|
|
}
|
327 |
|
|
|
328 |
2077dd18
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
329 |
|
|
|
330 |
3e605536
|
Leszek Koltunski
|
int getNumCubitVariants(int numLayers)
|
331 |
2077dd18
|
Leszek Koltunski
|
{
|
332 |
|
|
return 2;
|
333 |
|
|
}
|
334 |
|
|
|
335 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
336 |
|
|
|
337 |
|
|
int getCubitVariant(int cubit, int numLayers)
|
338 |
|
|
{
|
339 |
|
|
return cubit<8 ? 0:1;
|
340 |
|
|
}
|
341 |
|
|
|
342 |
68f6046c
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
343 |
|
|
|
344 |
|
|
int getFaceColor(int cubit, int cubitface, int size)
|
345 |
|
|
{
|
346 |
1dd8d3af
|
Leszek Koltunski
|
if( mFaceMap==null )
|
347 |
|
|
{
|
348 |
|
|
// Colors of the faces of cubits.
|
349 |
|
|
// YELLOW 0 WHITE 1 BLUE 2 GREEN 3 RED 4 ORANGE 5
|
350 |
|
|
// YELLOW 6 WHITE 7 BLUE 8 GREEN 9 RED 10 ORANGE 11
|
351 |
|
|
mFaceMap = new int[][]
|
352 |
|
|
{
|
353 |
|
|
{ 4, 2, 0 },
|
354 |
|
|
{ 2, 5, 0 },
|
355 |
|
|
{ 3, 4, 0 },
|
356 |
|
|
{ 5, 3, 0 },
|
357 |
|
|
{ 1, 2, 4 },
|
358 |
|
|
{ 5, 2, 1 },
|
359 |
|
|
{ 4, 3, 1 },
|
360 |
|
|
{ 1, 3, 5 },
|
361 |
|
|
|
362 |
|
|
{ 10, 8,12 },
|
363 |
|
|
{ 6,10,12 },
|
364 |
|
|
{ 10, 9,12 },
|
365 |
|
|
{ 7,10,12 },
|
366 |
|
|
{ 8, 6,12 },
|
367 |
|
|
{ 9, 6,12 },
|
368 |
|
|
{ 9, 7,12 },
|
369 |
|
|
{ 8, 7,12 },
|
370 |
|
|
{ 11, 8,12 },
|
371 |
|
|
{ 6,11,12 },
|
372 |
|
|
{ 11, 9,12 },
|
373 |
|
|
{ 7,11,12 },
|
374 |
|
|
};
|
375 |
|
|
}
|
376 |
|
|
|
377 |
|
|
return cubitface<3 ? mFaceMap[cubit][cubitface] : NUM_TEXTURES;
|
378 |
68f6046c
|
Leszek Koltunski
|
}
|
379 |
|
|
|
380 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
381 |
|
|
|
382 |
9c06394a
|
Leszek Koltunski
|
int getColor(int face)
|
383 |
68f6046c
|
Leszek Koltunski
|
{
|
384 |
9c06394a
|
Leszek Koltunski
|
return FACE_COLORS[face];
|
385 |
|
|
}
|
386 |
68f6046c
|
Leszek Koltunski
|
|
387 |
9c06394a
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
388 |
|
|
|
389 |
|
|
ObjectSticker retSticker(int face)
|
390 |
|
|
{
|
391 |
1dd8d3af
|
Leszek Koltunski
|
if( mStickers==null )
|
392 |
|
|
{
|
393 |
|
|
float[][] STICKERS = new float[][]
|
394 |
|
|
{
|
395 |
|
|
{ -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f },
|
396 |
|
|
{ -0.3125f, 0.4375f, -0.3125f, -0.1875f, 0.0f, -0.5f, 0.3125f, -0.1875f, 0.3125f, 0.4375f }
|
397 |
|
|
};
|
398 |
|
|
|
399 |
|
|
final float R0 = 0.09f;
|
400 |
|
|
final float R1 = 0.06f;
|
401 |
|
|
final float[][] radii = { {R0,R0,R0,R0},{R1,R1,R1,R1,R1} };
|
402 |
|
|
final float[] strokes = { 0.09f,0.06f };
|
403 |
|
|
|
404 |
|
|
mStickers = new ObjectSticker[STICKERS.length];
|
405 |
|
|
|
406 |
|
|
for(int s=0; s<STICKERS.length; s++)
|
407 |
|
|
{
|
408 |
|
|
mStickers[s] = new ObjectSticker(STICKERS[s],null,radii[s],strokes[s]);
|
409 |
|
|
}
|
410 |
|
|
}
|
411 |
|
|
|
412 |
9c06394a
|
Leszek Koltunski
|
return mStickers[face/NUM_FACES];
|
413 |
68f6046c
|
Leszek Koltunski
|
}
|
414 |
|
|
|
415 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
416 |
|
|
|
417 |
|
|
float returnMultiplier()
|
418 |
|
|
{
|
419 |
|
|
return 2.0f;
|
420 |
|
|
}
|
421 |
|
|
|
422 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
423 |
|
|
|
424 |
cda32fc1
|
Leszek Koltunski
|
private void initializeScrambling()
|
425 |
68f6046c
|
Leszek Koltunski
|
{
|
426 |
cda32fc1
|
Leszek Koltunski
|
int numLayers = getNumLayers();
|
427 |
0812242b
|
Leszek Koltunski
|
|
428 |
cda32fc1
|
Leszek Koltunski
|
if( mScrambleTable ==null )
|
429 |
|
|
{
|
430 |
|
|
mScrambleTable = new int[NUM_AXIS][numLayers];
|
431 |
|
|
}
|
432 |
|
|
if( mNumOccurences ==null )
|
433 |
|
|
{
|
434 |
|
|
int max=0;
|
435 |
0812242b
|
Leszek Koltunski
|
|
436 |
cda32fc1
|
Leszek Koltunski
|
for (ScrambleState mState : mStates)
|
437 |
0812242b
|
Leszek Koltunski
|
{
|
438 |
cda32fc1
|
Leszek Koltunski
|
int tmp = mState.getTotal(-1);
|
439 |
|
|
if (max < tmp) max = tmp;
|
440 |
0812242b
|
Leszek Koltunski
|
}
|
441 |
|
|
|
442 |
cda32fc1
|
Leszek Koltunski
|
mNumOccurences = new int[max];
|
443 |
|
|
}
|
444 |
0812242b
|
Leszek Koltunski
|
|
445 |
cda32fc1
|
Leszek Koltunski
|
for(int i=0; i<NUM_AXIS; i++)
|
446 |
|
|
for(int j=0; j<numLayers; j++) mScrambleTable[i][j] = 0;
|
447 |
4c737817
|
Leszek Koltunski
|
}
|
448 |
|
|
|
449 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
450 |
cda32fc1
|
Leszek Koltunski
|
// PUBLIC API
|
451 |
4c737817
|
Leszek Koltunski
|
|
452 |
cda32fc1
|
Leszek Koltunski
|
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles)
|
453 |
0812242b
|
Leszek Koltunski
|
{
|
454 |
cda32fc1
|
Leszek Koltunski
|
if( curr==0 )
|
455 |
0812242b
|
Leszek Koltunski
|
{
|
456 |
cda32fc1
|
Leszek Koltunski
|
mCurrState = 0;
|
457 |
|
|
mIndexExcluded =-1;
|
458 |
|
|
initializeScrambling();
|
459 |
0812242b
|
Leszek Koltunski
|
}
|
460 |
|
|
|
461 |
cda32fc1
|
Leszek Koltunski
|
int[] info= mStates[mCurrState].getRandom(rnd, mIndexExcluded, mScrambleTable, mNumOccurences);
|
462 |
0812242b
|
Leszek Koltunski
|
|
463 |
cda32fc1
|
Leszek Koltunski
|
scramble[curr][0] = info[0];
|
464 |
|
|
scramble[curr][1] = info[1];
|
465 |
|
|
scramble[curr][2] = info[2];
|
466 |
0812242b
|
Leszek Koltunski
|
|
467 |
cda32fc1
|
Leszek Koltunski
|
mCurrState = info[3];
|
468 |
|
|
mIndexExcluded = info[0];
|
469 |
|
|
}
|
470 |
0812242b
|
Leszek Koltunski
|
|
471 |
cda32fc1
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
472 |
0812242b
|
Leszek Koltunski
|
|
473 |
cda32fc1
|
Leszek Koltunski
|
public Static3D[] getRotationAxis()
|
474 |
|
|
{
|
475 |
|
|
return ROT_AXIS;
|
476 |
0812242b
|
Leszek Koltunski
|
}
|
477 |
|
|
|
478 |
68f6046c
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
479 |
|
|
|
480 |
cda32fc1
|
Leszek Koltunski
|
public int[] getBasicAngle()
|
481 |
68f6046c
|
Leszek Koltunski
|
{
|
482 |
1dd8d3af
|
Leszek Koltunski
|
if( mBasicAngle ==null ) mBasicAngle = new int[] { 3,3,3,3 };
|
483 |
|
|
return mBasicAngle;
|
484 |
68f6046c
|
Leszek Koltunski
|
}
|
485 |
|
|
|
486 |
6fd4a72c
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
487 |
|
|
|
488 |
|
|
public int getObjectName(int numLayers)
|
489 |
|
|
{
|
490 |
|
|
return R.string.redi2;
|
491 |
|
|
}
|
492 |
|
|
|
493 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
494 |
|
|
|
495 |
|
|
public int getInventor(int numLayers)
|
496 |
|
|
{
|
497 |
|
|
return R.string.redi2_inventor;
|
498 |
|
|
}
|
499 |
|
|
|
500 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
501 |
|
|
|
502 |
|
|
public int getComplexity(int numLayers)
|
503 |
|
|
{
|
504 |
|
|
return 4;
|
505 |
|
|
}
|
506 |
68f6046c
|
Leszek Koltunski
|
}
|