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};
|
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
|
boolean[] tmp = new boolean[] {true,true};
|
114
|
return new boolean[][] { tmp,tmp,tmp,tmp,tmp,tmp };
|
115
|
}
|
116
|
|
117
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
118
|
|
119
|
public int getTouchControlType()
|
120
|
{
|
121
|
return TC_ICOSAHEDRON;
|
122
|
}
|
123
|
|
124
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
125
|
|
126
|
public int getTouchControlSplit()
|
127
|
{
|
128
|
return TYPE_NOT_SPLIT;
|
129
|
}
|
130
|
|
131
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
132
|
|
133
|
public int[][][] getEnabled()
|
134
|
{
|
135
|
return new int[][][]
|
136
|
{
|
137
|
{{3,4,5}}, {{1,4,5}}, {{1,2,5}}, {{1,2,3}}, {{2,3,4}},
|
138
|
{{0,2,5}}, {{0,1,3}}, {{0,2,4}}, {{0,3,5}}, {{0,1,4}},
|
139
|
{{0,2,5}}, {{0,1,3}}, {{0,2,4}}, {{0,3,5}}, {{0,1,4}},
|
140
|
{{3,4,5}}, {{1,4,5}}, {{1,2,5}}, {{1,2,3}}, {{2,3,4}},
|
141
|
};
|
142
|
}
|
143
|
|
144
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
145
|
|
146
|
public float[] getDist3D(int[] numLayers)
|
147
|
{
|
148
|
return TouchControlIcosahedron.D3D;
|
149
|
}
|
150
|
|
151
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
152
|
|
153
|
public Static3D[] getFaceAxis()
|
154
|
{
|
155
|
return TouchControlIcosahedron.FACE_AXIS;
|
156
|
}
|
157
|
|
158
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
159
|
|
160
|
public float[][] getCubitPositions(int[] numLayers)
|
161
|
{
|
162
|
if( mPosition==null )
|
163
|
{
|
164
|
float N = numLayers[0];
|
165
|
float AN = N*A;
|
166
|
float BN = N*B;
|
167
|
float CN = N*C;
|
168
|
float DN = N*D;
|
169
|
float EN = N*E;
|
170
|
float FN = N*F;
|
171
|
float HN = N*H;
|
172
|
|
173
|
mPosition = new float[][]
|
174
|
{
|
175
|
{ 0, AN, 0},
|
176
|
|
177
|
{ 0, BN, CN},
|
178
|
{ DN, BN, EN},
|
179
|
{ FN, BN, HN},
|
180
|
{-FN, BN, HN},
|
181
|
{-DN, BN, EN},
|
182
|
|
183
|
{ DN,-BN,-EN},
|
184
|
{ FN,-BN,-HN},
|
185
|
{-FN,-BN,-HN},
|
186
|
{-DN,-BN,-EN},
|
187
|
{ 0,-BN,-CN},
|
188
|
|
189
|
{ 0,-AN, 0},
|
190
|
|
191
|
{ X1*N, Y1*N, Z1*N },
|
192
|
{ X2*N, Y1*N, Z2*N },
|
193
|
{ 0, Y1*N, Z3*N },
|
194
|
{ -X2*N, Y1*N, Z2*N },
|
195
|
{ -X1*N, Y1*N, Z1*N },
|
196
|
|
197
|
{ 0,-Y2*N, Z4*N },
|
198
|
{ X3*N,-Y2*N, Z5*N },
|
199
|
{ X4*N,-Y2*N, Z6*N },
|
200
|
{ -X4*N,-Y2*N, Z6*N },
|
201
|
{ -X3*N,-Y2*N, Z5*N },
|
202
|
|
203
|
{ 0, Y2*N,-Z4*N },
|
204
|
{ -X3*N, Y2*N,-Z5*N },
|
205
|
{ -X4*N, Y2*N,-Z6*N },
|
206
|
{ X4*N, Y2*N,-Z6*N },
|
207
|
{ X3*N, Y2*N,-Z5*N },
|
208
|
|
209
|
{ -X1*N,-Y1*N,-Z1*N },
|
210
|
{ -X2*N,-Y1*N,-Z2*N },
|
211
|
{ 0,-Y1*N,-Z3*N },
|
212
|
{ X2*N,-Y1*N,-Z2*N },
|
213
|
{ X1*N,-Y1*N,-Z1*N },
|
214
|
};
|
215
|
}
|
216
|
|
217
|
return mPosition;
|
218
|
}
|
219
|
|
220
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
221
|
|
222
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
223
|
{
|
224
|
if( mQuatIndex==null )
|
225
|
{
|
226
|
mQuatIndex = new int[]
|
227
|
{
|
228
|
0,12,5,9,13,8,10,6,7,18,14,55,
|
229
|
0,4,3,2,1, 6,11,32,14,26, 41,27,7,5,10, 35,18,45,33,15
|
230
|
};
|
231
|
}
|
232
|
|
233
|
return mObjectQuats[mQuatIndex[cubit]];
|
234
|
}
|
235
|
|
236
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
237
|
|
238
|
private float[][] getVertices(int variant)
|
239
|
{
|
240
|
if( variant==0 )
|
241
|
{
|
242
|
float N = getNumLayers()[0];
|
243
|
float X = B-A;
|
244
|
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} };
|
245
|
}
|
246
|
else
|
247
|
{
|
248
|
float N = getNumLayers()[0];
|
249
|
float CX = X1*N;
|
250
|
float CY = Y1*N;
|
251
|
float CZ = Z1*N;
|
252
|
|
253
|
return new float[][] { { D-CX, A*(N-1)+ B-CY, E-CZ },
|
254
|
{ D-CX, A*(N-2)+2*B-CY, C+E-CZ },
|
255
|
{ -CX, A*(N-1)+ B-CY, C -CZ },
|
256
|
{ -CX, -CY, -CZ }
|
257
|
};
|
258
|
}
|
259
|
}
|
260
|
|
261
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
262
|
|
263
|
public ObjectShape getObjectShape(int variant)
|
264
|
{
|
265
|
if( variant==0 )
|
266
|
{
|
267
|
int[][] indices =
|
268
|
{
|
269
|
{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}
|
270
|
};
|
271
|
|
272
|
return new ObjectShape(getVertices(variant), indices);
|
273
|
}
|
274
|
else
|
275
|
{
|
276
|
int[][] indices =
|
277
|
{
|
278
|
{0,2,1},{0,1,3},{2,0,3},{1,2,3}
|
279
|
};
|
280
|
|
281
|
return new ObjectShape(getVertices(variant), indices);
|
282
|
}
|
283
|
}
|
284
|
|
285
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
286
|
|
287
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
288
|
{
|
289
|
if( variant==0 )
|
290
|
{
|
291
|
float h1 = isInIconMode() ? 0.001f : 0.04f;
|
292
|
float h2 = 0.001f;
|
293
|
float[][] bands = { {h1,27,0.2f,0.4f,5,0,0}, {h2,27,0.2f,0.4f,3,0,0} };
|
294
|
int[] indices = { 0,0,0,0,0, 1,1,1,1,1,1 };
|
295
|
return new ObjectFaceShape(bands,indices,null);
|
296
|
}
|
297
|
else
|
298
|
{
|
299
|
float h1 = isInIconMode() ? 0.001f : 0.04f;
|
300
|
float h2 = 0.001f;
|
301
|
float[][] bands = { {h1,25,0.2f,0.4f,5,0,0}, {h2,25,0.2f,0.4f,3,0,0} };
|
302
|
int[] indices = { 0,1,1,1 };
|
303
|
return new ObjectFaceShape(bands,indices,null);
|
304
|
}
|
305
|
}
|
306
|
|
307
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
308
|
|
309
|
public ObjectVertexEffects getVertexEffects(int variant)
|
310
|
{
|
311
|
if( variant==0 )
|
312
|
{
|
313
|
float[][] corners = { {0.04f,0.12f},{0.04f,0.10f} };
|
314
|
int[] cornerIndices= { 0,1,1,1,1,1,-1 };
|
315
|
float[][] centers = { {0,-A/2,0} };
|
316
|
int[] centerIndices= { 0,0,0,0,0,0,-1 };
|
317
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
|
318
|
}
|
319
|
else
|
320
|
{
|
321
|
float[][] corners = { {0.04f,0.15f} };
|
322
|
int[] indices = { 0,0,0,-1 };
|
323
|
float[][] centers = { {0,Y2/2,-Z4/2} };
|
324
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
|
325
|
}
|
326
|
}
|
327
|
|
328
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
329
|
|
330
|
public int getNumCubitVariants(int[] numLayers)
|
331
|
{
|
332
|
return 2;
|
333
|
}
|
334
|
|
335
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
336
|
|
337
|
public int getCubitVariant(int cubit, int[] numLayers)
|
338
|
{
|
339
|
return cubit<12 ? 0:1;
|
340
|
}
|
341
|
|
342
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
343
|
|
344
|
public float getStickerRadius()
|
345
|
{
|
346
|
return 0.09f;
|
347
|
}
|
348
|
|
349
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
350
|
|
351
|
public float getStickerStroke()
|
352
|
{
|
353
|
return isInIconMode() ? 0.14f : 0.09f;
|
354
|
}
|
355
|
|
356
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
357
|
|
358
|
public float[][] getStickerAngles()
|
359
|
{
|
360
|
return null;
|
361
|
}
|
362
|
|
363
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
364
|
// PUBLIC API
|
365
|
|
366
|
public Static3D[] getRotationAxis()
|
367
|
{
|
368
|
return ROT_AXIS;
|
369
|
}
|
370
|
|
371
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
372
|
|
373
|
public int[][] getBasicAngles()
|
374
|
{
|
375
|
if( mBasicAngle==null )
|
376
|
{
|
377
|
int num = getNumLayers()[0];
|
378
|
int[] tmp = new int[num];
|
379
|
for(int i=0; i<num; i++) tmp[i] = 5;
|
380
|
mBasicAngle = new int[][] { tmp,tmp,tmp,tmp,tmp,tmp };
|
381
|
}
|
382
|
|
383
|
return mBasicAngle;
|
384
|
}
|
385
|
|
386
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
387
|
|
388
|
public String getShortName()
|
389
|
{
|
390
|
return ObjectType.ICOS_2.name();
|
391
|
}
|
392
|
|
393
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
394
|
|
395
|
public ObjectSignature getSignature()
|
396
|
{
|
397
|
return new ObjectSignature(ObjectSignatures.ICOS_2);
|
398
|
}
|
399
|
|
400
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
401
|
|
402
|
public String getObjectName()
|
403
|
{
|
404
|
return "Icosamate";
|
405
|
}
|
406
|
|
407
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
408
|
|
409
|
public String getInventor()
|
410
|
{
|
411
|
return "Jason Smith";
|
412
|
}
|
413
|
|
414
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
415
|
|
416
|
public int getYearOfInvention()
|
417
|
{
|
418
|
return 2010;
|
419
|
}
|
420
|
|
421
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
422
|
|
423
|
public int getComplexity()
|
424
|
{
|
425
|
return 3;
|
426
|
}
|
427
|
|
428
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
429
|
|
430
|
public String[][] getTutorials()
|
431
|
{
|
432
|
return new String[][] {
|
433
|
{"gb","e7Es4Zx6Sl4","Icosamate introduction & algorithms","Superantoniovivaldi"},
|
434
|
{"gb","ZhkklbYfs98","Icosamate solve","Superantoniovivaldi"},
|
435
|
{"pl","eJTLTeoicWI","Icosamate TUTORIAL PL","MrUK"},
|
436
|
{"vn","RVjjxj9rPeg","BẠN PHẠM BẢO GIẢI ICOSAMATE","VĂN CÔNG TÙNG"},
|
437
|
};
|
438
|
}
|
439
|
}
|