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