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