1 |
d5411af4
|
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.objectlib.objects;
|
21 |
|
|
|
22 |
|
|
import org.distorted.library.type.Static3D;
|
23 |
|
|
import org.distorted.library.type.Static4D;
|
24 |
|
|
import org.distorted.objectlib.helpers.ObjectFaceShape;
|
25 |
|
|
import org.distorted.objectlib.helpers.ObjectShape;
|
26 |
|
|
import org.distorted.objectlib.helpers.ObjectSignature;
|
27 |
|
|
import org.distorted.objectlib.main.ObjectType;
|
28 |
|
|
import org.distorted.objectlib.main.ShapeHexahedron;
|
29 |
|
|
import org.distorted.objectlib.scrambling.ScrambleState;
|
30 |
|
|
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
|
31 |
|
|
|
32 |
|
|
import java.io.InputStream;
|
33 |
|
|
|
34 |
|
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_HEXAHEDRON;
|
35 |
|
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
|
36 |
|
|
|
37 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
38 |
|
|
|
39 |
|
|
public class TwistyMixup extends ShapeHexahedron
|
40 |
|
|
{
|
41 |
|
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
42 |
|
|
{
|
43 |
|
|
new Static3D(1,0,0),
|
44 |
|
|
new Static3D(0,1,0),
|
45 |
|
|
new Static3D(0,0,1)
|
46 |
|
|
};
|
47 |
|
|
|
48 |
|
|
private ScrambleState[] mStates;
|
49 |
|
|
private int[][] mBasicAngle;
|
50 |
|
|
private float[][] mCuts;
|
51 |
|
|
private float[][] mPosition;
|
52 |
b804acaf
|
Leszek Koltunski
|
private int[] mQuatIndex;
|
53 |
d5411af4
|
Leszek Koltunski
|
|
54 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
55 |
|
|
|
56 |
|
|
public TwistyMixup(int[] numL, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
|
57 |
|
|
{
|
58 |
|
|
super(numL, meshState, iconMode, numL[0], quat, move, scale, stream);
|
59 |
|
|
}
|
60 |
|
|
|
61 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
62 |
|
|
|
63 |
|
|
public ScrambleState[] getScrambleStates()
|
64 |
|
|
{
|
65 |
|
|
if( mStates==null )
|
66 |
|
|
{
|
67 |
|
|
int[][] m = new int[16][];
|
68 |
|
|
|
69 |
|
|
for(int i=0; i<16; i++) m[i] = new int[] { 0,-2,i,0, 2,i,0, 4,i,
|
70 |
|
|
1,-3,i,1,-2,i,1,-1,i,1,1,i,1,2,i,1,3,i,1,4,i,
|
71 |
|
|
2,-2,i,2, 2,i,2, 4,i };
|
72 |
|
|
|
73 |
|
|
mStates = new ScrambleState[]
|
74 |
|
|
{
|
75 |
|
|
new ScrambleState( new int[][] { m[ 1], m[ 2], m[ 3] } ), // 0 0
|
76 |
|
|
new ScrambleState( new int[][] { null, m[ 4], m[ 5] } ), // 1 x
|
77 |
|
|
new ScrambleState( new int[][] { m[ 6], null, m[ 7] } ), // 2 y
|
78 |
|
|
new ScrambleState( new int[][] { m[ 8], m[ 9], null } ), // 3 z
|
79 |
|
|
new ScrambleState( new int[][] { m[10], null, m[ 7] } ), // 4 xy
|
80 |
|
|
new ScrambleState( new int[][] { m[11], m[ 9], null } ), // 5 xz
|
81 |
|
|
new ScrambleState( new int[][] { null, m[12], m[ 5] } ), // 6 yx
|
82 |
|
|
new ScrambleState( new int[][] { m[ 8], m[13], null } ), // 7 yz
|
83 |
|
|
new ScrambleState( new int[][] { null, m[ 4], m[14] } ), // 8 zx
|
84 |
|
|
new ScrambleState( new int[][] { m[ 6], null, m[15] } ), // 9 zy
|
85 |
|
|
new ScrambleState( new int[][] { null, null, m[ 5] } ), // 10 xyx
|
86 |
|
|
new ScrambleState( new int[][] { null, m[ 4], null } ), // 11 xzx
|
87 |
|
|
new ScrambleState( new int[][] { null, null, m[ 7] } ), // 12 yxy
|
88 |
|
|
new ScrambleState( new int[][] { m[ 6], null, null } ), // 13 yzy
|
89 |
|
|
new ScrambleState( new int[][] { null, m[ 9], null } ), // 14 zxz
|
90 |
|
|
new ScrambleState( new int[][] { m[ 8], null, null } ), // 15 zyz
|
91 |
|
|
};
|
92 |
|
|
}
|
93 |
|
|
|
94 |
|
|
return mStates;
|
95 |
|
|
}
|
96 |
|
|
|
97 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
98 |
|
|
|
99 |
|
|
public float[][] getCuts(int[] numLayers)
|
100 |
|
|
{
|
101 |
|
|
if( mCuts==null )
|
102 |
|
|
{
|
103 |
|
|
float C = 1.5f*(SQ2-1);
|
104 |
|
|
float[] cut = new float[] {-C,+C};
|
105 |
|
|
mCuts = new float[][] { cut,cut,cut };
|
106 |
|
|
}
|
107 |
|
|
|
108 |
|
|
return mCuts;
|
109 |
|
|
}
|
110 |
|
|
|
111 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
112 |
|
|
|
113 |
|
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
114 |
|
|
{
|
115 |
|
|
boolean[] tmp = new boolean[] {true,true,true};
|
116 |
|
|
return new boolean[][] { tmp,tmp,tmp };
|
117 |
|
|
}
|
118 |
|
|
|
119 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
120 |
|
|
|
121 |
|
|
public int getTouchControlType()
|
122 |
|
|
{
|
123 |
|
|
return TC_HEXAHEDRON;
|
124 |
|
|
}
|
125 |
|
|
|
126 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
127 |
|
|
|
128 |
|
|
public int getTouchControlSplit()
|
129 |
|
|
{
|
130 |
|
|
return TYPE_NOT_SPLIT;
|
131 |
|
|
}
|
132 |
|
|
|
133 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
134 |
|
|
|
135 |
|
|
public int[][][] getEnabled()
|
136 |
|
|
{
|
137 |
|
|
return new int[][][] { {{1,2}},{{1,2}},{{0,2}},{{0,2}},{{0,1}},{{0,1}} };
|
138 |
|
|
}
|
139 |
|
|
|
140 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
141 |
|
|
|
142 |
|
|
public float[] getDist3D(int[] numLayers)
|
143 |
|
|
{
|
144 |
|
|
return TouchControlHexahedron.D3D;
|
145 |
|
|
}
|
146 |
|
|
|
147 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
148 |
|
|
|
149 |
|
|
public Static3D[] getFaceAxis()
|
150 |
|
|
{
|
151 |
|
|
return TouchControlHexahedron.FACE_AXIS;
|
152 |
|
|
}
|
153 |
|
|
|
154 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
155 |
|
|
// TODO
|
156 |
|
|
|
157 |
|
|
public float[][] getCubitPositions(int[] numLayers)
|
158 |
|
|
{
|
159 |
|
|
if( mPosition==null )
|
160 |
|
|
{
|
161 |
b804acaf
|
Leszek Koltunski
|
float SHORT_EDGE = 1.5f-0.75f*SQ2;
|
162 |
|
|
float LONG_EDGE = 1.5f*(SQ2-1);
|
163 |
|
|
|
164 |
|
|
final float DIST_CORNER = LONG_EDGE+SHORT_EDGE;
|
165 |
|
|
final float DIST_EDGE = LONG_EDGE+SHORT_EDGE;
|
166 |
|
|
final float DIST_CENTER = LONG_EDGE+SHORT_EDGE;
|
167 |
d5411af4
|
Leszek Koltunski
|
|
168 |
|
|
mPosition = new float[][]
|
169 |
|
|
{
|
170 |
|
|
{ DIST_CORNER, DIST_CORNER, DIST_CORNER },
|
171 |
|
|
{ DIST_CORNER, DIST_CORNER,-DIST_CORNER },
|
172 |
|
|
{ DIST_CORNER,-DIST_CORNER, DIST_CORNER },
|
173 |
|
|
{ DIST_CORNER,-DIST_CORNER,-DIST_CORNER },
|
174 |
|
|
{-DIST_CORNER, DIST_CORNER, DIST_CORNER },
|
175 |
|
|
{-DIST_CORNER, DIST_CORNER,-DIST_CORNER },
|
176 |
|
|
{-DIST_CORNER,-DIST_CORNER, DIST_CORNER },
|
177 |
|
|
{-DIST_CORNER,-DIST_CORNER,-DIST_CORNER },
|
178 |
|
|
|
179 |
|
|
{ 0.0f, DIST_EDGE, DIST_EDGE },
|
180 |
|
|
{ DIST_EDGE, 0.0f, DIST_EDGE },
|
181 |
|
|
{ 0.0f,-DIST_EDGE, DIST_EDGE },
|
182 |
|
|
{-DIST_EDGE, 0.0f, DIST_EDGE },
|
183 |
|
|
{ DIST_EDGE, DIST_EDGE, 0.0f },
|
184 |
|
|
{ DIST_EDGE,-DIST_EDGE, 0.0f },
|
185 |
|
|
{-DIST_EDGE,-DIST_EDGE, 0.0f },
|
186 |
|
|
{-DIST_EDGE, DIST_EDGE, 0.0f },
|
187 |
|
|
{ 0.0f, DIST_EDGE,-DIST_EDGE },
|
188 |
|
|
{ DIST_EDGE, 0.0f,-DIST_EDGE },
|
189 |
|
|
{ 0.0f,-DIST_EDGE,-DIST_EDGE },
|
190 |
b804acaf
|
Leszek Koltunski
|
{-DIST_EDGE, 0.0f,-DIST_EDGE },
|
191 |
|
|
|
192 |
|
|
{ 0, 0, DIST_CENTER },
|
193 |
|
|
{ 0, 0,-DIST_CENTER },
|
194 |
|
|
{ 0, DIST_CENTER, 0 },
|
195 |
|
|
{ 0,-DIST_CENTER, 0 },
|
196 |
|
|
{ DIST_CENTER, 0, 0 },
|
197 |
|
|
{-DIST_CENTER, 0, 0 },
|
198 |
d5411af4
|
Leszek Koltunski
|
};
|
199 |
|
|
}
|
200 |
|
|
|
201 |
|
|
return mPosition;
|
202 |
|
|
}
|
203 |
|
|
|
204 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
205 |
|
|
|
206 |
|
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
207 |
|
|
{
|
208 |
b804acaf
|
Leszek Koltunski
|
if( mQuatIndex==null )
|
209 |
d5411af4
|
Leszek Koltunski
|
{
|
210 |
b804acaf
|
Leszek Koltunski
|
mQuatIndex = new int[] { 0,1,3,2,8,9,16,23,
|
211 |
|
|
0,15,3,17,10,37,36,8,1,24,2,22,
|
212 |
|
|
0,2,1,3,10,8 };
|
213 |
d5411af4
|
Leszek Koltunski
|
}
|
214 |
|
|
|
215 |
b804acaf
|
Leszek Koltunski
|
return mObjectQuats[mQuatIndex[cubit]];
|
216 |
d5411af4
|
Leszek Koltunski
|
}
|
217 |
|
|
|
218 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
219 |
|
|
|
220 |
|
|
public ObjectShape getObjectShape(int variant)
|
221 |
|
|
{
|
222 |
b804acaf
|
Leszek Koltunski
|
float SHORT_EDGE = 1.5f-0.75f*SQ2;
|
223 |
|
|
float LONG_EDGE = 1.5f*(SQ2-1);
|
224 |
|
|
float X = variant==0 ? SHORT_EDGE : LONG_EDGE;
|
225 |
|
|
float Y = variant<=1 ? SHORT_EDGE : LONG_EDGE;
|
226 |
|
|
float Z = SHORT_EDGE;
|
227 |
d5411af4
|
Leszek Koltunski
|
|
228 |
b804acaf
|
Leszek Koltunski
|
float[][] vertices =
|
229 |
d5411af4
|
Leszek Koltunski
|
{
|
230 |
b804acaf
|
Leszek Koltunski
|
{ -X,-Y,-Z },
|
231 |
|
|
{ -X,-Y,+Z },
|
232 |
|
|
{ -X,+Y,-Z },
|
233 |
|
|
{ -X,+Y,+Z },
|
234 |
|
|
{ +X,-Y,-Z },
|
235 |
|
|
{ +X,-Y,+Z },
|
236 |
|
|
{ +X,+Y,-Z },
|
237 |
|
|
{ +X,+Y,+Z },
|
238 |
d5411af4
|
Leszek Koltunski
|
};
|
239 |
|
|
|
240 |
b804acaf
|
Leszek Koltunski
|
int[][] indices =
|
241 |
d5411af4
|
Leszek Koltunski
|
{
|
242 |
b804acaf
|
Leszek Koltunski
|
{1,5,7,3},
|
243 |
|
|
{3,7,6,2},
|
244 |
|
|
{5,4,6,7},
|
245 |
|
|
{0,1,3,2},
|
246 |
|
|
{4,0,2,6},
|
247 |
|
|
{0,4,5,1}
|
248 |
d5411af4
|
Leszek Koltunski
|
};
|
249 |
|
|
|
250 |
b804acaf
|
Leszek Koltunski
|
return new ObjectShape(vertices, indices);
|
251 |
d5411af4
|
Leszek Koltunski
|
}
|
252 |
|
|
|
253 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
254 |
|
|
|
255 |
|
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
256 |
|
|
{
|
257 |
b804acaf
|
Leszek Koltunski
|
float h1 = isInIconMode() ? 0.001f : 0.06f;
|
258 |
|
|
float h2 = 0.001f;
|
259 |
|
|
float[][] bands = { {h1,45,0.3f,0.5f,5,1,0}, {h2,45,0.3f,0.5f,5,1,0} };
|
260 |
|
|
float[][] centers = { { 0.0f, 0.0f, 0.0f} };
|
261 |
|
|
float[][] corners = { {0.04f,0.10f} };
|
262 |
|
|
|
263 |
d5411af4
|
Leszek Koltunski
|
if( variant==0 )
|
264 |
|
|
{
|
265 |
b804acaf
|
Leszek Koltunski
|
int[] bandIndices = { 0,0,0,1,1,1 };
|
266 |
|
|
int[] indices = { -1,0,0,0,0,0,0,0 };
|
267 |
|
|
return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
|
268 |
|
|
}
|
269 |
|
|
if( variant==1 )
|
270 |
|
|
{
|
271 |
|
|
int[] bandIndices = { 0,0,1,1,1,1 };
|
272 |
|
|
int[] indices = { -1,0,0,0,-1,0,0,0 };
|
273 |
|
|
return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
|
274 |
d5411af4
|
Leszek Koltunski
|
}
|
275 |
|
|
else
|
276 |
|
|
{
|
277 |
b804acaf
|
Leszek Koltunski
|
int[] bandIndices = { 0,1,1,1,1,1 };
|
278 |
|
|
int[] indices = { -1,0,-1,0,-1,0,-1,0 };
|
279 |
|
|
return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
|
280 |
d5411af4
|
Leszek Koltunski
|
}
|
281 |
|
|
}
|
282 |
|
|
|
283 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
284 |
|
|
|
285 |
|
|
public int getNumCubitVariants(int[] numLayers)
|
286 |
|
|
{
|
287 |
|
|
return 3;
|
288 |
|
|
}
|
289 |
|
|
|
290 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
291 |
|
|
|
292 |
|
|
public int getCubitVariant(int cubit, int[] numLayers)
|
293 |
|
|
{
|
294 |
|
|
return cubit<8 ? 0 : (cubit<20?1:2);
|
295 |
|
|
}
|
296 |
|
|
|
297 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
298 |
|
|
|
299 |
|
|
public float getStickerRadius()
|
300 |
|
|
{
|
301 |
|
|
return 0.09f;
|
302 |
|
|
}
|
303 |
|
|
|
304 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
305 |
|
|
|
306 |
|
|
public float getStickerStroke()
|
307 |
|
|
{
|
308 |
|
|
return isInIconMode() ? 0.20f : 0.09f;
|
309 |
|
|
}
|
310 |
|
|
|
311 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
312 |
|
|
|
313 |
|
|
public float[][] getStickerAngles()
|
314 |
|
|
{
|
315 |
|
|
return null;
|
316 |
|
|
}
|
317 |
|
|
|
318 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
319 |
|
|
// PUBLIC API
|
320 |
|
|
|
321 |
|
|
public Static3D[] getRotationAxis()
|
322 |
|
|
{
|
323 |
|
|
return ROT_AXIS;
|
324 |
|
|
}
|
325 |
|
|
|
326 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
327 |
|
|
|
328 |
|
|
public int[][] getBasicAngles()
|
329 |
|
|
{
|
330 |
|
|
if( mBasicAngle ==null )
|
331 |
|
|
{
|
332 |
|
|
int[] tmp = new int[] {4,8,4};
|
333 |
|
|
mBasicAngle = new int[][] { tmp,tmp,tmp };
|
334 |
|
|
}
|
335 |
|
|
|
336 |
|
|
return mBasicAngle;
|
337 |
|
|
}
|
338 |
|
|
|
339 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
340 |
|
|
|
341 |
|
|
public String getShortName()
|
342 |
|
|
{
|
343 |
|
|
return ObjectType.MIXU_3.name();
|
344 |
|
|
}
|
345 |
|
|
|
346 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
347 |
|
|
|
348 |
|
|
public ObjectSignature getSignature()
|
349 |
|
|
{
|
350 |
|
|
return new ObjectSignature(ObjectType.MIXU_3);
|
351 |
|
|
}
|
352 |
|
|
|
353 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
354 |
|
|
|
355 |
|
|
public String getObjectName()
|
356 |
|
|
{
|
357 |
|
|
return "Mixup Cube";
|
358 |
|
|
}
|
359 |
|
|
|
360 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
361 |
|
|
|
362 |
|
|
public String getInventor()
|
363 |
|
|
{
|
364 |
|
|
return "Sergey Makarov";
|
365 |
|
|
}
|
366 |
|
|
|
367 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
368 |
|
|
|
369 |
|
|
public int getYearOfInvention()
|
370 |
|
|
{
|
371 |
|
|
return 1985;
|
372 |
|
|
}
|
373 |
|
|
|
374 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
375 |
|
|
|
376 |
|
|
public int getComplexity()
|
377 |
|
|
{
|
378 |
|
|
return 2;
|
379 |
|
|
}
|
380 |
|
|
|
381 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
382 |
|
|
|
383 |
|
|
public String[][] getTutorials()
|
384 |
|
|
{
|
385 |
|
|
return new String[][] {
|
386 |
|
|
{"gb","Qn7TJED6O-4","How to Solve the MoYu Redi Cube","Z3"},
|
387 |
|
|
{"es","g0M38Aotgac","Resolver Redi Cube","Cuby"},
|
388 |
|
|
{"ru","dlNRbE-hyzU","Как собрать Реди Куб","Алексей Ярыгин"},
|
389 |
|
|
{"fr","zw7UZcqqsgA","Comment résoudre le Redi Cube","ValentinoCube"},
|
390 |
|
|
{"de","YU8riouyC2w","Redi Cube Solve","CubaroCubing"},
|
391 |
|
|
{"pl","vxo3lXMsWQI","Jak ułożyć Redi Cube?","DJ rubiks"},
|
392 |
|
|
{"br","muQ8U_G4LmM","Como resolver o Redi Cube","Rafael Cinoto"},
|
393 |
|
|
{"kr","a5CzDMbRzbY","레디큐브를 배우기","vincentcube"},
|
394 |
|
|
{"vn","2JZxtmrKUn4","Tutorial N.6 - Redi","Duy Thích Rubik"},
|
395 |
|
|
};
|
396 |
|
|
}
|
397 |
|
|
}
|