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