1 |
1bd4a248
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2022 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.main.ObjectType;
|
27 |
29e1b835
|
Leszek Koltunski
|
import org.distorted.objectlib.scrambling.ScrambleState;
|
28 |
1bd4a248
|
Leszek Koltunski
|
|
29 |
|
|
import java.io.InputStream;
|
30 |
|
|
|
31 |
|
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
|
32 |
|
|
import static org.distorted.objectlib.touchcontrol.TouchControlDodecahedron.C2;
|
33 |
|
|
import static org.distorted.objectlib.touchcontrol.TouchControlDodecahedron.COS54;
|
34 |
|
|
import static org.distorted.objectlib.touchcontrol.TouchControlDodecahedron.SIN54;
|
35 |
|
|
|
36 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
37 |
|
|
|
38 |
|
|
public class TwistyPentultimate extends TwistyMinx
|
39 |
|
|
{
|
40 |
|
|
private float[][] mCuts;
|
41 |
|
|
private float[][] mPosition;
|
42 |
|
|
private int[] mQuatIndex;
|
43 |
|
|
|
44 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
45 |
|
|
|
46 |
|
|
public TwistyPentultimate(int[] numL, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
|
47 |
|
|
{
|
48 |
|
|
super(numL, meshState, iconMode, quat, move, scale, stream);
|
49 |
|
|
}
|
50 |
|
|
|
51 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
52 |
|
|
|
53 |
|
|
@Override
|
54 |
29e1b835
|
Leszek Koltunski
|
public ScrambleState[] getScrambleStates()
|
55 |
1bd4a248
|
Leszek Koltunski
|
{
|
56 |
29e1b835
|
Leszek Koltunski
|
if( mStates==null )
|
57 |
|
|
{
|
58 |
|
|
int[] ALL = new int[] { 0,-2,0, 0,-1,0, 0,1,0, 0,2,0, 1,-2,0, 1,-1,0, 1,1,0, 1,2,0 };
|
59 |
|
|
|
60 |
|
|
mStates = new ScrambleState[]
|
61 |
|
|
{
|
62 |
|
|
new ScrambleState( new int[][] { ALL,ALL,ALL,ALL,ALL,ALL } )
|
63 |
|
|
};
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
return mStates;
|
67 |
1bd4a248
|
Leszek Koltunski
|
}
|
68 |
|
|
|
69 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
70 |
|
|
|
71 |
|
|
@Override
|
72 |
|
|
public int getTouchControlSplit()
|
73 |
|
|
{
|
74 |
|
|
return TYPE_NOT_SPLIT;
|
75 |
|
|
}
|
76 |
|
|
|
77 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
78 |
|
|
|
79 |
|
|
@Override
|
80 |
|
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
81 |
|
|
{
|
82 |
|
|
boolean[] tmp = new boolean[] {true,true};
|
83 |
|
|
return new boolean[][] {tmp,tmp,tmp,tmp,tmp,tmp};
|
84 |
|
|
}
|
85 |
|
|
|
86 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
87 |
|
|
|
88 |
|
|
@Override
|
89 |
|
|
public int[][][] getEnabled()
|
90 |
|
|
{
|
91 |
|
|
return new int[][][]
|
92 |
|
|
{
|
93 |
|
|
{{1,2,3,4,5}},
|
94 |
|
|
{{0,2,3,4,5}},
|
95 |
|
|
{{0,2,3,4,5}},
|
96 |
|
|
{{1,2,3,4,5}},
|
97 |
|
|
{{0,1,3,4,5}},
|
98 |
|
|
{{0,1,2,4,5}},
|
99 |
|
|
{{0,1,2,4,5}},
|
100 |
|
|
{{0,1,3,4,5}},
|
101 |
|
|
{{0,1,2,3,5}},
|
102 |
|
|
{{0,1,2,3,4}},
|
103 |
|
|
{{0,1,2,3,4}},
|
104 |
|
|
{{0,1,2,3,5}},
|
105 |
|
|
};
|
106 |
|
|
}
|
107 |
|
|
|
108 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
109 |
|
|
|
110 |
|
|
public float[][] getCubitPositions(int[] numLayers)
|
111 |
|
|
{
|
112 |
|
|
if( mPosition==null )
|
113 |
|
|
{
|
114 |
|
|
if( mCenterCoords==null ) initializeCenterCoords();
|
115 |
|
|
final float A = 2.0f/3;
|
116 |
|
|
|
117 |
|
|
mPosition = new float[NUM_CORNERS+NUM_CENTERS][3];
|
118 |
|
|
|
119 |
|
|
for(int corner=0; corner<NUM_CORNERS; corner++)
|
120 |
|
|
{
|
121 |
|
|
mPosition[corner][0] = A*mCorners[corner][0];
|
122 |
|
|
mPosition[corner][1] = A*mCorners[corner][1];
|
123 |
|
|
mPosition[corner][2] = A*mCorners[corner][2];
|
124 |
|
|
}
|
125 |
|
|
|
126 |
|
|
for(int center=0; center<NUM_CENTERS; center++)
|
127 |
|
|
{
|
128 |
|
|
int index = center+NUM_CORNERS;
|
129 |
|
|
mPosition[index][0] = A*mCenterCoords[center][0];
|
130 |
|
|
mPosition[index][1] = A*mCenterCoords[center][1];
|
131 |
|
|
mPosition[index][2] = A*mCenterCoords[center][2];
|
132 |
|
|
}
|
133 |
|
|
}
|
134 |
|
|
|
135 |
|
|
return mPosition;
|
136 |
|
|
}
|
137 |
|
|
|
138 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
139 |
|
|
|
140 |
|
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
141 |
|
|
{
|
142 |
|
|
if( mQuatIndex==null )
|
143 |
|
|
{
|
144 |
|
|
mQuatIndex = new int[]
|
145 |
|
|
{
|
146 |
a4af26c1
|
Leszek Koltunski
|
0,29,59,48,18,53,22,49,11,54,10,52,17,27,19,26, 9,28,23,45,
|
147 |
|
|
0, 4, 5, 6,26, 3, 2, 7,16,13, 1,19
|
148 |
1bd4a248
|
Leszek Koltunski
|
};
|
149 |
|
|
}
|
150 |
|
|
|
151 |
|
|
return mObjectQuats[mQuatIndex[cubit]];
|
152 |
|
|
}
|
153 |
|
|
|
154 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
155 |
|
|
|
156 |
|
|
public ObjectShape getObjectShape(int variant)
|
157 |
|
|
{
|
158 |
|
|
final float A = 2.0f/3;
|
159 |
|
|
|
160 |
|
|
if( variant==0 ) // corner
|
161 |
|
|
{
|
162 |
|
|
float x0 = A*mCorners[ 0][0];
|
163 |
|
|
float x2 = A*mCorners[ 2][0];
|
164 |
|
|
float x12 = A*mCorners[12][0];
|
165 |
|
|
float x16 = A*mCorners[16][0];
|
166 |
|
|
float y0 = A*mCorners[ 0][1];
|
167 |
|
|
float y2 = A*mCorners[ 2][1];
|
168 |
|
|
float y12 = A*mCorners[12][1];
|
169 |
|
|
float y16 = A*mCorners[16][1];
|
170 |
|
|
float z0 = A*mCorners[ 0][2];
|
171 |
|
|
float z2 = A*mCorners[ 2][2];
|
172 |
|
|
float z12 = A*mCorners[12][2];
|
173 |
|
|
float z16 = A*mCorners[16][2];
|
174 |
|
|
|
175 |
|
|
float[][] vertices =
|
176 |
|
|
{
|
177 |
|
|
{ 0,0,0 },
|
178 |
|
|
{ (x16-x0)/2, (y16-y0)/2, (z16-z0)/2, },
|
179 |
|
|
{ (x12-x0)/2, (y12-y0)/2, (z12-z0)/2, },
|
180 |
|
|
{ (x2 -x0)/2, (y2 -y0)/2, (z2 -z0)/2, },
|
181 |
|
|
{ 0,-1,-2*C2 },
|
182 |
|
|
};
|
183 |
|
|
|
184 |
|
|
int[][] indices =
|
185 |
|
|
{
|
186 |
|
|
{0,1,3},
|
187 |
|
|
{0,3,2},
|
188 |
|
|
{0,2,1},
|
189 |
|
|
{4,3,1},
|
190 |
|
|
{4,2,3},
|
191 |
|
|
{4,1,2}
|
192 |
|
|
};
|
193 |
|
|
|
194 |
|
|
return new ObjectShape(vertices, indices);
|
195 |
|
|
}
|
196 |
|
|
else
|
197 |
|
|
{
|
198 |
|
|
int i0 = mCenterMap[0][0];
|
199 |
|
|
int i1 = mCenterMap[0][1];
|
200 |
|
|
int i2 = mCenterMap[0][2];
|
201 |
|
|
int i3 = mCenterMap[0][3];
|
202 |
|
|
int i4 = mCenterMap[0][4];
|
203 |
|
|
|
204 |
|
|
float x0 = A*mCorners[i0][0];
|
205 |
|
|
float x1 = A*mCorners[i1][0];
|
206 |
|
|
float x2 = A*mCorners[i2][0];
|
207 |
|
|
float x3 = A*mCorners[i3][0];
|
208 |
|
|
float x4 = A*mCorners[i4][0];
|
209 |
|
|
|
210 |
|
|
float y0 = A*mCorners[i0][1];
|
211 |
|
|
float y1 = A*mCorners[i1][1];
|
212 |
|
|
float y2 = A*mCorners[i2][1];
|
213 |
|
|
float y3 = A*mCorners[i3][1];
|
214 |
|
|
float y4 = A*mCorners[i4][1];
|
215 |
|
|
|
216 |
|
|
float z0 = A*mCorners[i0][2];
|
217 |
|
|
float z1 = A*mCorners[i1][2];
|
218 |
|
|
float z2 = A*mCorners[i2][2];
|
219 |
|
|
float z3 = A*mCorners[i3][2];
|
220 |
|
|
float z4 = A*mCorners[i4][2];
|
221 |
|
|
|
222 |
|
|
float cx = A*mCenterCoords[0][0];
|
223 |
|
|
float cy = A*mCenterCoords[0][1];
|
224 |
|
|
float cz = A*mCenterCoords[0][2];
|
225 |
|
|
|
226 |
|
|
float X0 = (x0+x1)/2 -cx;
|
227 |
|
|
float Y0 = (y0+y1)/2 -cy;
|
228 |
|
|
float Z0 = (z0+z1)/2 -cz;
|
229 |
|
|
|
230 |
|
|
float X1 = (x1+x2)/2 -cx;
|
231 |
|
|
float Y1 = (y1+y2)/2 -cy;
|
232 |
|
|
float Z1 = (z1+z2)/2 -cz;
|
233 |
|
|
|
234 |
|
|
float X2 = (x2+x3)/2 -cx;
|
235 |
|
|
float Y2 = (y2+y3)/2 -cy;
|
236 |
|
|
float Z2 = (z2+z3)/2 -cz;
|
237 |
|
|
|
238 |
|
|
float X3 = (x3+x4)/2 -cx;
|
239 |
|
|
float Y3 = (y3+y4)/2 -cy;
|
240 |
|
|
float Z3 = (z3+z4)/2 -cz;
|
241 |
|
|
|
242 |
|
|
float X4 = (x4+x0)/2 -cx;
|
243 |
|
|
float Y4 = (y4+y0)/2 -cy;
|
244 |
|
|
float Z4 = (z4+z0)/2 -cz;
|
245 |
|
|
|
246 |
|
|
float X5 = -cx;
|
247 |
|
|
float Y5 = -cy;
|
248 |
|
|
float Z5 = -cz;
|
249 |
|
|
|
250 |
|
|
float[][] vertices =
|
251 |
|
|
{
|
252 |
|
|
{ X0,Y0,Z0 },
|
253 |
|
|
{ X1,Y1,Z1 },
|
254 |
|
|
{ X2,Y2,Z2 },
|
255 |
|
|
{ X3,Y3,Z3 },
|
256 |
|
|
{ X4,Y4,Z4 },
|
257 |
|
|
{ X5,Y5,Z5 }
|
258 |
|
|
};
|
259 |
|
|
int[][] indices =
|
260 |
|
|
{
|
261 |
a4af26c1
|
Leszek Koltunski
|
{0,1,2,3,4},
|
262 |
1bd4a248
|
Leszek Koltunski
|
{0,5,1},
|
263 |
|
|
{1,5,2},
|
264 |
|
|
{2,5,3},
|
265 |
|
|
{3,5,4},
|
266 |
|
|
{4,5,0}
|
267 |
|
|
};
|
268 |
|
|
|
269 |
|
|
return new ObjectShape(vertices, indices);
|
270 |
|
|
}
|
271 |
|
|
}
|
272 |
|
|
|
273 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
274 |
|
|
|
275 |
|
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
276 |
|
|
{
|
277 |
|
|
if( variant==0 )
|
278 |
|
|
{
|
279 |
|
|
float A = (2*SQ3/3)*SIN54;
|
280 |
|
|
float B = 0.4f;
|
281 |
|
|
float H = isInIconMode() ? 0.001f : 0.03f;
|
282 |
|
|
float[][] bands = { {H,10,0.5f,0.2f,4,0,0}, {0.001f, 1,0.5f,0.2f,3,0,0} };
|
283 |
|
|
int[] bandIndices = { 0,0,0,1,1,1 };
|
284 |
|
|
float[][] corners = { { 0.025f, 0.20f } };
|
285 |
|
|
int[] cornerIndices = { 0,0,0,-1,-1,-1 };
|
286 |
|
|
float[][] centers = { {0.0f, -(float)Math.sqrt(1-A*A)*B,-A*B} };
|
287 |
|
|
int[] centerIndices = { 0,0,0,-1,-1,-1 };
|
288 |
|
|
return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
|
289 |
|
|
}
|
290 |
|
|
else
|
291 |
|
|
{
|
292 |
|
|
final double ANGLE = 0.825f*Math.PI;
|
293 |
|
|
final float cosA = (float)Math.cos(ANGLE);
|
294 |
|
|
final float sinA = (float)Math.sin(ANGLE);
|
295 |
|
|
float TAN54 = SIN54/COS54;
|
296 |
|
|
float R = 1.5f*(TAN54-(1/TAN54));
|
297 |
|
|
float H = isInIconMode() ? 0.001f : 0.03f;
|
298 |
|
|
float[][] bands = { {H,15,0.5f,0.2f,6,0,0}, {0.001f, 1,0.5f,0.2f,3,0,0} };
|
299 |
|
|
int[] bandIndices = { 0,1,1,1,1,1 };
|
300 |
|
|
float[][] corners = { { 0.025f, 0.20f } };
|
301 |
|
|
int[] cornerIndices = { 0,0,0,0,0,-1 };
|
302 |
|
|
float[][] centers = { { 0.0f,R*cosA,-R*sinA } };
|
303 |
|
|
int[] centerIndices = { 0,0,0,0,0,-1 };
|
304 |
|
|
return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
|
305 |
|
|
}
|
306 |
|
|
}
|
307 |
|
|
|
308 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
309 |
|
|
|
310 |
|
|
public int getNumCubitVariants(int[] numLayers)
|
311 |
|
|
{
|
312 |
|
|
return 2;
|
313 |
|
|
}
|
314 |
|
|
|
315 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
316 |
|
|
|
317 |
|
|
public int getCubitVariant(int cubit, int[] numLayers)
|
318 |
|
|
{
|
319 |
|
|
return cubit<NUM_CORNERS ? 0:1;
|
320 |
|
|
}
|
321 |
|
|
|
322 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
323 |
|
|
|
324 |
|
|
public float[][] getCuts(int[] numLayers)
|
325 |
|
|
{
|
326 |
|
|
if( mCuts==null )
|
327 |
|
|
{
|
328 |
|
|
float[] cut = new float[] { 0 };
|
329 |
|
|
mCuts = new float[][] { cut,cut,cut,cut,cut,cut };
|
330 |
|
|
}
|
331 |
|
|
|
332 |
|
|
return mCuts;
|
333 |
|
|
}
|
334 |
|
|
|
335 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
336 |
|
|
|
337 |
|
|
public float getStickerRadius()
|
338 |
|
|
{
|
339 |
|
|
return 0.15f;
|
340 |
|
|
}
|
341 |
|
|
|
342 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
343 |
|
|
|
344 |
|
|
public float getStickerStroke()
|
345 |
|
|
{
|
346 |
|
|
return isInIconMode() ? 0.20f : 0.13f;
|
347 |
|
|
}
|
348 |
|
|
|
349 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
350 |
|
|
|
351 |
|
|
public float[][] getStickerAngles()
|
352 |
|
|
{
|
353 |
|
|
return null;
|
354 |
|
|
}
|
355 |
|
|
|
356 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
357 |
|
|
// PUBLIC API
|
358 |
|
|
|
359 |
|
|
public String getShortName()
|
360 |
|
|
{
|
361 |
|
|
return ObjectType.PENT_2.name();
|
362 |
|
|
}
|
363 |
|
|
|
364 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
365 |
|
|
|
366 |
|
|
public long getSignature()
|
367 |
|
|
{
|
368 |
|
|
return ObjectType.PENT_2.ordinal();
|
369 |
|
|
}
|
370 |
|
|
|
371 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
372 |
|
|
|
373 |
|
|
public String getObjectName()
|
374 |
|
|
{
|
375 |
|
|
return "Pentultimate";
|
376 |
|
|
}
|
377 |
|
|
|
378 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
379 |
|
|
|
380 |
|
|
public String getInventor()
|
381 |
|
|
{
|
382 |
|
|
return "Jason Smith";
|
383 |
|
|
}
|
384 |
|
|
|
385 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
386 |
|
|
|
387 |
|
|
public int getYearOfInvention()
|
388 |
|
|
{
|
389 |
|
|
return 2008;
|
390 |
|
|
}
|
391 |
|
|
|
392 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
393 |
|
|
|
394 |
|
|
public int getComplexity()
|
395 |
|
|
{
|
396 |
79bf5a5e
|
Leszek Koltunski
|
return 3;
|
397 |
1bd4a248
|
Leszek Koltunski
|
}
|
398 |
|
|
|
399 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
400 |
|
|
|
401 |
|
|
public String[][] getTutorials()
|
402 |
|
|
{
|
403 |
|
|
return new String[][]{
|
404 |
79bf5a5e
|
Leszek Koltunski
|
{"gb","raeskk-whbU","Pentultimate classification and solve","SuperAntoniovivaldi"},
|
405 |
|
|
{"gb","QamIeNJBB1M","How to solve a Pentultimate","bmenrigh"},
|
406 |
1bd4a248
|
Leszek Koltunski
|
};
|
407 |
|
|
}
|
408 |
|
|
}
|