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