1 |
d54d1f8a
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2023 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
|
|
// This file is part of Magic Cube. //
|
5 |
|
|
// //
|
6 |
|
|
// Magic Cube is proprietary software licensed under an EULA which you should have received //
|
7 |
|
|
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html //
|
8 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
9 |
|
|
|
10 |
|
|
package org.distorted.objectlib.objects;
|
11 |
|
|
|
12 |
|
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_ICOSAHEDRON;
|
13 |
|
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
|
14 |
|
|
|
15 |
|
|
import org.distorted.library.type.Static3D;
|
16 |
|
|
import org.distorted.library.type.Static4D;
|
17 |
|
|
import org.distorted.objectlib.helpers.FactoryCubit;
|
18 |
|
|
import org.distorted.objectlib.helpers.ObjectFaceShape;
|
19 |
|
|
import org.distorted.objectlib.helpers.ObjectShape;
|
20 |
|
|
import org.distorted.objectlib.helpers.ObjectSignature;
|
21 |
|
|
import org.distorted.objectlib.helpers.ObjectVertexEffects;
|
22 |
|
|
import org.distorted.objectlib.main.InitAssets;
|
23 |
|
|
import org.distorted.objectlib.main.InitData;
|
24 |
|
|
import org.distorted.objectlib.main.ObjectSignatures;
|
25 |
|
|
import org.distorted.objectlib.main.ObjectType;
|
26 |
|
|
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator;
|
27 |
|
|
import org.distorted.objectlib.shape.ShapeHexahedron;
|
28 |
|
|
import org.distorted.objectlib.touchcontrol.TouchControlIcosahedron;
|
29 |
|
|
|
30 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
31 |
|
|
|
32 |
|
|
public class TwistyIcosamate extends ShapeHexahedron
|
33 |
|
|
{
|
34 |
|
|
// topmost vertex (0,A,0) and 3 vertices from the second-topmost-layer, front one and two ones
|
35 |
|
|
// to the right: (0,B,C) , (D,B,E) , (F,B,H)
|
36 |
|
|
|
37 |
|
|
private static final float Z = (float)Math.sqrt(5+SQ5);
|
38 |
|
|
|
39 |
|
|
private static final float A = Z*(SQ2/4);
|
40 |
|
|
private static final float B = Z*(SQ2*SQ5/20);
|
41 |
|
|
private static final float C = Z*(SQ2*SQ5/10);
|
42 |
|
|
private static final float D = (SQ5+1)/4;
|
43 |
|
|
private static final float E = Z*(SQ5-1)/(4*SQ2*SQ5);
|
44 |
|
|
private static final float F = 0.5f;
|
45 |
|
|
private static final float H =-Z*(SQ5+1)/(4*SQ2*SQ5);
|
46 |
|
|
|
47 |
|
|
private static final float X1 = D/3;
|
48 |
|
|
private static final float X2 = (D+F)/3;
|
49 |
|
|
private static final float X3 = (2*D+F)/3;
|
50 |
|
|
private static final float X4 = (D+F)/2;
|
51 |
|
|
private static final float Y1 = (A+2*B)/3;
|
52 |
|
|
private static final float Y2 = B/3;
|
53 |
|
|
private static final float Z1 = (C+E)/3;
|
54 |
|
|
private static final float Z2 = (E+H)/3;
|
55 |
|
|
private static final float Z3 = 2*H/3;
|
56 |
|
|
private static final float Z4 = (C-2*H)/3;
|
57 |
|
|
private static final float Z5 = -H/3;
|
58 |
|
|
private static final float Z6 = (H-C-E)/3;
|
59 |
|
|
|
60 |
|
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
61 |
|
|
{
|
62 |
|
|
new Static3D( 0, 1, 0),
|
63 |
|
|
new Static3D( 0,B/A,C/A),
|
64 |
|
|
new Static3D( D/A,B/A,E/A),
|
65 |
|
|
new Static3D( F/A,B/A,H/A),
|
66 |
|
|
new Static3D(-F/A,B/A,H/A),
|
67 |
|
|
new Static3D(-D/A,B/A,E/A)
|
68 |
|
|
};
|
69 |
|
|
|
70 |
|
|
private int[][] mEdges;
|
71 |
|
|
private int[][] mBasicAngle;
|
72 |
|
|
private float[][] mCuts;
|
73 |
|
|
private float[][] mPosition;
|
74 |
|
|
|
75 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
76 |
|
|
|
77 |
|
|
public TwistyIcosamate(int meshState, int iconMode, Static4D quat, Static3D move, float scale, InitData data, InitAssets asset)
|
78 |
|
|
{
|
79 |
|
|
super(meshState, iconMode, data.getNumLayers()[0], quat, move, scale, data, asset);
|
80 |
|
|
}
|
81 |
|
|
|
82 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
83 |
|
|
|
84 |
|
|
public int[][] getScrambleEdges()
|
85 |
|
|
{
|
86 |
|
|
if( mEdges==null )
|
87 |
|
|
{
|
88 |
|
|
int[][] basicAngle = getBasicAngles();
|
89 |
|
|
mEdges = ScrambleEdgeGenerator.getScrambleEdgesSingle(basicAngle);
|
90 |
|
|
}
|
91 |
|
|
|
92 |
|
|
return mEdges;
|
93 |
|
|
}
|
94 |
|
|
|
95 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
96 |
|
|
|
97 |
|
|
public float[][] getCuts(int[] numLayers)
|
98 |
|
|
{
|
99 |
|
|
if( mCuts==null )
|
100 |
|
|
{
|
101 |
|
|
float[] cut = new float[] {0};
|
102 |
|
|
mCuts = new float[][] { cut,cut,cut,cut,cut,cut };
|
103 |
|
|
}
|
104 |
|
|
|
105 |
|
|
return mCuts;
|
106 |
|
|
}
|
107 |
|
|
|
108 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
109 |
|
|
|
110 |
|
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
111 |
|
|
{
|
112 |
|
|
boolean[] tmp = new boolean[] {true,true};
|
113 |
|
|
return new boolean[][] { tmp,tmp,tmp,tmp,tmp,tmp };
|
114 |
|
|
}
|
115 |
|
|
|
116 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
117 |
|
|
|
118 |
|
|
public int getTouchControlType()
|
119 |
|
|
{
|
120 |
|
|
return TC_ICOSAHEDRON;
|
121 |
|
|
}
|
122 |
|
|
|
123 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
124 |
|
|
|
125 |
|
|
public int getTouchControlSplit()
|
126 |
|
|
{
|
127 |
|
|
return TYPE_NOT_SPLIT;
|
128 |
|
|
}
|
129 |
|
|
|
130 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
131 |
|
|
|
132 |
|
|
public int[][][] getEnabled()
|
133 |
|
|
{
|
134 |
|
|
return new int[][][]
|
135 |
|
|
{
|
136 |
|
|
{{3,4,5}}, {{1,4,5}}, {{1,2,5}}, {{1,2,3}}, {{2,3,4}},
|
137 |
|
|
{{0,2,5}}, {{0,1,3}}, {{0,2,4}}, {{0,3,5}}, {{0,1,4}},
|
138 |
|
|
{{0,2,5}}, {{0,1,3}}, {{0,2,4}}, {{0,3,5}}, {{0,1,4}},
|
139 |
|
|
{{3,4,5}}, {{1,4,5}}, {{1,2,5}}, {{1,2,3}}, {{2,3,4}},
|
140 |
|
|
};
|
141 |
|
|
}
|
142 |
|
|
|
143 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
144 |
|
|
|
145 |
|
|
public float[] getDist3D(int[] numLayers)
|
146 |
|
|
{
|
147 |
|
|
return TouchControlIcosahedron.D3D;
|
148 |
|
|
}
|
149 |
|
|
|
150 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
151 |
|
|
|
152 |
|
|
public Static3D[] getFaceAxis()
|
153 |
|
|
{
|
154 |
|
|
return TouchControlIcosahedron.FACE_AXIS;
|
155 |
|
|
}
|
156 |
|
|
|
157 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
158 |
|
|
|
159 |
|
|
public float[][] getCubitPositions(int[] numLayers)
|
160 |
|
|
{
|
161 |
|
|
if( mPosition==null )
|
162 |
|
|
{
|
163 |
|
|
mPosition = new float[][]
|
164 |
|
|
{
|
165 |
|
|
{ 0, A, 0},
|
166 |
|
|
|
167 |
|
|
{ 0, B, C},
|
168 |
|
|
{ D, B, E},
|
169 |
|
|
{ F, B, H},
|
170 |
|
|
{-F, B, H},
|
171 |
|
|
{-D, B, E},
|
172 |
|
|
|
173 |
|
|
{ D,-B,-E},
|
174 |
|
|
{ F,-B,-H},
|
175 |
|
|
{-F,-B,-H},
|
176 |
|
|
{-D,-B,-E},
|
177 |
|
|
{ 0,-B,-C},
|
178 |
|
|
|
179 |
|
|
{ 0,-A, 0},
|
180 |
|
|
|
181 |
|
|
{ X1, Y1, Z1 },
|
182 |
|
|
{ X2, Y1, Z2 },
|
183 |
|
|
{ 0, Y1, Z3 },
|
184 |
|
|
{ -X2, Y1, Z2 },
|
185 |
|
|
{ -X1, Y1, Z1 },
|
186 |
|
|
|
187 |
|
|
{ 0,-Y2, Z4 },
|
188 |
|
|
{ X3,-Y2, Z5 },
|
189 |
|
|
{ X4,-Y2, Z6 },
|
190 |
|
|
{ -X4,-Y2, Z6 },
|
191 |
|
|
{ -X3,-Y2, Z5 },
|
192 |
|
|
|
193 |
|
|
{ 0, Y2,-Z4 },
|
194 |
|
|
{ -X3, Y2,-Z5 },
|
195 |
|
|
{ -X4, Y2,-Z6 },
|
196 |
|
|
{ X4, Y2,-Z6 },
|
197 |
|
|
{ X3, Y2,-Z5 },
|
198 |
|
|
|
199 |
|
|
{ -X1,-Y1,-Z1 },
|
200 |
|
|
{ -X2,-Y1,-Z2 },
|
201 |
|
|
{ 0,-Y1,-Z3 },
|
202 |
|
|
{ X2,-Y1,-Z2 },
|
203 |
|
|
{ X1,-Y1,-Z1 },
|
204 |
|
|
};
|
205 |
|
|
}
|
206 |
|
|
|
207 |
|
|
return mPosition;
|
208 |
|
|
}
|
209 |
|
|
|
210 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
211 |
|
|
|
212 |
|
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
213 |
|
|
{
|
214 |
|
|
return mObjectQuats[0]; // TODO
|
215 |
|
|
}
|
216 |
|
|
|
217 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
218 |
|
|
|
219 |
|
|
private float[][] getVertices(int variant)
|
220 |
|
|
{
|
221 |
|
|
if( variant==0 )
|
222 |
|
|
{
|
223 |
|
|
float H1 = (B-A)/2;
|
224 |
|
|
return new float[][] { {0,0,0},{0,H1,C/2},{D/2,H1,E/2},{F/2,H1,H/2},{-F/2,H1,H/2},{-D/2,H1,E/2},{0,-A,0} };
|
225 |
|
|
}
|
226 |
|
|
else
|
227 |
|
|
{
|
228 |
|
|
return new float[][] { {F/2,Y2,(C-H)/2-Z4},{0,-B+Y2,-H-Z4},{-F/2,Y2,(C-H)/2-Z4},{0,Y2,-Z4} };
|
229 |
|
|
}
|
230 |
|
|
}
|
231 |
|
|
|
232 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
233 |
|
|
|
234 |
|
|
public ObjectShape getObjectShape(int variant)
|
235 |
|
|
{
|
236 |
|
|
if( variant==0 )
|
237 |
|
|
{
|
238 |
|
|
int[][] indices =
|
239 |
|
|
{
|
240 |
|
|
{1,2,0},{2,3,0},{3,4,0},{4,5,0},{5,1,0}, {6,2,1},{6,3,2},{6,4,3},{6,5,4},{6,1,5}
|
241 |
|
|
};
|
242 |
|
|
|
243 |
|
|
return new ObjectShape(getVertices(variant), indices);
|
244 |
|
|
}
|
245 |
|
|
else
|
246 |
|
|
{
|
247 |
|
|
int[][] indices =
|
248 |
|
|
{
|
249 |
|
|
{0,2,1},{0,1,3},{2,0,3},{1,2,3}
|
250 |
|
|
};
|
251 |
|
|
|
252 |
|
|
return new ObjectShape(getVertices(variant), indices);
|
253 |
|
|
}
|
254 |
|
|
}
|
255 |
|
|
|
256 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
257 |
|
|
|
258 |
|
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
259 |
|
|
{
|
260 |
|
|
if( variant==0 )
|
261 |
|
|
{
|
262 |
|
|
float h1 = isInIconMode() ? 0.001f : 0.04f;
|
263 |
|
|
float h2 = 0.001f;
|
264 |
|
|
float[][] bands = { {h1,27,0.2f,0.4f,5,0,0}, {h2,27,0.2f,0.4f,3,0,0} };
|
265 |
|
|
int[] indices = { 0,0,0,0,0, 1,1,1,1,1,1 };
|
266 |
|
|
return new ObjectFaceShape(bands,indices,null);
|
267 |
|
|
}
|
268 |
|
|
else
|
269 |
|
|
{
|
270 |
|
|
float h1 = isInIconMode() ? 0.001f : 0.04f;
|
271 |
|
|
float h2 = 0.001f;
|
272 |
|
|
float[][] bands = { {h1,25,0.2f,0.4f,5,0,0}, {h2,25,0.2f,0.4f,3,0,0} };
|
273 |
|
|
int[] indices = { 0,1,1,1 };
|
274 |
|
|
return new ObjectFaceShape(bands,indices,null);
|
275 |
|
|
}
|
276 |
|
|
}
|
277 |
|
|
|
278 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
279 |
|
|
|
280 |
|
|
public ObjectVertexEffects getVertexEffects(int variant)
|
281 |
|
|
{
|
282 |
|
|
if( variant==0 )
|
283 |
|
|
{
|
284 |
|
|
float[][] corners = { {0.04f,0.12f},{0.04f,0.10f} };
|
285 |
|
|
int[] cornerIndices= { 0,1,1,1,1,1,-1 };
|
286 |
|
|
float[][] centers = { {0,-A/2,0} };
|
287 |
|
|
int[] centerIndices= { 0,0,0,0,0,0,-1 };
|
288 |
|
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
|
289 |
|
|
}
|
290 |
|
|
else
|
291 |
|
|
{
|
292 |
|
|
float[][] corners = { {0.04f,0.15f} };
|
293 |
|
|
int[] indices = { 0,0,0,-1 };
|
294 |
|
|
float[][] centers = { {0,Y2/2,-Z4/2} };
|
295 |
|
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
|
296 |
|
|
}
|
297 |
|
|
}
|
298 |
|
|
|
299 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
300 |
|
|
|
301 |
|
|
public int getNumCubitVariants(int[] numLayers)
|
302 |
|
|
{
|
303 |
|
|
return 2;
|
304 |
|
|
}
|
305 |
|
|
|
306 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
307 |
|
|
|
308 |
|
|
public int getCubitVariant(int cubit, int[] numLayers)
|
309 |
|
|
{
|
310 |
|
|
return cubit<12 ? 0:1;
|
311 |
|
|
}
|
312 |
|
|
|
313 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
314 |
|
|
|
315 |
|
|
public float getStickerRadius()
|
316 |
|
|
{
|
317 |
|
|
return 0.09f;
|
318 |
|
|
}
|
319 |
|
|
|
320 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
321 |
|
|
|
322 |
|
|
public float getStickerStroke()
|
323 |
|
|
{
|
324 |
|
|
return isInIconMode() ? 0.20f : 0.09f;
|
325 |
|
|
}
|
326 |
|
|
|
327 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
328 |
|
|
|
329 |
|
|
public float[][] getStickerAngles()
|
330 |
|
|
{
|
331 |
|
|
return null;
|
332 |
|
|
}
|
333 |
|
|
|
334 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
335 |
|
|
// PUBLIC API
|
336 |
|
|
|
337 |
|
|
public Static3D[] getRotationAxis()
|
338 |
|
|
{
|
339 |
|
|
return ROT_AXIS;
|
340 |
|
|
}
|
341 |
|
|
|
342 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
343 |
|
|
|
344 |
|
|
public int[][] getBasicAngles()
|
345 |
|
|
{
|
346 |
|
|
if( mBasicAngle==null )
|
347 |
|
|
{
|
348 |
|
|
int num = getNumLayers()[0];
|
349 |
|
|
int[] tmp = new int[num];
|
350 |
|
|
for(int i=0; i<num; i++) tmp[i] = 5;
|
351 |
|
|
mBasicAngle = new int[][] { tmp,tmp,tmp,tmp,tmp,tmp };
|
352 |
|
|
}
|
353 |
|
|
|
354 |
|
|
return mBasicAngle;
|
355 |
|
|
}
|
356 |
|
|
|
357 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
358 |
|
|
|
359 |
|
|
public String getShortName()
|
360 |
|
|
{
|
361 |
|
|
return ObjectType.ICOS_2.name();
|
362 |
|
|
}
|
363 |
|
|
|
364 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
365 |
|
|
|
366 |
|
|
public ObjectSignature getSignature()
|
367 |
|
|
{
|
368 |
|
|
return new ObjectSignature(ObjectSignatures.ICOS_2);
|
369 |
|
|
}
|
370 |
|
|
|
371 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
372 |
|
|
|
373 |
|
|
public String getObjectName()
|
374 |
|
|
{
|
375 |
|
|
return "Icosamate";
|
376 |
|
|
}
|
377 |
|
|
|
378 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
379 |
|
|
|
380 |
|
|
public String getInventor()
|
381 |
|
|
{
|
382 |
|
|
return "Jason Smith";
|
383 |
|
|
}
|
384 |
|
|
|
385 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
386 |
|
|
|
387 |
|
|
public int getYearOfInvention()
|
388 |
|
|
{
|
389 |
|
|
return 2010;
|
390 |
|
|
}
|
391 |
|
|
|
392 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
393 |
|
|
|
394 |
|
|
public int getComplexity()
|
395 |
|
|
{
|
396 |
|
|
return 3;
|
397 |
|
|
}
|
398 |
|
|
|
399 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
400 |
|
|
|
401 |
|
|
public String[][] getTutorials()
|
402 |
|
|
{
|
403 |
|
|
return new String[][] {
|
404 |
|
|
{"gb","e7Es4Zx6Sl4","Icosamate introduction & algorithms","Superantoniovivaldi"},
|
405 |
|
|
{"gb","ZhkklbYfs98","Icosamate solve","Superantoniovivaldi"},
|
406 |
|
|
{"pl","eJTLTeoicWI","Icosamate TUTORIAL PL","MrUK"},
|
407 |
|
|
{"vn","RVjjxj9rPeg","BẠN PHẠM BẢO GIẢI ICOSAMATE","VĂN CÔNG TÙNG"},
|
408 |
|
|
};
|
409 |
|
|
}
|
410 |
|
|
}
|