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.touchcontrol.TouchControlHexahedron;
|
32
|
import org.distorted.objectlib.main.ObjectType;
|
33
|
import org.distorted.objectlib.helpers.ObjectShape;
|
34
|
import org.distorted.objectlib.scrambling.ScrambleState;
|
35
|
import org.distorted.objectlib.main.ShapeHexahedron;
|
36
|
|
37
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
38
|
|
39
|
public class TwistyRex extends ShapeHexahedron
|
40
|
{
|
41
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
42
|
{
|
43
|
new Static3D(+SQ3/3,+SQ3/3,+SQ3/3),
|
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
|
};
|
48
|
|
49
|
public static final float REX_D = 0.2f;
|
50
|
|
51
|
private ScrambleState[] mStates;
|
52
|
private int[] mBasicAngle;
|
53
|
private float[][] mCuts;
|
54
|
|
55
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
56
|
|
57
|
public TwistyRex(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
|
@Override
|
65
|
public void adjustStickerCoords()
|
66
|
{
|
67
|
mStickerCoords = new float[][]
|
68
|
{
|
69
|
{ -0.5f, 0.1428f, -0.1428f, 0.5f, 0.35f, -0.35f },
|
70
|
{ -0.5f, 0.0f, 0.0f, -0.5f, 0.5f, 0.0f, 0.0f, 0.5f },
|
71
|
{ -0.525f, 0.105f, 0.525f, 0.105f, 0.000f, -0.200f }
|
72
|
};
|
73
|
}
|
74
|
|
75
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
76
|
|
77
|
public ScrambleState[] getScrambleStates()
|
78
|
{
|
79
|
if( mStates==null )
|
80
|
{
|
81
|
int[] tmp = {0,-1,0, 0,1,0, 2,-1,0, 2,1,0 };
|
82
|
|
83
|
mStates = new ScrambleState[]
|
84
|
{
|
85
|
new ScrambleState( new int[][] {tmp,tmp,tmp,tmp} )
|
86
|
};
|
87
|
}
|
88
|
|
89
|
return mStates;
|
90
|
}
|
91
|
|
92
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
93
|
|
94
|
public float[][] getCuts(int[] numLayers)
|
95
|
{
|
96
|
if( mCuts==null )
|
97
|
{
|
98
|
float C = SQ3*0.45f; // bit less than 1/2 of the length of the main diagonal
|
99
|
float[] cut = new float[] {-C,+C};
|
100
|
mCuts = new float[][] { cut,cut,cut,cut };
|
101
|
}
|
102
|
|
103
|
return mCuts;
|
104
|
}
|
105
|
|
106
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
107
|
|
108
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
109
|
{
|
110
|
boolean[] tmp = new boolean[] {true,false,true};
|
111
|
return new boolean[][] { tmp,tmp,tmp,tmp };
|
112
|
}
|
113
|
|
114
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
115
|
|
116
|
public int getTouchControlType()
|
117
|
{
|
118
|
return TC_HEXAHEDRON;
|
119
|
}
|
120
|
|
121
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
122
|
|
123
|
public int getTouchControlSplit()
|
124
|
{
|
125
|
return TYPE_SPLIT_CORNER;
|
126
|
}
|
127
|
|
128
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
129
|
|
130
|
public int[][][] getEnabled()
|
131
|
{
|
132
|
return new int[][][]
|
133
|
{
|
134
|
{{0,1},{3,1},{2,3},{0,2}},
|
135
|
{{2,3},{3,1},{0,1},{0,2}},
|
136
|
{{1,2},{0,1},{0,3},{2,3}},
|
137
|
{{1,2},{2,3},{0,3},{0,1}},
|
138
|
{{0,3},{0,2},{1,2},{1,3}},
|
139
|
{{1,2},{0,2},{0,3},{1,3}},
|
140
|
};
|
141
|
}
|
142
|
|
143
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
144
|
|
145
|
public float[] getDist3D(int[] numLayers)
|
146
|
{
|
147
|
return TouchControlHexahedron.D3D;
|
148
|
}
|
149
|
|
150
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
151
|
|
152
|
public Static3D[] getFaceAxis()
|
153
|
{
|
154
|
return TouchControlHexahedron.FACE_AXIS;
|
155
|
}
|
156
|
|
157
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
158
|
|
159
|
public float[][] getCubitPositions(int[] numLayers)
|
160
|
{
|
161
|
final float DIST1= 1.50f;
|
162
|
final float DIST2= (1+2*REX_D)/2;
|
163
|
final float DIST3= 1.53f;
|
164
|
|
165
|
return new float[][]
|
166
|
{
|
167
|
{ +DIST3, +DIST2, +DIST2 },
|
168
|
{ +DIST3, +DIST2, -DIST2 },
|
169
|
{ +DIST3, -DIST2, -DIST2 },
|
170
|
{ +DIST3, -DIST2, +DIST2 },
|
171
|
{ -DIST3, +DIST2, +DIST2 },
|
172
|
{ -DIST3, +DIST2, -DIST2 },
|
173
|
{ -DIST3, -DIST2, -DIST2 },
|
174
|
{ -DIST3, -DIST2, +DIST2 },
|
175
|
{ +DIST2, +DIST3, +DIST2 },
|
176
|
{ +DIST2, +DIST3, -DIST2 },
|
177
|
{ -DIST2, +DIST3, -DIST2 },
|
178
|
{ -DIST2, +DIST3, +DIST2 },
|
179
|
{ +DIST2, -DIST3, +DIST2 },
|
180
|
{ +DIST2, -DIST3, -DIST2 },
|
181
|
{ -DIST2, -DIST3, -DIST2 },
|
182
|
{ -DIST2, -DIST3, +DIST2 },
|
183
|
{ +DIST2, +DIST2, +DIST3 },
|
184
|
{ +DIST2, -DIST2, +DIST3 },
|
185
|
{ -DIST2, -DIST2, +DIST3 },
|
186
|
{ -DIST2, +DIST2, +DIST3 },
|
187
|
{ +DIST2, +DIST2, -DIST3 },
|
188
|
{ +DIST2, -DIST2, -DIST3 },
|
189
|
{ -DIST2, -DIST2, -DIST3 },
|
190
|
{ -DIST2, +DIST2, -DIST3 },
|
191
|
|
192
|
{ +DIST3, +0.00f, +0.00f },
|
193
|
{ -DIST3, +0.00f, +0.00f },
|
194
|
{ +0.00f, +DIST3, +0.00f },
|
195
|
{ +0.00f, -DIST3, +0.00f },
|
196
|
{ +0.00f, +0.00f, +DIST3 },
|
197
|
{ +0.00f, +0.00f, -DIST3 },
|
198
|
|
199
|
{ +0.00f, +DIST1, +DIST1 },
|
200
|
{ +DIST1, +0.00f, +DIST1 },
|
201
|
{ +0.00f, -DIST1, +DIST1 },
|
202
|
{ -DIST1, +0.00f, +DIST1 },
|
203
|
{ +DIST1, +DIST1, +0.00f },
|
204
|
{ +DIST1, -DIST1, +0.00f },
|
205
|
{ -DIST1, -DIST1, +0.00f },
|
206
|
{ -DIST1, +DIST1, +0.00f },
|
207
|
{ +0.00f, +DIST1, -DIST1 },
|
208
|
{ +DIST1, +0.00f, -DIST1 },
|
209
|
{ +0.00f, -DIST1, -DIST1 },
|
210
|
{ -DIST1, +0.00f, -DIST1 },
|
211
|
};
|
212
|
}
|
213
|
|
214
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
215
|
|
216
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
217
|
{
|
218
|
switch(cubit)
|
219
|
{
|
220
|
case 0: return new Static4D(+SQ2/2, 0,+SQ2/2, 0);
|
221
|
case 1: return mObjectQuats[2];
|
222
|
case 2: return new Static4D( 0,-SQ2/2, 0, SQ2/2);
|
223
|
case 3: return mObjectQuats[5];
|
224
|
case 4: return mObjectQuats[3];
|
225
|
case 5: return new Static4D(-SQ2/2, 0,+SQ2/2, 0);
|
226
|
case 6: return mObjectQuats[8];
|
227
|
case 7: return new Static4D( 0,+SQ2/2, 0, SQ2/2);
|
228
|
case 8: return new Static4D(+SQ2/2, 0, 0, SQ2/2);
|
229
|
case 9: return mObjectQuats[7];
|
230
|
case 10: return new Static4D( 0,+SQ2/2,+SQ2/2, 0);
|
231
|
case 11: return mObjectQuats[1];
|
232
|
case 12: return mObjectQuats[6];
|
233
|
case 13: return new Static4D(-SQ2/2, 0, 0, SQ2/2);
|
234
|
case 14: return mObjectQuats[4];
|
235
|
case 15: return new Static4D( 0,-SQ2/2,+SQ2/2, 0);
|
236
|
case 16: return new Static4D( 0, 0,-SQ2/2, SQ2/2);
|
237
|
case 17: return mObjectQuats[0];
|
238
|
case 18: return new Static4D( 0, 0,+SQ2/2, SQ2/2);
|
239
|
case 19: return mObjectQuats[10];
|
240
|
case 20: return mObjectQuats[9];
|
241
|
case 21: return new Static4D(+SQ2/2,-SQ2/2, 0, 0);
|
242
|
case 22: return mObjectQuats[11];
|
243
|
case 23: return new Static4D(+SQ2/2,+SQ2/2, 0, 0);
|
244
|
|
245
|
case 24: return new Static4D( 0,-SQ2/2, 0, SQ2/2);
|
246
|
case 25: return new Static4D( 0,+SQ2/2, 0, SQ2/2);
|
247
|
case 26: return new Static4D(+SQ2/2, 0, 0, SQ2/2);
|
248
|
case 27: return new Static4D(-SQ2/2, 0, 0, SQ2/2);
|
249
|
case 28: return mObjectQuats[0];
|
250
|
case 29: return mObjectQuats[9];
|
251
|
|
252
|
case 30: return mObjectQuats[0];
|
253
|
case 31: return new Static4D( 0, 0,+SQ2/2, SQ2/2);
|
254
|
case 32: return mObjectQuats[10];
|
255
|
case 33: return new Static4D( 0, 0,-SQ2/2, SQ2/2);
|
256
|
case 34: return new Static4D( 0,-SQ2/2, 0, SQ2/2);
|
257
|
case 35: return mObjectQuats[4];
|
258
|
case 36: return mObjectQuats[6];
|
259
|
case 37: return new Static4D( 0,+SQ2/2, 0, SQ2/2);
|
260
|
case 38: return new Static4D(+SQ2/2, 0, 0, SQ2/2);
|
261
|
case 39: return mObjectQuats[5];
|
262
|
case 40: return mObjectQuats[9];
|
263
|
case 41: return mObjectQuats[3];
|
264
|
}
|
265
|
|
266
|
return mObjectQuats[0];
|
267
|
}
|
268
|
|
269
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
270
|
|
271
|
public ObjectShape getObjectShape(int variant)
|
272
|
{
|
273
|
if( variant==0 )
|
274
|
{
|
275
|
float[][] vertices= { {-0.10f,0.70f,0},{-0.70f,0.10f,0},{+0.65f,-0.71f,0},{+0.71f,-0.65f,0},{0,0.05f,-0.2f} };
|
276
|
int[][] indices = { {0,1,2,3},{0,3,4},{3,2,4},{2,1,4},{1,0,4} };
|
277
|
return new ObjectShape(vertices, indices);
|
278
|
}
|
279
|
else if( variant==1 )
|
280
|
{
|
281
|
float G = 3*REX_D;
|
282
|
float[][] vertices= { { -G, 0, 0 },{ 0,-G, 0 },{ +G, 0, 0 },{ 0,+G,0 },{ 0, 0,-G} };
|
283
|
int[][] indices = { {0,1,2,3},{0,3,4},{3,2,4},{2,1,4},{1,0,4} };
|
284
|
return new ObjectShape(vertices, indices);
|
285
|
}
|
286
|
else
|
287
|
{
|
288
|
float E = 1.5f - 3*REX_D;
|
289
|
float F = 1.5f;
|
290
|
float[][] vertices= { { -F, 0, 0 },{ 0,-E, 0 },{ +F, 0, 0 },{ 0, 0,-E } };
|
291
|
int[][] indices = { {0,1,2}, {0,2,3}, {0,3,1}, {1,3,2} };
|
292
|
return new ObjectShape(vertices, indices);
|
293
|
}
|
294
|
}
|
295
|
|
296
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
297
|
|
298
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
299
|
{
|
300
|
if( variant==0 )
|
301
|
{
|
302
|
float height = isInIconMode() ? 0.001f : 0.02f;
|
303
|
float G = (1-REX_D)*SQ2/2;
|
304
|
float[][] centers= { {0.0f,0.0f,-G} };
|
305
|
float[][] corners= { {0.03f,0.30f} };
|
306
|
int[] indices = {-1,-1,0,0,-1};
|
307
|
int[] bandIndices= { 0,1,1,1,1 };
|
308
|
float[][] bands = { { height,10,G/3,0.5f,5,1,1},{ 0.001f,45,0.1f,0.1f,2,0,0} };
|
309
|
return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
|
310
|
}
|
311
|
else if( variant==1 )
|
312
|
{
|
313
|
float height = isInIconMode() ? 0.001f : 0.025f;
|
314
|
float G = 3*REX_D;
|
315
|
int[] indices = {-1,-1,-1,-1,-1};
|
316
|
int[] bandIndices= { 0,1,1,1,1 };
|
317
|
float[][] bands = { {height,10,G/2,0.5f,5,0,0},{0.001f,45,G/2,0.0f,2,0,0} };
|
318
|
return new ObjectFaceShape(bands,bandIndices,null,indices,null,indices,null);
|
319
|
}
|
320
|
else
|
321
|
{
|
322
|
float h1 = isInIconMode() ? 0.001f : 0.03f;
|
323
|
float h2 = isInIconMode() ? 0.001f : 0.01f;
|
324
|
float E = 1.5f - 3*REX_D;
|
325
|
float F = 1.5f;
|
326
|
float G = (float)Math.sqrt(E*E+F*F);
|
327
|
float[][] centers= { {0.0f,-1.5f,-1.5f} };
|
328
|
float[][] corners= { {0.06f,0.20f} };
|
329
|
int[] indices = { 0,-1,0,-1 };
|
330
|
int[] bandIndices= { 0,0,1,1 };
|
331
|
float[][] bands = { {h1,12,F/3,0.8f,5,2,3},{h2,45,G/3,0.2f,5,2,3} };
|
332
|
return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
|
333
|
}
|
334
|
}
|
335
|
|
336
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
337
|
|
338
|
public int getNumCubitVariants(int[] numLayers)
|
339
|
{
|
340
|
return 3;
|
341
|
}
|
342
|
|
343
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
344
|
|
345
|
public int getCubitVariant(int cubit, int[] numLayers)
|
346
|
{
|
347
|
return cubit<24 ? 0 : (cubit<30?1:2);
|
348
|
}
|
349
|
|
350
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
351
|
|
352
|
public float getStickerRadius()
|
353
|
{
|
354
|
return 0.09f;
|
355
|
}
|
356
|
|
357
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
358
|
|
359
|
public float getStickerStroke()
|
360
|
{
|
361
|
return isInIconMode() ? 0.25f : 0.12f;
|
362
|
}
|
363
|
|
364
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
365
|
|
366
|
public float[][] getStickerAngles()
|
367
|
{
|
368
|
final float F = (float)(Math.PI/20);
|
369
|
return new float[][] { { -F/2,F,F },null,{ F/10,-F,-F } };
|
370
|
}
|
371
|
|
372
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
373
|
// PUBLIC API
|
374
|
|
375
|
public Static3D[] getRotationAxis()
|
376
|
{
|
377
|
return ROT_AXIS;
|
378
|
}
|
379
|
|
380
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
381
|
|
382
|
public int[] getBasicAngles()
|
383
|
{
|
384
|
if( mBasicAngle ==null ) mBasicAngle = new int[] { 3,3,3,3 };
|
385
|
return mBasicAngle;
|
386
|
}
|
387
|
|
388
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
389
|
|
390
|
public String getShortName()
|
391
|
{
|
392
|
return ObjectType.REX_3.name();
|
393
|
}
|
394
|
|
395
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
396
|
|
397
|
public long getSignature()
|
398
|
{
|
399
|
return ObjectType.REX_3.ordinal();
|
400
|
}
|
401
|
|
402
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
403
|
|
404
|
public String getObjectName()
|
405
|
{
|
406
|
return "Rex Cube";
|
407
|
}
|
408
|
|
409
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
410
|
|
411
|
public String getInventor()
|
412
|
{
|
413
|
return "Andrew Cormier";
|
414
|
}
|
415
|
|
416
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
417
|
|
418
|
public int getYearOfInvention()
|
419
|
{
|
420
|
return 2009;
|
421
|
}
|
422
|
|
423
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
424
|
|
425
|
public int getComplexity()
|
426
|
{
|
427
|
return 3;
|
428
|
}
|
429
|
|
430
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
431
|
|
432
|
public String[][] getTutorials()
|
433
|
{
|
434
|
return new String[][]{
|
435
|
{"gb","noAQfWqlMbk","Rex Cube Tutorial","CrazyBadCuber"},
|
436
|
{"es","Q90x9rjLJzw","Resolver Cubo Rex","Cuby"},
|
437
|
{"ru","Dr9CLM6A3fU","Как собрать Рекс Куб","Алексей Ярыгин"},
|
438
|
{"fr","SvK1kf6c43c","Résolution du Rex Cube","Asthalis"},
|
439
|
{"de","AI4vtwpRkEQ","Rex Cube - Tutorial","GerCubing"},
|
440
|
{"pl","ffbFRnHglWY","Rex Cube TUTORIAL PL","MrUk"},
|
441
|
{"kr","B3ftZzHRQyU","렉스 큐브 해법","듀나메스 큐브 해법연구소"},
|
442
|
{"vn","5nE9Q7QmOP4","Tutorial N.87 - Rex Cube","Duy Thích Rubik"},
|
443
|
};
|
444
|
}
|
445
|
}
|