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