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