1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2019 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_DODECAHEDRON;
|
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
|
|
18
|
import org.distorted.objectlib.helpers.FactoryCubit;
|
19
|
import org.distorted.objectlib.helpers.ObjectFaceShape;
|
20
|
import org.distorted.objectlib.metadata.Metadata;
|
21
|
import org.distorted.objectlib.helpers.ObjectVertexEffects;
|
22
|
import org.distorted.objectlib.main.InitAssets;
|
23
|
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator;
|
24
|
import org.distorted.objectlib.touchcontrol.TouchControlDodecahedron;
|
25
|
import org.distorted.objectlib.metadata.ListObjects;
|
26
|
import org.distorted.objectlib.helpers.ObjectShape;
|
27
|
import org.distorted.objectlib.shape.ShapeDodecahedron;
|
28
|
|
29
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
30
|
|
31
|
public class TwistyUltimate extends ShapeDodecahedron
|
32
|
{
|
33
|
private static final float A = (float)Math.sqrt(21*SQ5+47);
|
34
|
private static final float B = SQ6*(5*SQ5+11)/(6*A);
|
35
|
private static final float C = SQ6*( SQ5+ 2)/(3*A);
|
36
|
private static final float D = SQ3/3;
|
37
|
private static final float E = (SQ5+1)/4;
|
38
|
private static final float G = (SQ5+3)/4;
|
39
|
|
40
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
41
|
{
|
42
|
new Static3D( B,0,C ),
|
43
|
new Static3D( C,B,0 ),
|
44
|
new Static3D(-D,D,D ),
|
45
|
new Static3D( 0,C,-B)
|
46
|
};
|
47
|
|
48
|
private int[][] mEdges;
|
49
|
private int[][] mBasicAngle;
|
50
|
private float[][] mCuts;
|
51
|
private float[][] mPositions;
|
52
|
private int[] mQuatIndex;
|
53
|
|
54
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
55
|
|
56
|
public TwistyUltimate(int iconMode, Static4D quat, Static3D move, float scale, Metadata meta, InitAssets asset)
|
57
|
{
|
58
|
super(iconMode, meta.getNumLayers()[0], quat, move, scale, meta, asset);
|
59
|
}
|
60
|
|
61
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
62
|
|
63
|
public int[][] getScrambleEdges()
|
64
|
{
|
65
|
if( mEdges==null ) mEdges = ScrambleEdgeGenerator.getScrambleEdgesSingle(mBasicAngle);
|
66
|
return mEdges;
|
67
|
}
|
68
|
|
69
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
70
|
|
71
|
public float[][] getCubitPositions(int[] numLayers)
|
72
|
{
|
73
|
if( mPositions==null )
|
74
|
{
|
75
|
mPositions = new float[][]
|
76
|
{
|
77
|
{ 0, -1, 2*G },
|
78
|
{ 2*E,-2*E,-2*E },
|
79
|
{-2*G, 0, -1 },
|
80
|
{ 1, 2*G, 0 },
|
81
|
|
82
|
{-2*E, 2*E, 2*E },
|
83
|
{ 2*G, 0, 1 },
|
84
|
{ -1, -2*G, 0 },
|
85
|
{ 0, 1,-2*G },
|
86
|
|
87
|
{ E, (E+0.5f), (E+G) },
|
88
|
{ -(E+G), -E, (E+0.5f) },
|
89
|
{ (E+0.5f), -(E+G), E },
|
90
|
{ -E,-(E+0.5f), -(E+G) },
|
91
|
{ (E+G), E,-(E+0.5f) },
|
92
|
{-(E+0.5f), (E+G), -E }
|
93
|
};
|
94
|
}
|
95
|
|
96
|
return mPositions;
|
97
|
}
|
98
|
|
99
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
100
|
|
101
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
102
|
{
|
103
|
if( mQuatIndex==null ) mQuatIndex = new int[] { 0,2,5,6,
|
104
|
0,8,2,1,
|
105
|
0,5,8,9,1,6 };
|
106
|
return mObjectQuats[mQuatIndex[cubit]];
|
107
|
}
|
108
|
|
109
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
110
|
|
111
|
private float[][] getVertices(int variant)
|
112
|
{
|
113
|
if( variant==0 )
|
114
|
{
|
115
|
return new float[][]
|
116
|
{
|
117
|
{ 0 , 0 , 0 },
|
118
|
{ -E , E+0.5f, -0.5f },
|
119
|
{-0.5f , -E , -E-0.5f},
|
120
|
{ E+0.5f, 0.5f , -E },
|
121
|
{ 0 , 1 , -2*E-1 },
|
122
|
{ 0 , 1 , 0 },
|
123
|
{ -E ,-E+0.5f, -0.5f },
|
124
|
{ E ,-E+0.5f, -0.5f }
|
125
|
};
|
126
|
}
|
127
|
else if( variant==1 )
|
128
|
{
|
129
|
return new float[][]
|
130
|
{
|
131
|
{ 0.00f, 0.00f, 0.00f},
|
132
|
{ - 0.50f,-SQ5/4 - 0.25f,-SQ5/4 - 0.75f},
|
133
|
{ SQ5/4 + 0.25f,-SQ5/4 - 0.75f, + 0.50f},
|
134
|
{ SQ5/4 + 0.75f, + 0.50f,-SQ5/4 - 0.25f},
|
135
|
{ SQ5/2 + 0.50f,-SQ5/2 - 0.50f,-SQ5/2 - 0.50f},
|
136
|
{ SQ5/4 - 0.25f, + 0.50f,-SQ5/4 - 0.25f},
|
137
|
{ - 0.50f,-SQ5/4 - 0.25f,-SQ5/4 + 0.25f},
|
138
|
{ SQ5/4 + 0.25f,-SQ5/4 + 0.25f, + 0.50f}
|
139
|
};
|
140
|
}
|
141
|
else
|
142
|
{
|
143
|
return new float[][]
|
144
|
{
|
145
|
{ -E ,-E+0.5f, 0.5f},
|
146
|
{ E , E-0.5f, -0.5f},
|
147
|
{-2*E , 0.0f, 0.0f},
|
148
|
{ 0.5f, E , -E-0.5f},
|
149
|
{ -E ,-E-0.5f, 0.5f},
|
150
|
{ E+0.5f, -0.5f, -E },
|
151
|
{-2*E , -1.0f, 0.0f},
|
152
|
{ 1.0f, 0.0f,-2*E },
|
153
|
{-2*E+0.5f, E , -E-0.5f},
|
154
|
{ 0.5f,-E-1.0f, -E+0.5f},
|
155
|
{ -E ,-E-0.5f,-2*E-0.5f}
|
156
|
};
|
157
|
}
|
158
|
}
|
159
|
|
160
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
161
|
|
162
|
public ObjectShape getObjectShape(int variant)
|
163
|
{
|
164
|
if( variant==0 )
|
165
|
{
|
166
|
int[][] indices =
|
167
|
{
|
168
|
{6,0,5,1},
|
169
|
{0,7,3,5},
|
170
|
{0,6,2,7},
|
171
|
{1,5,3,4},
|
172
|
{3,7,2,4},
|
173
|
{2,6,1,4},
|
174
|
};
|
175
|
|
176
|
return new ObjectShape(getVertices(variant), indices);
|
177
|
}
|
178
|
else if( variant==1 )
|
179
|
{
|
180
|
int[][] indices =
|
181
|
{
|
182
|
{6,0,5,1},
|
183
|
{0,7,3,5},
|
184
|
{0,6,2,7},
|
185
|
{1,5,3,4},
|
186
|
{3,7,2,4},
|
187
|
{2,6,1,4},
|
188
|
};
|
189
|
|
190
|
return new ObjectShape(getVertices(variant), indices);
|
191
|
}
|
192
|
else
|
193
|
{
|
194
|
int[][] indices =
|
195
|
{
|
196
|
{0,1,3,8,2},
|
197
|
{0,4,9,5,1},
|
198
|
{ 0,2,6,4},
|
199
|
{ 1,5,7,3},
|
200
|
{10,9,4,6},
|
201
|
{7,5,9,10},
|
202
|
{10,8,3,7},
|
203
|
{6,2,8,10}
|
204
|
};
|
205
|
|
206
|
return new ObjectShape(getVertices(variant), indices);
|
207
|
}
|
208
|
}
|
209
|
|
210
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
211
|
|
212
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
213
|
{
|
214
|
int angle = 25;
|
215
|
float R = 0.7f;
|
216
|
float S = 0.5f;
|
217
|
|
218
|
if( variant==0 )
|
219
|
{
|
220
|
float h1 = isInIconMode() ? 0.001f : 0.05f;
|
221
|
float h2 = isInIconMode() ? 0.001f : 0.01f;
|
222
|
float[][] bands = { {h1,angle,R,S,5,1,0}, {h2,angle,R,S,5,1,0} };
|
223
|
int[] indices = { 0,0,0,1,1,1 };
|
224
|
return new ObjectFaceShape(bands,indices,null);
|
225
|
}
|
226
|
else if( variant==1 )
|
227
|
{
|
228
|
float h1 = isInIconMode() ? 0.001f : 0.05f;
|
229
|
float h2 = isInIconMode() ? 0.001f : 0.01f;
|
230
|
float[][] bands = { {h1,angle,R,S,5,1,0}, {h2,angle,R,S,5,1,0} };
|
231
|
int[] indices = { 0,0,0,1,1,1 };
|
232
|
return new ObjectFaceShape(bands,indices,null);
|
233
|
}
|
234
|
else
|
235
|
{
|
236
|
float h1 = isInIconMode() ? 0.001f : 0.03f;
|
237
|
float h2 = isInIconMode() ? 0.001f : 0.05f;
|
238
|
float h3 = isInIconMode() ? 0.001f : 0.01f;
|
239
|
float[][] bands = { {h1,angle,R,S,5,1,0}, {h2,angle,R,S,5,1,0}, {h3,angle,R,S,5,1,0} };
|
240
|
int[] indices = { 0,0,1,1,2,2,2,2 };
|
241
|
return new ObjectFaceShape(bands,indices,null);
|
242
|
}
|
243
|
}
|
244
|
|
245
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
246
|
|
247
|
public ObjectVertexEffects getVertexEffects(int variant)
|
248
|
{
|
249
|
if( variant==0 )
|
250
|
{
|
251
|
float[][] corners = { { 0.013f, 0.16f } };
|
252
|
int[] cornerIndices = { 0, 0, 0, 0,-1, 0, 0, 0 };
|
253
|
float[][] centers = { { 0.0f,-1.0f, -(SQ5+3)/2 } };
|
254
|
int[] centerIndices = { 0,0,0,0,0,0,0,0 };
|
255
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
|
256
|
}
|
257
|
else if( variant==1 )
|
258
|
{
|
259
|
float[][] corners = { { 0.013f, 0.16f } };
|
260
|
int[] cornerIndices = { 0, 0, 0, 0,-1, 0, 0, 0 };
|
261
|
float[][] centers = { { 0.0f,-1.0f, -(SQ5+3)/2 } };
|
262
|
int[] centerIndices = { 0,0,0,0,0,0,0,0 };
|
263
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
|
264
|
}
|
265
|
else
|
266
|
{
|
267
|
float[][] corners = { { 0.013f, 0.16f } };
|
268
|
int[] cornerIndices = { 0,0,0,0,0,0,0,0,0,0,-1 };
|
269
|
float[][] centers = { { -(SQ5+1)/4, 0.5f, -(SQ5+5)/4 } };
|
270
|
int[] centerIndices = { 0,0,0,0,0,0,0,0,0,0,0 };
|
271
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
|
272
|
}
|
273
|
}
|
274
|
|
275
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
276
|
|
277
|
public int getNumCubitVariants(int[] numLayers)
|
278
|
{
|
279
|
return 3;
|
280
|
}
|
281
|
|
282
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
283
|
|
284
|
public int getCubitVariant(int cubit, int[] numLayers)
|
285
|
{
|
286
|
return cubit<4 ? 0 : (cubit<8 ? 1:2);
|
287
|
}
|
288
|
|
289
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
290
|
|
291
|
public float[][] getCuts(int[] numLayers)
|
292
|
{
|
293
|
if( mCuts==null )
|
294
|
{
|
295
|
float[] cut = new float[] {0.0f};
|
296
|
mCuts = new float[][] { cut,cut,cut,cut };
|
297
|
}
|
298
|
|
299
|
return mCuts;
|
300
|
}
|
301
|
|
302
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
303
|
|
304
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
305
|
{
|
306
|
boolean[] tmp = new boolean[] {true,true};
|
307
|
return new boolean[][] { tmp,tmp,tmp,tmp };
|
308
|
}
|
309
|
|
310
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
311
|
|
312
|
public int getTouchControlType()
|
313
|
{
|
314
|
return TC_DODECAHEDRON;
|
315
|
}
|
316
|
|
317
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
318
|
|
319
|
public int getTouchControlSplit()
|
320
|
{
|
321
|
return TYPE_NOT_SPLIT;
|
322
|
}
|
323
|
|
324
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
325
|
|
326
|
public int[][][] getEnabled()
|
327
|
{
|
328
|
return new int[][][]
|
329
|
{
|
330
|
{{2,3}},{{1,3}},{{1,3}},{{2,3}},{{0,3}},{{0,2}},{{0,2}},{{0,3}},{{1,2}},{{0,1}},{{0,1}},{{1,2}}
|
331
|
};
|
332
|
}
|
333
|
|
334
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
335
|
|
336
|
public float[] getDist3D(int[] numLayers)
|
337
|
{
|
338
|
return TouchControlDodecahedron.D3D;
|
339
|
}
|
340
|
|
341
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
342
|
|
343
|
public Static3D[] getFaceAxis()
|
344
|
{
|
345
|
return TouchControlDodecahedron.FACE_AXIS;
|
346
|
}
|
347
|
|
348
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
349
|
|
350
|
public float getStickerRadius()
|
351
|
{
|
352
|
return 0.18f;
|
353
|
}
|
354
|
|
355
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
356
|
|
357
|
public float getStickerStroke()
|
358
|
{
|
359
|
return isInIconMode() ? 0.22f : 0.15f;
|
360
|
}
|
361
|
|
362
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
363
|
|
364
|
public float[][][] getStickerAngles()
|
365
|
{
|
366
|
return null;
|
367
|
}
|
368
|
|
369
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
370
|
// PUBLIC API
|
371
|
|
372
|
public Static3D[] getRotationAxis()
|
373
|
{
|
374
|
return ROT_AXIS;
|
375
|
}
|
376
|
|
377
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
378
|
|
379
|
public int[][] getBasicAngles()
|
380
|
{
|
381
|
if( mBasicAngle ==null )
|
382
|
{
|
383
|
int num = getNumLayers()[0];
|
384
|
int[] tmp = new int[num];
|
385
|
for(int i=0; i<num; i++) tmp[i] = 3;
|
386
|
mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
|
387
|
}
|
388
|
|
389
|
return mBasicAngle;
|
390
|
}
|
391
|
|
392
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
393
|
|
394
|
public String getShortName()
|
395
|
{
|
396
|
return ListObjects.ULTI_2.name();
|
397
|
}
|
398
|
|
399
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
400
|
|
401
|
public String[][] getTutorials()
|
402
|
{
|
403
|
return new String[][]{
|
404
|
{"gb","n1ikPKZxGEo","Ultimate Skewb Tutorial","BeardedCubing"},
|
405
|
{"es","wNL1WJ_sCfs","Resolver Skewb ULTIMATE","Cuby"},
|
406
|
{"ru","ifkM8Rr3Y8E","Как собрать Скьюб Ультимейт","Алексей Ярыгин"},
|
407
|
{"fr","r_eoNcejdrA","Résoudre le Skewb Ultimate","ValentinoCube"},
|
408
|
{"de","16ioOywTVvI","Skewb Ultimate - Tutorial","GerCubing"},
|
409
|
{"pl","8MsyPs1VB8U","Ultimate skewb TUTORIAL PL","MrUK"},
|
410
|
{"kr","VOt9_K48c0k","스큐브 얼티미트 공식","노케빈"},
|
411
|
{"vn","VOt9_K48c0k","Tutorial N.147 - Skewb Ultimate","Duy Thích Rubik"},
|
412
|
};
|
413
|
}
|
414
|
}
|