1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2021 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_TETRAHEDRON;
|
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.helpers.ObjectSignature;
|
21
|
import org.distorted.objectlib.helpers.ObjectVertexEffects;
|
22
|
import org.distorted.objectlib.main.InitAssets;
|
23
|
import org.distorted.objectlib.main.ObjectSignatures;
|
24
|
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator;
|
25
|
import org.distorted.objectlib.main.InitData;
|
26
|
import org.distorted.objectlib.touchcontrol.TouchControlTetrahedron;
|
27
|
import org.distorted.objectlib.main.ObjectType;
|
28
|
import org.distorted.objectlib.helpers.ObjectShape;
|
29
|
import org.distorted.objectlib.shape.ShapeTetrahedron;
|
30
|
|
31
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
32
|
|
33
|
public class TwistyJing extends ShapeTetrahedron
|
34
|
{
|
35
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
36
|
{
|
37
|
new Static3D( 0,-SQ3/3,-SQ6/3),
|
38
|
new Static3D( 0,-SQ3/3, SQ6/3),
|
39
|
new Static3D( SQ6/3, SQ3/3, 0),
|
40
|
new Static3D(-SQ6/3, SQ3/3, 0),
|
41
|
};
|
42
|
|
43
|
public static final float F = 0.48f; // length of the edge of the corner cubit. Keep<0.5
|
44
|
// Assuming the length of the edge of the whole
|
45
|
// tetrahedron is 2.0 (ie standard, equal to numLayers)
|
46
|
|
47
|
private int[][] mEdges;
|
48
|
private int[][] mBasicAngle;
|
49
|
private int[] mQuatIndex;
|
50
|
private float[][] mCuts;
|
51
|
private float[][] mCenters;
|
52
|
|
53
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
54
|
|
55
|
public TwistyJing(int meshState, int iconMode, Static4D quat, Static3D move, float scale, InitData data, InitAssets asset)
|
56
|
{
|
57
|
super(meshState, iconMode, data.getNumLayers()[0], quat, move, scale, data, asset);
|
58
|
}
|
59
|
|
60
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
61
|
|
62
|
@Override
|
63
|
public float getPillowCoeff()
|
64
|
{
|
65
|
return 1.25f;
|
66
|
}
|
67
|
|
68
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
69
|
|
70
|
public int[][] getScrambleEdges()
|
71
|
{
|
72
|
if( mEdges==null ) mEdges = ScrambleEdgeGenerator.getScrambleEdgesSingle(mBasicAngle);
|
73
|
return mEdges;
|
74
|
}
|
75
|
|
76
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
77
|
|
78
|
public float[][] getCuts(int[] numLayers)
|
79
|
{
|
80
|
if( mCuts==null )
|
81
|
{
|
82
|
float[] cut = { (F-0.5f)*(SQ6/3) };
|
83
|
mCuts = new float[][] { cut,cut,cut,cut };
|
84
|
}
|
85
|
|
86
|
return mCuts;
|
87
|
}
|
88
|
|
89
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
90
|
|
91
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
92
|
{
|
93
|
boolean[] tmp = {true,true};
|
94
|
return new boolean[][] { tmp,tmp,tmp,tmp };
|
95
|
}
|
96
|
|
97
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
98
|
|
99
|
public int getTouchControlType()
|
100
|
{
|
101
|
return TC_TETRAHEDRON;
|
102
|
}
|
103
|
|
104
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
105
|
|
106
|
public int getTouchControlSplit()
|
107
|
{
|
108
|
return TYPE_NOT_SPLIT;
|
109
|
}
|
110
|
|
111
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
112
|
|
113
|
public int[][][] getEnabled()
|
114
|
{
|
115
|
return new int[][][] { {{1,2,3}},{{0,2,3}},{{0,1,3}},{{0,1,2}} };
|
116
|
}
|
117
|
|
118
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
119
|
|
120
|
public float[] getDist3D(int[] numLayers)
|
121
|
{
|
122
|
return TouchControlTetrahedron.D3D;
|
123
|
}
|
124
|
|
125
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
126
|
|
127
|
public Static3D[] getFaceAxis()
|
128
|
{
|
129
|
return TouchControlTetrahedron.FACE_AXIS;
|
130
|
}
|
131
|
|
132
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
133
|
|
134
|
public float[][] getCubitPositions(int[] numLayers)
|
135
|
{
|
136
|
if( mCenters==null )
|
137
|
{
|
138
|
mCenters = new float[][]
|
139
|
{
|
140
|
{ 0.000f, -SQ2/2, 1.000f },
|
141
|
{ 0.000f, -SQ2/2,-1.000f },
|
142
|
{-1.000f, SQ2/2, 0.000f },
|
143
|
{ 1.000f, SQ2/2, 0.000f },
|
144
|
|
145
|
{ 0.000f, -SQ2/2, 0.000f },
|
146
|
{-0.500f, 0.000f, 0.500f },
|
147
|
{ 0.500f, 0.000f, 0.500f },
|
148
|
{-0.500f, 0.000f,-0.500f },
|
149
|
{ 0.500f, 0.000f,-0.500f },
|
150
|
{ 0.000f, SQ2/2, 0.000f },
|
151
|
|
152
|
{ 0.000f, SQ2/6, 1.0f/3 },
|
153
|
{ 0.000f, SQ2/6,-1.0f/3 },
|
154
|
{-1.0f/3, -SQ2/6, 0.000f },
|
155
|
{ 1.0f/3, -SQ2/6, 0.000f },
|
156
|
};
|
157
|
}
|
158
|
|
159
|
return mCenters;
|
160
|
}
|
161
|
|
162
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
163
|
|
164
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
165
|
{
|
166
|
if( mQuatIndex==null ) mQuatIndex = new int[] {0,10,5,8,
|
167
|
0,5,8,6,7,9,
|
168
|
0,10,7,3};
|
169
|
return mObjectQuats[mQuatIndex[cubit]];
|
170
|
}
|
171
|
|
172
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
173
|
|
174
|
private float[][] getVertices(int variant)
|
175
|
{
|
176
|
final float X = F/2;
|
177
|
final float Y = F*SQ2/2;
|
178
|
final float Z =-F/2;
|
179
|
final float L = (2.0f-3*F);
|
180
|
final float X2= L/2;
|
181
|
final float Y2= L*SQ2/2;
|
182
|
final float Z2=-L/2;
|
183
|
final float D = F/L;
|
184
|
final float G = 1.0f-F;
|
185
|
|
186
|
if( variant==0 )
|
187
|
{
|
188
|
return new float[][]
|
189
|
{
|
190
|
{ 0, 0, 0 },
|
191
|
{ X, Y, Z },
|
192
|
{ 0, 2*Y, 2*Z },
|
193
|
{ -X, Y, Z },
|
194
|
{ 0, 0, -F },
|
195
|
{ X, Y, Z-F },
|
196
|
{ 0, 2*Y, 2*Z-F },
|
197
|
{ -X, Y, Z-F },
|
198
|
};
|
199
|
}
|
200
|
else if( variant==1 )
|
201
|
{
|
202
|
return new float[][]
|
203
|
{
|
204
|
{ 0, 0, G },
|
205
|
{ X, Y, Z+G },
|
206
|
{ 0, 2*Y, 2*Z+G },
|
207
|
{ -X, Y, Z+G },
|
208
|
{ 0, 0, -G },
|
209
|
{ X, Y, -Z-G },
|
210
|
{ 0, 2*Y,-2*Z-G },
|
211
|
{ -X, Y, -Z-G },
|
212
|
};
|
213
|
}
|
214
|
else
|
215
|
{
|
216
|
return new float[][]
|
217
|
{
|
218
|
{ 0, -2*Y2/3, -2*Z2/3 },
|
219
|
{ X2, Y2/3, Z2/3 },
|
220
|
{ -X2, Y2/3, Z2/3 },
|
221
|
{ 0, -2*Y2/3,-2*Z2/3+2*D*Z2 },
|
222
|
{ X2-D*X2, Y2/3-D*Y2, Z2/3+D*Z2 },
|
223
|
{ -X2+D*X2, Y2/3-D*Y2, Z2/3+D*Z2 },
|
224
|
};
|
225
|
}
|
226
|
}
|
227
|
|
228
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
229
|
|
230
|
public ObjectShape getObjectShape(int variant)
|
231
|
{
|
232
|
if( variant==0 )
|
233
|
{
|
234
|
int[][] indices =
|
235
|
{
|
236
|
{0,1,2,3},
|
237
|
{1,0,4,5},
|
238
|
{7,4,0,3},
|
239
|
{1,5,6,2},
|
240
|
{7,3,2,6},
|
241
|
{4,7,6,5}
|
242
|
};
|
243
|
|
244
|
return new ObjectShape(getVertices(variant), indices);
|
245
|
}
|
246
|
else if( variant==1 )
|
247
|
{
|
248
|
int[][] indices =
|
249
|
{
|
250
|
{0,4,5,1},
|
251
|
{3,7,4,0},
|
252
|
{0,1,2,3},
|
253
|
{4,7,6,5},
|
254
|
{1,5,6,2},
|
255
|
{2,6,7,3}
|
256
|
};
|
257
|
|
258
|
return new ObjectShape(getVertices(variant), indices);
|
259
|
}
|
260
|
else
|
261
|
{
|
262
|
int[][] indices =
|
263
|
{
|
264
|
{0,1,2},
|
265
|
{3,5,4},
|
266
|
{0,3,4,1},
|
267
|
{5,3,0,2},
|
268
|
{4,5,2,1}
|
269
|
};
|
270
|
|
271
|
return new ObjectShape(getVertices(variant), indices);
|
272
|
}
|
273
|
}
|
274
|
|
275
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
276
|
|
277
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
278
|
{
|
279
|
if( variant==0 )
|
280
|
{
|
281
|
float height = isInIconMode() ? 0.001f : 0.015f;
|
282
|
float[][] bands = { {height,35,0.25f*F,0.5f*F,5,1,1},{0.001f,35,0.25f*F,0.5f*F,5,1,1} };
|
283
|
int[] indices = { 0,0,0,1,1,1 };
|
284
|
return new ObjectFaceShape(bands,indices,null);
|
285
|
}
|
286
|
else if( variant==1 )
|
287
|
{
|
288
|
float height = isInIconMode() ? 0.001f : 0.015f;
|
289
|
float[][] bands = { {height,35,0.2f*F,0.3f*F,7,0,0},{0.001f,35,0.2f*F,0.3f*F,7,0,0} };
|
290
|
int[] indices = { 0,0,1,1,1,1 };
|
291
|
return new ObjectFaceShape(bands,indices,null);
|
292
|
}
|
293
|
else
|
294
|
{
|
295
|
final float L = (2.0f-3*F);
|
296
|
float height = isInIconMode() ? 0.001f : 0.020f;
|
297
|
float[][] bands = { {height,35,0.20f*L,0.6f*L,5,1,1}, {0.001f,35,0.05f*L,0.1f*L,5,1,1} };
|
298
|
int[] indices = { 0,1,1,1,1,1 };
|
299
|
return new ObjectFaceShape(bands,indices,null);
|
300
|
}
|
301
|
}
|
302
|
|
303
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
304
|
|
305
|
public ObjectVertexEffects getVertexEffects(int variant)
|
306
|
{
|
307
|
final float Y = F*SQ2/2;
|
308
|
final float Z =-F/2;
|
309
|
|
310
|
if( variant==0 )
|
311
|
{
|
312
|
float[][] corners = { {0.08f,0.20f*F},{0.07f,0.20f*F} };
|
313
|
int[] cornerIndices = { 0,1,1,-1,1,-1,-1,-1 };
|
314
|
float[][] centers = { { 0.0f, Y, Z-F/2} };
|
315
|
int[] centerIndices = { 0,0,0,-1,0,-1,-1,-1 };
|
316
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
|
317
|
}
|
318
|
else if( variant==1 )
|
319
|
{
|
320
|
float[][] corners = { {0.07f,0.20f*F} };
|
321
|
int[] cornerIndices = { 0,0,-1,0,0,0,-1,0 };
|
322
|
float[][] centers = { { 0, F*SQ2/2, 0 } };
|
323
|
int[] centerIndices = { 0,0,-1,0,0,0,-1,0 };
|
324
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
|
325
|
}
|
326
|
else
|
327
|
{
|
328
|
float[][] corners = { {0.04f,0.6f*F} };
|
329
|
int[] cornerIndices = { 0,0,0,-1,-1,-1 };
|
330
|
float[][] centers = { { 0, -2*Y/3, 4*Z/3 } };
|
331
|
int[] centerIndices = { 0,0,0,-1,-1,-1 };
|
332
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
|
333
|
}
|
334
|
}
|
335
|
|
336
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
337
|
|
338
|
public int getNumCubitVariants(int[] numLayers)
|
339
|
{
|
340
|
return 3;
|
341
|
}
|
342
|
|
343
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
344
|
|
345
|
public int getCubitVariant(int cubit, int[] numLayers)
|
346
|
{
|
347
|
return cubit<4 ? 0 : (cubit<10?1:2);
|
348
|
}
|
349
|
|
350
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
351
|
|
352
|
public float getStickerRadius()
|
353
|
{
|
354
|
return 0.04f;
|
355
|
}
|
356
|
|
357
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
358
|
|
359
|
public float getStickerStroke()
|
360
|
{
|
361
|
return isInIconMode() ? 0.08f : 0.04f;
|
362
|
}
|
363
|
|
364
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
365
|
|
366
|
public float[][] getStickerAngles()
|
367
|
{
|
368
|
return null;
|
369
|
}
|
370
|
|
371
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
372
|
// PUBLIC API
|
373
|
|
374
|
public Static3D[] getRotationAxis()
|
375
|
{
|
376
|
return ROT_AXIS;
|
377
|
}
|
378
|
|
379
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
380
|
|
381
|
public int[][] getBasicAngles()
|
382
|
{
|
383
|
if( mBasicAngle ==null )
|
384
|
{
|
385
|
int num = getNumLayers()[0];
|
386
|
int[] tmp = new int[num];
|
387
|
for(int i=0; i<num; i++) tmp[i] = 3;
|
388
|
mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
|
389
|
}
|
390
|
|
391
|
return mBasicAngle;
|
392
|
}
|
393
|
|
394
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
395
|
|
396
|
public String getShortName()
|
397
|
{
|
398
|
return ObjectType.JING_2.name();
|
399
|
}
|
400
|
|
401
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
402
|
|
403
|
public ObjectSignature getSignature()
|
404
|
{
|
405
|
return new ObjectSignature(ObjectSignatures.JING_2);
|
406
|
}
|
407
|
|
408
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
409
|
|
410
|
public String getObjectName()
|
411
|
{
|
412
|
return "Jing Pyraminx";
|
413
|
}
|
414
|
|
415
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
416
|
|
417
|
public String getInventor()
|
418
|
{
|
419
|
return "Tony Fisher";
|
420
|
}
|
421
|
|
422
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
423
|
|
424
|
public int getYearOfInvention()
|
425
|
{
|
426
|
return 1991;
|
427
|
}
|
428
|
|
429
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
430
|
|
431
|
public int getComplexity()
|
432
|
{
|
433
|
return 1;
|
434
|
}
|
435
|
|
436
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
437
|
|
438
|
public String[][] getTutorials()
|
439
|
{
|
440
|
return new String[][]{
|
441
|
{"gb","0T8Iw6aI2gA","Jing's Pyraminx Tutorial","SuperAntoniovivaldi"},
|
442
|
{"es","Na27_GUIzqY","Resolver Jing Pyraminx","Cuby"},
|
443
|
{"ru","rlQXFzjsyAo","Как собрать Jing's pyraminx","Илья Топор-Гилка"},
|
444
|
{"fr","zC9dGqZRSic","Résolution du Jing's Pyraminx","Asthalis"},
|
445
|
{"de","6ihN4fdHH6o","Jings Pyraminx - Tutorial","GerCubing"},
|
446
|
{"pl","nRYoJAy1c_8","Jing's Pyraminx TUTORIAL PL","MrUK"},
|
447
|
{"vn","yX9KjDpHjws","Tutorial N.50 - Jing's Pyraminx","Duy Thích Rubik"},
|
448
|
};
|
449
|
}
|
450
|
}
|