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
|
|
18
|
import org.distorted.objectlib.helpers.FactoryCubit;
|
19
|
import org.distorted.objectlib.helpers.ObjectFaceShape;
|
20
|
import org.distorted.objectlib.helpers.ObjectSignature;
|
21
|
import org.distorted.objectlib.helpers.ObjectVertexEffects;
|
22
|
import org.distorted.objectlib.main.InitAssets;
|
23
|
import org.distorted.objectlib.main.InitData;
|
24
|
import org.distorted.objectlib.main.ObjectSignatures;
|
25
|
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
|
26
|
import org.distorted.objectlib.main.ObjectType;
|
27
|
import org.distorted.objectlib.helpers.ObjectShape;
|
28
|
import org.distorted.objectlib.shape.ShapeHexahedron;
|
29
|
|
30
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
31
|
|
32
|
public class TwistyRedi extends ShapeHexahedron
|
33
|
{
|
34
|
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[][] mPosition;
|
46
|
|
47
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
48
|
|
49
|
public TwistyRedi(int meshState, int iconMode, Static4D quat, Static3D move, float scale, InitData data, InitAssets asset)
|
50
|
{
|
51
|
super(meshState, iconMode, data.getNumLayers()[0], quat, move, scale, data, asset);
|
52
|
}
|
53
|
|
54
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
55
|
|
56
|
public int[][] getScrambleEdges()
|
57
|
{
|
58
|
if( mEdges==null )
|
59
|
{
|
60
|
mEdges = new int[][]
|
61
|
{
|
62
|
{ 0,8,1,8, 4,1,5,1, 6,7,7,7, 10,2,11,2, 12,6,13,6, 16,3,17,3, 18,5,19,5, 22,4,23,4 }, // 0
|
63
|
{ 10,2,11,2, 16,3,17,3, 18,5,19,5 }, // 1
|
64
|
{ 4,1,5,1, 12,6,13,6, 22,4,23,4 }, // 2
|
65
|
{ 4,1,5,1, 6,7,7,7, 22,4,23,4 }, // 3
|
66
|
{ 0,8,1,8, 10,2,11,2, 16,3,17,3 }, // 4
|
67
|
{ 4,1,5,1, 6,7,7,7, 12,6,13,6 }, // 5
|
68
|
{ 0,8,1,8, 10,2,11,2, 18,5,19,5 }, // 6
|
69
|
{ 0,8,1,8, 16,3,17,3, 18,5,19,5 }, // 7
|
70
|
{ 6,7,7,7, 12,6,13,6, 22,4,23,4 }, // 8
|
71
|
};
|
72
|
}
|
73
|
|
74
|
return mEdges;
|
75
|
}
|
76
|
|
77
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
78
|
|
79
|
public float[][] getCuts(int[] numLayers)
|
80
|
{
|
81
|
if( mCuts==null )
|
82
|
{
|
83
|
float C = SQ3/3 +0.05f;
|
84
|
float[] cut = new float[] {-C,C};
|
85
|
mCuts = new float[][] { cut,cut,cut,cut };
|
86
|
}
|
87
|
|
88
|
return mCuts;
|
89
|
}
|
90
|
|
91
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
92
|
|
93
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
94
|
{
|
95
|
boolean[] tmp = new boolean[] {true,false,true};
|
96
|
return new boolean[][] { tmp,tmp,tmp,tmp };
|
97
|
}
|
98
|
|
99
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
100
|
|
101
|
public int getTouchControlType()
|
102
|
{
|
103
|
return TC_HEXAHEDRON;
|
104
|
}
|
105
|
|
106
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
107
|
|
108
|
public int getTouchControlSplit()
|
109
|
{
|
110
|
return TYPE_SPLIT_CORNER;
|
111
|
}
|
112
|
|
113
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
114
|
|
115
|
public int[][][] getEnabled()
|
116
|
{
|
117
|
return new int[][][]
|
118
|
{
|
119
|
{{0,1},{3,1},{2,3},{0,2}},
|
120
|
{{2,3},{3,1},{0,1},{0,2}},
|
121
|
{{1,2},{0,1},{0,3},{2,3}},
|
122
|
{{1,2},{2,3},{0,3},{0,1}},
|
123
|
{{0,3},{0,2},{1,2},{1,3}},
|
124
|
{{1,2},{0,2},{0,3},{1,3}},
|
125
|
};
|
126
|
}
|
127
|
|
128
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
129
|
|
130
|
public float[] getDist3D(int[] numLayers)
|
131
|
{
|
132
|
return TouchControlHexahedron.D3D;
|
133
|
}
|
134
|
|
135
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
136
|
|
137
|
public Static3D[] getFaceAxis()
|
138
|
{
|
139
|
return TouchControlHexahedron.FACE_AXIS;
|
140
|
}
|
141
|
|
142
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
143
|
|
144
|
public float[][] getCubitPositions(int[] numLayers)
|
145
|
{
|
146
|
if( mPosition==null )
|
147
|
{
|
148
|
final float DIST_CORNER = 1.0f;
|
149
|
final float DIST_EDGE = 1.5f;
|
150
|
|
151
|
mPosition = new float[][]
|
152
|
{
|
153
|
{ DIST_CORNER, DIST_CORNER, DIST_CORNER },
|
154
|
{ DIST_CORNER, DIST_CORNER,-DIST_CORNER },
|
155
|
{ DIST_CORNER,-DIST_CORNER, DIST_CORNER },
|
156
|
{ DIST_CORNER,-DIST_CORNER,-DIST_CORNER },
|
157
|
{-DIST_CORNER, DIST_CORNER, DIST_CORNER },
|
158
|
{-DIST_CORNER, DIST_CORNER,-DIST_CORNER },
|
159
|
{-DIST_CORNER,-DIST_CORNER, DIST_CORNER },
|
160
|
{-DIST_CORNER,-DIST_CORNER,-DIST_CORNER },
|
161
|
|
162
|
{ 0.0f, DIST_EDGE, DIST_EDGE },
|
163
|
{ DIST_EDGE, 0.0f, DIST_EDGE },
|
164
|
{ 0.0f,-DIST_EDGE, DIST_EDGE },
|
165
|
{-DIST_EDGE, 0.0f, DIST_EDGE },
|
166
|
{ DIST_EDGE, DIST_EDGE, 0.0f },
|
167
|
{ DIST_EDGE,-DIST_EDGE, 0.0f },
|
168
|
{-DIST_EDGE,-DIST_EDGE, 0.0f },
|
169
|
{-DIST_EDGE, DIST_EDGE, 0.0f },
|
170
|
{ 0.0f, DIST_EDGE,-DIST_EDGE },
|
171
|
{ DIST_EDGE, 0.0f,-DIST_EDGE },
|
172
|
{ 0.0f,-DIST_EDGE,-DIST_EDGE },
|
173
|
{-DIST_EDGE, 0.0f,-DIST_EDGE }
|
174
|
};
|
175
|
}
|
176
|
|
177
|
return mPosition;
|
178
|
}
|
179
|
|
180
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
181
|
|
182
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
183
|
{
|
184
|
switch(cubit)
|
185
|
{
|
186
|
case 0: return mObjectQuats[0]; // unit quat
|
187
|
case 1: return new Static4D( SQ2/2,0,0,SQ2/2); // 90 along X
|
188
|
case 2: return new Static4D(-SQ2/2,0,0,SQ2/2); // -90 along X
|
189
|
case 3: return mObjectQuats[9]; // 180 along X
|
190
|
case 4: return new Static4D(0, SQ2/2,0,SQ2/2); // 90 along Y
|
191
|
case 5: return mObjectQuats[11]; // 180 along Y
|
192
|
case 6: return mObjectQuats[10]; // 180 along Z
|
193
|
case 7: return new Static4D(SQ2/2,0,-SQ2/2,0); // 180 along (SQ2/2,0,-SQ2/2)
|
194
|
|
195
|
case 8: return mObjectQuats[0];
|
196
|
case 9: return mObjectQuats[2];
|
197
|
case 10: return mObjectQuats[10];
|
198
|
case 11: return mObjectQuats[8];
|
199
|
case 12: return mObjectQuats[1];
|
200
|
case 13: return mObjectQuats[4];
|
201
|
case 14: return mObjectQuats[6];
|
202
|
case 15: return mObjectQuats[7];
|
203
|
case 16: return mObjectQuats[11];
|
204
|
case 17: return mObjectQuats[5];
|
205
|
case 18: return mObjectQuats[9];
|
206
|
case 19: return mObjectQuats[3];
|
207
|
}
|
208
|
|
209
|
return null;
|
210
|
}
|
211
|
|
212
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
213
|
|
214
|
private float[][] getVertices(int variant)
|
215
|
{
|
216
|
if( variant==0 )
|
217
|
{
|
218
|
return new float[][]
|
219
|
{
|
220
|
{ 0.0f, 0.0f, 0.0f },
|
221
|
{-0.5f, 0.5f, 0.5f },
|
222
|
{-0.5f,-0.5f, 0.5f },
|
223
|
{ 0.5f, 0.5f, 0.5f },
|
224
|
{ 0.5f,-0.5f, 0.5f },
|
225
|
{ 0.5f, 0.5f,-0.5f },
|
226
|
{ 0.5f,-0.5f,-0.5f },
|
227
|
{-0.5f, 0.5f,-0.5f },
|
228
|
};
|
229
|
}
|
230
|
else
|
231
|
{
|
232
|
return new float[][]
|
233
|
{
|
234
|
{-0.5f, 0.0f, 0.0f},
|
235
|
{ 0.5f, 0.0f, 0.0f},
|
236
|
{-0.5f,-1.0f, 0.0f},
|
237
|
{ 0.5f,-1.0f, 0.0f},
|
238
|
{ 0.0f,-1.5f, 0.0f},
|
239
|
{-0.5f, 0.0f,-1.0f},
|
240
|
{ 0.5f, 0.0f,-1.0f},
|
241
|
{ 0.0f, 0.0f,-1.5f},
|
242
|
};
|
243
|
}
|
244
|
}
|
245
|
|
246
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
247
|
|
248
|
public ObjectShape getObjectShape(int variant)
|
249
|
{
|
250
|
if( variant==0 )
|
251
|
{
|
252
|
int[][] indices =
|
253
|
{
|
254
|
{ 2,4,3,1 },
|
255
|
{ 1,3,5,7 },
|
256
|
{ 4,6,5,3 },
|
257
|
|
258
|
{ 0,4,2 },
|
259
|
{ 0,7,5 },
|
260
|
{ 0,6,4 },
|
261
|
{ 0,1,7 },
|
262
|
{ 0,2,1 },
|
263
|
{ 0,5,6 }
|
264
|
};
|
265
|
|
266
|
return new ObjectShape(getVertices(variant), indices);
|
267
|
}
|
268
|
else
|
269
|
{
|
270
|
int[][] indices =
|
271
|
{
|
272
|
{ 0,2,4,3,1 },
|
273
|
{ 0,1,6,7,5 },
|
274
|
{ 1,3,6 },
|
275
|
{ 5,2,0 },
|
276
|
{ 4,7,6,3 },
|
277
|
{ 2,5,7,4 }
|
278
|
};
|
279
|
|
280
|
return new ObjectShape(getVertices(variant), indices);
|
281
|
}
|
282
|
}
|
283
|
|
284
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
285
|
|
286
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
287
|
{
|
288
|
if( variant==0 )
|
289
|
{
|
290
|
float h1 = isInIconMode() ? 0.001f : 0.06f;
|
291
|
float h2 = isInIconMode() ? 0.001f : 0.01f;
|
292
|
float[][] bands = { {h1,35,0.5f,0.7f,5,2,2}, {h2,35,0.2f,0.4f,5,2,2} };
|
293
|
int[] indices = { 0,0,0,1,1,1,1,1,1 };
|
294
|
return new ObjectFaceShape(bands,indices,null);
|
295
|
}
|
296
|
else
|
297
|
{
|
298
|
float h1 = isInIconMode() ? 0.001f : 0.038f;
|
299
|
float h2 = isInIconMode() ? 0.001f : 0.020f;
|
300
|
float[][] bands = { {h1,35,0.250f,0.7f,7,2,2}, {h2,35,0.125f,0.2f,3,1,2}, {h2,35,0.125f,0.2f,3,1,1} };
|
301
|
int[] indices = { 0,0,1,1,2,2 };
|
302
|
return new ObjectFaceShape(bands,indices,null);
|
303
|
}
|
304
|
}
|
305
|
|
306
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
307
|
|
308
|
public ObjectVertexEffects getVertexEffects(int variant)
|
309
|
{
|
310
|
if( variant==0 )
|
311
|
{
|
312
|
float[][] corners = { {0.06f,0.12f} };
|
313
|
int[] indices = { -1,0,-1,0,0,0,-1,-1 };
|
314
|
float[][] centers = { { 0.0f, 0.0f, 0.0f} };
|
315
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
|
316
|
}
|
317
|
else
|
318
|
{
|
319
|
float[][] corners = { {0.06f,0.20f} };
|
320
|
int[] indices = { 0,0,-1,-1,-1,-1,-1,-1 };
|
321
|
float[][] centers = { { 0.0f,-0.75f,-0.75f} };
|
322
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
|
323
|
}
|
324
|
}
|
325
|
|
326
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
327
|
|
328
|
public int getNumCubitVariants(int[] numLayers)
|
329
|
{
|
330
|
return 2;
|
331
|
}
|
332
|
|
333
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
334
|
|
335
|
public int getCubitVariant(int cubit, int[] numLayers)
|
336
|
{
|
337
|
return cubit<8 ? 0:1;
|
338
|
}
|
339
|
|
340
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
341
|
|
342
|
public float getStickerRadius()
|
343
|
{
|
344
|
return 0.09f;
|
345
|
}
|
346
|
|
347
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
348
|
|
349
|
public float getStickerStroke()
|
350
|
{
|
351
|
return isInIconMode() ? 0.20f : 0.09f;
|
352
|
}
|
353
|
|
354
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
355
|
|
356
|
public float[][] getStickerAngles()
|
357
|
{
|
358
|
return null;
|
359
|
}
|
360
|
|
361
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
362
|
// PUBLIC API
|
363
|
|
364
|
public Static3D[] getRotationAxis()
|
365
|
{
|
366
|
return ROT_AXIS;
|
367
|
}
|
368
|
|
369
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
370
|
|
371
|
public int[][] getBasicAngles()
|
372
|
{
|
373
|
if( mBasicAngle ==null )
|
374
|
{
|
375
|
int num = getNumLayers()[0];
|
376
|
int[] tmp = new int[num];
|
377
|
for(int i=0; i<num; i++) tmp[i] = 3;
|
378
|
mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
|
379
|
}
|
380
|
|
381
|
return mBasicAngle;
|
382
|
}
|
383
|
|
384
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
385
|
|
386
|
public String getShortName()
|
387
|
{
|
388
|
return ObjectType.REDI_3.name();
|
389
|
}
|
390
|
|
391
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
392
|
|
393
|
public ObjectSignature getSignature()
|
394
|
{
|
395
|
return new ObjectSignature(ObjectSignatures.REDI_3);
|
396
|
}
|
397
|
|
398
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
399
|
|
400
|
public String getObjectName()
|
401
|
{
|
402
|
return "Redi Cube";
|
403
|
}
|
404
|
|
405
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
406
|
|
407
|
public String getInventor()
|
408
|
{
|
409
|
return "Oskar van Deventer";
|
410
|
}
|
411
|
|
412
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
413
|
|
414
|
public int getYearOfInvention()
|
415
|
{
|
416
|
return 2009;
|
417
|
}
|
418
|
|
419
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
420
|
|
421
|
public int getComplexity()
|
422
|
{
|
423
|
return 1;
|
424
|
}
|
425
|
|
426
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
427
|
|
428
|
public String[][] getTutorials()
|
429
|
{
|
430
|
return new String[][] {
|
431
|
{"gb","Qn7TJED6O-4","How to Solve the MoYu Redi Cube","Z3"},
|
432
|
{"es","g0M38Aotgac","Resolver Redi Cube","Cuby"},
|
433
|
{"ru","dlNRbE-hyzU","Как собрать Реди Куб","Алексей Ярыгин"},
|
434
|
{"fr","zw7UZcqqsgA","Comment résoudre le Redi Cube","ValentinoCube"},
|
435
|
{"de","YU8riouyC2w","Redi Cube Solve","CubaroCubing"},
|
436
|
{"pl","vxo3lXMsWQI","Jak ułożyć Redi Cube?","DJ rubiks"},
|
437
|
{"br","muQ8U_G4LmM","Como resolver o Redi Cube","Rafael Cinoto"},
|
438
|
{"kr","a5CzDMbRzbY","레디큐브를 배우기","vincentcube"},
|
439
|
{"vn","2JZxtmrKUn4","Tutorial N.6 - Redi","Duy Thích Rubik"},
|
440
|
};
|
441
|
}
|
442
|
}
|