1 |
a64e07d0
|
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 |
af0de0af
|
Leszek Koltunski
|
import org.distorted.helpers.ObjectSticker;
|
25 |
aa26ba7f
|
Leszek Koltunski
|
import org.distorted.helpers.ScrambleState;
|
26 |
a64e07d0
|
Leszek Koltunski
|
import org.distorted.library.main.DistortedEffects;
|
27 |
|
|
import org.distorted.library.main.DistortedTexture;
|
28 |
|
|
import org.distorted.library.mesh.MeshSquare;
|
29 |
|
|
import org.distorted.library.type.Static3D;
|
30 |
|
|
import org.distorted.library.type.Static4D;
|
31 |
|
|
|
32 |
|
|
import java.util.Random;
|
33 |
|
|
|
34 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
35 |
|
|
|
36 |
|
|
abstract class TwistyMinx extends TwistyObject
|
37 |
|
|
{
|
38 |
|
|
private static final int FACES_PER_CUBIT =6;
|
39 |
|
|
|
40 |
ead91342
|
Leszek Koltunski
|
static final int NUM_CORNERS = 20;
|
41 |
|
|
static final int NUM_CENTERS = 12;
|
42 |
|
|
static final int NUM_EDGES = 30;
|
43 |
|
|
|
44 |
bb11be2a
|
Leszek Koltunski
|
static final float C2 = (SQ5+3)/4;
|
45 |
|
|
static final float LEN = (float)(Math.sqrt(1.25f+0.5f*SQ5));
|
46 |
|
|
static final float SIN54 = (SQ5+1)/4;
|
47 |
|
|
static final float COS54 = (float)(Math.sqrt(10-2*SQ5)/4);
|
48 |
|
|
static final float SIN18 = (SQ5-1)/4;
|
49 |
|
|
static final float COS18 = (float)(0.25f*Math.sqrt(10.0f+2.0f*SQ5));
|
50 |
|
|
static final float COS_HALFD= (float)(Math.sqrt(0.5f-0.1f*SQ5)); // cos(half the dihedral angle)
|
51 |
|
|
static final float SIN_HALFD= (float)(Math.sqrt(0.5f+0.1f*SQ5)); // sin(half the dihedral angle)
|
52 |
a64e07d0
|
Leszek Koltunski
|
|
53 |
|
|
// the six rotation axis of a Minx. Must be normalized.
|
54 |
|
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
55 |
|
|
{
|
56 |
bb11be2a
|
Leszek Koltunski
|
new Static3D( C2/LEN, SIN54/LEN, 0 ),
|
57 |
|
|
new Static3D( -C2/LEN, SIN54/LEN, 0 ),
|
58 |
|
|
new Static3D( 0 , C2/LEN, SIN54/LEN ),
|
59 |
|
|
new Static3D( 0 , -C2/LEN, SIN54/LEN ),
|
60 |
|
|
new Static3D( SIN54/LEN, 0 , C2/LEN ),
|
61 |
|
|
new Static3D( SIN54/LEN, 0 , -C2/LEN )
|
62 |
a64e07d0
|
Leszek Koltunski
|
};
|
63 |
|
|
|
64 |
bc649d9a
|
Leszek Koltunski
|
static final int MINX_LGREEN = 0xff53aa00;
|
65 |
|
|
static final int MINX_PINK = 0xfffd7ab7;
|
66 |
|
|
static final int MINX_SANDY = 0xffefd48b;
|
67 |
|
|
static final int MINX_LBLUE = 0xff00a2d7;
|
68 |
|
|
static final int MINX_ORANGE = 0xffff6200;
|
69 |
|
|
static final int MINX_VIOLET = 0xff7d59a4;
|
70 |
|
|
static final int MINX_DGREEN = 0xff007a47;
|
71 |
|
|
static final int MINX_DRED = 0xffbd0000;
|
72 |
|
|
static final int MINX_DBLUE = 0xff1a29b2;
|
73 |
|
|
static final int MINX_DYELLOW= 0xffffc400;
|
74 |
|
|
static final int MINX_WHITE = 0xffffffff;
|
75 |
|
|
static final int MINX_GREY = 0xff727c7b;
|
76 |
a64e07d0
|
Leszek Koltunski
|
|
77 |
|
|
static final int[] FACE_COLORS = new int[]
|
78 |
|
|
{
|
79 |
|
|
MINX_LGREEN, MINX_PINK , MINX_SANDY , MINX_LBLUE,
|
80 |
|
|
MINX_ORANGE, MINX_VIOLET , MINX_DGREEN, MINX_DRED ,
|
81 |
|
|
MINX_DBLUE , MINX_DYELLOW, MINX_WHITE , MINX_GREY
|
82 |
|
|
};
|
83 |
|
|
|
84 |
af0de0af
|
Leszek Koltunski
|
private int mCurrState;
|
85 |
|
|
private int mIndexExcluded;
|
86 |
|
|
private ScrambleState[] mStates;
|
87 |
|
|
private int[][] mScrambleTable;
|
88 |
|
|
private int[] mNumOccurences;
|
89 |
|
|
private int[] mBasicAngle;
|
90 |
|
|
private int[] mFaceMap;
|
91 |
|
|
Static4D[] mQuats;
|
92 |
|
|
float[][] mCenterCoords;
|
93 |
|
|
float[][] mCorners;
|
94 |
|
|
int[][] mCornerFaceMap;
|
95 |
|
|
int[] mQuatEdgeIndices;
|
96 |
|
|
int[] mQuatCornerIndices;
|
97 |
|
|
int[][] mEdgeMap;
|
98 |
|
|
int[][] mCenterMap;
|
99 |
|
|
Static4D[] mBasicCornerV, mCurrCornerV;
|
100 |
|
|
ObjectSticker[] mStickers;
|
101 |
a480ee80
|
Leszek Koltunski
|
|
102 |
af0de0af
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
103 |
a64e07d0
|
Leszek Koltunski
|
|
104 |
af0de0af
|
Leszek Koltunski
|
TwistyMinx(int numLayers, int realSize, Static4D quat, DistortedTexture texture, MeshSquare mesh,
|
105 |
|
|
DistortedEffects effects, int[][] moves, ObjectList obj, Resources res, int scrWidth)
|
106 |
|
|
{
|
107 |
|
|
super(numLayers, realSize, quat, texture, mesh, effects, moves, obj, res, scrWidth);
|
108 |
a64e07d0
|
Leszek Koltunski
|
|
109 |
af0de0af
|
Leszek Koltunski
|
initializeScrambleStates(numLayers);
|
110 |
|
|
}
|
111 |
a64e07d0
|
Leszek Koltunski
|
|
112 |
7764a67a
|
Leszek Koltunski
|
|
113 |
af0de0af
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
114 |
7764a67a
|
Leszek Koltunski
|
|
115 |
af0de0af
|
Leszek Koltunski
|
void initializeCornerV()
|
116 |
|
|
{
|
117 |
|
|
mBasicCornerV = new Static4D[3];
|
118 |
|
|
mCurrCornerV = new Static4D[3];
|
119 |
|
|
|
120 |
|
|
mBasicCornerV[0] = new Static4D( (SQ5+1)*0.125f, (SQ5-1)*0.125f, -0.250f, 0.0f );
|
121 |
|
|
mBasicCornerV[1] = new Static4D(-(SQ5+1)*0.125f, (SQ5-1)*0.125f, -0.250f, 0.0f );
|
122 |
|
|
mBasicCornerV[2] = new Static4D( 0, -0.500f, 0.0f, 0.0f );
|
123 |
|
|
}
|
124 |
|
|
|
125 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
126 |
|
|
// the five vertices that form a given face. Order: the same as colors of the faces in TwistyMinx.
|
127 |
|
|
|
128 |
|
|
void initializeCenterMap()
|
129 |
|
|
{
|
130 |
|
|
mCenterMap = new int[][]
|
131 |
|
|
{
|
132 |
|
|
{ 0, 12, 4, 14, 2},
|
133 |
|
|
{ 0, 2, 18, 6, 16},
|
134 |
|
|
{ 6, 18, 11, 19, 7},
|
135 |
|
|
{ 3, 15, 9, 11, 19},
|
136 |
|
|
{ 4, 5, 15, 9, 14},
|
137 |
|
|
{ 1, 13, 5, 15, 3},
|
138 |
|
|
{ 1, 3, 19, 7, 17},
|
139 |
|
|
{10, 16, 6, 7, 17},
|
140 |
|
|
{ 0, 12, 8, 10, 16},
|
141 |
|
|
{ 8, 13, 5, 4, 12},
|
142 |
|
|
{ 1, 13, 8, 10, 17},
|
143 |
|
|
{ 2, 14, 9, 11, 18},
|
144 |
|
|
};
|
145 |
|
|
}
|
146 |
d38f1397
|
Leszek Koltunski
|
|
147 |
af0de0af
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
148 |
|
|
// the quadruple ( corner1, corner2, face1, face2 ) defining an edge.
|
149 |
|
|
// In fact the 2 corners already define it, the faces only provide easy
|
150 |
|
|
// way to get to know the colors. Order: arbitrary. Face1 arbitrarily on
|
151 |
|
|
// the 'left' or right of vector corner1 --> corner2, according to Quat.
|
152 |
|
|
|
153 |
|
|
void initializeEdgeMap()
|
154 |
|
|
{
|
155 |
|
|
mEdgeMap = new int[][]
|
156 |
ead91342
|
Leszek Koltunski
|
{
|
157 |
7a606778
|
Leszek Koltunski
|
{ 0, 12, 0, 8}, //0
|
158 |
ead91342
|
Leszek Koltunski
|
{ 12, 4, 0, 9},
|
159 |
|
|
{ 4, 14, 0, 4},
|
160 |
|
|
{ 14, 2, 0, 11},
|
161 |
|
|
{ 2, 0, 0, 1},
|
162 |
7a606778
|
Leszek Koltunski
|
{ 14, 9, 11, 4}, //5
|
163 |
|
|
{ 9, 11, 11, 3},
|
164 |
|
|
{ 11, 18, 11, 2},
|
165 |
|
|
{ 18, 2, 11, 1},
|
166 |
ead91342
|
Leszek Koltunski
|
{ 18, 6, 1, 2},
|
167 |
7a606778
|
Leszek Koltunski
|
{ 6, 16, 1, 7}, //10
|
168 |
|
|
{ 16, 0, 1, 8},
|
169 |
|
|
{ 16, 10, 8, 7},
|
170 |
|
|
{ 10, 8, 8, 10},
|
171 |
|
|
{ 8, 12, 8, 9},
|
172 |
|
|
{ 8, 13, 9, 10}, //15
|
173 |
ead91342
|
Leszek Koltunski
|
{ 13, 5, 9, 5},
|
174 |
|
|
{ 5, 4, 9, 4},
|
175 |
7a606778
|
Leszek Koltunski
|
{ 5, 15, 4, 5},
|
176 |
|
|
{ 15, 9, 4, 3},
|
177 |
|
|
{ 11, 19, 2, 3}, //20
|
178 |
ead91342
|
Leszek Koltunski
|
{ 19, 7, 2, 6},
|
179 |
|
|
{ 7, 6, 2, 7},
|
180 |
|
|
{ 7, 17, 7, 6},
|
181 |
|
|
{ 17, 10, 7, 10},
|
182 |
7a606778
|
Leszek Koltunski
|
{ 17, 1, 10, 6}, //25
|
183 |
ead91342
|
Leszek Koltunski
|
{ 1, 3, 5, 6},
|
184 |
|
|
{ 3, 19, 3, 6},
|
185 |
|
|
{ 1, 13, 10, 5},
|
186 |
7a606778
|
Leszek Koltunski
|
{ 3, 15, 5, 3},
|
187 |
ead91342
|
Leszek Koltunski
|
};
|
188 |
af0de0af
|
Leszek Koltunski
|
}
|
189 |
ead91342
|
Leszek Koltunski
|
|
190 |
af0de0af
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
191 |
ead91342
|
Leszek Koltunski
|
|
192 |
af0de0af
|
Leszek Koltunski
|
void initializeQuatIndices()
|
193 |
ead91342
|
Leszek Koltunski
|
{
|
194 |
af0de0af
|
Leszek Koltunski
|
mQuatEdgeIndices = new int[]
|
195 |
ead91342
|
Leszek Koltunski
|
{
|
196 |
af0de0af
|
Leszek Koltunski
|
56, 40, 43, 59, 0, 19, 9, 54, 58, 49,
|
197 |
|
|
48, 24, 52, 4, 16, 32, 20, 11, 21, 35,
|
198 |
|
|
37, 30, 8, 28, 36, 44, 1, 46, 12, 47
|
199 |
|
|
};
|
200 |
|
|
mQuatCornerIndices = new int[]
|
201 |
|
|
{
|
202 |
|
|
0, 2, 3, 1, 40, 31, 41, 30, 39, 35,
|
203 |
|
|
36, 34, 56, 32, 43, 21, 48, 28, 42, 23
|
204 |
|
|
};
|
205 |
|
|
}
|
206 |
ead91342
|
Leszek Koltunski
|
|
207 |
af0de0af
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
208 |
ead91342
|
Leszek Koltunski
|
|
209 |
af0de0af
|
Leszek Koltunski
|
void initializeCornerFaceMap()
|
210 |
|
|
{
|
211 |
|
|
mCornerFaceMap = new int[][]
|
212 |
|
|
{
|
213 |
|
|
{ 0, 1, 8 },
|
214 |
|
|
{ 6, 5,10 },
|
215 |
|
|
{ 1, 0,11 },
|
216 |
|
|
{ 5, 6, 3 },
|
217 |
|
|
{ 0, 9, 4 },
|
218 |
|
|
{ 5, 4, 9 },
|
219 |
|
|
{ 7, 1, 2 },
|
220 |
|
|
{ 2, 6, 7 },
|
221 |
|
|
{ 10, 9, 8 },
|
222 |
|
|
{ 4, 3,11 },
|
223 |
|
|
{ 7,10, 8 },
|
224 |
|
|
{ 3, 2,11 },
|
225 |
|
|
{ 0, 8, 9 },
|
226 |
|
|
{ 9,10, 5 },
|
227 |
|
|
{ 0, 4,11 },
|
228 |
|
|
{ 4, 5, 3 },
|
229 |
|
|
{ 1, 7, 8 },
|
230 |
|
|
{ 7, 6,10 },
|
231 |
|
|
{ 2, 1,11 },
|
232 |
|
|
{ 6, 2, 3 },
|
233 |
|
|
};
|
234 |
|
|
}
|
235 |
ead91342
|
Leszek Koltunski
|
|
236 |
af0de0af
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
237 |
ead91342
|
Leszek Koltunski
|
|
238 |
af0de0af
|
Leszek Koltunski
|
void initializeQuats()
|
239 |
|
|
{
|
240 |
|
|
mQuats = new Static4D[]
|
241 |
|
|
{
|
242 |
|
|
new Static4D( 0.0f, 0.0f, 0.0f, 1.0f ), //0
|
243 |
|
|
new Static4D( 1.0f, 0.0f, 0.0f, 0.0f ),
|
244 |
|
|
new Static4D( 0.0f, 1.0f, 0.0f, 0.0f ),
|
245 |
|
|
new Static4D( 0.0f, 0.0f, 1.0f, 0.0f ),
|
246 |
|
|
|
247 |
|
|
new Static4D( 0.5f, 0.5f, 0.5f, 0.5f ), //4
|
248 |
|
|
new Static4D( 0.5f, 0.5f, -0.5f, 0.5f ),
|
249 |
|
|
new Static4D( 0.5f, -0.5f, 0.5f, 0.5f ),
|
250 |
|
|
new Static4D( 0.5f, -0.5f, -0.5f, 0.5f ),
|
251 |
|
|
new Static4D( -0.5f, 0.5f, 0.5f, 0.5f ),
|
252 |
|
|
new Static4D( -0.5f, 0.5f, -0.5f, 0.5f ),
|
253 |
|
|
new Static4D( -0.5f, -0.5f, 0.5f, 0.5f ),
|
254 |
|
|
new Static4D( -0.5f, -0.5f, -0.5f, 0.5f ),
|
255 |
|
|
|
256 |
|
|
new Static4D( 0.5f, SIN54, SIN18, 0.0f ), // 12
|
257 |
|
|
new Static4D( 0.5f, SIN54,-SIN18, 0.0f ),
|
258 |
|
|
new Static4D( 0.5f,-SIN54, SIN18, 0.0f ),
|
259 |
|
|
new Static4D( 0.5f,-SIN54,-SIN18, 0.0f ),
|
260 |
|
|
new Static4D( SIN18, 0.5f, SIN54, 0.0f ),
|
261 |
|
|
new Static4D( SIN18, 0.5f,-SIN54, 0.0f ),
|
262 |
|
|
new Static4D(-SIN18, 0.5f, SIN54, 0.0f ),
|
263 |
|
|
new Static4D(-SIN18, 0.5f,-SIN54, 0.0f ),
|
264 |
|
|
new Static4D( SIN54, SIN18, 0.5f, 0.0f ),
|
265 |
|
|
new Static4D( SIN54,-SIN18, 0.5f, 0.0f ),
|
266 |
|
|
new Static4D(-SIN54, SIN18, 0.5f, 0.0f ),
|
267 |
|
|
new Static4D(-SIN54,-SIN18, 0.5f, 0.0f ),
|
268 |
|
|
|
269 |
|
|
new Static4D( 0.0f, SIN18, SIN54, 0.5f ), //24
|
270 |
|
|
new Static4D( 0.0f, SIN18,-SIN54, 0.5f ),
|
271 |
|
|
new Static4D( 0.0f,-SIN18, SIN54, 0.5f ),
|
272 |
|
|
new Static4D( 0.0f,-SIN18,-SIN54, 0.5f ),
|
273 |
|
|
new Static4D( SIN18, SIN54, 0.0f, 0.5f ),
|
274 |
|
|
new Static4D( SIN18,-SIN54, 0.0f, 0.5f ),
|
275 |
|
|
new Static4D(-SIN18, SIN54, 0.0f, 0.5f ),
|
276 |
|
|
new Static4D(-SIN18,-SIN54, 0.0f, 0.5f ),
|
277 |
|
|
new Static4D( SIN54, 0.0f, SIN18, 0.5f ),
|
278 |
|
|
new Static4D( SIN54, 0.0f,-SIN18, 0.5f ),
|
279 |
|
|
new Static4D(-SIN54, 0.0f, SIN18, 0.5f ),
|
280 |
|
|
new Static4D(-SIN54, 0.0f,-SIN18, 0.5f ),
|
281 |
|
|
|
282 |
|
|
new Static4D( 0.0f, SIN54, 0.5f, SIN18 ), //36
|
283 |
|
|
new Static4D( 0.0f, SIN54, -0.5f, SIN18 ),
|
284 |
|
|
new Static4D( 0.0f,-SIN54, 0.5f, SIN18 ),
|
285 |
|
|
new Static4D( 0.0f,-SIN54, -0.5f, SIN18 ),
|
286 |
|
|
new Static4D( 0.5f, 0.0f, SIN54, SIN18 ),
|
287 |
|
|
new Static4D( 0.5f, 0.0f,-SIN54, SIN18 ),
|
288 |
|
|
new Static4D( -0.5f, 0.0f, SIN54, SIN18 ),
|
289 |
|
|
new Static4D( -0.5f, 0.0f,-SIN54, SIN18 ),
|
290 |
|
|
new Static4D( SIN54, 0.5f, 0.0f, SIN18 ),
|
291 |
|
|
new Static4D( SIN54, -0.5f, 0.0f, SIN18 ),
|
292 |
|
|
new Static4D(-SIN54, 0.5f, 0.0f, SIN18 ),
|
293 |
|
|
new Static4D(-SIN54, -0.5f, 0.0f, SIN18 ),
|
294 |
|
|
|
295 |
|
|
new Static4D( 0.0f, 0.5f, SIN18, SIN54 ), //48
|
296 |
|
|
new Static4D( 0.0f, 0.5f,-SIN18, SIN54 ),
|
297 |
|
|
new Static4D( 0.0f, -0.5f, SIN18, SIN54 ),
|
298 |
|
|
new Static4D( 0.0f, -0.5f,-SIN18, SIN54 ),
|
299 |
|
|
new Static4D( 0.5f, SIN18, 0.0f, SIN54 ),
|
300 |
|
|
new Static4D( 0.5f,-SIN18, 0.0f, SIN54 ),
|
301 |
|
|
new Static4D( -0.5f, SIN18, 0.0f, SIN54 ),
|
302 |
|
|
new Static4D( -0.5f,-SIN18, 0.0f, SIN54 ),
|
303 |
|
|
new Static4D( SIN18, 0.0f, 0.5f, SIN54 ),
|
304 |
|
|
new Static4D( SIN18, 0.0f, -0.5f, SIN54 ),
|
305 |
|
|
new Static4D(-SIN18, 0.0f, 0.5f, SIN54 ),
|
306 |
|
|
new Static4D(-SIN18, 0.0f, -0.5f, SIN54 ),
|
307 |
|
|
};
|
308 |
ead91342
|
Leszek Koltunski
|
}
|
309 |
|
|
|
310 |
af0de0af
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
311 |
|
|
// Coordinates of all 20 corners of a Minx
|
312 |
ead91342
|
Leszek Koltunski
|
|
313 |
af0de0af
|
Leszek Koltunski
|
void initializeCorners()
|
314 |
ead91342
|
Leszek Koltunski
|
{
|
315 |
af0de0af
|
Leszek Koltunski
|
mCorners = new float[][]
|
316 |
|
|
{
|
317 |
|
|
{ 0.0f, 0.5f, C2},
|
318 |
|
|
{ 0.0f, 0.5f, -C2},
|
319 |
|
|
{ 0.0f, -0.5f, C2},
|
320 |
|
|
{ 0.0f, -0.5f, -C2},
|
321 |
|
|
{ C2, 0.0f, 0.5f},
|
322 |
|
|
{ C2, 0.0f, -0.5f},
|
323 |
|
|
{ -C2, 0.0f, 0.5f},
|
324 |
|
|
{ -C2, 0.0f, -0.5f},
|
325 |
|
|
{ 0.5f, C2, 0.0f},
|
326 |
|
|
{ 0.5f, -C2, 0.0f},
|
327 |
|
|
{ -0.5f, C2, 0.0f},
|
328 |
|
|
{ -0.5f, -C2, 0.0f},
|
329 |
|
|
{ SIN54, SIN54, SIN54},
|
330 |
|
|
{ SIN54, SIN54,-SIN54},
|
331 |
|
|
{ SIN54,-SIN54, SIN54},
|
332 |
|
|
{ SIN54,-SIN54,-SIN54},
|
333 |
|
|
{-SIN54, SIN54, SIN54},
|
334 |
|
|
{-SIN54, SIN54,-SIN54},
|
335 |
|
|
{-SIN54,-SIN54, SIN54},
|
336 |
|
|
{-SIN54,-SIN54,-SIN54},
|
337 |
|
|
};
|
338 |
ead91342
|
Leszek Koltunski
|
}
|
339 |
|
|
|
340 |
a64e07d0
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
341 |
|
|
|
342 |
af0de0af
|
Leszek Koltunski
|
void initializeCenterCoords()
|
343 |
a64e07d0
|
Leszek Koltunski
|
{
|
344 |
af0de0af
|
Leszek Koltunski
|
if( mCorners==null ) initializeCorners();
|
345 |
|
|
if( mCenterMap==null ) initializeCenterMap();
|
346 |
aa26ba7f
|
Leszek Koltunski
|
|
347 |
af0de0af
|
Leszek Koltunski
|
mCenterCoords = new float[NUM_CENTERS][3];
|
348 |
|
|
|
349 |
|
|
for(int center=0; center<NUM_CENTERS; center++)
|
350 |
|
|
{
|
351 |
|
|
int[] map = mCenterMap[center];
|
352 |
|
|
|
353 |
|
|
float x = mCorners[map[0]][0] +
|
354 |
|
|
mCorners[map[1]][0] +
|
355 |
|
|
mCorners[map[2]][0] +
|
356 |
|
|
mCorners[map[3]][0] +
|
357 |
|
|
mCorners[map[4]][0] ;
|
358 |
|
|
|
359 |
|
|
float y = mCorners[map[0]][1] +
|
360 |
|
|
mCorners[map[1]][1] +
|
361 |
|
|
mCorners[map[2]][1] +
|
362 |
|
|
mCorners[map[3]][1] +
|
363 |
|
|
mCorners[map[4]][1] ;
|
364 |
|
|
|
365 |
|
|
float z = mCorners[map[0]][2] +
|
366 |
|
|
mCorners[map[1]][2] +
|
367 |
|
|
mCorners[map[2]][2] +
|
368 |
|
|
mCorners[map[3]][2] +
|
369 |
|
|
mCorners[map[4]][2] ;
|
370 |
|
|
|
371 |
|
|
mCenterCoords[center][0] = x/5;
|
372 |
|
|
mCenterCoords[center][1] = y/5;
|
373 |
|
|
mCenterCoords[center][2] = z/5;
|
374 |
|
|
}
|
375 |
a64e07d0
|
Leszek Koltunski
|
}
|
376 |
|
|
|
377 |
a480ee80
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
378 |
|
|
|
379 |
aa26ba7f
|
Leszek Koltunski
|
private int[] generateL(int numLayers, int index)
|
380 |
a480ee80
|
Leszek Koltunski
|
{
|
381 |
aa26ba7f
|
Leszek Koltunski
|
int rows = (numLayers-1)/2;
|
382 |
|
|
int[] ret = new int[3*4*rows];
|
383 |
|
|
|
384 |
|
|
for(int i=0; i<rows; i++)
|
385 |
|
|
{
|
386 |
|
|
ret[12*i ] = i;
|
387 |
|
|
ret[12*i+ 1] =-2;
|
388 |
|
|
ret[12*i+ 2] = index;
|
389 |
|
|
ret[12*i+ 3] = i;
|
390 |
|
|
ret[12*i+ 4] =-1;
|
391 |
|
|
ret[12*i+ 5] = index;
|
392 |
|
|
ret[12*i+ 6] = i;
|
393 |
|
|
ret[12*i+ 7] =+1;
|
394 |
|
|
ret[12*i+ 8] = index;
|
395 |
|
|
ret[12*i+ 9] = i;
|
396 |
|
|
ret[12*i+10] =+2;
|
397 |
|
|
ret[12*i+11] = index;
|
398 |
|
|
}
|
399 |
|
|
|
400 |
|
|
return ret;
|
401 |
a480ee80
|
Leszek Koltunski
|
}
|
402 |
|
|
|
403 |
a64e07d0
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
404 |
|
|
|
405 |
aa26ba7f
|
Leszek Koltunski
|
private int[] generateR(int numLayers, int index)
|
406 |
a64e07d0
|
Leszek Koltunski
|
{
|
407 |
aa26ba7f
|
Leszek Koltunski
|
int rows = (numLayers-1)/2;
|
408 |
|
|
int[] ret = new int[3*4*rows];
|
409 |
|
|
|
410 |
|
|
for(int i=0; i<rows; i++)
|
411 |
|
|
{
|
412 |
|
|
int lay = rows+i+1;
|
413 |
|
|
|
414 |
|
|
ret[12*i ] = lay;
|
415 |
|
|
ret[12*i+ 1] =-2;
|
416 |
|
|
ret[12*i+ 2] = index;
|
417 |
|
|
ret[12*i+ 3] = lay;
|
418 |
|
|
ret[12*i+ 4] =-1;
|
419 |
|
|
ret[12*i+ 5] = index;
|
420 |
|
|
ret[12*i+ 6] = lay;
|
421 |
|
|
ret[12*i+ 7] =+1;
|
422 |
|
|
ret[12*i+ 8] = index;
|
423 |
|
|
ret[12*i+ 9] = lay;
|
424 |
|
|
ret[12*i+10] =+2;
|
425 |
|
|
ret[12*i+11] = index;
|
426 |
|
|
}
|
427 |
|
|
|
428 |
|
|
return ret;
|
429 |
a64e07d0
|
Leszek Koltunski
|
}
|
430 |
|
|
|
431 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
432 |
|
|
|
433 |
aa26ba7f
|
Leszek Koltunski
|
private int[] generateB(int numLayers, int index)
|
434 |
a64e07d0
|
Leszek Koltunski
|
{
|
435 |
aa26ba7f
|
Leszek Koltunski
|
int rows = (numLayers-1);
|
436 |
|
|
int half = rows/2;
|
437 |
|
|
int[] ret = new int[3*4*rows];
|
438 |
|
|
|
439 |
|
|
for(int i=0; i<rows; i++)
|
440 |
|
|
{
|
441 |
|
|
int ind = i<half? index : index+1;
|
442 |
|
|
int lay = i<half? i : i+1;
|
443 |
|
|
|
444 |
|
|
ret[12*i ] = lay;
|
445 |
|
|
ret[12*i+ 1] =-2;
|
446 |
|
|
ret[12*i+ 2] = ind;
|
447 |
|
|
ret[12*i+ 3] = lay;
|
448 |
|
|
ret[12*i+ 4] =-1;
|
449 |
|
|
ret[12*i+ 5] = ind;
|
450 |
|
|
ret[12*i+ 6] = lay;
|
451 |
|
|
ret[12*i+ 7] =+1;
|
452 |
|
|
ret[12*i+ 8] = ind;
|
453 |
|
|
ret[12*i+ 9] = lay;
|
454 |
|
|
ret[12*i+10] =+2;
|
455 |
|
|
ret[12*i+11] = ind;
|
456 |
|
|
}
|
457 |
|
|
|
458 |
|
|
return ret;
|
459 |
a64e07d0
|
Leszek Koltunski
|
}
|
460 |
|
|
|
461 |
169219a7
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
462 |
|
|
|
463 |
aa26ba7f
|
Leszek Koltunski
|
private void initializeScrambleStates(int numLayers)
|
464 |
169219a7
|
Leszek Koltunski
|
{
|
465 |
aa26ba7f
|
Leszek Koltunski
|
int[] LEFT0 = generateL(numLayers,1);
|
466 |
|
|
int[] RIGH0 = generateR(numLayers,2);
|
467 |
|
|
int[] LEFT1 = generateL(numLayers,3);
|
468 |
|
|
int[] RIGH1 = generateR(numLayers,4);
|
469 |
|
|
int[] LEFT2 = generateL(numLayers,5);
|
470 |
|
|
int[] RIGH2 = generateR(numLayers,6);
|
471 |
|
|
int[] LEFT3 = generateL(numLayers,7);
|
472 |
|
|
int[] RIGH3 = generateR(numLayers,8);
|
473 |
|
|
int[] LEFT4 = generateL(numLayers,9);
|
474 |
|
|
int[] RIGH4 = generateR(numLayers,10);
|
475 |
|
|
int[] LEFT5 = generateL(numLayers,11);
|
476 |
|
|
int[] RIGH5 = generateR(numLayers,12);
|
477 |
|
|
|
478 |
|
|
int[] BOTH1 = generateB(numLayers,1);
|
479 |
|
|
int[] BOTH3 = generateB(numLayers,3);
|
480 |
|
|
int[] BOTH5 = generateB(numLayers,5);
|
481 |
|
|
int[] BOTH7 = generateB(numLayers,7);
|
482 |
|
|
int[] BOTH9 = generateB(numLayers,9);
|
483 |
|
|
int[] BOTH11= generateB(numLayers,11);
|
484 |
|
|
|
485 |
|
|
mStates = new ScrambleState[]
|
486 |
|
|
{
|
487 |
|
|
new ScrambleState( new int[][] { BOTH1,BOTH3,BOTH5,BOTH7,BOTH9,BOTH11 } ), // beg
|
488 |
|
|
new ScrambleState( new int[][] { {} ,RIGH1,LEFT2,RIGH3,LEFT4,LEFT5 } ), // 0L
|
489 |
|
|
new ScrambleState( new int[][] { {} ,LEFT1,RIGH2,LEFT3,RIGH4,RIGH5 } ), // 0R
|
490 |
|
|
new ScrambleState( new int[][] { RIGH0,{} ,LEFT2,RIGH3,RIGH4,RIGH5 } ), // 1L
|
491 |
|
|
new ScrambleState( new int[][] { LEFT0,{} ,RIGH2,LEFT3,LEFT4,LEFT5 } ), // 1R
|
492 |
|
|
new ScrambleState( new int[][] { LEFT0,LEFT1,{} ,RIGH3,LEFT4,RIGH5 } ), // 2L
|
493 |
|
|
new ScrambleState( new int[][] { RIGH0,RIGH1,{} ,LEFT3,RIGH4,LEFT5 } ), // 2R
|
494 |
|
|
new ScrambleState( new int[][] { RIGH0,RIGH1,RIGH2,{} ,LEFT4,RIGH5 } ), // 3L
|
495 |
|
|
new ScrambleState( new int[][] { LEFT0,LEFT1,LEFT2,{} ,RIGH4,LEFT5 } ), // 3R
|
496 |
|
|
new ScrambleState( new int[][] { LEFT0,RIGH1,LEFT2,LEFT3,{} ,RIGH5 } ), // 4L
|
497 |
|
|
new ScrambleState( new int[][] { RIGH0,LEFT1,RIGH2,RIGH3,{} ,LEFT5 } ), // 4R
|
498 |
|
|
new ScrambleState( new int[][] { LEFT0,RIGH1,RIGH2,RIGH3,RIGH4,{} } ), // 5L
|
499 |
|
|
new ScrambleState( new int[][] { RIGH0,LEFT1,LEFT2,LEFT3,LEFT4,{} } ), // 5R
|
500 |
|
|
};
|
501 |
169219a7
|
Leszek Koltunski
|
}
|
502 |
|
|
|
503 |
a64e07d0
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
504 |
|
|
|
505 |
aa26ba7f
|
Leszek Koltunski
|
int[] getSolvedQuats(int cubit, int numLayers)
|
506 |
a64e07d0
|
Leszek Koltunski
|
{
|
507 |
af0de0af
|
Leszek Koltunski
|
if( mQuats==null ) initializeQuats();
|
508 |
|
|
if( mFaceMap==null ) mFaceMap = new int[] {8,10,3,7,1,11,9,2,4,0,5,6};
|
509 |
aa26ba7f
|
Leszek Koltunski
|
int status = retCubitSolvedStatus(cubit,numLayers);
|
510 |
af0de0af
|
Leszek Koltunski
|
return status<0 ? null : buildSolvedQuats(MovementMinx.FACE_AXIS[mFaceMap[status]],mQuats);
|
511 |
a64e07d0
|
Leszek Koltunski
|
}
|
512 |
|
|
|
513 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
514 |
|
|
|
515 |
aa26ba7f
|
Leszek Koltunski
|
Static4D[] getQuats()
|
516 |
a64e07d0
|
Leszek Koltunski
|
{
|
517 |
af0de0af
|
Leszek Koltunski
|
if( mQuats==null ) initializeQuats();
|
518 |
|
|
return mQuats;
|
519 |
a64e07d0
|
Leszek Koltunski
|
}
|
520 |
|
|
|
521 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
522 |
|
|
|
523 |
aa26ba7f
|
Leszek Koltunski
|
int getNumFaces()
|
524 |
a64e07d0
|
Leszek Koltunski
|
{
|
525 |
aa26ba7f
|
Leszek Koltunski
|
return FACE_COLORS.length;
|
526 |
a64e07d0
|
Leszek Koltunski
|
}
|
527 |
|
|
|
528 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
529 |
|
|
|
530 |
aa26ba7f
|
Leszek Koltunski
|
int getSolvedFunctionIndex()
|
531 |
a64e07d0
|
Leszek Koltunski
|
{
|
532 |
aa26ba7f
|
Leszek Koltunski
|
return 0;
|
533 |
a64e07d0
|
Leszek Koltunski
|
}
|
534 |
|
|
|
535 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
536 |
|
|
|
537 |
aa26ba7f
|
Leszek Koltunski
|
boolean shouldResetTextureMaps()
|
538 |
a64e07d0
|
Leszek Koltunski
|
{
|
539 |
aa26ba7f
|
Leszek Koltunski
|
return false;
|
540 |
0812242b
|
Leszek Koltunski
|
}
|
541 |
|
|
|
542 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
543 |
|
|
|
544 |
aa26ba7f
|
Leszek Koltunski
|
int getNumCubitFaces()
|
545 |
0812242b
|
Leszek Koltunski
|
{
|
546 |
aa26ba7f
|
Leszek Koltunski
|
return FACES_PER_CUBIT;
|
547 |
a64e07d0
|
Leszek Koltunski
|
}
|
548 |
|
|
|
549 |
4c737817
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
550 |
|
|
|
551 |
aa26ba7f
|
Leszek Koltunski
|
float returnMultiplier()
|
552 |
4c737817
|
Leszek Koltunski
|
{
|
553 |
aa26ba7f
|
Leszek Koltunski
|
return 2.0f;
|
554 |
4c737817
|
Leszek Koltunski
|
}
|
555 |
|
|
|
556 |
a64e07d0
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
557 |
|
|
|
558 |
aa26ba7f
|
Leszek Koltunski
|
private void initializeScrambling()
|
559 |
0812242b
|
Leszek Koltunski
|
{
|
560 |
aa26ba7f
|
Leszek Koltunski
|
int numLayers = getNumLayers();
|
561 |
0812242b
|
Leszek Koltunski
|
|
562 |
aa26ba7f
|
Leszek Koltunski
|
if( mScrambleTable ==null )
|
563 |
0812242b
|
Leszek Koltunski
|
{
|
564 |
aa26ba7f
|
Leszek Koltunski
|
mScrambleTable = new int[NUM_AXIS][numLayers];
|
565 |
0812242b
|
Leszek Koltunski
|
}
|
566 |
aa26ba7f
|
Leszek Koltunski
|
if( mNumOccurences ==null )
|
567 |
0812242b
|
Leszek Koltunski
|
{
|
568 |
aa26ba7f
|
Leszek Koltunski
|
int max=0;
|
569 |
0812242b
|
Leszek Koltunski
|
|
570 |
aa26ba7f
|
Leszek Koltunski
|
for (ScrambleState mState : mStates)
|
571 |
0812242b
|
Leszek Koltunski
|
{
|
572 |
aa26ba7f
|
Leszek Koltunski
|
int tmp = mState.getTotal(-1);
|
573 |
|
|
if (max < tmp) max = tmp;
|
574 |
0812242b
|
Leszek Koltunski
|
}
|
575 |
|
|
|
576 |
aa26ba7f
|
Leszek Koltunski
|
mNumOccurences = new int[max];
|
577 |
|
|
}
|
578 |
0812242b
|
Leszek Koltunski
|
|
579 |
aa26ba7f
|
Leszek Koltunski
|
for(int i=0; i<NUM_AXIS; i++)
|
580 |
|
|
for(int j=0; j<numLayers; j++) mScrambleTable[i][j] = 0;
|
581 |
0812242b
|
Leszek Koltunski
|
}
|
582 |
|
|
|
583 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
584 |
|
|
// PUBLIC API
|
585 |
|
|
|
586 |
aa26ba7f
|
Leszek Koltunski
|
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles)
|
587 |
a64e07d0
|
Leszek Koltunski
|
{
|
588 |
9f171eba
|
Leszek Koltunski
|
if( curr==0 )
|
589 |
a64e07d0
|
Leszek Koltunski
|
{
|
590 |
aa26ba7f
|
Leszek Koltunski
|
mCurrState = 0;
|
591 |
|
|
mIndexExcluded =-1;
|
592 |
|
|
initializeScrambling();
|
593 |
a64e07d0
|
Leszek Koltunski
|
}
|
594 |
bbc6471c
|
Leszek Koltunski
|
|
595 |
aa26ba7f
|
Leszek Koltunski
|
int[] info= mStates[mCurrState].getRandom(rnd, mIndexExcluded, mScrambleTable, mNumOccurences);
|
596 |
|
|
|
597 |
|
|
scramble[curr][0] = info[0];
|
598 |
|
|
scramble[curr][1] = info[1];
|
599 |
|
|
scramble[curr][2] = info[2];
|
600 |
|
|
|
601 |
|
|
mCurrState = info[3];
|
602 |
|
|
mIndexExcluded = info[0];
|
603 |
a64e07d0
|
Leszek Koltunski
|
}
|
604 |
|
|
|
605 |
0812242b
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
606 |
|
|
|
607 |
|
|
public Static3D[] getRotationAxis()
|
608 |
|
|
{
|
609 |
|
|
return ROT_AXIS;
|
610 |
|
|
}
|
611 |
|
|
|
612 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
613 |
|
|
|
614 |
|
|
public int[] getBasicAngle()
|
615 |
|
|
{
|
616 |
af0de0af
|
Leszek Koltunski
|
if( mBasicAngle ==null ) mBasicAngle = new int[] { 5,5,5,5,5,5 };
|
617 |
|
|
return mBasicAngle;
|
618 |
0812242b
|
Leszek Koltunski
|
}
|
619 |
a64e07d0
|
Leszek Koltunski
|
}
|