1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2020 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_HEXAHEDRON;
|
13
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_SPLIT_CORNER;
|
14
|
|
15
|
import org.distorted.library.type.Static3D;
|
16
|
import org.distorted.library.type.Static4D;
|
17
|
import org.distorted.objectlib.helpers.FactoryCubit;
|
18
|
import org.distorted.objectlib.helpers.ObjectFaceShape;
|
19
|
import org.distorted.objectlib.helpers.ObjectShape;
|
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.InitData;
|
24
|
import org.distorted.objectlib.main.ObjectSignatures;
|
25
|
import org.distorted.objectlib.main.ObjectType;
|
26
|
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator;
|
27
|
import org.distorted.objectlib.shape.ShapeHexahedron;
|
28
|
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
|
29
|
|
30
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
31
|
|
32
|
public class TwistyTins extends ShapeHexahedron
|
33
|
{
|
34
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
35
|
{
|
36
|
new Static3D( SQ3/3, SQ3/3, SQ3/3),
|
37
|
new Static3D( SQ3/3, SQ3/3,-SQ3/3),
|
38
|
new Static3D( SQ3/3,-SQ3/3, SQ3/3),
|
39
|
new Static3D( SQ3/3,-SQ3/3,-SQ3/3)
|
40
|
};
|
41
|
|
42
|
private int[][] mEdges;
|
43
|
private int[][] mBasicAngle;
|
44
|
private float[][] mCuts;
|
45
|
private float[][] mPosition;
|
46
|
private int[] mQuatIndex;
|
47
|
|
48
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
49
|
|
50
|
public TwistyTins(int meshState, int iconMode, Static4D quat, Static3D move, float scale, InitData data, InitAssets asset)
|
51
|
{
|
52
|
super(meshState, iconMode, 4, quat, move, scale, data, asset);
|
53
|
}
|
54
|
|
55
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
56
|
|
57
|
public int[][] getScrambleEdges()
|
58
|
{
|
59
|
if( mEdges==null ) mEdges = ScrambleEdgeGenerator.getScrambleEdgesSingle(mBasicAngle);
|
60
|
return mEdges;
|
61
|
}
|
62
|
|
63
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
64
|
|
65
|
public float[][] getCuts(int[] numLayers)
|
66
|
{
|
67
|
if( mCuts==null )
|
68
|
{
|
69
|
float C1 = -4*SQ3/3;
|
70
|
float C2 = -2*SQ3/3;
|
71
|
float C3 = 2*SQ3/3;
|
72
|
float C4 = SQ3+0.01f;
|
73
|
|
74
|
float[] cut1 = new float[] { C1, C2, C3, C4 };
|
75
|
float[] cut2 = new float[] {-C4,-C3,-C2,-C1 };
|
76
|
|
77
|
mCuts = new float[][] { cut1,cut2,cut2,cut1 };
|
78
|
}
|
79
|
|
80
|
return mCuts;
|
81
|
}
|
82
|
|
83
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
84
|
|
85
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
86
|
{
|
87
|
boolean[] tmp = new boolean[] {true,true,false,true,true};
|
88
|
return new boolean[][] { tmp,tmp,tmp,tmp };
|
89
|
}
|
90
|
|
91
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
92
|
|
93
|
public int getTouchControlType()
|
94
|
{
|
95
|
return TC_HEXAHEDRON;
|
96
|
}
|
97
|
|
98
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
99
|
|
100
|
public int getTouchControlSplit()
|
101
|
{
|
102
|
return TYPE_SPLIT_CORNER;
|
103
|
}
|
104
|
|
105
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
106
|
|
107
|
public int[][][] getEnabled()
|
108
|
{
|
109
|
return new int[][][]
|
110
|
{
|
111
|
{{0,1},{3,1},{2,3},{0,2}},
|
112
|
{{2,3},{3,1},{0,1},{0,2}},
|
113
|
{{1,2},{0,1},{0,3},{2,3}},
|
114
|
{{1,2},{2,3},{0,3},{0,1}},
|
115
|
{{0,3},{0,2},{1,2},{1,3}},
|
116
|
{{1,2},{0,2},{0,3},{1,3}},
|
117
|
};
|
118
|
}
|
119
|
|
120
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
121
|
|
122
|
public float[] getDist3D(int[] numLayers)
|
123
|
{
|
124
|
return TouchControlHexahedron.D3D;
|
125
|
}
|
126
|
|
127
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
128
|
|
129
|
public Static3D[] getFaceAxis()
|
130
|
{
|
131
|
return TouchControlHexahedron.FACE_AXIS;
|
132
|
}
|
133
|
|
134
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
135
|
// corner cubes, corner 'dino' , edges, centers.
|
136
|
|
137
|
public float[][] getCubitPositions(int[] numLayers)
|
138
|
{
|
139
|
if( mPosition==null )
|
140
|
{
|
141
|
float C1 = 1.5f;
|
142
|
float C2 = 1.0f;
|
143
|
float C3 = 2.0f;
|
144
|
float C4 = 0.5f;
|
145
|
float C5 = 0.25f;
|
146
|
float C6 = 0.75f;
|
147
|
|
148
|
mPosition = new float[][]
|
149
|
{
|
150
|
{ C1, C1, C1},
|
151
|
{-C1, C1,-C1},
|
152
|
{ C1,-C1,-C1},
|
153
|
{-C1,-C1, C1},
|
154
|
|
155
|
{-C2, C3, C3},
|
156
|
{-C3, C2, C3},
|
157
|
{-C3, C3, C2},
|
158
|
{ C2, C3,-C3},
|
159
|
{ C3, C2,-C3},
|
160
|
{ C3, C3,-C2},
|
161
|
{ C2,-C3, C3},
|
162
|
{ C3,-C2, C3},
|
163
|
{ C3,-C3, C2},
|
164
|
{-C2,-C3,-C3},
|
165
|
{-C3,-C2,-C3},
|
166
|
{-C3,-C3,-C2},
|
167
|
|
168
|
{ C4, C3, C3},
|
169
|
{ C3, C4, C3},
|
170
|
{-C4,-C3, C3},
|
171
|
{-C3,-C4, C3},
|
172
|
{ C3, C3, C4},
|
173
|
{ C3,-C3,-C4},
|
174
|
{-C3,-C3, C4},
|
175
|
{-C3, C3,-C4},
|
176
|
{-C4, C3,-C3},
|
177
|
{ C3,-C4,-C3},
|
178
|
{ C4,-C3,-C3},
|
179
|
{-C3, C4,-C3},
|
180
|
|
181
|
{-C5, C6, C3}, // F
|
182
|
{ C5,-C6, C3},
|
183
|
{ C5, C6,-C3}, // B
|
184
|
{-C5,-C6,-C3},
|
185
|
{ C3, C5,-C6}, // R
|
186
|
{ C3,-C5, C6},
|
187
|
{-C3,-C5,-C6}, // L
|
188
|
{-C3, C5, C6},
|
189
|
{-C6, C3, C5}, // T
|
190
|
{ C6, C3,-C5},
|
191
|
{-C6,-C3,-C5}, // D
|
192
|
{ C6,-C3, C5},
|
193
|
|
194
|
{ C6,-C5, C3},
|
195
|
{-C6, C5, C3},
|
196
|
{-C6,-C5,-C3},
|
197
|
{ C6, C5,-C3},
|
198
|
{ C3,-C6, C5},
|
199
|
{ C3, C6,-C5},
|
200
|
{-C3, C6, C5},
|
201
|
{-C3,-C6,-C5},
|
202
|
{ C5, C3,-C6},
|
203
|
{-C5, C3, C6},
|
204
|
{ C5,-C3, C6},
|
205
|
{-C5,-C3,-C6},
|
206
|
};
|
207
|
}
|
208
|
|
209
|
return mPosition;
|
210
|
}
|
211
|
|
212
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
213
|
|
214
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
215
|
{
|
216
|
if( mQuatIndex==null ) mQuatIndex = new int[] { 0, 3, 4, 6,
|
217
|
0, 8, 7,11, 5, 1,10, 2, 4, 9, 3, 6,
|
218
|
0, 2,10, 8, 1, 4, 6, 7,11, 5, 9, 3,
|
219
|
0,10,11, 9, 5, 2, 3, 8, 7, 1, 6, 4,
|
220
|
0,10,11, 9, 5, 2, 3, 8, 7, 1, 6, 4,
|
221
|
};
|
222
|
return mObjectQuats[mQuatIndex[cubit]];
|
223
|
}
|
224
|
|
225
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
226
|
|
227
|
private float[][] getVertices(int variant)
|
228
|
{
|
229
|
if( variant==0 )
|
230
|
{
|
231
|
return new float[][]
|
232
|
{
|
233
|
{ 0.0f, 0.0f, 0.0f },
|
234
|
{-0.5f, 0.5f, 0.5f },
|
235
|
{-0.5f,-0.5f, 0.5f },
|
236
|
{ 0.5f, 0.5f, 0.5f },
|
237
|
{ 0.5f,-0.5f, 0.5f },
|
238
|
{ 0.5f, 0.5f,-0.5f },
|
239
|
{ 0.5f,-0.5f,-0.5f },
|
240
|
{-0.5f, 0.5f,-0.5f },
|
241
|
};
|
242
|
}
|
243
|
else if( variant==1 )
|
244
|
{
|
245
|
return new float[][]
|
246
|
{
|
247
|
{-1.0f, 0.0f, 0.0f},
|
248
|
{ 1.0f, 0.0f, 0.0f},
|
249
|
{ 0.0f,-1.0f, 0.0f},
|
250
|
{ 0.0f, 0.0f,-1.0f}
|
251
|
};
|
252
|
}
|
253
|
else if( variant==2 )
|
254
|
{
|
255
|
return new float[][]
|
256
|
{
|
257
|
{-0.5f, 0.0f, 0.0f},
|
258
|
{ 0.5f, 0.0f, 0.0f},
|
259
|
{ 0.5f,-1.0f, 0.0f},
|
260
|
{ 0.0f,-1.5f, 0.0f},
|
261
|
{-1.0f,-0.5f, 0.0f},
|
262
|
{-1.0f, 0.0f,-0.5f},
|
263
|
{ 0.0f, 0.0f,-1.5f},
|
264
|
{ 0.5f, 0.0f,-1.0f}
|
265
|
};
|
266
|
}
|
267
|
else if( variant==3 )
|
268
|
{
|
269
|
return new float[][]
|
270
|
{
|
271
|
{-0.25f, 0.75f, 0.00f},
|
272
|
{ 0.75f,-0.25f, 0.00f},
|
273
|
{ 0.25f,-0.75f, 0.00f},
|
274
|
{-0.75f, 0.25f, 0.00f},
|
275
|
{-0.25f, 1.00f,-0.25f},
|
276
|
{ 0.75f, 0.50f,-0.75f},
|
277
|
{ 0.25f, 0.25f,-1.00f},
|
278
|
{-0.75f, 0.75f,-0.50f}
|
279
|
};
|
280
|
}
|
281
|
else
|
282
|
{
|
283
|
return new float[][]
|
284
|
{
|
285
|
{-0.25f, 0.75f, 0.00f},
|
286
|
{ 0.75f,-0.25f, 0.00f},
|
287
|
{ 0.25f,-0.75f, 0.00f},
|
288
|
{-0.75f, 0.25f, 0.00f},
|
289
|
{ 0.50f, 0.75f,-0.75f},
|
290
|
{ 1.00f,-0.25f,-0.25f},
|
291
|
{ 0.75f,-0.75f,-0.50f},
|
292
|
{ 0.25f, 0.25f,-1.00f}
|
293
|
};
|
294
|
}
|
295
|
}
|
296
|
|
297
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
298
|
|
299
|
public ObjectShape getObjectShape(int variant)
|
300
|
{
|
301
|
if( variant==0 )
|
302
|
{
|
303
|
int[][] indices =
|
304
|
{
|
305
|
{ 2,4,3,1 },
|
306
|
{ 1,3,5,7 },
|
307
|
{ 4,6,5,3 },
|
308
|
{ 0,4,2 },
|
309
|
{ 0,7,5 },
|
310
|
{ 0,6,4 },
|
311
|
{ 0,1,7 },
|
312
|
{ 0,2,1 },
|
313
|
{ 0,5,6 }
|
314
|
};
|
315
|
|
316
|
return new ObjectShape(getVertices(variant), indices);
|
317
|
}
|
318
|
else if( variant==1 )
|
319
|
{
|
320
|
int[][] indices =
|
321
|
{
|
322
|
{2,1,0},
|
323
|
{3,0,1},
|
324
|
{2,3,1},
|
325
|
{3,2,0}
|
326
|
};
|
327
|
|
328
|
return new ObjectShape(getVertices(variant), indices);
|
329
|
}
|
330
|
else if( variant==2 )
|
331
|
{
|
332
|
int[][] indices =
|
333
|
{
|
334
|
{4,3,2,1,0},
|
335
|
{0,1,7,6,5},
|
336
|
{1,2,7},
|
337
|
{2,3,6,7},
|
338
|
{3,4,5,6},
|
339
|
{0,5,4}
|
340
|
};
|
341
|
|
342
|
return new ObjectShape(getVertices(variant), indices);
|
343
|
}
|
344
|
else
|
345
|
{
|
346
|
int[][] indices =
|
347
|
{
|
348
|
{3,2,1,0},
|
349
|
{6,5,1,2},
|
350
|
{5,4,0,1},
|
351
|
{4,7,3,0},
|
352
|
{7,6,2,3},
|
353
|
{4,5,6,7}
|
354
|
};
|
355
|
|
356
|
return new ObjectShape(getVertices(variant), indices);
|
357
|
}
|
358
|
}
|
359
|
|
360
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
361
|
|
362
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
363
|
{
|
364
|
if( variant==0 )
|
365
|
{
|
366
|
float h1 = isInIconMode() ? 0.001f : 0.06f;
|
367
|
float h2 = isInIconMode() ? 0.001f : 0.01f;
|
368
|
float[][] bands = { {h1,35,0.5f,0.7f,5,1,0}, {h2,35,0.2f,0.4f,5,1,0} };
|
369
|
int[] indices = { 0,0,0,1,1,1,1,1,1 };
|
370
|
return new ObjectFaceShape(bands,indices,null);
|
371
|
}
|
372
|
else if( variant==1 )
|
373
|
{
|
374
|
float h1 = isInIconMode() ? 0.001f : 0.035f;
|
375
|
float h2 = isInIconMode() ? 0.001f : 0.010f;
|
376
|
float[][] bands = { {h1,30,0.16f,0.8f,5,0,0}, {h2,30,0.16f,0.2f,5,0,0} };
|
377
|
int[] bandIndices= { 0,0,1,1 };
|
378
|
return new ObjectFaceShape(bands,bandIndices,null);
|
379
|
}
|
380
|
else if( variant==2 )
|
381
|
{
|
382
|
float h1 = isInIconMode() ? 0.001f : 0.035f;
|
383
|
float h2 = isInIconMode() ? 0.001f : 0.010f;
|
384
|
float[][] bands = { {h1,30,0.16f,0.8f,5,1,0}, {h2,30,0.16f,0.2f,5,0,0} };
|
385
|
int[] bandIndices= { 0,0,1,1,1,1 };
|
386
|
return new ObjectFaceShape(bands,bandIndices,null);
|
387
|
}
|
388
|
else
|
389
|
{
|
390
|
float h1 = isInIconMode() ? 0.001f : 0.040f;
|
391
|
float h2 = isInIconMode() ? 0.001f : 0.002f;
|
392
|
float[][] bands = { {h1,30,0.3f,0.5f,5,0,0}, {h2,30,0.1f,0.2f,3,0,0} };
|
393
|
int[] bandIndices= { 0,1,1,1,1,1,1,1 };
|
394
|
return new ObjectFaceShape(bands,bandIndices,null);
|
395
|
}
|
396
|
}
|
397
|
|
398
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
399
|
|
400
|
public ObjectVertexEffects getVertexEffects(int variant)
|
401
|
{
|
402
|
if( variant==0 )
|
403
|
{
|
404
|
float[][] corners = { {0.06f,0.12f} };
|
405
|
int[] indices = { -1,0,-1,0,0,0,-1,-1 };
|
406
|
float[][] centers = { { 0.0f, 0.0f, 0.0f} };
|
407
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
|
408
|
}
|
409
|
else if( variant==1 )
|
410
|
{
|
411
|
float[][] corners = { {0.05f,0.30f}, {0.05f,0.20f} };
|
412
|
int[] cornerIndices = { 0,0,1,1 };
|
413
|
float[][] centers = { {0.0f, -0.75f, -0.75f} };
|
414
|
int[] centerIndices = { 0,0,0,0 };
|
415
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
|
416
|
}
|
417
|
else if( variant==2 )
|
418
|
{
|
419
|
float[][] corners = { {0.05f,0.20f}, {0.05f,0.15f} };
|
420
|
int[] cornerIndices = { 0,0,1,1,1,1,1,1 };
|
421
|
float[][] centers = { {0.0f, -0.5f, -0.5f} };
|
422
|
int[] centerIndices = { 0,0,0,0,0,0,0,0 };
|
423
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
|
424
|
}
|
425
|
else
|
426
|
{
|
427
|
return null;
|
428
|
}
|
429
|
}
|
430
|
|
431
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
432
|
|
433
|
public int getNumCubitVariants(int[] numLayers)
|
434
|
{
|
435
|
return 5;
|
436
|
}
|
437
|
|
438
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
439
|
|
440
|
public int getCubitVariant(int cubit, int[] numLayers)
|
441
|
{
|
442
|
return cubit<4 ? 0: (cubit<16 ? 1: (cubit<28 ? 2: (cubit<40 ? 3:4)));
|
443
|
}
|
444
|
|
445
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
446
|
|
447
|
public float getStickerRadius()
|
448
|
{
|
449
|
return 0.09f;
|
450
|
}
|
451
|
|
452
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
453
|
|
454
|
public float getStickerStroke()
|
455
|
{
|
456
|
return isInIconMode() ? 0.20f : 0.09f;
|
457
|
}
|
458
|
|
459
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
460
|
|
461
|
public float[][] getStickerAngles()
|
462
|
{
|
463
|
return null;
|
464
|
}
|
465
|
|
466
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
467
|
// PUBLIC API
|
468
|
|
469
|
public Static3D[] getRotationAxis()
|
470
|
{
|
471
|
return ROT_AXIS;
|
472
|
}
|
473
|
|
474
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
475
|
|
476
|
public int[][] getBasicAngles()
|
477
|
{
|
478
|
if( mBasicAngle ==null )
|
479
|
{
|
480
|
int[] tmp = {3,3,3,3,3};
|
481
|
mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
|
482
|
}
|
483
|
|
484
|
return mBasicAngle;
|
485
|
}
|
486
|
|
487
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
488
|
|
489
|
public String getShortName()
|
490
|
{
|
491
|
return ObjectType.TINS_5.name();
|
492
|
}
|
493
|
|
494
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
495
|
|
496
|
public ObjectSignature getSignature()
|
497
|
{
|
498
|
return new ObjectSignature(ObjectSignatures.TINS_5);
|
499
|
}
|
500
|
|
501
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
502
|
|
503
|
public String getObjectName()
|
504
|
{
|
505
|
return "Tins Cube";
|
506
|
}
|
507
|
|
508
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
509
|
|
510
|
public String getInventor()
|
511
|
{
|
512
|
return "조현준";
|
513
|
}
|
514
|
|
515
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
516
|
|
517
|
public int getYearOfInvention()
|
518
|
{
|
519
|
return 2021;
|
520
|
}
|
521
|
|
522
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
523
|
|
524
|
public int getComplexity()
|
525
|
{
|
526
|
return 2;
|
527
|
}
|
528
|
|
529
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
530
|
|
531
|
public String[][] getTutorials()
|
532
|
{
|
533
|
return null;
|
534
|
}
|
535
|
}
|