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