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.ObjectVertexEffects;
|
21
|
import org.distorted.objectlib.main.InitAssets;
|
22
|
import org.distorted.objectlib.main.InitData;
|
23
|
import org.distorted.objectlib.main.ObjectType;
|
24
|
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator;
|
25
|
import org.distorted.objectlib.shape.ShapeHexahedron;
|
26
|
import org.distorted.objectlib.signature.ObjectConstants;
|
27
|
import org.distorted.objectlib.signature.ObjectSignature;
|
28
|
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
|
29
|
|
30
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
31
|
|
32
|
public class TwistyLattice extends ShapeHexahedron
|
33
|
{
|
34
|
public 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[][] mPositions;
|
46
|
private int[] mQuatIndex;
|
47
|
private boolean[][] mRotatable;
|
48
|
|
49
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
50
|
|
51
|
public TwistyLattice(int iconMode, Static4D quat, Static3D move, float scale, InitData data, InitAssets asset)
|
52
|
{
|
53
|
super(iconMode, data.getNumLayers()[0], quat, move, scale, data, asset);
|
54
|
}
|
55
|
|
56
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
57
|
|
58
|
@Override
|
59
|
public float[][] returnRotationFactor()
|
60
|
{
|
61
|
int numL = getNumLayers()[0];
|
62
|
float[] f = new float[numL];
|
63
|
for(int i=0; i<numL; i++) f[i] = 1.7f;
|
64
|
return new float[][] { f,f,f,f };
|
65
|
}
|
66
|
|
67
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
68
|
|
69
|
public int[][] getScrambleEdges()
|
70
|
{
|
71
|
if( mEdges==null )
|
72
|
{
|
73
|
mEdges = new int[][]
|
74
|
{
|
75
|
{ 0,16,1,16,2,8,3,8, 4,1,5,1,6,9,7,9, 8,15,9,15,10,7,11,7, 12,2,13,2,14,10,15,10, 16,14,17,14,18,6,19,6, 20,3,21,3,22,11,23,11, 24,13,25,13,26,5,27,5, 28,4,29,4,30,12,31,12 }, // 0
|
76
|
|
77
|
{ 12,2,13,2,14,10,15,10, 20,3,21,3,22,11,23,11, 24,13,25,13,26,5,27,5, }, // 1
|
78
|
{ 4,1,5,1,6,9,7,9, 16,14,17,14,18,6,19,6, 28,4,29,4,30,12,31,12 }, // 2
|
79
|
{ 4,1,5,1,6,9,7,9, 8,15,9,15,10,7,11,7, 28,4,29,4,30,12,31,12 }, // 3
|
80
|
{ 0,16,1,16,2,8,3,8, 12,2,13,2,14,10,15,10, 20,3,21,3,22,11,23,11, }, // 4
|
81
|
{ 4,1,5,1,6,9,7,9, 8,15,9,15,10,7,11,7, 16,14,17,14,18,6,19,6, }, // 5
|
82
|
{ 0,16,1,16,2,8,3,8, 12,2,13,2,14,10,15,10, 24,13,25,13,26,5,27,5, }, // 6
|
83
|
{ 0,16,1,16,2,8,3,8, 20,3,21,3,22,11,23,11, 24,13,25,13,26,5,27,5, }, // 7
|
84
|
{ 8,15,9,15,10,7,11,7, 16,14,17,14,18,6,19,6, 28,4,29,4,30,12,31,12 }, // 8
|
85
|
|
86
|
{ 12,2,13,2, 20,3,21,3, 26,5,27,5, }, // 9
|
87
|
{ 4,1,5,1, 18,6,19,6, 28,4,29,4, }, // 10
|
88
|
{ 4,1,5,1, 10,7,11,7, 28,4,29,4, }, // 11
|
89
|
{ 2,8,3,8, 12,2,13,2, 20,3,21,3, }, // 12
|
90
|
{ 4,1,5,1, 10,7,11,7, 18,6,19,6, }, // 13
|
91
|
{ 2,8,3,8, 12,2,13,2, 26,5,27,5, }, // 14
|
92
|
{ 2,8,3,8, 20,3,21,3, 26,5,27,5, }, // 15
|
93
|
{ 10,7,11,7, 18,6,19,6, 28,4,29,4, }, // 16
|
94
|
};
|
95
|
}
|
96
|
|
97
|
return mEdges;
|
98
|
}
|
99
|
|
100
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
101
|
|
102
|
@Override
|
103
|
public int[][] getScrambleAlgorithms()
|
104
|
{
|
105
|
if( mRotatable==null ) createRotatable();
|
106
|
return ScrambleEdgeGenerator.getScramblingAlgorithms(mBasicAngle, mRotatable);
|
107
|
}
|
108
|
|
109
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
110
|
|
111
|
public float[][] getCuts(int[] numLayers)
|
112
|
{
|
113
|
if( mCuts==null )
|
114
|
{
|
115
|
float C = 5*SQ3/6;
|
116
|
float[] c = {-2*C,-C,C,2*C};
|
117
|
mCuts = new float[][] {c,c,c,c};
|
118
|
}
|
119
|
|
120
|
return mCuts;
|
121
|
}
|
122
|
|
123
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
124
|
|
125
|
private void createRotatable()
|
126
|
{
|
127
|
boolean[] tmp = new boolean[] {true,true,false,true,true};
|
128
|
mRotatable = new boolean[][] { tmp,tmp,tmp,tmp };
|
129
|
}
|
130
|
|
131
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
132
|
|
133
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
134
|
{
|
135
|
if( mRotatable==null ) createRotatable();
|
136
|
return mRotatable;
|
137
|
}
|
138
|
|
139
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
140
|
|
141
|
public int getTouchControlType()
|
142
|
{
|
143
|
return TC_HEXAHEDRON;
|
144
|
}
|
145
|
|
146
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
147
|
|
148
|
public int getTouchControlSplit()
|
149
|
{
|
150
|
return TYPE_SPLIT_CORNER;
|
151
|
}
|
152
|
|
153
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
154
|
|
155
|
public int[][][] getEnabled()
|
156
|
{
|
157
|
return new int[][][]
|
158
|
{
|
159
|
{{0,1},{3,1},{2,3},{0,2}},
|
160
|
{{2,3},{3,1},{0,1},{0,2}},
|
161
|
{{1,2},{0,1},{0,3},{2,3}},
|
162
|
{{1,2},{2,3},{0,3},{0,1}},
|
163
|
{{0,3},{0,2},{1,2},{1,3}},
|
164
|
{{1,2},{0,2},{0,3},{1,3}},
|
165
|
};
|
166
|
}
|
167
|
|
168
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
169
|
|
170
|
public float[] getDist3D(int[] numLayers)
|
171
|
{
|
172
|
return TouchControlHexahedron.D3D;
|
173
|
}
|
174
|
|
175
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
176
|
|
177
|
public Static3D[] getFaceAxis()
|
178
|
{
|
179
|
return TouchControlHexahedron.FACE_AXIS;
|
180
|
}
|
181
|
|
182
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
183
|
|
184
|
public float[][] getCubitPositions(int[] numLayers)
|
185
|
{
|
186
|
if( mPositions==null )
|
187
|
{
|
188
|
final float C = 1.25f;
|
189
|
|
190
|
mPositions = new float[][]
|
191
|
{
|
192
|
{ 0, C, 2*C}, { C, 0, 2*C}, { 0,-C, 2*C}, {-C, 0, 2*C},
|
193
|
{ 0, C,-2*C}, { C, 0,-2*C}, { 0,-C,-2*C}, {-C, 0,-2*C},
|
194
|
{ 0, 2*C, C}, { C, 2*C, 0}, { 0, 2*C,-C}, {-C, 2*C, 0},
|
195
|
{ 0,-2*C, C}, { C,-2*C, 0}, { 0,-2*C,-C}, {-C,-2*C, 0},
|
196
|
{ 2*C, 0, C}, { 2*C, C, 0}, { 2*C, 0,-C}, { 2*C,-C, 0},
|
197
|
{-2*C, 0, C}, {-2*C, C, 0}, {-2*C, 0,-C}, {-2*C,-C, 0},
|
198
|
|
199
|
{ C, 2*C, 2*C }, {-C, 2*C, 2*C },
|
200
|
{ 2*C, C, 2*C }, { 2*C,-C, 2*C },
|
201
|
{ C,-2*C, 2*C }, {-C,-2*C, 2*C },
|
202
|
{-2*C, C, 2*C }, {-2*C,-C, 2*C },
|
203
|
{ 2*C, 2*C, C }, { 2*C, 2*C,-C },
|
204
|
{ 2*C,-2*C, C }, { 2*C,-2*C,-C },
|
205
|
{-2*C,-2*C, C }, {-2*C,-2*C,-C },
|
206
|
{-2*C, 2*C, C }, {-2*C, 2*C,-C },
|
207
|
{ C, 2*C,-2*C }, {-C, 2*C,-2*C },
|
208
|
{ 2*C, C,-2*C }, { 2*C,-C,-2*C },
|
209
|
{ C,-2*C,-2*C }, {-C,-2*C,-2*C },
|
210
|
{-2*C, C,-2*C }, {-2*C,-C,-2*C },
|
211
|
};
|
212
|
}
|
213
|
|
214
|
return mPositions;
|
215
|
}
|
216
|
|
217
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
218
|
|
219
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
220
|
{
|
221
|
if( mQuatIndex==null )
|
222
|
{
|
223
|
mQuatIndex = new int[]
|
224
|
{
|
225
|
0,0,0,0,9,9,9,9,1,1,1,1,4,4,4,4,2,2,2,2,3,3,3,3,
|
226
|
0,0,2,2,10,10,8,8, 1,1,4,4,6,6,7,7, 11,11,5,5,9,9,3,3,
|
227
|
};
|
228
|
}
|
229
|
|
230
|
return mObjectQuats[mQuatIndex[cubit]];
|
231
|
}
|
232
|
|
233
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
234
|
|
235
|
private float[][] getVertices(int variant)
|
236
|
{
|
237
|
final float C = 1.25f;
|
238
|
if( variant==0 ) return new float[][] { {-C,0,0},{0,-C,0},{C,0,0},{0,C,0},{0,0,-C} };
|
239
|
else return new float[][] { {-C,0,0},{C,0,0},{0,-C,0},{0,0,-C} };
|
240
|
}
|
241
|
|
242
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
243
|
|
244
|
public ObjectShape getObjectShape(int variant)
|
245
|
{
|
246
|
if( variant==0 )
|
247
|
{
|
248
|
int[][] indices = { {0,1,2,3},{4,1,0},{4,2,1},{4,3,2},{4,0,3} };
|
249
|
return new ObjectShape(getVertices(variant), indices);
|
250
|
}
|
251
|
else
|
252
|
{
|
253
|
int[][] indices = { {2,1,0},{3,0,1},{2,3,1},{3,2,0} };
|
254
|
return new ObjectShape(getVertices(variant), indices);
|
255
|
}
|
256
|
}
|
257
|
|
258
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
259
|
|
260
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
261
|
{
|
262
|
if( variant==0 )
|
263
|
{
|
264
|
int N = 4;
|
265
|
int E = 1;
|
266
|
float height = isInIconMode() ? 0.001f : 0.04f;
|
267
|
float[][] bands = { {height,35,SQ2/8,0.9f,N,E,E}, {0.001f,35,1,0.0f,3,0,0} };
|
268
|
int[] indices = { 0,1,1,1,1 };
|
269
|
return new ObjectFaceShape(bands,indices,null);
|
270
|
}
|
271
|
else
|
272
|
{
|
273
|
int N = 5;
|
274
|
int E = 2;
|
275
|
float h1 = isInIconMode() ? 0.001f : 0.035f;
|
276
|
float h2 = isInIconMode() ? 0.001f : 0.020f;
|
277
|
float[][] bands = { {h1,30,0.16f,0.8f,N,2,E}, {h2,45,0.16f,0.2f,3,1,2} };
|
278
|
int[] indices = { 0,0,1,1 };
|
279
|
return new ObjectFaceShape(bands,indices,null);
|
280
|
}
|
281
|
}
|
282
|
|
283
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
284
|
|
285
|
public ObjectVertexEffects getVertexEffects(int variant)
|
286
|
{
|
287
|
if( variant==0 )
|
288
|
{
|
289
|
final float C = 1.25f;
|
290
|
float[][] corners = { {0.03f,0.15f} };
|
291
|
int[] cornerIndices = { 0,0,0,0,0 };
|
292
|
float[][] centers = { {-C,0,-C},{0,-C,-C},{C,0,-C},{0,C,-C} };
|
293
|
int[] centerIndices = { 0,1,2,3,-1 };
|
294
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
|
295
|
}
|
296
|
else
|
297
|
{
|
298
|
float[][] corners = { {0.07f,0.20f}, {0.02f,0.30f} };
|
299
|
int[] cornerIndices = { 0,0,1,1 };
|
300
|
float[][] centers = { {0.0f, -0.5f, -0.5f} };
|
301
|
int[] centerIndices = { 0,0,0,0 };
|
302
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
|
303
|
}
|
304
|
}
|
305
|
|
306
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
307
|
|
308
|
public int getNumCubitVariants(int[] numLayers)
|
309
|
{
|
310
|
return 2;
|
311
|
}
|
312
|
|
313
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
314
|
|
315
|
public int getCubitVariant(int cubit, int[] numLayers)
|
316
|
{
|
317
|
return cubit<24 ? 0:1;
|
318
|
}
|
319
|
|
320
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
321
|
|
322
|
public float getStickerRadius()
|
323
|
{
|
324
|
return 0.12f;
|
325
|
}
|
326
|
|
327
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
328
|
|
329
|
public float getStickerStroke()
|
330
|
{
|
331
|
return isInIconMode() ? 0.27f : 0.12f;
|
332
|
}
|
333
|
|
334
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
335
|
|
336
|
public float[][][] getStickerAngles()
|
337
|
{
|
338
|
return null;
|
339
|
}
|
340
|
|
341
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
342
|
// PUBLIC API
|
343
|
|
344
|
public Static3D[] getRotationAxis()
|
345
|
{
|
346
|
return ROT_AXIS;
|
347
|
}
|
348
|
|
349
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
350
|
|
351
|
public int[][] getBasicAngles()
|
352
|
{
|
353
|
if( mBasicAngle ==null )
|
354
|
{
|
355
|
int[] tmp = {3,3,3,3,3};
|
356
|
mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
|
357
|
}
|
358
|
|
359
|
return mBasicAngle;
|
360
|
}
|
361
|
|
362
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
363
|
|
364
|
public String getShortName()
|
365
|
{
|
366
|
return ObjectType.LATT_5.name();
|
367
|
}
|
368
|
|
369
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
370
|
|
371
|
public ObjectSignature getSignature()
|
372
|
{
|
373
|
return new ObjectSignature(ObjectConstants.LATT_5);
|
374
|
}
|
375
|
|
376
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
377
|
|
378
|
public String getObjectName()
|
379
|
{
|
380
|
return "Lattice Cube";
|
381
|
}
|
382
|
|
383
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
384
|
|
385
|
public String getInventor()
|
386
|
{
|
387
|
return "Katsuhiko Okamoto";
|
388
|
}
|
389
|
|
390
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
391
|
|
392
|
public int getYearOfInvention()
|
393
|
{
|
394
|
return 2003;
|
395
|
}
|
396
|
|
397
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
398
|
|
399
|
public int getComplexity()
|
400
|
{
|
401
|
return 2;
|
402
|
}
|
403
|
|
404
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
405
|
|
406
|
public String[][] getTutorials()
|
407
|
{
|
408
|
return new String[][]
|
409
|
{
|
410
|
{"gb","fzrjXO0MUgE","How to solve Lattice Cube","martywolfman"},
|
411
|
{"fr","7Tfp3opCCsQ","Résolution du Lattice Cube","asthalis"},
|
412
|
{"pl","EPKHJ5C2yQY","Lattice Cube Tutorial PL","MrUK"},
|
413
|
{"tw","V4zuvJBPdr8","格子方塊 教學","不正常魔術方塊研究中心"},
|
414
|
};
|
415
|
}
|
416
|
}
|