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.scrambling.ScrambleState;
|
27
|
import org.distorted.objectlib.main.ObjectControl;
|
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[][] mCenters;
|
52
|
private int[] mQuatIndex;
|
53
|
|
54
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
55
|
|
56
|
public TwistyVoid(int[] numL, int meshState, Static4D quat, Static3D move, float scale, InputStream stream)
|
57
|
{
|
58
|
super(numL, meshState, 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, A, A, -0.5f, -0.5f, -0.5f },
|
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
|
// 3x3 without the middle layer
|
89
|
|
90
|
public ScrambleState[] getScrambleStates()
|
91
|
{
|
92
|
if( mStates==null )
|
93
|
{
|
94
|
int[][] m = new int[16][];
|
95
|
|
96
|
for(int i=0; i<16; i++) m[i] = new int[] { 0,-1,i,0,1,i,0,2,i, 2,-1,i,2,1,i,2,2,i};
|
97
|
|
98
|
mStates = new ScrambleState[]
|
99
|
{
|
100
|
new ScrambleState( new int[][] { m[ 1], m[ 2], m[ 3] } ), // 0 0
|
101
|
new ScrambleState( new int[][] { null, m[ 4], m[ 5] } ), // 1 x
|
102
|
new ScrambleState( new int[][] { m[ 6], null, m[ 7] } ), // 2 y
|
103
|
new ScrambleState( new int[][] { m[ 8], m[ 9], null } ), // 3 z
|
104
|
new ScrambleState( new int[][] { m[10], null, m[ 7] } ), // 4 xy
|
105
|
new ScrambleState( new int[][] { m[11], m[ 9], null } ), // 5 xz
|
106
|
new ScrambleState( new int[][] { null, m[12], m[ 5] } ), // 6 yx
|
107
|
new ScrambleState( new int[][] { m[ 8], m[13], null } ), // 7 yz
|
108
|
new ScrambleState( new int[][] { null, m[ 4], m[14] } ), // 8 zx
|
109
|
new ScrambleState( new int[][] { m[ 6], null, m[15] } ), // 9 zy
|
110
|
new ScrambleState( new int[][] { null, null, m[ 5] } ), // 10 xyx
|
111
|
new ScrambleState( new int[][] { null, m[ 4], null } ), // 11 xzx
|
112
|
new ScrambleState( new int[][] { null, null, m[ 7] } ), // 12 yxy
|
113
|
new ScrambleState( new int[][] { m[ 6], null, null } ), // 13 yzy
|
114
|
new ScrambleState( new int[][] { null, m[ 9], null } ), // 14 zxz
|
115
|
new ScrambleState( new int[][] { m[ 8], null, null } ), // 15 zyz
|
116
|
};
|
117
|
}
|
118
|
|
119
|
return mStates;
|
120
|
}
|
121
|
|
122
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
123
|
|
124
|
public float[][] getCuts(int[] numLayers)
|
125
|
{
|
126
|
if( mCuts==null )
|
127
|
{
|
128
|
float C = 0.5f;
|
129
|
float[] cut = new float[] {-C,+C};
|
130
|
mCuts = new float[][] { cut,cut,cut };
|
131
|
}
|
132
|
|
133
|
return mCuts;
|
134
|
}
|
135
|
|
136
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
137
|
|
138
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
139
|
{
|
140
|
boolean[] tmp = new boolean[] {true,false,true};
|
141
|
return new boolean[][] { tmp,tmp,tmp };
|
142
|
}
|
143
|
|
144
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
145
|
|
146
|
public int getTouchControlType()
|
147
|
{
|
148
|
return TC_HEXAHEDRON;
|
149
|
}
|
150
|
|
151
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
152
|
|
153
|
public int getTouchControlSplit()
|
154
|
{
|
155
|
return TYPE_NOT_SPLIT;
|
156
|
}
|
157
|
|
158
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
159
|
|
160
|
public int[][][] getEnabled()
|
161
|
{
|
162
|
return new int[][][] { {{1,2}},{{1,2}},{{0,2}},{{0,2}},{{0,1}},{{0,1}} };
|
163
|
}
|
164
|
|
165
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
166
|
|
167
|
public float[] getDist3D(int[] numLayers)
|
168
|
{
|
169
|
return TouchControlHexahedron.D3D;
|
170
|
}
|
171
|
|
172
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
173
|
|
174
|
public Static3D[] getFaceAxis()
|
175
|
{
|
176
|
return TouchControlHexahedron.FACE_AXIS;
|
177
|
}
|
178
|
|
179
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
180
|
|
181
|
public float[][] getCubitPositions(int[] numLayers)
|
182
|
{
|
183
|
if( mCenters==null )
|
184
|
{
|
185
|
mCenters = new float[][]
|
186
|
{
|
187
|
{ 1.0f, 1.0f, 1.0f},
|
188
|
{ 1.0f, 1.0f,-1.0f},
|
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
|
|
196
|
{ 1.0f, 1.0f, 0.0f},
|
197
|
{ 1.0f,-1.0f, 0.0f},
|
198
|
{ 1.0f, 0.0f, 1.0f},
|
199
|
{ 1.0f, 0.0f,-1.0f},
|
200
|
{-1.0f, 1.0f, 0.0f},
|
201
|
{-1.0f,-1.0f, 0.0f},
|
202
|
{-1.0f, 0.0f, 1.0f},
|
203
|
{-1.0f, 0.0f,-1.0f},
|
204
|
|
205
|
{ 0.0f, 1.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
|
};
|
210
|
}
|
211
|
|
212
|
return mCenters;
|
213
|
}
|
214
|
|
215
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
216
|
|
217
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
218
|
{
|
219
|
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 };
|
220
|
return mObjectQuats[mQuatIndex[cubit]];
|
221
|
}
|
222
|
|
223
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
224
|
|
225
|
public ObjectShape getObjectShape(int variant)
|
226
|
{
|
227
|
if( variant==0 ) // corner
|
228
|
{
|
229
|
final float X = 0.3f;
|
230
|
final double A = 54*Math.PI/180;
|
231
|
final float COS = (float)Math.cos(A);
|
232
|
final float SIN = (float)Math.sin(A);
|
233
|
|
234
|
float[][] vertices =
|
235
|
{
|
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
|
{ +0.5f, -0.5f, +0.5f },
|
242
|
{ -0.5f, +0.5f, +0.5f },
|
243
|
{ +0.5f, +0.5f, -0.5f+X },
|
244
|
{ +0.5f, -0.5f+X, +0.5f },
|
245
|
{ -0.5f+X, +0.5f, +0.5f },
|
246
|
{ SIN-0.5f, 0.5f, COS-0.5f },
|
247
|
{ COS-0.5f, 0.5f, SIN-0.5f },
|
248
|
{ COS-0.5f, SIN-0.5f, 0.5f },
|
249
|
{ SIN-0.5f, COS-0.5f, 0.5f },
|
250
|
{ 0.5f, COS-0.5f, SIN-0.5f },
|
251
|
{ 0.5f, SIN-0.5f, COS-0.5f },
|
252
|
};
|
253
|
|
254
|
int[][] indices =
|
255
|
{
|
256
|
{6,1,5,8,13,12,9},
|
257
|
{5,3,4,7,15,14,8},
|
258
|
{4,2,6,9,11,10,7},
|
259
|
{0,1,6,2},
|
260
|
{0,3,5,1},
|
261
|
{0,2,4,3},
|
262
|
{9,12,11},
|
263
|
{8,14,13},
|
264
|
{7,10,15},
|
265
|
{10,11,12,13,14,15}
|
266
|
};
|
267
|
|
268
|
return new ObjectShape(vertices, indices);
|
269
|
}
|
270
|
else // edge
|
271
|
{
|
272
|
final float A = 0.13f;
|
273
|
final float B = 0.18f;
|
274
|
|
275
|
float[][] vertices =
|
276
|
{
|
277
|
{ 0.5f, 0.5f, 0.5f},
|
278
|
{ 0.5f, 0.5f,-0.5f},
|
279
|
{ 0.5f,-0.5f, 0.5f},
|
280
|
{ 0.5f,-0.5f,-0.5f},
|
281
|
{-0.5f, 0.5f, 0.5f},
|
282
|
{-0.5f, 0.5f,-0.5f},
|
283
|
{-0.5f,-0.5f, 0.5f},
|
284
|
{-0.5f,-0.5f,-0.5f},
|
285
|
|
286
|
{-0.5f+A, 0.25f, 0.5f},
|
287
|
{-0.5f+B, 0.00f, 0.5f},
|
288
|
{-0.5f+A,-0.25f, 0.5f},
|
289
|
|
290
|
{-0.5f+A, 0.25f,-0.5f+A},
|
291
|
{-0.5f+B, 0.00f,-0.5f+B},
|
292
|
{-0.5f+A,-0.25f,-0.5f+A},
|
293
|
|
294
|
{ 0.5f , 0.25f,-0.5f+A},
|
295
|
{ 0.5f , 0.00f,-0.5f+B},
|
296
|
{ 0.5f ,-0.25f,-0.5f+A},
|
297
|
};
|
298
|
|
299
|
int[][] indices =
|
300
|
{
|
301
|
{6,2,0,4,8,9,10},
|
302
|
{1,0,2,3,16,15,14},
|
303
|
{4,0,1,5},
|
304
|
{2,6,7,3},
|
305
|
|
306
|
{11,8,4,5},
|
307
|
{12,9,8,11},
|
308
|
{13,10,9,12},
|
309
|
{7,6,10,13},
|
310
|
{13,16,3,7},
|
311
|
{12,15,16,13},
|
312
|
{11,14,15,12},
|
313
|
{5,1,14,11}
|
314
|
};
|
315
|
|
316
|
return new ObjectShape(vertices, indices);
|
317
|
}
|
318
|
}
|
319
|
|
320
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
321
|
|
322
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
323
|
{
|
324
|
if( variant==0 )
|
325
|
{
|
326
|
float[][] bands = { {0.015f,20,0.2f,0.4f,5,1,0}, {0.01f,5,0.3f,0.2f,5,0,0}, {0.03f,8,0.3f,0.2f,6,0,0} };
|
327
|
int[] bandIndices = { 0,0,0,1,1,1,1,1,1,2 };
|
328
|
float[][] corners = { {0.02f,0.09f} };
|
329
|
int[] indices = { -1,0,0,0,0,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1 };
|
330
|
float[][] centers = { { -0.5f, -0.5f, -0.5f } };
|
331
|
return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
|
332
|
}
|
333
|
else
|
334
|
{
|
335
|
float[][] bands = { {0.01f,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} };
|
336
|
int[] bandIndices = { 0,0,1,1,2,2,2,2,2,2,2,2 };
|
337
|
float[][] corners = { {0.04f,0.12f} };
|
338
|
int[] indices = { -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 };
|
339
|
float[][] centers = { { 0.0f, 0.0f, 0.0f } };
|
340
|
return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
|
341
|
}
|
342
|
}
|
343
|
|
344
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
345
|
|
346
|
public int getNumCubitVariants(int[] numLayers)
|
347
|
{
|
348
|
return 2;
|
349
|
}
|
350
|
|
351
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
352
|
|
353
|
public int getCubitVariant(int cubit, int[] numLayers)
|
354
|
{
|
355
|
return cubit<8 ? 0:1;
|
356
|
}
|
357
|
|
358
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
359
|
|
360
|
public float getStickerRadius()
|
361
|
{
|
362
|
return 0.01f;
|
363
|
}
|
364
|
|
365
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
366
|
|
367
|
public float getStickerStroke()
|
368
|
{
|
369
|
return ObjectControl.isInIconMode() ? 0.22f : 0.12f;
|
370
|
}
|
371
|
|
372
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
373
|
|
374
|
public float[][] getStickerAngles()
|
375
|
{
|
376
|
float D = (float)(Math.PI/6);
|
377
|
return new float[][] { { D,0,0 },{ 0,0,0,D } };
|
378
|
}
|
379
|
|
380
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
381
|
// PUBLIC API
|
382
|
|
383
|
public Static3D[] getRotationAxis()
|
384
|
{
|
385
|
return ROT_AXIS;
|
386
|
}
|
387
|
|
388
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
389
|
|
390
|
public int[] getBasicAngles()
|
391
|
{
|
392
|
if( mBasicAngle ==null ) mBasicAngle = new int[] { 4,4,4 };
|
393
|
return mBasicAngle;
|
394
|
}
|
395
|
|
396
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
397
|
|
398
|
public String getShortName()
|
399
|
{
|
400
|
return ObjectType.VOID_3.name();
|
401
|
}
|
402
|
|
403
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
404
|
|
405
|
public long getSignature()
|
406
|
{
|
407
|
return ObjectType.VOID_3.ordinal();
|
408
|
}
|
409
|
|
410
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
411
|
|
412
|
public String getObjectName()
|
413
|
{
|
414
|
return "Void Cube";
|
415
|
}
|
416
|
|
417
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
418
|
|
419
|
public String getInventor()
|
420
|
{
|
421
|
return "Katsuhiko Okamoto";
|
422
|
}
|
423
|
|
424
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
425
|
|
426
|
public int getYearOfInvention()
|
427
|
{
|
428
|
return 2012;
|
429
|
}
|
430
|
|
431
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
432
|
|
433
|
public int getComplexity()
|
434
|
{
|
435
|
return 2;
|
436
|
}
|
437
|
|
438
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
439
|
|
440
|
public String[][] getTutorials()
|
441
|
{
|
442
|
return new String[][]{
|
443
|
{"gb","3sLMpQrX_dU","How to Solve the Void Cube","Z3"},
|
444
|
{"gb","EB0bmcI1RnM","aVOIDing parity: Void Cube","SuperAntoniovivaldi"},
|
445
|
{"es","tDV4vmo7Qz4","Resolver 3x3 Void (Hueco)","Cuby"},
|
446
|
{"ru","BCa6Zh8-I_g","Как собрать Войд-Куб","RBcuber"},
|
447
|
{"fr","yqSyPu5ciAc","Résoudre le Void Cube","TwinsCuber"},
|
448
|
{"de","1mh-jRrcP0w","Void Cube: Parity intuitiv lösen","rofrisch"},
|
449
|
{"br","uTC01oMGBJ8","3x3 Void cube Tutorial","Cubo vicio"},
|
450
|
{"kr","eCfepw1gVBA","보이드 큐브(홀큐브)","듀나메스 큐브 해법연구소"},
|
451
|
};
|
452
|
}
|
453
|
}
|