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