1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2022 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.ObjectSignature;
|
27
|
import org.distorted.objectlib.scrambling.ScrambleState;
|
28
|
import org.distorted.objectlib.main.ObjectType;
|
29
|
import org.distorted.objectlib.main.ShapeHexahedron;
|
30
|
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
|
31
|
|
32
|
import java.io.InputStream;
|
33
|
|
34
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_CHANGING_SHAPEMOD;
|
35
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
|
36
|
|
37
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
38
|
|
39
|
public class TwistyFisher extends ShapeHexahedron
|
40
|
{
|
41
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
42
|
{
|
43
|
new Static3D( SQ2/2, 0.0f, SQ2/2),
|
44
|
new Static3D( 0.0f, 1.0f, 0.0f),
|
45
|
new Static3D( SQ2/2, 0.0f,-SQ2/2),
|
46
|
};
|
47
|
|
48
|
private ScrambleState[] mStates;
|
49
|
private int[][] mBasicAngle;
|
50
|
private float[][] mCuts;
|
51
|
private float[][] mCenters;
|
52
|
private int[] mQuatIndex;
|
53
|
|
54
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
55
|
|
56
|
public TwistyFisher(int[] numL, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
|
57
|
{
|
58
|
super(numL, meshState, iconMode, numL[0], quat, move, scale, stream);
|
59
|
}
|
60
|
|
61
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
62
|
|
63
|
@Override
|
64
|
public int getInternalColor()
|
65
|
{
|
66
|
return 0xff333333;
|
67
|
}
|
68
|
|
69
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
70
|
// same as in a 3x3
|
71
|
|
72
|
public ScrambleState[] getScrambleStates()
|
73
|
{
|
74
|
if( mStates==null )
|
75
|
{
|
76
|
int[][] m = new int[16][];
|
77
|
|
78
|
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};
|
79
|
|
80
|
mStates = new ScrambleState[]
|
81
|
{
|
82
|
new ScrambleState( new int[][] { m[ 1], m[ 2], m[ 3] } ), // 0 0
|
83
|
new ScrambleState( new int[][] { null, m[ 4], m[ 5] } ), // 1 x
|
84
|
new ScrambleState( new int[][] { m[ 6], null, m[ 7] } ), // 2 y
|
85
|
new ScrambleState( new int[][] { m[ 8], m[ 9], null } ), // 3 z
|
86
|
new ScrambleState( new int[][] { m[10], null, m[ 7] } ), // 4 xy
|
87
|
new ScrambleState( new int[][] { m[11], m[ 9], null } ), // 5 xz
|
88
|
new ScrambleState( new int[][] { null, m[12], m[ 5] } ), // 6 yx
|
89
|
new ScrambleState( new int[][] { m[ 8], m[13], null } ), // 7 yz
|
90
|
new ScrambleState( new int[][] { null, m[ 4], m[14] } ), // 8 zx
|
91
|
new ScrambleState( new int[][] { m[ 6], null, m[15] } ), // 9 zy
|
92
|
new ScrambleState( new int[][] { null, null, m[ 5] } ), // 10 xyx
|
93
|
new ScrambleState( new int[][] { null, m[ 4], null } ), // 11 xzx
|
94
|
new ScrambleState( new int[][] { null, null, m[ 7] } ), // 12 yxy
|
95
|
new ScrambleState( new int[][] { m[ 6], null, null } ), // 13 yzy
|
96
|
new ScrambleState( new int[][] { null, m[ 9], null } ), // 14 zxz
|
97
|
new ScrambleState( new int[][] { m[ 8], null, null } ), // 15 zyz
|
98
|
};
|
99
|
}
|
100
|
|
101
|
return mStates;
|
102
|
}
|
103
|
|
104
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
105
|
|
106
|
public float[][] getCuts(int[] numLayers)
|
107
|
{
|
108
|
if( mCuts==null )
|
109
|
{
|
110
|
float C = 0.5f;
|
111
|
float[] cut = new float[] {-C,+C};
|
112
|
mCuts = new float[][] { cut,cut,cut };
|
113
|
}
|
114
|
|
115
|
return mCuts;
|
116
|
}
|
117
|
|
118
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
119
|
|
120
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
121
|
{
|
122
|
boolean[] tmp = new boolean[] {true,true,true};
|
123
|
return new boolean[][] { tmp,tmp,tmp };
|
124
|
}
|
125
|
|
126
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
127
|
|
128
|
public int getTouchControlType()
|
129
|
{
|
130
|
return TC_CHANGING_SHAPEMOD;
|
131
|
}
|
132
|
|
133
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
134
|
|
135
|
public int getTouchControlSplit()
|
136
|
{
|
137
|
return TYPE_NOT_SPLIT;
|
138
|
}
|
139
|
|
140
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
141
|
|
142
|
public int[][][] getEnabled()
|
143
|
{
|
144
|
return null;
|
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( mCenters==null )
|
166
|
{
|
167
|
mCenters = new float[][]
|
168
|
{
|
169
|
{ 0.0f, 1.0f, 1.5f },
|
170
|
{ 1.5f, 1.0f, 0.0f },
|
171
|
{ 0.0f, 1.0f,-1.5f },
|
172
|
{-1.5f, 1.0f, 0.0f },
|
173
|
{ 0.0f, 0.0f, 1.5f },
|
174
|
{ 1.5f, 0.0f, 0.0f },
|
175
|
{ 0.0f, 0.0f,-1.5f },
|
176
|
{-1.5f, 0.0f, 0.0f },
|
177
|
{ 0.0f,-1.0f, 1.5f },
|
178
|
{ 1.5f,-1.0f, 0.0f },
|
179
|
{ 0.0f,-1.0f,-1.5f },
|
180
|
{-1.5f,-1.0f, 0.0f },
|
181
|
|
182
|
{-1.5f, 1.0f, 1.5f },
|
183
|
{ 1.5f, 1.0f, 1.5f },
|
184
|
{ 1.5f, 1.0f,-1.5f },
|
185
|
{-1.5f, 1.0f,-1.5f },
|
186
|
{-1.5f, 0.0f, 1.5f },
|
187
|
{ 1.5f, 0.0f, 1.5f },
|
188
|
{ 1.5f, 0.0f,-1.5f },
|
189
|
{-1.5f, 0.0f,-1.5f },
|
190
|
{-1.5f,-1.0f, 1.5f },
|
191
|
{ 1.5f,-1.0f, 1.5f },
|
192
|
{ 1.5f,-1.0f,-1.5f },
|
193
|
{-1.5f,-1.0f,-1.5f },
|
194
|
|
195
|
{ 0.0f, 1.0f, 0.0f },
|
196
|
{ 0.0f,-1.0f, 0.0f },
|
197
|
};
|
198
|
}
|
199
|
|
200
|
return mCenters;
|
201
|
}
|
202
|
|
203
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
204
|
|
205
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
206
|
{
|
207
|
if( mQuatIndex==null )
|
208
|
{
|
209
|
mQuatIndex = new int[] {0,6,5,4,0,6,5,4,0,6,5,4,
|
210
|
0,6,5,4,0,6,5,4,0,6,5,4,
|
211
|
0,0 };
|
212
|
}
|
213
|
|
214
|
return mObjectQuats[mQuatIndex[cubit]];
|
215
|
}
|
216
|
|
217
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
218
|
|
219
|
public ObjectShape getObjectShape(int variant)
|
220
|
{
|
221
|
if( variant==0 )
|
222
|
{
|
223
|
final float A = (3-SQ2)/2;
|
224
|
|
225
|
float[][] vertices =
|
226
|
{
|
227
|
{ -A, 0.5f, 0.0f },
|
228
|
{ A, 0.5f, 0.0f },
|
229
|
{ A,-0.5f, 0.0f },
|
230
|
{ -A,-0.5f, 0.0f },
|
231
|
{0.0f, 0.5f, -A },
|
232
|
{0.0f,-0.5f, -A },
|
233
|
};
|
234
|
|
235
|
int[][] indices =
|
236
|
{
|
237
|
{ 3,2,1,0 },
|
238
|
{ 0,1,4 },
|
239
|
{ 5,2,3 },
|
240
|
{ 5,3,0,4 },
|
241
|
{ 2,5,4,1 },
|
242
|
};
|
243
|
|
244
|
return new ObjectShape(vertices, indices);
|
245
|
}
|
246
|
else if( variant==1 )
|
247
|
{
|
248
|
final float A = SQ2/2;
|
249
|
final float B = (3-SQ2)/2;
|
250
|
|
251
|
float[][] vertices =
|
252
|
{
|
253
|
{0.0f, 0.5f, 0.0f},
|
254
|
{ A, 0.5f, 0.0f},
|
255
|
{1.5f, 0.5f, -B},
|
256
|
{ B, 0.5f,-1.5f},
|
257
|
{0.0f, 0.5f, -A},
|
258
|
{0.0f,-0.5f, 0.0f},
|
259
|
{ A,-0.5f, 0.0f},
|
260
|
{1.5f,-0.5f, -B},
|
261
|
{ B,-0.5f,-1.5f},
|
262
|
{0.0f,-0.5f, -A},
|
263
|
};
|
264
|
|
265
|
int[][] indices =
|
266
|
{
|
267
|
{0,1,2,3,4},
|
268
|
{9,8,7,6,5},
|
269
|
{5,6,1,0},
|
270
|
{6,7,2,1},
|
271
|
{7,8,3,2},
|
272
|
{8,9,4,3},
|
273
|
{9,5,0,4}
|
274
|
};
|
275
|
|
276
|
return new ObjectShape(vertices, indices);
|
277
|
}
|
278
|
else
|
279
|
{
|
280
|
final float A = SQ2/2;
|
281
|
|
282
|
float[][] vertices =
|
283
|
{
|
284
|
{ -A, 0.5f, 0.0f },
|
285
|
{ 0.0f, 0.5f, A },
|
286
|
{ 0.0f,-0.5f, A },
|
287
|
{ -A,-0.5f, 0.0f },
|
288
|
{ 0.0f, 0.5f, -A },
|
289
|
{ A, 0.5f, 0.0f },
|
290
|
{ A,-0.5f, 0.0f },
|
291
|
{ 0.0f,-0.5f, -A },
|
292
|
};
|
293
|
|
294
|
int[][] indices =
|
295
|
{
|
296
|
{ 3,2,1,0 },
|
297
|
{ 0,1,5,4 },
|
298
|
{ 7,6,2,3 },
|
299
|
{ 2,6,5,1 },
|
300
|
{ 6,7,4,5 },
|
301
|
{ 7,3,0,4 }
|
302
|
};
|
303
|
|
304
|
return new ObjectShape(vertices, indices);
|
305
|
}
|
306
|
}
|
307
|
|
308
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
309
|
|
310
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
311
|
{
|
312
|
if( variant==0 )
|
313
|
{
|
314
|
final float A = (3-SQ2)/2;
|
315
|
float h1 = isInIconMode() ? 0.001f : 0.025f;
|
316
|
float h2 = isInIconMode() ? 0.001f : 0.020f;
|
317
|
float[][] bands = { {h1,20,0.2f,0.4f,5,1,1}, {h2,20,0.2f,0.4f,5,1,1} };
|
318
|
int[] bandIndices = { 0,0,0,1,1 };
|
319
|
float[][] corners = { {0.04f,0.09f} };
|
320
|
int[] indices = { 0,0,0,0,-1,-1 };
|
321
|
float[][] centers = { { 0.0f, 0.0f,-A/2 } };
|
322
|
return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
|
323
|
}
|
324
|
else if( variant==1 )
|
325
|
{
|
326
|
final float B = SQ2/2;
|
327
|
float h1 = isInIconMode() ? 0.001f : 0.025f;
|
328
|
float h2 = isInIconMode() ? 0.001f : 0.020f;
|
329
|
float[][] bands = { {h1,20,0.2f,0.4f,5,1,1}, {h2,20,0.2f,0.4f,5,1,1} };
|
330
|
int[] bandIndices = { 0,0,0,1,1,1,0 };
|
331
|
float[][] corners = { {0.03f,0.09f} };
|
332
|
int[] indices = { 0,0,-1,-1,0,0,0,-1,-1,0 };
|
333
|
float[][] centers = { { B, 0.0f, -B } };
|
334
|
return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
|
335
|
}
|
336
|
else
|
337
|
{
|
338
|
float h1 = isInIconMode() ? 0.001f : 0.05f;
|
339
|
float h2 = isInIconMode() ? 0.001f : 0.04f;
|
340
|
float[][] bands = { {h1,35,0.25f,0.7f,5,1,0}, {h2,35,0.25f,0.7f,5,1,0} };
|
341
|
int[] bandIndices = { 1,0,0,1,1,1 };
|
342
|
float[][] corners = { {0.04f,0.12f} };
|
343
|
int[] indices = { 0,0,0,0,0,0,0,0 };
|
344
|
float[][] centers = { {0.0f, 0.0f, 0.0f } };
|
345
|
return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
|
346
|
}
|
347
|
}
|
348
|
|
349
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
350
|
|
351
|
public int getNumCubitVariants(int[] numLayers)
|
352
|
{
|
353
|
return 3;
|
354
|
}
|
355
|
|
356
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
357
|
|
358
|
public int getCubitVariant(int cubit, int[] numLayers)
|
359
|
{
|
360
|
return cubit<12 ? 0 : (cubit<24 ? 1:2);
|
361
|
}
|
362
|
|
363
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
364
|
|
365
|
public float getStickerRadius()
|
366
|
{
|
367
|
return 0.13f;
|
368
|
}
|
369
|
|
370
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
371
|
|
372
|
public float getStickerStroke()
|
373
|
{
|
374
|
return isInIconMode() ? 0.22f : 0.10f;
|
375
|
}
|
376
|
|
377
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
378
|
|
379
|
public float[][] getStickerAngles()
|
380
|
{
|
381
|
return null;
|
382
|
}
|
383
|
|
384
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
385
|
// PUBLIC API
|
386
|
|
387
|
public Static3D[] getRotationAxis()
|
388
|
{
|
389
|
return ROT_AXIS;
|
390
|
}
|
391
|
|
392
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
393
|
|
394
|
public int[][] getBasicAngles()
|
395
|
{
|
396
|
if( mBasicAngle==null )
|
397
|
{
|
398
|
int num = getNumLayers()[0];
|
399
|
int[] tmp = new int[num];
|
400
|
for(int i=0; i<num; i++) tmp[i] = 4;
|
401
|
mBasicAngle = new int[][] { tmp,tmp,tmp };
|
402
|
}
|
403
|
|
404
|
return mBasicAngle;
|
405
|
}
|
406
|
|
407
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
408
|
|
409
|
public String getShortName()
|
410
|
{
|
411
|
return ObjectType.FISH_3.name();
|
412
|
}
|
413
|
|
414
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
415
|
|
416
|
public ObjectSignature getSignature()
|
417
|
{
|
418
|
return new ObjectSignature(ObjectType.FISH_3);
|
419
|
}
|
420
|
|
421
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
422
|
|
423
|
public String getObjectName()
|
424
|
{
|
425
|
return "Fisher Cube";
|
426
|
}
|
427
|
|
428
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
429
|
|
430
|
public String getInventor()
|
431
|
{
|
432
|
return "Tony Fisher";
|
433
|
}
|
434
|
|
435
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
436
|
|
437
|
public int getYearOfInvention()
|
438
|
{
|
439
|
return 1982;
|
440
|
}
|
441
|
|
442
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
443
|
|
444
|
public int getComplexity()
|
445
|
{
|
446
|
return 2;
|
447
|
}
|
448
|
|
449
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
450
|
|
451
|
public String[][] getTutorials()
|
452
|
{
|
453
|
return new String[][]{
|
454
|
{"gb","HhQLhGGcKK0","Solving the Fisher Cube","Junk Cuber"},
|
455
|
{"es","Ndd0V1gWju0","Como resolver 3x3x3 Fisher Cube","Tutoriales Rubik"},
|
456
|
{"ru","KfeDuy4n72Q","Как собрать Фишер Куб","Алексей Ярыгин"},
|
457
|
{"fr","qnnvpFzcZO4","Résolution du Fisher's Cube","asthalis"},
|
458
|
{"de","aSrF0VxVqck","Fisher Cube Tutorial","Pezcraft"},
|
459
|
{"pl","vFKujycV3cs","Fisher Cube TUTORIAL PL","MrUk"},
|
460
|
{"br","S4En0RXDIbs","Como resolver o Fisher Cube","Pedro Filho"},
|
461
|
{"kr","x9SySGU_iqE","피셔 큐브 맞추는 방법","iamzoone"},
|
462
|
{"vn","pW3nmZtkfwk","Hướng Dẫn Giải Rubik Fisher","Rubik Cube"},
|
463
|
};
|
464
|
}
|
465
|
}
|