1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2021 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 static org.distorted.objectlib.touchcontrol.TouchControl.TC_BALL;
|
13
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
|
14
|
|
15
|
import org.distorted.library.type.Static3D;
|
16
|
import org.distorted.library.type.Static4D;
|
17
|
import org.distorted.objectlib.helpers.FactoryCubit;
|
18
|
import org.distorted.objectlib.helpers.ObjectFaceShape;
|
19
|
import org.distorted.objectlib.helpers.ObjectShape;
|
20
|
import org.distorted.objectlib.metadata.Metadata;
|
21
|
import org.distorted.objectlib.helpers.ObjectVertexEffects;
|
22
|
import org.distorted.objectlib.main.InitAssets;
|
23
|
import org.distorted.objectlib.metadata.ListObjects;
|
24
|
import org.distorted.objectlib.shape.ShapeDiamond;
|
25
|
import org.distorted.objectlib.touchcontrol.TouchControlBall;
|
26
|
|
27
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
28
|
|
29
|
public class TwistyMasterball extends ShapeDiamond
|
30
|
{
|
31
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
32
|
{
|
33
|
new Static3D( 0, 1, 0),
|
34
|
new Static3D( 1, 0, 0),
|
35
|
new Static3D( SQ2/2, 0, SQ2/2),
|
36
|
new Static3D( 0, 0, 1),
|
37
|
new Static3D(-SQ2/2, 0, SQ2/2),
|
38
|
};
|
39
|
|
40
|
private static final float D = 0.1f; // shape; keep between (-0.5,0.5)
|
41
|
|
42
|
private int[][] mEdges;
|
43
|
private int[][] mBasicAngle;
|
44
|
private int[] mQuatIndex;
|
45
|
private float[][] mCuts;
|
46
|
private float[][] mCenters;
|
47
|
|
48
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
49
|
|
50
|
public TwistyMasterball(int iconMode, Static4D quat, Static3D move, float scale, Metadata meta, InitAssets asset)
|
51
|
{
|
52
|
super(iconMode, meta.getNumLayers()[0], quat, move, scale, meta, asset);
|
53
|
}
|
54
|
|
55
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
56
|
// here we cannot automatically detect the outer monochromatic walls -> use the old way.
|
57
|
|
58
|
@Override
|
59
|
public int getSolvedFunctionIndex()
|
60
|
{
|
61
|
return 0;
|
62
|
}
|
63
|
|
64
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
65
|
|
66
|
@Override
|
67
|
public float[][] returnRotationFactor()
|
68
|
{
|
69
|
float C1 = 1.0f;
|
70
|
float C2 = 1.7f;
|
71
|
float[] f1 = new float[] { C1,C1,C1,C1 };
|
72
|
float[] f2 = new float[] { C2,C2};
|
73
|
return new float[][] { f1,f2,f2,f2,f2 };
|
74
|
}
|
75
|
|
76
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
77
|
// make the equator a bit thicker
|
78
|
|
79
|
@Override
|
80
|
public void adjustStickerCoords()
|
81
|
{
|
82
|
final float X1 = -0.38861537f;
|
83
|
final float Y1 = -0.4252297f;
|
84
|
final float X2 = 0.5f;
|
85
|
final float Y2 = -0.2860808f;
|
86
|
final float X3 = 0.18867691f;
|
87
|
final float Y3 = 0.39392126f;
|
88
|
final float X4 = -0.30006152f;
|
89
|
final float Y4 = 0.3173893f;
|
90
|
|
91
|
final float Y = 0.02f;
|
92
|
|
93
|
mStickerCoords = new float[][][][]
|
94
|
{
|
95
|
{ { {X1+Y*(X4-X1), Y1+Y*(Y4-Y1)}, {X2+Y*(X3-X2), Y2+Y*(Y3-Y2)}, {X3, Y3}, {X4, Y4} } },
|
96
|
{ { {-0.17166577f, -0.28301144f}, {0.24996112f, -0.21698855f}, {-0.07829534f, 0.5f} } }
|
97
|
};
|
98
|
}
|
99
|
|
100
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
101
|
|
102
|
@Override
|
103
|
public float getPillowCoeff()
|
104
|
{
|
105
|
return 100f;
|
106
|
}
|
107
|
|
108
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
109
|
|
110
|
@Override
|
111
|
public int[][] getSolvedQuats()
|
112
|
{
|
113
|
// special SolvedQuats for the case where there are no corner of edge cubits.
|
114
|
// first row {0} - means there are no corners or edges.
|
115
|
// each next defines all cubits of a singe face
|
116
|
// (numCubits, firstCubit, cubit1,..,cubitN-1, quat0,..., quatM)
|
117
|
|
118
|
return new int[][] {
|
119
|
{0},
|
120
|
{4, 0, 1,16,17, 13},
|
121
|
{4, 2, 3,18,19, 12},
|
122
|
{4, 4, 5,20,21, 15},
|
123
|
{4, 6, 7,22,23, 14},
|
124
|
{4, 8, 9,24,25, 13},
|
125
|
{4,10,11,26,27, 12},
|
126
|
{4,12,13,28,29, 15},
|
127
|
{4,14,15,30,31, 14},
|
128
|
};
|
129
|
}
|
130
|
|
131
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
132
|
|
133
|
public int[][] getScrambleEdges()
|
134
|
{
|
135
|
if( mEdges==null )
|
136
|
{
|
137
|
mEdges = new int[][]
|
138
|
{
|
139
|
{ 0,1, 1,1, 2,1, 3,1, 4,1, 5,1, 6,1, 7,1, 8,1, 9,1,
|
140
|
10,1,11,1,12,1,13,1,14,1,15,1,16,1,17,1,18,1,19,1,
|
141
|
20,1,21,1,22,1,23,1,24,1,25,1,26,1,27,1
|
142
|
},
|
143
|
|
144
|
{28,2,29,2,30,2,31,2,32,2,33,2,34,2,35,2 },
|
145
|
|
146
|
{ 0,1, 1,1, 2,1, 3,1, 4,1, 5,1, 6,1, 7,1, 8,1, 9,1,
|
147
|
10,1,11,1,12,1,13,1,14,1,15,1,16,1,17,1,18,1,19,1,
|
148
|
20,1,21,1,22,1,23,1,24,1,25,1,26,1,27,1,
|
149
|
28,0,29,0,30,0,31,0,32,0,33,0,34,0,35,0
|
150
|
}
|
151
|
};
|
152
|
}
|
153
|
|
154
|
return mEdges;
|
155
|
}
|
156
|
|
157
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
158
|
|
159
|
public float[][] getCuts(int[] numLayers)
|
160
|
{
|
161
|
if( mCuts==null )
|
162
|
{
|
163
|
float cut = 1.0f;
|
164
|
float[] cutH = { -cut,0.0f,cut };
|
165
|
float[] cutV = { 0.0f };
|
166
|
mCuts = new float[][] { cutH,cutV,cutV,cutV,cutV };
|
167
|
}
|
168
|
|
169
|
return mCuts;
|
170
|
}
|
171
|
|
172
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
173
|
|
174
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
175
|
{
|
176
|
boolean[] LV = {true,true,true,true};
|
177
|
boolean[] LH = {true,true};
|
178
|
return new boolean[][] { LV,LH,LH,LH,LH };
|
179
|
}
|
180
|
|
181
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
182
|
|
183
|
public int getTouchControlType()
|
184
|
{
|
185
|
return TC_BALL;
|
186
|
}
|
187
|
|
188
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
189
|
// not used
|
190
|
|
191
|
public int getTouchControlSplit()
|
192
|
{
|
193
|
return TYPE_NOT_SPLIT;
|
194
|
}
|
195
|
|
196
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
197
|
// Each 'face' is a vertical strip of 1/8 of longitude (PI/4).
|
198
|
// The first one spans longitude from -PI/8 to +PI/8, where Greenwich is long=0.
|
199
|
// Next successively to the east.
|
200
|
|
201
|
public int[][][] getEnabled()
|
202
|
{
|
203
|
return new int[][][] { {{0,1}},{{0,4}},{{0,3}},{{0,2}},{{0,1}},{{0,4}},{{0,3}},{{0,2}} };
|
204
|
}
|
205
|
|
206
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
207
|
|
208
|
public float[] getDist3D(int[] numLayers)
|
209
|
{
|
210
|
final float D = 0.5f*(float)Math.sqrt((2*SQ2+5)/17);
|
211
|
return new float[] { D,D,D,D,D,D,D,D,D,D,D,D,D,D,D,D };
|
212
|
}
|
213
|
|
214
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
215
|
|
216
|
public Static3D[] getFaceAxis()
|
217
|
{
|
218
|
return TouchControlBall.FACE_AXIS;
|
219
|
}
|
220
|
|
221
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
222
|
|
223
|
public float[][] getCubitPositions(int[] numLayers)
|
224
|
{
|
225
|
if( mCenters==null )
|
226
|
{
|
227
|
final float X1 = 3*SQ2/8;
|
228
|
final float Y1 = 0.5f;
|
229
|
final float Z1 = 0.750f+3*SQ2/8;
|
230
|
final float X2 = X1/3;
|
231
|
final float Y2 = 1.5f;
|
232
|
final float Z2 = Z1/3;
|
233
|
|
234
|
mCenters = new float[][]
|
235
|
{
|
236
|
{ X1, Y1, Z1 },
|
237
|
{ X1,-Y1, Z1 },
|
238
|
{ Z1, Y1, X1 },
|
239
|
{ Z1,-Y1, X1 },
|
240
|
{ Z1, Y1,-X1 },
|
241
|
{ Z1,-Y1,-X1 },
|
242
|
{ X1, Y1,-Z1 },
|
243
|
{ X1,-Y1,-Z1 },
|
244
|
{-X1, Y1,-Z1 },
|
245
|
{-X1,-Y1,-Z1 },
|
246
|
{-Z1, Y1,-X1 },
|
247
|
{-Z1,-Y1,-X1 },
|
248
|
{-Z1, Y1, X1 },
|
249
|
{-Z1,-Y1, X1 },
|
250
|
{-X1, Y1, Z1 },
|
251
|
{-X1,-Y1, Z1 },
|
252
|
|
253
|
{ X2, Y2, Z2 },
|
254
|
{ X2,-Y2, Z2 },
|
255
|
{ Z2, Y2, X2 },
|
256
|
{ Z2,-Y2, X2 },
|
257
|
{ Z2, Y2,-X2 },
|
258
|
{ Z2,-Y2,-X2 },
|
259
|
{ X2, Y2,-Z2 },
|
260
|
{ X2,-Y2,-Z2 },
|
261
|
{-X2, Y2,-Z2 },
|
262
|
{-X2,-Y2,-Z2 },
|
263
|
{-Z2, Y2,-X2 },
|
264
|
{-Z2,-Y2,-X2 },
|
265
|
{-Z2, Y2, X2 },
|
266
|
{-Z2,-Y2, X2 },
|
267
|
{-X2, Y2, Z2 },
|
268
|
{-X2,-Y2, Z2 },
|
269
|
};
|
270
|
}
|
271
|
|
272
|
return mCenters;
|
273
|
}
|
274
|
|
275
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
276
|
|
277
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
278
|
{
|
279
|
if( mQuatIndex==null ) mQuatIndex = new int[] { 0,13,7,9,6,12,5,8,4,15,3,11,2,14,1,10,
|
280
|
0,13,7,9,6,12,5,8,4,15,3,11,2,14,1,10 };
|
281
|
return mObjectQuats[mQuatIndex[cubit]];
|
282
|
}
|
283
|
|
284
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
285
|
|
286
|
private float[][] getVertices(int variant)
|
287
|
{
|
288
|
if( variant==0 )
|
289
|
{
|
290
|
return new float[][]
|
291
|
{
|
292
|
{ -3*SQ2/8 , -0.5f , 1.250f-3*SQ2/8 },
|
293
|
{ 5*SQ2/8 , -0.5f , -0.750f+5*SQ2/8 },
|
294
|
{ -3*SQ2/8 , 0.5f-D, 0.250f-3*SQ2/8 +D },
|
295
|
{ SQ2/8 +D*(4*SQ2/8), 0.5f-D, -0.750f+ SQ2/8 +D*(4*SQ2/8) },
|
296
|
{ -3*SQ2/8 , -0.5f , -0.750f-3*SQ2/8 },
|
297
|
{ -3*SQ2/8 , 0.01f*(0.5f-D), -0.750f-3*SQ2/8 },
|
298
|
};
|
299
|
}
|
300
|
else
|
301
|
{
|
302
|
return new float[][]
|
303
|
{
|
304
|
{ -SQ2/8 , -0.5f -D, -SQ2/8+0.75f +D },
|
305
|
{3*SQ2/8 +D*(4*SQ2/8), -0.5f -D, 3*SQ2/8-0.25f +D*(4*SQ2/8) },
|
306
|
{ -SQ2/8 , -0.5f -D, -SQ2/8-0.25f },
|
307
|
{ -SQ2/8 , +0.5f , -SQ2/8-0.25f }
|
308
|
};
|
309
|
}
|
310
|
}
|
311
|
|
312
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
313
|
|
314
|
public ObjectShape getObjectShape(int variant)
|
315
|
{
|
316
|
if( variant==0 )
|
317
|
{
|
318
|
int[][] indices =
|
319
|
{
|
320
|
{0,1,3,2},
|
321
|
{4,0,2,5},
|
322
|
{1,4,5,3},
|
323
|
{2,3,5},
|
324
|
{4,1,0}
|
325
|
};
|
326
|
|
327
|
return new ObjectShape(getVertices(variant), indices);
|
328
|
}
|
329
|
else
|
330
|
{
|
331
|
int[][] indices =
|
332
|
{
|
333
|
{0,1,3},
|
334
|
{2,0,3},
|
335
|
{1,2,3},
|
336
|
{2,1,0}
|
337
|
};
|
338
|
|
339
|
return new ObjectShape(getVertices(variant), indices);
|
340
|
}
|
341
|
}
|
342
|
|
343
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
344
|
|
345
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
346
|
{
|
347
|
if( variant==0 )
|
348
|
{
|
349
|
float height = isInIconMode() ? 0.001f : 0.015f;
|
350
|
float[][] bands = { {height,35,0.25f,0.5f,10,0,0},{0.001f,35,0.25f,0.5f,4,0,0} };
|
351
|
int[] indices = { 0,1,1,1,1 };
|
352
|
return new ObjectFaceShape(bands,indices,null);
|
353
|
}
|
354
|
else
|
355
|
{
|
356
|
float height = isInIconMode() ? 0.001f : 0.020f;
|
357
|
float[][] bands = { {height,35,0.20f,0.6f,9,0,0}, {0.001f,35,0.20f,0.6f,4,0,0} };
|
358
|
int[] indices = { 0,1,1,1 };
|
359
|
return new ObjectFaceShape(bands,indices,null);
|
360
|
}
|
361
|
}
|
362
|
|
363
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
364
|
|
365
|
public ObjectVertexEffects getVertexEffects(int variant)
|
366
|
{
|
367
|
if( variant==0 )
|
368
|
{
|
369
|
float[][] corners = { {0.04f,0.10f} };
|
370
|
int[] cornerIndices = { -1,-1,-1,-1,-1,-1 };
|
371
|
float[][] centers = { { -3*SQ2/16, -0.5f,-0.375f-3*SQ2/16 } };
|
372
|
int[] centerIndices = { 0,0,0,0,-1,-1 };
|
373
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
|
374
|
}
|
375
|
else
|
376
|
{
|
377
|
float[][] corners = { {0.02f,0.10f} };
|
378
|
int[] cornerIndices = { -1,-1,-1,-1 };
|
379
|
float[][] centers = { { -SQ2/8, -0.5f, -SQ2/8-0.25f } };
|
380
|
int[] centerIndices = { 0,0,-1,0 };
|
381
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
|
382
|
}
|
383
|
}
|
384
|
|
385
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
386
|
|
387
|
public int getNumCubitVariants(int[] numLayers)
|
388
|
{
|
389
|
return 2;
|
390
|
}
|
391
|
|
392
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
393
|
|
394
|
public int getCubitVariant(int cubit, int[] numLayers)
|
395
|
{
|
396
|
return cubit<16 ? 0:1;
|
397
|
}
|
398
|
|
399
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
400
|
|
401
|
public float getStickerRadius()
|
402
|
{
|
403
|
return 0.10f;
|
404
|
}
|
405
|
|
406
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
407
|
|
408
|
public float getStickerStroke()
|
409
|
{
|
410
|
return isInIconMode() ? 0.13f : 0.07f;
|
411
|
}
|
412
|
|
413
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
414
|
|
415
|
public float[][][] getStickerAngles()
|
416
|
{
|
417
|
return null;
|
418
|
}
|
419
|
|
420
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
421
|
// PUBLIC API
|
422
|
|
423
|
public Static3D[] getRotationAxis()
|
424
|
{
|
425
|
return ROT_AXIS;
|
426
|
}
|
427
|
|
428
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
429
|
|
430
|
public int[][] getBasicAngles()
|
431
|
{
|
432
|
if( mBasicAngle==null )
|
433
|
{
|
434
|
int[] AV = {8,8,8,8};
|
435
|
int[] AH = {2,2};
|
436
|
mBasicAngle = new int[][] { AV,AH,AH,AH,AH };
|
437
|
}
|
438
|
|
439
|
return mBasicAngle;
|
440
|
}
|
441
|
|
442
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
443
|
|
444
|
public String getShortName()
|
445
|
{
|
446
|
return ListObjects.BALL_4.name();
|
447
|
}
|
448
|
|
449
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
450
|
|
451
|
public String[][] getTutorials()
|
452
|
{
|
453
|
return new String[][]{
|
454
|
{"gb","n41Rng0g65c","How to solve Masterball","javahamburg"},
|
455
|
{"es","zmdgV15BQi0","Tutorial para la Masterball","Robert Cubes"},
|
456
|
{"de","EjGf-VytMcA","Masterball Tutorial Deutsch","javahamburg"},
|
457
|
};
|
458
|
}
|
459
|
}
|