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 org.distorted.library.type.Static3D;
|
23
|
import org.distorted.library.type.Static4D;
|
24
|
import org.distorted.objectlib.helpers.ObjectFaceShape;
|
25
|
import org.distorted.objectlib.helpers.ObjectShape;
|
26
|
import org.distorted.objectlib.helpers.ScrambleState;
|
27
|
import org.distorted.objectlib.main.ObjectControl;
|
28
|
import org.distorted.objectlib.main.ObjectType;
|
29
|
import org.distorted.objectlib.main.ShapeOctahedron;
|
30
|
import org.distorted.objectlib.touchcontrol.TouchControlOctahedron;
|
31
|
|
32
|
import java.io.InputStream;
|
33
|
|
34
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_OCTAHEDRON;
|
35
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
|
36
|
|
37
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
38
|
|
39
|
public class TwistyTrajber extends ShapeOctahedron
|
40
|
{
|
41
|
// each cut is at 1/5 of the length of the segment from the center to a vertex.
|
42
|
private static final float CUT = 0.2f;
|
43
|
private static final float LEN = 1.5f;
|
44
|
|
45
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
46
|
{
|
47
|
new Static3D(SQ2/2, 0, SQ2/2),
|
48
|
new Static3D( 0, 1, 0),
|
49
|
new Static3D(SQ2/2, 0,-SQ2/2)
|
50
|
};
|
51
|
|
52
|
private ScrambleState[] mStates;
|
53
|
private int[] mBasicAngle;
|
54
|
private float[][] mCuts;
|
55
|
private float[][] mCenters;
|
56
|
private int[] mQuatIndex;
|
57
|
|
58
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
59
|
|
60
|
public TwistyTrajber(int[] numL, int meshState, Static4D quat, Static3D move, float scale, InputStream stream)
|
61
|
{
|
62
|
super(numL, meshState, numL[0], quat, move, scale, stream);
|
63
|
}
|
64
|
|
65
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
66
|
|
67
|
public ScrambleState[] getScrambleStates()
|
68
|
{
|
69
|
if( mStates==null )
|
70
|
{
|
71
|
int[][] m = new int[16][];
|
72
|
|
73
|
for(int i=0; i<16; i++) m[i] = new int[] { 0,-1,i,0,1,i,0,2,i, 1,-1,i,1,1,i,1,2,i, 2,-1,i,2,1,i,2,2,i};
|
74
|
|
75
|
mStates = new ScrambleState[]
|
76
|
{
|
77
|
new ScrambleState( new int[][] { m[ 1], m[ 2], m[ 3] } ), // 0 0
|
78
|
new ScrambleState( new int[][] { null, m[ 4], m[ 5] } ), // 1 x
|
79
|
new ScrambleState( new int[][] { m[ 6], null, m[ 7] } ), // 2 y
|
80
|
new ScrambleState( new int[][] { m[ 8], m[ 9], null } ), // 3 z
|
81
|
new ScrambleState( new int[][] { m[10], null, m[ 7] } ), // 4 xy
|
82
|
new ScrambleState( new int[][] { m[11], m[ 9], null } ), // 5 xz
|
83
|
new ScrambleState( new int[][] { null, m[12], m[ 5] } ), // 6 yx
|
84
|
new ScrambleState( new int[][] { m[ 8], m[13], null } ), // 7 yz
|
85
|
new ScrambleState( new int[][] { null, m[ 4], m[14] } ), // 8 zx
|
86
|
new ScrambleState( new int[][] { m[ 6], null, m[15] } ), // 9 zy
|
87
|
new ScrambleState( new int[][] { null, null, m[ 5] } ), // 10 xyx
|
88
|
new ScrambleState( new int[][] { null, m[ 4], null } ), // 11 xzx
|
89
|
new ScrambleState( new int[][] { null, null, m[ 7] } ), // 12 yxy
|
90
|
new ScrambleState( new int[][] { m[ 6], null, null } ), // 13 yzy
|
91
|
new ScrambleState( new int[][] { null, m[ 9], null } ), // 14 zxz
|
92
|
new ScrambleState( new int[][] { m[ 8], null, null } ), // 15 zyz
|
93
|
};
|
94
|
}
|
95
|
|
96
|
return mStates;
|
97
|
}
|
98
|
|
99
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
100
|
|
101
|
public float[][] getCuts(int[] numLayers)
|
102
|
{
|
103
|
if( mCuts==null )
|
104
|
{
|
105
|
final float cut= CUT*LEN*SQ2;
|
106
|
mCuts = new float[][] { {-cut,+cut},{-cut,+cut},{-cut,+cut} };
|
107
|
}
|
108
|
|
109
|
return mCuts;
|
110
|
}
|
111
|
|
112
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
113
|
|
114
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
115
|
{
|
116
|
boolean[] tmp = {true,true,true};
|
117
|
return new boolean[][] { tmp,tmp,tmp };
|
118
|
}
|
119
|
|
120
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
121
|
|
122
|
public int getTouchControlType()
|
123
|
{
|
124
|
return TC_OCTAHEDRON;
|
125
|
}
|
126
|
|
127
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
128
|
|
129
|
public int getTouchControlSplit()
|
130
|
{
|
131
|
return TYPE_NOT_SPLIT;
|
132
|
}
|
133
|
|
134
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
135
|
|
136
|
public int[][][] getEnabled()
|
137
|
{
|
138
|
return new int[][][]
|
139
|
{
|
140
|
{{0,1,2}},{{0,1,2}},{{0,1,2}},{{0,1,2}},{{0,1,2}},{{0,1,2}},{{0,1,2}},{{0,1,2}}
|
141
|
};
|
142
|
}
|
143
|
|
144
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
145
|
|
146
|
public float[] getDist3D(int[] numLayers)
|
147
|
{
|
148
|
return TouchControlOctahedron.D3D;
|
149
|
}
|
150
|
|
151
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
152
|
|
153
|
public Static3D[] getFaceAxis()
|
154
|
{
|
155
|
return TouchControlOctahedron.FACE_AXIS;
|
156
|
}
|
157
|
|
158
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
159
|
|
160
|
public float[][] getCubitPositions(int[] numLayers)
|
161
|
{
|
162
|
if( mCenters==null )
|
163
|
{
|
164
|
mCenters = new float[][]
|
165
|
{
|
166
|
{ LEN, 0, LEN},
|
167
|
{ -LEN, 0, -LEN},
|
168
|
{ 0, SQ2*LEN, 0},
|
169
|
{ 0,-SQ2*LEN, 0},
|
170
|
{ -LEN, 0, LEN},
|
171
|
{ LEN, 0, -LEN},
|
172
|
|
173
|
{-LEN/2, (SQ2/2)*LEN, LEN/2},
|
174
|
{ LEN/2, (SQ2/2)*LEN,-LEN/2},
|
175
|
{-LEN/2,-(SQ2/2)*LEN, LEN/2},
|
176
|
{ LEN/2,-(SQ2/2)*LEN,-LEN/2},
|
177
|
{ 0, 0, LEN},
|
178
|
{ LEN, 0, 0},
|
179
|
{ -LEN, 0, 0},
|
180
|
{ 0, 0, -LEN},
|
181
|
{ LEN/2, (SQ2/2)*LEN, LEN/2},
|
182
|
{ LEN/2,-(SQ2/2)*LEN, LEN/2},
|
183
|
{-LEN/2, (SQ2/2)*LEN,-LEN/2},
|
184
|
{-LEN/2,-(SQ2/2)*LEN,-LEN/2},
|
185
|
|
186
|
{ 0, SQ2*LEN/3, 2*LEN/3},
|
187
|
{ 2*LEN/3, SQ2*LEN/3, 0},
|
188
|
{ 0,-SQ2*LEN/3, 2*LEN/3},
|
189
|
{ 2*LEN/3,-SQ2*LEN/3, 0},
|
190
|
{-2*LEN/3, SQ2*LEN/3, 0},
|
191
|
{ 0, SQ2*LEN/3,-2*LEN/3},
|
192
|
{-2*LEN/3,-SQ2*LEN/3, 0},
|
193
|
{ 0,-SQ2*LEN/3,-2*LEN/3},
|
194
|
};
|
195
|
}
|
196
|
|
197
|
return mCenters;
|
198
|
}
|
199
|
|
200
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
201
|
|
202
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
203
|
{
|
204
|
if( mQuatIndex==null ) mQuatIndex = new int[] {6,4,1,3,0,2, 7,19,9,18, 0,2,8,5, 1,3,14,11, 0,1,3,2,7,5,8,16 };
|
205
|
return mObjectQuats[mQuatIndex[cubit]];
|
206
|
}
|
207
|
|
208
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
209
|
|
210
|
public ObjectShape getObjectShape(int variant)
|
211
|
{
|
212
|
if( variant==0 )
|
213
|
{
|
214
|
final float A = SQ2*CUT*LEN;
|
215
|
final float B = CUT*LEN;
|
216
|
|
217
|
float[][] vertices =
|
218
|
{
|
219
|
{ 0, 0, 0},
|
220
|
{ B, A, -B},
|
221
|
{ B, -A, -B},
|
222
|
{ 2*B, 0, 0},
|
223
|
{ 0, 0, -2*B},
|
224
|
{ 3*B, A, -B},
|
225
|
{ 3*B, -A, -B},
|
226
|
{ B, A, -3*B},
|
227
|
{ B, -A, -3*B},
|
228
|
|
229
|
{ LEN , A, SQ2*A-LEN},
|
230
|
{ LEN , -A, SQ2*A-LEN},
|
231
|
{ LEN-SQ2*A, A, -LEN},
|
232
|
{ LEN-SQ2*A, -A, -LEN}
|
233
|
};
|
234
|
|
235
|
int[][] indices =
|
236
|
{
|
237
|
{0,3,5,1},
|
238
|
{0,2,6,3},
|
239
|
{0,4,8,2},
|
240
|
{0,1,7,4},
|
241
|
{3,6,10,9,5},
|
242
|
{2,8,12,10,6},
|
243
|
{4,7,11,12,8},
|
244
|
{1,5,9,11,7},
|
245
|
{9,10,12,11}
|
246
|
};
|
247
|
|
248
|
return new ObjectShape(vertices, indices);
|
249
|
}
|
250
|
if( variant==1 )
|
251
|
{
|
252
|
final float A = SQ2*CUT*LEN;
|
253
|
final float B = LEN-2*LEN*CUT;
|
254
|
final float C = (SQ2/2)*A;
|
255
|
|
256
|
float[][] vertices =
|
257
|
{
|
258
|
{ -B, 0, 0 },
|
259
|
{ -B+C, A, -C },
|
260
|
{ -B+C,-A, -C },
|
261
|
{ B, 0, 0 },
|
262
|
{ B-C, A, -C },
|
263
|
{ B-C,-A, -C },
|
264
|
{ 0, A, -B },
|
265
|
{ 0,-A, -B },
|
266
|
};
|
267
|
|
268
|
int[][] indices =
|
269
|
{
|
270
|
{0,3,4,1},
|
271
|
{0,2,5,3},
|
272
|
{1,4,6},
|
273
|
{2,7,5},
|
274
|
{0,1,6,7,2},
|
275
|
{3,5,7,6,4}
|
276
|
};
|
277
|
|
278
|
return new ObjectShape(vertices, indices);
|
279
|
}
|
280
|
else
|
281
|
{
|
282
|
final float L = LEN-3*LEN*CUT;
|
283
|
|
284
|
float[][] vertices =
|
285
|
{
|
286
|
{ -L, -(SQ2/3)*L, L/3 },
|
287
|
{ L, -(SQ2/3)*L, L/3 },
|
288
|
{ 0,(2*SQ2/3)*L,-2*L/3 },
|
289
|
{ 0, -(SQ2/3)*L,-2*L/3 },
|
290
|
};
|
291
|
|
292
|
int[][] indices =
|
293
|
{
|
294
|
{0,1,2},
|
295
|
{3,1,0},
|
296
|
{0,2,3},
|
297
|
{1,3,2},
|
298
|
};
|
299
|
|
300
|
return new ObjectShape(vertices, indices);
|
301
|
}
|
302
|
}
|
303
|
|
304
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
305
|
|
306
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
307
|
{
|
308
|
if( variant==0 )
|
309
|
{
|
310
|
float[][] bands = { {0.05f,35,0.15f,0.3f,4,1,1},{0.00f,35,0.15f,0.3f,4,1,1} };
|
311
|
int[] bandIndices = { 0,0,0,0,1,1,1,1,1 };
|
312
|
float[][] corners = { {0.03f,0.10f} };
|
313
|
int[] cornerIndices = { 0,-1,-1,-1,-1,0,0,0,0,-1,-1,-1,-1 };
|
314
|
float[][] centers = { { LEN/2, 0.0f, -LEN/2} };
|
315
|
int[] centerIndices = { 0,-1,-1,-1,-1,0,0,0,0,-1,-1,-1,-1 };
|
316
|
return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
|
317
|
}
|
318
|
if( variant==1 )
|
319
|
{
|
320
|
final float B = LEN-2*LEN*CUT;
|
321
|
float[][] bands = { {0.03f,35,0.15f,0.3f,3,1,1},{0.00f,35,0.15f,0.3f,3,1,1} };
|
322
|
int[] bandIndices = { 0,0,1,1,1,1 };
|
323
|
float[][] corners = { {0.02f,0.10f} };
|
324
|
int[] cornerIndices = { 0,0,0,0,0,0,-1,-1 };
|
325
|
float[][] centers = { { 0, 0, -B} };
|
326
|
int[] centerIndices = { 0,0,0,0,0,0,-1,-1 };
|
327
|
return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
|
328
|
}
|
329
|
else
|
330
|
{
|
331
|
final float L = LEN-3*LEN*CUT;
|
332
|
float[][] bands = { {0.03f,35,0.15f,0.3f,4,1,1},{0.00f,35,0.15f,0.3f,4,0,0} };
|
333
|
int[] bandIndices = { 0,1,1,1 };
|
334
|
float[][] corners = { {0.02f,0.10f} };
|
335
|
int[] cornerIndices = { 0,0,0,-1 };
|
336
|
float[][] centers = { {0, -(SQ2/3)*L,-2*L/3} };
|
337
|
int[] centerIndices = { 0,0,0,-1 };
|
338
|
return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
|
339
|
}
|
340
|
}
|
341
|
|
342
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
343
|
|
344
|
public int getNumCubitVariants(int[] numLayers)
|
345
|
{
|
346
|
return 3;
|
347
|
}
|
348
|
|
349
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
350
|
|
351
|
public int getCubitVariant(int cubit, int[] numLayers)
|
352
|
{
|
353
|
return cubit<6 ? 0 : cubit<18 ? 1 : 2;
|
354
|
}
|
355
|
|
356
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
357
|
|
358
|
public float getStickerRadius()
|
359
|
{
|
360
|
return 0.12f;
|
361
|
}
|
362
|
|
363
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
364
|
|
365
|
public float getStickerStroke()
|
366
|
{
|
367
|
return ObjectControl.isInIconMode() ? 0.20f : 0.10f;
|
368
|
}
|
369
|
|
370
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
371
|
|
372
|
public float[][] getStickerAngles()
|
373
|
{
|
374
|
return null;
|
375
|
}
|
376
|
|
377
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
378
|
// PUBLIC API
|
379
|
|
380
|
public Static3D[] getRotationAxis()
|
381
|
{
|
382
|
return ROT_AXIS;
|
383
|
}
|
384
|
|
385
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
386
|
|
387
|
public int[] getBasicAngles()
|
388
|
{
|
389
|
if( mBasicAngle ==null ) mBasicAngle = new int[] { 4,4,4 };
|
390
|
return mBasicAngle;
|
391
|
}
|
392
|
|
393
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
394
|
|
395
|
public ObjectType intGetObjectType(int[] numLayers)
|
396
|
{
|
397
|
return ObjectType.TRAJ_3;
|
398
|
}
|
399
|
|
400
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
401
|
|
402
|
public String getObjectName()
|
403
|
{
|
404
|
return "Trajber's Octahedron";
|
405
|
}
|
406
|
|
407
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
408
|
|
409
|
public String getInventor()
|
410
|
{
|
411
|
return "Josef Trajber";
|
412
|
}
|
413
|
|
414
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
415
|
|
416
|
public int getYearOfInvention()
|
417
|
{
|
418
|
return 1982;
|
419
|
}
|
420
|
|
421
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
422
|
|
423
|
public int getComplexity()
|
424
|
{
|
425
|
return 2;
|
426
|
}
|
427
|
|
428
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
429
|
|
430
|
public String[][] getTutorials()
|
431
|
{
|
432
|
return new String[][] {
|
433
|
{"gb","Q2NSiuJWVvk","Trajber and UFO Tutorial","SuperAntoniovivaldi"},
|
434
|
{"es","FPBirEJ8ZfY","Resolver Octaedro 3x3","Solución Rubik"},
|
435
|
{"de","FjQXlwJGniQ","Trajbers Octahedron Tutorial","GerCubing"},
|
436
|
{"br","kO3nMpZKv3Q","Resolver Octaedro Trajber","Rafael Cinoto"},
|
437
|
};
|
438
|
}
|
439
|
}
|