1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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.ShapeIcosahedron;
|
28
|
import org.distorted.objectlib.touchcontrol.TouchControlIcosahedron;
|
29
|
|
30
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
31
|
|
32
|
public class TwistyIcosamate extends ShapeIcosahedron
|
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)/3;
|
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
|
private int[] mQuatIndex;
|
75
|
|
76
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
77
|
|
78
|
public TwistyIcosamate(int meshState, int iconMode, Static4D quat, Static3D move, float scale, InitData data, InitAssets asset)
|
79
|
{
|
80
|
super(meshState, iconMode, data.getNumLayers()[0], quat, move, scale, data, asset);
|
81
|
}
|
82
|
|
83
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
84
|
|
85
|
public int[][] getScrambleEdges()
|
86
|
{
|
87
|
if( mEdges==null )
|
88
|
{
|
89
|
int[][] basicAngle = getBasicAngles();
|
90
|
mEdges = ScrambleEdgeGenerator.getScrambleEdgesSingle(basicAngle);
|
91
|
}
|
92
|
|
93
|
return mEdges;
|
94
|
}
|
95
|
|
96
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
97
|
|
98
|
public float[][] getCuts(int[] numLayers)
|
99
|
{
|
100
|
if( mCuts==null )
|
101
|
{
|
102
|
float[] cut = new float[] {0}; // TODO
|
103
|
mCuts = new float[][] { cut,cut,cut,cut,cut,cut };
|
104
|
}
|
105
|
|
106
|
return mCuts;
|
107
|
}
|
108
|
|
109
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
110
|
|
111
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
112
|
{
|
113
|
int nL = numLayers[0];
|
114
|
boolean[] tmp = new boolean[nL];
|
115
|
for(int i=0; i<nL; i++) tmp[i] = true;
|
116
|
return new boolean[][] { tmp,tmp,tmp,tmp,tmp,tmp };
|
117
|
}
|
118
|
|
119
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
120
|
|
121
|
public int getTouchControlType()
|
122
|
{
|
123
|
return TC_ICOSAHEDRON;
|
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[][][]
|
138
|
{
|
139
|
{{3,4,5}}, {{1,4,5}}, {{1,2,5}}, {{1,2,3}}, {{2,3,4}},
|
140
|
{{0,2,5}}, {{0,1,3}}, {{0,2,4}}, {{0,3,5}}, {{0,1,4}},
|
141
|
{{0,2,5}}, {{0,1,3}}, {{0,2,4}}, {{0,3,5}}, {{0,1,4}},
|
142
|
{{3,4,5}}, {{1,4,5}}, {{1,2,5}}, {{1,2,3}}, {{2,3,4}},
|
143
|
};
|
144
|
}
|
145
|
|
146
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
147
|
|
148
|
public float[] getDist3D(int[] numLayers)
|
149
|
{
|
150
|
return TouchControlIcosahedron.D3D;
|
151
|
}
|
152
|
|
153
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
154
|
|
155
|
public Static3D[] getFaceAxis()
|
156
|
{
|
157
|
return TouchControlIcosahedron.FACE_AXIS;
|
158
|
}
|
159
|
|
160
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
161
|
|
162
|
public float[][] getCubitPositions(int[] numLayers)
|
163
|
{
|
164
|
if( mPosition==null )
|
165
|
{
|
166
|
float N = numLayers[0];
|
167
|
float AN = N*A;
|
168
|
float BN = N*B;
|
169
|
float CN = N*C;
|
170
|
float DN = N*D;
|
171
|
float EN = N*E;
|
172
|
float FN = N*F;
|
173
|
float HN = N*H;
|
174
|
|
175
|
mPosition = new float[][]
|
176
|
{
|
177
|
{ 0, AN, 0},
|
178
|
|
179
|
{ 0, BN, CN},
|
180
|
{ DN, BN, EN},
|
181
|
{ FN, BN, HN},
|
182
|
{-FN, BN, HN},
|
183
|
{-DN, BN, EN},
|
184
|
|
185
|
{ DN,-BN,-EN},
|
186
|
{ FN,-BN,-HN},
|
187
|
{-FN,-BN,-HN},
|
188
|
{-DN,-BN,-EN},
|
189
|
{ 0,-BN,-CN},
|
190
|
|
191
|
{ 0,-AN, 0},
|
192
|
|
193
|
{ X1*N, Y1*N, Z1*N },
|
194
|
{ X2*N, Y1*N, Z2*N },
|
195
|
{ 0, Y1*N, Z3*N },
|
196
|
{ -X2*N, Y1*N, Z2*N },
|
197
|
{ -X1*N, Y1*N, Z1*N },
|
198
|
|
199
|
{ 0,-Y2*N, Z4*N },
|
200
|
{ X3*N,-Y2*N, Z5*N },
|
201
|
{ X4*N,-Y2*N, Z6*N },
|
202
|
{ -X4*N,-Y2*N, Z6*N },
|
203
|
{ -X3*N,-Y2*N, Z5*N },
|
204
|
|
205
|
{ 0, Y2*N,-Z4*N },
|
206
|
{ -X3*N, Y2*N,-Z5*N },
|
207
|
{ -X4*N, Y2*N,-Z6*N },
|
208
|
{ X4*N, Y2*N,-Z6*N },
|
209
|
{ X3*N, Y2*N,-Z5*N },
|
210
|
|
211
|
{ -X1*N,-Y1*N,-Z1*N },
|
212
|
{ -X2*N,-Y1*N,-Z2*N },
|
213
|
{ 0,-Y1*N,-Z3*N },
|
214
|
{ X2*N,-Y1*N,-Z2*N },
|
215
|
{ X1*N,-Y1*N,-Z1*N },
|
216
|
};
|
217
|
}
|
218
|
|
219
|
return mPosition;
|
220
|
}
|
221
|
|
222
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
223
|
|
224
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
225
|
{
|
226
|
if( mQuatIndex==null )
|
227
|
{
|
228
|
mQuatIndex = new int[]
|
229
|
{
|
230
|
0,12,5,9,13,8,10,6,7,18,14,55,
|
231
|
0,4,3,2,1, 6,11,32,14,26, 41,27,7,5,10, 35,18,45,33,15
|
232
|
};
|
233
|
}
|
234
|
|
235
|
return mObjectQuats[mQuatIndex[cubit]];
|
236
|
}
|
237
|
|
238
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
239
|
|
240
|
private float[][] getVertices(int variant)
|
241
|
{
|
242
|
if( variant==0 )
|
243
|
{
|
244
|
float N = getNumLayers()[0];
|
245
|
float X = B-A;
|
246
|
return new float[][] { {0,0,0},{0,X,C},{D,X,E},{F,X,H},{-F,X,H},{-D,X,E},{0,-A*N,0} };
|
247
|
}
|
248
|
else
|
249
|
{
|
250
|
float N = getNumLayers()[0];
|
251
|
float CX = X1*N;
|
252
|
float CY = Y1*N;
|
253
|
float CZ = Z1*N;
|
254
|
|
255
|
return new float[][] { { D-CX, A*(N-1)+ B-CY, E-CZ },
|
256
|
{ D-CX, A*(N-2)+2*B-CY, C+E-CZ },
|
257
|
{ -CX, A*(N-1)+ B-CY, C -CZ },
|
258
|
{ -CX, -CY, -CZ }
|
259
|
};
|
260
|
}
|
261
|
}
|
262
|
|
263
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
264
|
|
265
|
public ObjectShape getObjectShape(int variant)
|
266
|
{
|
267
|
if( variant==0 )
|
268
|
{
|
269
|
int[][] indices =
|
270
|
{
|
271
|
{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}
|
272
|
};
|
273
|
|
274
|
return new ObjectShape(getVertices(variant), indices);
|
275
|
}
|
276
|
else
|
277
|
{
|
278
|
int[][] indices =
|
279
|
{
|
280
|
{0,2,1},{0,1,3},{2,0,3},{1,2,3}
|
281
|
};
|
282
|
|
283
|
return new ObjectShape(getVertices(variant), indices);
|
284
|
}
|
285
|
}
|
286
|
|
287
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
288
|
|
289
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
290
|
{
|
291
|
if( variant==0 )
|
292
|
{
|
293
|
float h1 = isInIconMode() ? 0.001f : 0.04f;
|
294
|
float h2 = 0.001f;
|
295
|
float[][] bands = { {h1,27,0.2f,0.4f,5,0,0}, {h2,27,0.2f,0.4f,3,0,0} };
|
296
|
int[] indices = { 0,0,0,0,0, 1,1,1,1,1,1 };
|
297
|
return new ObjectFaceShape(bands,indices,null);
|
298
|
}
|
299
|
else
|
300
|
{
|
301
|
float h1 = isInIconMode() ? 0.001f : 0.04f;
|
302
|
float h2 = 0.001f;
|
303
|
float[][] bands = { {h1,25,0.2f,0.4f,5,0,0}, {h2,25,0.2f,0.4f,3,0,0} };
|
304
|
int[] indices = { 0,1,1,1 };
|
305
|
return new ObjectFaceShape(bands,indices,null);
|
306
|
}
|
307
|
}
|
308
|
|
309
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
310
|
|
311
|
public ObjectVertexEffects getVertexEffects(int variant)
|
312
|
{
|
313
|
if( variant==0 )
|
314
|
{
|
315
|
float[][] corners = { {0.04f,0.12f},{0.04f,0.10f} };
|
316
|
int[] cornerIndices= { 0,1,1,1,1,1,-1 };
|
317
|
float[][] centers = { {0,-A/2,0} };
|
318
|
int[] centerIndices= { 0,0,0,0,0,0,-1 };
|
319
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
|
320
|
}
|
321
|
else
|
322
|
{
|
323
|
float[][] corners = { {0.04f,0.15f} };
|
324
|
int[] indices = { 0,0,0,-1 };
|
325
|
float[][] centers = { {0,Y2/2,-Z4/2} };
|
326
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
|
327
|
}
|
328
|
}
|
329
|
|
330
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
331
|
|
332
|
public int getNumCubitVariants(int[] numLayers)
|
333
|
{
|
334
|
return getNumLayers()[0]==2 ? 2 : 3;
|
335
|
}
|
336
|
|
337
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
338
|
|
339
|
public int getCubitVariant(int cubit, int[] numLayers)
|
340
|
{
|
341
|
int N = getNumLayers()[0];
|
342
|
return cubit<12 ? 0 : (cubit<10*N*(N-1)+12 ? 1 : 2);
|
343
|
}
|
344
|
|
345
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
346
|
|
347
|
public float getStickerRadius()
|
348
|
{
|
349
|
return 0.09f;
|
350
|
}
|
351
|
|
352
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
353
|
|
354
|
public float getStickerStroke()
|
355
|
{
|
356
|
return isInIconMode() ? 0.14f : 0.09f;
|
357
|
}
|
358
|
|
359
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
360
|
|
361
|
public float[][] getStickerAngles()
|
362
|
{
|
363
|
return null;
|
364
|
}
|
365
|
|
366
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
367
|
// PUBLIC API
|
368
|
|
369
|
public Static3D[] getRotationAxis()
|
370
|
{
|
371
|
return ROT_AXIS;
|
372
|
}
|
373
|
|
374
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
375
|
|
376
|
public int[][] getBasicAngles()
|
377
|
{
|
378
|
if( mBasicAngle==null )
|
379
|
{
|
380
|
int num = getNumLayers()[0];
|
381
|
int[] tmp = new int[num];
|
382
|
for(int i=0; i<num; i++) tmp[i] = 5;
|
383
|
mBasicAngle = new int[][] { tmp,tmp,tmp,tmp,tmp,tmp };
|
384
|
}
|
385
|
|
386
|
return mBasicAngle;
|
387
|
}
|
388
|
|
389
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
390
|
|
391
|
public String getShortName()
|
392
|
{
|
393
|
switch(getNumLayers()[0])
|
394
|
{
|
395
|
case 2: return ObjectType.ICOS_2.name();
|
396
|
case 3: return ObjectType.ICOS_3.name();
|
397
|
}
|
398
|
|
399
|
return null;
|
400
|
}
|
401
|
|
402
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
403
|
|
404
|
public ObjectSignature getSignature()
|
405
|
{
|
406
|
switch(getNumLayers()[0])
|
407
|
{
|
408
|
case 2: return new ObjectSignature(ObjectSignatures.ICOS_2);
|
409
|
case 3: return new ObjectSignature(ObjectSignatures.ICOS_3);
|
410
|
}
|
411
|
|
412
|
return null;
|
413
|
}
|
414
|
|
415
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
416
|
|
417
|
public String getObjectName()
|
418
|
{
|
419
|
switch(getNumLayers()[0])
|
420
|
{
|
421
|
case 2: return "Icosamate";
|
422
|
case 3: return "Master Icosamate";
|
423
|
}
|
424
|
return null;
|
425
|
}
|
426
|
|
427
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
428
|
|
429
|
public String getInventor()
|
430
|
{
|
431
|
switch(getNumLayers()[0])
|
432
|
{
|
433
|
case 2: return "Jason Smith";
|
434
|
case 3: return "Keisuke Maruyama";
|
435
|
}
|
436
|
return null;
|
437
|
}
|
438
|
|
439
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
440
|
|
441
|
public int getYearOfInvention()
|
442
|
{
|
443
|
switch(getNumLayers()[0])
|
444
|
{
|
445
|
case 2: return 2010;
|
446
|
case 3: return 2018;
|
447
|
}
|
448
|
return 0;
|
449
|
}
|
450
|
|
451
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
452
|
|
453
|
public int getComplexity()
|
454
|
{
|
455
|
return getNumLayers()[0]==2 ? 3 : 4;
|
456
|
}
|
457
|
|
458
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
459
|
|
460
|
public String[][] getTutorials()
|
461
|
{
|
462
|
int[] numLayers = getNumLayers();
|
463
|
|
464
|
switch(numLayers[0])
|
465
|
{
|
466
|
case 2: return new String[][] {
|
467
|
{"gb","e7Es4Zx6Sl4","Icosamate introduction & algorithms","Superantoniovivaldi"},
|
468
|
{"gb","ZhkklbYfs98","Icosamate solve","Superantoniovivaldi"},
|
469
|
{"pl","eJTLTeoicWI","Icosamate TUTORIAL PL","MrUK"},
|
470
|
{"vn","RVjjxj9rPeg","BẠN PHẠM BẢO GIẢI ICOSAMATE","VĂN CÔNG TÙNG"},
|
471
|
};
|
472
|
case 3: return new String[][] {
|
473
|
{"gb","77aBjBdfA2Q","Master Icosamate Algorithms","Superantoniovivaldi"},
|
474
|
{"gb","j6AIwlIofFU","Master Icosamate Tutorial","Superantoniovivaldi"},
|
475
|
{"gb","5Z1B5r6-CxM","Astrominx Tutorial","Jabberwock Technologies"},
|
476
|
{"pl","","Icosamate TUTORIAL PL","MrUK"},
|
477
|
{"vn","C4YO0B4rgTc","Tutorial N.237- Master Icosamate 1/3","Duy Thích Rubik"},
|
478
|
{"vn","90m_0AoyOHU","Tutorial N.237- Master Icosamate 2/3","Duy Thích Rubik"},
|
479
|
{"vn","LOd5qBwoP_k","Tutorial N.237- Master Icosamate 3/3","Duy Thích Rubik"},
|
480
|
};
|
481
|
}
|
482
|
|
483
|
return null;
|
484
|
}
|
485
|
}
|