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.scrambling.ScrambleState;
|
27
|
import org.distorted.objectlib.main.ObjectControl;
|
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, Static4D quat, Static3D move, float scale, InputStream stream)
|
57
|
{
|
58
|
super(numL, meshState, 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
|
int I0 =0; int I1 =6; int I2 =5; int I3 =4;
|
208
|
if( mQuatIndex==null ) mQuatIndex = new int[] {I0,I1,I2,I3,I0,I1,I2,I3,I0,I1,I2,I3, I0,I1,I2,I3,I0,I1,I2,I3,I0,I1,I2,I3, 0,0 };
|
209
|
return mObjectQuats[mQuatIndex[cubit]];
|
210
|
}
|
211
|
|
212
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
213
|
|
214
|
public ObjectShape getObjectShape(int variant)
|
215
|
{
|
216
|
if( variant==0 )
|
217
|
{
|
218
|
final float A = (3-SQ2)/2;
|
219
|
|
220
|
float[][] vertices =
|
221
|
{
|
222
|
{ -A, 0.5f, 0.0f },
|
223
|
{ A, 0.5f, 0.0f },
|
224
|
{ A,-0.5f, 0.0f },
|
225
|
{ -A,-0.5f, 0.0f },
|
226
|
{0.0f, 0.5f, -A },
|
227
|
{0.0f,-0.5f, -A },
|
228
|
};
|
229
|
|
230
|
int[][] indices =
|
231
|
{
|
232
|
{ 3,2,1,0 },
|
233
|
{ 0,1,4 },
|
234
|
{ 5,2,3 },
|
235
|
{ 5,3,0,4 },
|
236
|
{ 2,5,4,1 },
|
237
|
};
|
238
|
|
239
|
return new ObjectShape(vertices, indices);
|
240
|
}
|
241
|
else if( variant==1 )
|
242
|
{
|
243
|
final float A = SQ2/2;
|
244
|
final float B = (3-SQ2)/2;
|
245
|
|
246
|
float[][] vertices =
|
247
|
{
|
248
|
{0.0f, 0.5f, 0.0f},
|
249
|
{ A, 0.5f, 0.0f},
|
250
|
{1.5f, 0.5f, -B},
|
251
|
{ B, 0.5f,-1.5f},
|
252
|
{0.0f, 0.5f, -A},
|
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
|
};
|
259
|
|
260
|
int[][] indices =
|
261
|
{
|
262
|
{0,1,2,3,4},
|
263
|
{9,8,7,6,5},
|
264
|
{5,6,1,0},
|
265
|
{6,7,2,1},
|
266
|
{7,8,3,2},
|
267
|
{8,9,4,3},
|
268
|
{9,5,0,4}
|
269
|
};
|
270
|
|
271
|
return new ObjectShape(vertices, indices);
|
272
|
}
|
273
|
else
|
274
|
{
|
275
|
final float A = SQ2/2;
|
276
|
|
277
|
float[][] vertices =
|
278
|
{
|
279
|
{ -A, 0.5f, 0.0f },
|
280
|
{ 0.0f, 0.5f, A },
|
281
|
{ 0.0f,-0.5f, A },
|
282
|
{ -A,-0.5f, 0.0f },
|
283
|
{ 0.0f, 0.5f, -A },
|
284
|
{ A, 0.5f, 0.0f },
|
285
|
{ A,-0.5f, 0.0f },
|
286
|
{ 0.0f,-0.5f, -A },
|
287
|
};
|
288
|
|
289
|
int[][] indices =
|
290
|
{
|
291
|
{ 3,2,1,0 },
|
292
|
{ 0,1,5,4 },
|
293
|
{ 7,6,2,3 },
|
294
|
{ 2,6,5,1 },
|
295
|
{ 6,7,4,5 },
|
296
|
{ 7,3,0,4 }
|
297
|
};
|
298
|
|
299
|
return new ObjectShape(vertices, indices);
|
300
|
}
|
301
|
}
|
302
|
|
303
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
304
|
|
305
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
306
|
{
|
307
|
if( variant==0 )
|
308
|
{
|
309
|
final float A = (3-SQ2)/2;
|
310
|
|
311
|
float[][] bands = { {0.025f,20,0.2f,0.4f,5,1,1}, {0.02f,20,0.2f,0.4f,5,1,1} };
|
312
|
int[] bandIndices = { 0,0,0,1,1 };
|
313
|
float[][] corners = { {0.04f,0.09f} };
|
314
|
int[] indices = { 0,0,0,0,-1,-1 };
|
315
|
float[][] centers = { { 0.0f, 0.0f,-A/2 } };
|
316
|
return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
|
317
|
}
|
318
|
else if( variant==1 )
|
319
|
{
|
320
|
final float B = SQ2/2;
|
321
|
|
322
|
float[][] bands = { {0.025f,20,0.2f,0.4f,5,1,1}, {0.02f,20,0.2f,0.4f,5,1,1} };
|
323
|
int[] bandIndices = { 0,0,0,1,1,1,0 };
|
324
|
float[][] corners = { {0.03f,0.09f} };
|
325
|
int[] indices = { 0,0,-1,-1,0,0,0,-1,-1,0 };
|
326
|
float[][] centers = { { B, 0.0f, -B } };
|
327
|
return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
|
328
|
}
|
329
|
else
|
330
|
{
|
331
|
float[][] bands = { {0.05f,35,0.25f,0.7f,5,1,0}, {0.04f,35,0.25f,0.7f,5,1,0} };
|
332
|
int[] bandIndices = { 1,0,0,1,1,1 };
|
333
|
float[][] corners = { {0.04f,0.12f} };
|
334
|
int[] indices = { 0,0,0,0,0,0,0,0 };
|
335
|
float[][] centers = { {0.0f, 0.0f, 0.0f } };
|
336
|
return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
|
337
|
}
|
338
|
}
|
339
|
|
340
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
341
|
|
342
|
public int getNumCubitVariants(int[] numLayers)
|
343
|
{
|
344
|
return 3;
|
345
|
}
|
346
|
|
347
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
348
|
|
349
|
public int getCubitVariant(int cubit, int[] numLayers)
|
350
|
{
|
351
|
return cubit<12 ? 0 : (cubit<24 ? 1:2);
|
352
|
}
|
353
|
|
354
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
355
|
|
356
|
public float getStickerRadius()
|
357
|
{
|
358
|
return 0.13f;
|
359
|
}
|
360
|
|
361
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
362
|
|
363
|
public float getStickerStroke()
|
364
|
{
|
365
|
return ObjectControl.isInIconMode() ? 0.22f : 0.10f;
|
366
|
}
|
367
|
|
368
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
369
|
|
370
|
public float[][] getStickerAngles()
|
371
|
{
|
372
|
return null;
|
373
|
}
|
374
|
|
375
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
376
|
// PUBLIC API
|
377
|
|
378
|
public Static3D[] getRotationAxis()
|
379
|
{
|
380
|
return ROT_AXIS;
|
381
|
}
|
382
|
|
383
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
384
|
|
385
|
public int[] getBasicAngles()
|
386
|
{
|
387
|
if( mBasicAngle ==null ) mBasicAngle = new int[] { 4,4,4 };
|
388
|
return mBasicAngle;
|
389
|
}
|
390
|
|
391
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
392
|
|
393
|
public String getShortName()
|
394
|
{
|
395
|
return ObjectType.FISH_3.name();
|
396
|
}
|
397
|
|
398
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
399
|
|
400
|
public long getSignature()
|
401
|
{
|
402
|
return ObjectType.FISH_3.ordinal();
|
403
|
}
|
404
|
|
405
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
406
|
|
407
|
public String getObjectName()
|
408
|
{
|
409
|
return "Fisher Cube";
|
410
|
}
|
411
|
|
412
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
413
|
|
414
|
public String getInventor()
|
415
|
{
|
416
|
return "Tony Fisher";
|
417
|
}
|
418
|
|
419
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
420
|
|
421
|
public int getYearOfInvention()
|
422
|
{
|
423
|
return 1982;
|
424
|
}
|
425
|
|
426
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
427
|
|
428
|
public int getComplexity()
|
429
|
{
|
430
|
return 2;
|
431
|
}
|
432
|
|
433
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
434
|
|
435
|
public String[][] getTutorials()
|
436
|
{
|
437
|
return new String[][]{
|
438
|
{"gb","HhQLhGGcKK0","Solving the Fisher Cube","Junk Cuber"},
|
439
|
{"es","Ndd0V1gWju0","Como resolver 3x3x3 Fisher Cube","Tutoriales Rubik"},
|
440
|
{"ru","KfeDuy4n72Q","Как собрать Фишер Куб","Алексей Ярыгин"},
|
441
|
{"fr","qnnvpFzcZO4","Résolution du Fisher's Cube","asthalis"},
|
442
|
{"de","aSrF0VxVqck","Fisher Cube Tutorial","Pezcraft"},
|
443
|
{"pl","vFKujycV3cs","Fisher Cube TUTORIAL PL","MrUk"},
|
444
|
{"br","S4En0RXDIbs","Como resolver o Fisher Cube","Pedro Filho"},
|
445
|
{"kr","x9SySGU_iqE","피셔 큐브 맞추는 방법","iamzoone"},
|
446
|
};
|
447
|
}
|
448
|
}
|