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