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.InitAssets;
|
20
|
import org.distorted.objectlib.main.InitData;
|
21
|
import org.distorted.objectlib.main.ObjectSignatures;
|
22
|
import org.distorted.objectlib.main.ObjectType;
|
23
|
import org.distorted.objectlib.shape.ShapeHexahedron;
|
24
|
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
|
25
|
|
26
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_HEXAHEDRON;
|
27
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
|
28
|
|
29
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
30
|
|
31
|
public class TwistyVoid extends ShapeHexahedron
|
32
|
{
|
33
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
34
|
{
|
35
|
new Static3D(1,0,0),
|
36
|
new Static3D(0,1,0),
|
37
|
new Static3D(0,0,1)
|
38
|
};
|
39
|
|
40
|
private int[][] mEdges;
|
41
|
private int[][] mBasicAngle;
|
42
|
private float[][] mCuts;
|
43
|
private float[][] mPositions;
|
44
|
private int[] mQuatIndex;
|
45
|
|
46
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
47
|
|
48
|
public TwistyVoid(int meshState, int iconMode, Static4D quat, Static3D move, float scale, InitData data, InitAssets asset)
|
49
|
{
|
50
|
super(meshState, iconMode, data.getNumLayers()[0], quat, move, scale, data, asset);
|
51
|
}
|
52
|
|
53
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
54
|
|
55
|
@Override
|
56
|
public void adjustStickerCoords()
|
57
|
{
|
58
|
final float A = 0.497f;
|
59
|
final float B = 0.38950402f;
|
60
|
final float C = 0.25900806f;
|
61
|
final float D = 0.51f;
|
62
|
|
63
|
mStickerCoords = new float[][]
|
64
|
{
|
65
|
{ -0.5f, -0.5f, A, -0.5f, -0.5f, A },
|
66
|
{ -C, -B, D, -B, D, B, -C, B }
|
67
|
};
|
68
|
}
|
69
|
|
70
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
71
|
|
72
|
@Override
|
73
|
public int getInternalColor()
|
74
|
{
|
75
|
return 0xff222222;
|
76
|
}
|
77
|
|
78
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
79
|
// +5 missing - it is the 180 deg rotation of the middle layer which we don't want.
|
80
|
|
81
|
private void insertSection(int[] table, int index, int alg, int state)
|
82
|
{
|
83
|
table[index ] = alg;
|
84
|
table[index+ 1] = state;
|
85
|
table[index+ 2] = alg+1;
|
86
|
table[index+ 3] = state;
|
87
|
table[index+ 4] = alg+2;
|
88
|
table[index+ 5] = state;
|
89
|
table[index+ 6] = alg+3;
|
90
|
table[index+ 7] = state;
|
91
|
table[index+ 8] = alg+4;
|
92
|
table[index+ 9] = state;
|
93
|
table[index+10] = alg+6;
|
94
|
table[index+11] = state;
|
95
|
table[index+12] = alg+7;
|
96
|
table[index+13] = state;
|
97
|
table[index+14] = alg+8;
|
98
|
table[index+15] = state;
|
99
|
}
|
100
|
|
101
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
102
|
|
103
|
private int[] createEdge(int stateX, int stateY, int stateZ)
|
104
|
{
|
105
|
int size= 8;
|
106
|
int num = 0;
|
107
|
if( stateX>=0 ) num += 2*size;
|
108
|
if( stateY>=0 ) num += 2*size;
|
109
|
if( stateZ>=0 ) num += 2*size;
|
110
|
|
111
|
int[] ret = new int[num];
|
112
|
|
113
|
int index = 0;
|
114
|
int alg = 0;
|
115
|
if( stateX>=0 ) { insertSection(ret,index,alg,stateX); index+= (2*size);}
|
116
|
alg += (size+1);
|
117
|
if( stateY>=0 ) { insertSection(ret,index,alg,stateY); index+= (2*size);}
|
118
|
alg += (size+1);
|
119
|
if( stateZ>=0 ) { insertSection(ret,index,alg,stateZ); }
|
120
|
|
121
|
return ret;
|
122
|
}
|
123
|
|
124
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
125
|
// Normal 3x3, but without the 180 deg move of the middle layer.
|
126
|
// We need to rotate the middle layer here (by swiping it is not possible) because otherwise the
|
127
|
// phantom centers would always stay at their initial positions which would defeat the point here.
|
128
|
|
129
|
public int[][] getScrambleEdges()
|
130
|
{
|
131
|
if( mEdges==null )
|
132
|
{
|
133
|
mEdges = new int[][]
|
134
|
{
|
135
|
createEdge( 1, 2, 3), // 0 0
|
136
|
createEdge(-1, 4, 5), // 1 x
|
137
|
createEdge( 6,-1, 7), // 2 y
|
138
|
createEdge( 8, 9,-1), // 3 z
|
139
|
createEdge(10,-1, 7), // 4 xy
|
140
|
createEdge(11, 9,-1), // 5 xz
|
141
|
createEdge(-1,12, 5), // 6 yx
|
142
|
createEdge( 8,13,-1), // 7 yz
|
143
|
createEdge(-1, 4,14), // 8 zx
|
144
|
createEdge( 6,-1,15), // 9 zy
|
145
|
createEdge(-1,-1, 5), // 10 xyx
|
146
|
createEdge(-1, 4,-1), // 11 xzx
|
147
|
createEdge(-1,-1, 7), // 12 yxy
|
148
|
createEdge( 6,-1,-1), // 13 yzy
|
149
|
createEdge(-1, 9,-1), // 14 zxz
|
150
|
createEdge( 8,-1,-1), // 15 zyz
|
151
|
};
|
152
|
}
|
153
|
|
154
|
return mEdges;
|
155
|
}
|
156
|
|
157
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
158
|
|
159
|
public float[][] getCuts(int[] numLayers)
|
160
|
{
|
161
|
if( mCuts==null )
|
162
|
{
|
163
|
float C = 0.5f;
|
164
|
float[] cut = new float[] {-C,+C};
|
165
|
mCuts = new float[][] { cut,cut,cut };
|
166
|
}
|
167
|
|
168
|
return mCuts;
|
169
|
}
|
170
|
|
171
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
172
|
|
173
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
174
|
{
|
175
|
boolean[] tmp = new boolean[] {true,false,true};
|
176
|
return new boolean[][] { tmp,tmp,tmp };
|
177
|
}
|
178
|
|
179
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
180
|
|
181
|
public int getTouchControlType()
|
182
|
{
|
183
|
return TC_HEXAHEDRON;
|
184
|
}
|
185
|
|
186
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
187
|
|
188
|
public int getTouchControlSplit()
|
189
|
{
|
190
|
return TYPE_NOT_SPLIT;
|
191
|
}
|
192
|
|
193
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
194
|
|
195
|
public int[][][] getEnabled()
|
196
|
{
|
197
|
return new int[][][] { {{1,2}},{{1,2}},{{0,2}},{{0,2}},{{0,1}},{{0,1}} };
|
198
|
}
|
199
|
|
200
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
201
|
|
202
|
public float[] getDist3D(int[] numLayers)
|
203
|
{
|
204
|
return TouchControlHexahedron.D3D;
|
205
|
}
|
206
|
|
207
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
208
|
|
209
|
public Static3D[] getFaceAxis()
|
210
|
{
|
211
|
return TouchControlHexahedron.FACE_AXIS;
|
212
|
}
|
213
|
|
214
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
215
|
|
216
|
public float[][] getCubitPositions(int[] numLayers)
|
217
|
{
|
218
|
if( mPositions==null )
|
219
|
{
|
220
|
mPositions = new float[][]
|
221
|
{
|
222
|
{ 1.0f, 1.0f, 1.0f},
|
223
|
{ 1.0f, 1.0f,-1.0f},
|
224
|
{ 1.0f,-1.0f, 1.0f},
|
225
|
{ 1.0f,-1.0f,-1.0f},
|
226
|
{-1.0f, 1.0f, 1.0f},
|
227
|
{-1.0f, 1.0f,-1.0f},
|
228
|
{-1.0f,-1.0f, 1.0f},
|
229
|
{-1.0f,-1.0f,-1.0f},
|
230
|
|
231
|
{ 1.0f, 1.0f, 0.0f},
|
232
|
{ 1.0f,-1.0f, 0.0f},
|
233
|
{ 1.0f, 0.0f, 1.0f},
|
234
|
{ 1.0f, 0.0f,-1.0f},
|
235
|
{-1.0f, 1.0f, 0.0f},
|
236
|
{-1.0f,-1.0f, 0.0f},
|
237
|
{-1.0f, 0.0f, 1.0f},
|
238
|
{-1.0f, 0.0f,-1.0f},
|
239
|
{ 0.0f, 1.0f, 1.0f},
|
240
|
{ 0.0f, 1.0f,-1.0f},
|
241
|
{ 0.0f,-1.0f, 1.0f},
|
242
|
{ 0.0f,-1.0f,-1.0f},
|
243
|
};
|
244
|
}
|
245
|
|
246
|
return mPositions;
|
247
|
}
|
248
|
|
249
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
250
|
|
251
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
252
|
{
|
253
|
if( mQuatIndex==null ) mQuatIndex = new int[] {0,1,17,22,4,5,8,19, 1,3,0,2,10,11,4,5,9,15,7,19 };
|
254
|
return mObjectQuats[mQuatIndex[cubit]];
|
255
|
}
|
256
|
|
257
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
258
|
|
259
|
private float[][] getVertices(int variant)
|
260
|
{
|
261
|
if( variant==0 )
|
262
|
{
|
263
|
final float X = 0.3f;
|
264
|
final double A = 54*Math.PI/180;
|
265
|
final float COS = (float)Math.cos(A);
|
266
|
final float SIN = (float)Math.sin(A);
|
267
|
|
268
|
return new float[][]
|
269
|
{
|
270
|
{ -0.5f, -0.5f, -0.5f },
|
271
|
{ -0.5f, -0.5f, +0.5f },
|
272
|
{ -0.5f, +0.5f, -0.5f },
|
273
|
{ +0.5f, -0.5f, -0.5f },
|
274
|
{ +0.5f, +0.5f, -0.5f },
|
275
|
{ +0.5f, -0.5f, +0.5f },
|
276
|
{ -0.5f, +0.5f, +0.5f },
|
277
|
{ +0.5f, +0.5f, -0.5f+X },
|
278
|
{ +0.5f, -0.5f+X, +0.5f },
|
279
|
{ -0.5f+X, +0.5f, +0.5f },
|
280
|
{ SIN-0.5f, 0.5f, COS-0.5f },
|
281
|
{ COS-0.5f, 0.5f, SIN-0.5f },
|
282
|
{ COS-0.5f, SIN-0.5f, 0.5f },
|
283
|
{ SIN-0.5f, COS-0.5f, 0.5f },
|
284
|
{ 0.5f, COS-0.5f, SIN-0.5f },
|
285
|
{ 0.5f, SIN-0.5f, COS-0.5f },
|
286
|
};
|
287
|
}
|
288
|
else
|
289
|
{
|
290
|
final float A = 0.13f;
|
291
|
final float B = 0.18f;
|
292
|
final float C = 0.52f;
|
293
|
|
294
|
return new float[][]
|
295
|
{
|
296
|
{ C, 0.5f, C},
|
297
|
{ 0.5f, 0.5f,-0.5f},
|
298
|
{ C,-0.5f, C},
|
299
|
{ 0.5f,-0.5f,-0.5f},
|
300
|
{-0.5f, 0.5f, 0.5f},
|
301
|
{-0.5f, 0.5f,-0.5f},
|
302
|
{-0.5f,-0.5f, 0.5f},
|
303
|
{-0.5f,-0.5f,-0.5f},
|
304
|
|
305
|
{-0.5f+A, 0.25f, 0.5f},
|
306
|
{-0.5f+B, 0.00f, 0.5f},
|
307
|
{-0.5f+A,-0.25f, 0.5f},
|
308
|
|
309
|
{-0.5f+A, 0.25f,-0.5f+A},
|
310
|
{-0.5f+B, 0.00f,-0.5f+B},
|
311
|
{-0.5f+A,-0.25f,-0.5f+A},
|
312
|
|
313
|
{ 0.5f , 0.25f,-0.5f+A},
|
314
|
{ 0.5f , 0.00f,-0.5f+B},
|
315
|
{ 0.5f ,-0.25f,-0.5f+A},
|
316
|
};
|
317
|
}
|
318
|
}
|
319
|
|
320
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
321
|
|
322
|
public ObjectShape getObjectShape(int variant)
|
323
|
{
|
324
|
if( variant==0 ) // corner
|
325
|
{
|
326
|
int[][] indices =
|
327
|
{
|
328
|
{6,1,5,8,13,12,9},
|
329
|
{5,3,4,7,15,14,8},
|
330
|
{4,2,6,9,11,10,7},
|
331
|
{0,1,6,2},
|
332
|
{0,3,5,1},
|
333
|
{0,2,4,3},
|
334
|
{9,12,11},
|
335
|
{8,14,13},
|
336
|
{7,10,15},
|
337
|
{10,11,12,13,14,15}
|
338
|
};
|
339
|
|
340
|
return new ObjectShape(getVertices(variant), indices);
|
341
|
}
|
342
|
else // edge
|
343
|
{
|
344
|
int[][] indices =
|
345
|
{
|
346
|
{6,2,0,4,8,9,10},
|
347
|
{1,0,2,3,16,15,14},
|
348
|
{4,0,1,5},
|
349
|
{2,6,7,3},
|
350
|
|
351
|
{11,8,4,5},
|
352
|
{12,9,8,11},
|
353
|
{13,10,9,12},
|
354
|
{7,6,10,13},
|
355
|
{13,16,3,7},
|
356
|
{12,15,16,13},
|
357
|
{11,14,15,12},
|
358
|
{5,1,14,11}
|
359
|
};
|
360
|
|
361
|
return new ObjectShape(getVertices(variant), indices);
|
362
|
}
|
363
|
}
|
364
|
|
365
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
366
|
|
367
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
368
|
{
|
369
|
if( variant==0 )
|
370
|
{
|
371
|
float h1 = isInIconMode() ? 0.001f : 0.015f;
|
372
|
float h2 = isInIconMode() ? 0.001f : 0.010f;
|
373
|
float h3 = isInIconMode() ? 0.001f : 0.030f;
|
374
|
float[][] bands = { {h1,20,0.2f,0.4f,5,1,0}, {h2,5,0.3f,0.2f,5,0,0}, {h3,8,0.3f,0.2f,6,0,0} };
|
375
|
int[] indices = { 0,0,0,1,1,1,1,1,1,2 };
|
376
|
return new ObjectFaceShape(bands,indices,null);
|
377
|
}
|
378
|
else
|
379
|
{
|
380
|
float h1 = isInIconMode() ? 0.001f : 0.01f;
|
381
|
float[][] bands = { {h1,5,0.2f,0.4f,5,1,0}, {0.001f,1,0.3f,0.5f,5,0,0}, {0.001f,1,0.3f,0.5f,5,0,0} };
|
382
|
int[] indices = { 0,0,1,1,2,2,2,2,2,2,2,2 };
|
383
|
return new ObjectFaceShape(bands,indices,null);
|
384
|
}
|
385
|
}
|
386
|
|
387
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
388
|
|
389
|
public ObjectVertexEffects getVertexEffects(int variant)
|
390
|
{
|
391
|
if( variant==0 )
|
392
|
{
|
393
|
float[][] corners = { {0.02f,0.09f} };
|
394
|
int[] indices = { -1,0,0,0,0,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1 };
|
395
|
float[][] centers = { { -0.5f, -0.5f, -0.5f } };
|
396
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
|
397
|
}
|
398
|
else
|
399
|
{
|
400
|
float[][] corners = { {0.02f,0.09f} };
|
401
|
int[] indices = { 0,-1,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 };
|
402
|
float[][] centers = { { 0.0f, 0.0f, 0.0f } };
|
403
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
|
404
|
}
|
405
|
}
|
406
|
|
407
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
408
|
|
409
|
public int getNumCubitVariants(int[] numLayers)
|
410
|
{
|
411
|
return 2;
|
412
|
}
|
413
|
|
414
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
415
|
|
416
|
public int getCubitVariant(int cubit, int[] numLayers)
|
417
|
{
|
418
|
return cubit<8 ? 0:1;
|
419
|
}
|
420
|
|
421
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
422
|
|
423
|
public float getStickerRadius()
|
424
|
{
|
425
|
return 0.05f;
|
426
|
}
|
427
|
|
428
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
429
|
|
430
|
public float getStickerStroke()
|
431
|
{
|
432
|
return isInIconMode() ? 0.22f : 0.12f;
|
433
|
}
|
434
|
|
435
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
436
|
|
437
|
public float[][] getStickerAngles()
|
438
|
{
|
439
|
float D = (float)(Math.PI/6);
|
440
|
return new float[][] { { 0,D,0 },{ 0,0,0,-D } };
|
441
|
}
|
442
|
|
443
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
444
|
// PUBLIC API
|
445
|
|
446
|
public Static3D[] getRotationAxis()
|
447
|
{
|
448
|
return ROT_AXIS;
|
449
|
}
|
450
|
|
451
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
452
|
|
453
|
public int[][] getBasicAngles()
|
454
|
{
|
455
|
if( mBasicAngle ==null )
|
456
|
{
|
457
|
int num = getNumLayers()[0];
|
458
|
int[] tmp = new int[num];
|
459
|
for(int i=0; i<num; i++) tmp[i] = 4;
|
460
|
mBasicAngle = new int[][] { tmp,tmp,tmp };
|
461
|
}
|
462
|
|
463
|
return mBasicAngle;
|
464
|
}
|
465
|
|
466
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
467
|
|
468
|
public String getShortName()
|
469
|
{
|
470
|
return ObjectType.VOID_3.name();
|
471
|
}
|
472
|
|
473
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
474
|
|
475
|
public ObjectSignature getSignature()
|
476
|
{
|
477
|
return new ObjectSignature(ObjectSignatures.VOID_3);
|
478
|
}
|
479
|
|
480
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
481
|
|
482
|
public String getObjectName()
|
483
|
{
|
484
|
return "Void Cube";
|
485
|
}
|
486
|
|
487
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
488
|
|
489
|
public String getInventor()
|
490
|
{
|
491
|
return "Katsuhiko Okamoto";
|
492
|
}
|
493
|
|
494
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
495
|
|
496
|
public int getYearOfInvention()
|
497
|
{
|
498
|
return 2012;
|
499
|
}
|
500
|
|
501
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
502
|
|
503
|
public int getComplexity()
|
504
|
{
|
505
|
return 2;
|
506
|
}
|
507
|
|
508
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
509
|
|
510
|
public String[][] getTutorials()
|
511
|
{
|
512
|
return new String[][]{
|
513
|
{"gb","3sLMpQrX_dU","How to Solve the Void Cube","Z3"},
|
514
|
{"gb","EB0bmcI1RnM","aVOIDing parity: Void Cube","SuperAntoniovivaldi"},
|
515
|
{"es","tDV4vmo7Qz4","Resolver 3x3 Void (Hueco)","Cuby"},
|
516
|
{"ru","BCa6Zh8-I_g","Как собрать Войд-Куб","RBcuber"},
|
517
|
{"fr","yqSyPu5ciAc","Résoudre le Void Cube","TwinsCuber"},
|
518
|
{"de","1mh-jRrcP0w","Void Cube: Parity intuitiv lösen","rofrisch"},
|
519
|
{"br","uTC01oMGBJ8","3x3 Void cube Tutorial","Cubo vicio"},
|
520
|
{"kr","eCfepw1gVBA","보이드 큐브(홀큐브)","듀나메스 큐브 해법연구소"},
|
521
|
};
|
522
|
}
|
523
|
}
|