1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2019 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.objects;
|
21
|
|
22
|
import android.content.res.Resources;
|
23
|
|
24
|
import org.distorted.helpers.ObjectShape;
|
25
|
import org.distorted.helpers.ObjectSticker;
|
26
|
import org.distorted.helpers.ScrambleState;
|
27
|
import org.distorted.library.main.DistortedEffects;
|
28
|
import org.distorted.library.main.DistortedTexture;
|
29
|
import org.distorted.library.mesh.MeshSquare;
|
30
|
import org.distorted.library.type.Static3D;
|
31
|
import org.distorted.library.type.Static4D;
|
32
|
import org.distorted.main.R;
|
33
|
|
34
|
import static org.distorted.objects.TwistyMinx.MINX_DBLUE;
|
35
|
import static org.distorted.objects.TwistyMinx.MINX_DGREEN;
|
36
|
import static org.distorted.objects.TwistyMinx.MINX_DRED;
|
37
|
import static org.distorted.objects.TwistyMinx.MINX_DYELLOW;
|
38
|
import static org.distorted.objects.TwistyMinx.MINX_GREY;
|
39
|
import static org.distorted.objects.TwistyMinx.MINX_LBLUE;
|
40
|
import static org.distorted.objects.TwistyMinx.MINX_LGREEN;
|
41
|
import static org.distorted.objects.TwistyMinx.MINX_ORANGE;
|
42
|
import static org.distorted.objects.TwistyMinx.MINX_PINK;
|
43
|
import static org.distorted.objects.TwistyMinx.MINX_SANDY;
|
44
|
import static org.distorted.objects.TwistyMinx.MINX_VIOLET;
|
45
|
import static org.distorted.objects.TwistyMinx.MINX_WHITE;
|
46
|
|
47
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
48
|
|
49
|
class TwistyUltimate extends TwistyObject
|
50
|
{
|
51
|
private static final float A = (float)Math.sqrt(21*SQ5+47);
|
52
|
private static final float B = SQ6*(5*SQ5+11)/(6*A);
|
53
|
private static final float C = SQ6*( SQ5+ 2)/(3*A);
|
54
|
private static final float D = SQ3/3;
|
55
|
private static final float E = (SQ5+1)/4;
|
56
|
private static final float F = (SQ5-1)/4;
|
57
|
private static final float G = (SQ5+3)/4;
|
58
|
|
59
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
60
|
{
|
61
|
new Static3D( B,0,C ),
|
62
|
new Static3D( C,B,0 ),
|
63
|
new Static3D(-D,D,D ),
|
64
|
new Static3D( 0,C,-B)
|
65
|
};
|
66
|
|
67
|
private static final int[] FACE_COLORS = new int[]
|
68
|
{
|
69
|
MINX_LGREEN, MINX_PINK , MINX_SANDY , MINX_LBLUE,
|
70
|
MINX_ORANGE, MINX_VIOLET , MINX_DGREEN, MINX_DRED ,
|
71
|
MINX_DBLUE , MINX_DYELLOW, MINX_WHITE , MINX_GREY
|
72
|
};
|
73
|
|
74
|
private ScrambleState[] mStates;
|
75
|
private int[] mBasicAngle;
|
76
|
private Static4D[] mQuats;
|
77
|
private int[][] mFaceMap;
|
78
|
private float[][] mCenters;
|
79
|
private int[] mQuatIndex;
|
80
|
private ObjectSticker[] mStickers;
|
81
|
private Movement mMovement;
|
82
|
|
83
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
84
|
|
85
|
TwistyUltimate(int size, Static4D quat, DistortedTexture texture,
|
86
|
MeshSquare mesh, DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
|
87
|
{
|
88
|
super(size, size, quat, texture, mesh, effects, moves, ObjectList.ULTI, res, scrWidth);
|
89
|
}
|
90
|
|
91
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
92
|
|
93
|
ScrambleState[] getScrambleStates()
|
94
|
{
|
95
|
if( mStates==null )
|
96
|
{
|
97
|
int[] tmp = {0,-1,0, 0,1,0, 1,-1,0, 1,1,0 };
|
98
|
|
99
|
mStates = new ScrambleState[]
|
100
|
{
|
101
|
new ScrambleState( new int[][] {tmp,tmp,tmp,tmp} )
|
102
|
};
|
103
|
}
|
104
|
|
105
|
return mStates;
|
106
|
}
|
107
|
|
108
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
109
|
|
110
|
private void initializeQuats()
|
111
|
{
|
112
|
mQuats = new Static4D[]
|
113
|
{
|
114
|
new Static4D( 0.0f, 0.0f, 0.0f, 1.0f ),
|
115
|
new Static4D(-0.5f, 0.5f, 0.5f, 0.5f ),
|
116
|
new Static4D( 0.5f,-0.5f,-0.5f, 0.5f ),
|
117
|
new Static4D( 0.0f, F, -E, 0.5f ),
|
118
|
new Static4D( 0.0f, -F, E, 0.5f ),
|
119
|
new Static4D( E, 0.0f, F, 0.5f ),
|
120
|
new Static4D( -E, 0.0f, -F, 0.5f ),
|
121
|
new Static4D( F, E, 0.0f, 0.5f ),
|
122
|
new Static4D( -F, -E, 0.0f, 0.5f ),
|
123
|
new Static4D( E, F,-0.5f, 0.0f ),
|
124
|
new Static4D( 0.5f, -E, F, 0.0f ),
|
125
|
new Static4D( F, 0.5f, E, 0.0f )
|
126
|
};
|
127
|
}
|
128
|
|
129
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
130
|
|
131
|
int[] getSolvedQuats(int cubit, int numLayers)
|
132
|
{
|
133
|
if( mQuats==null ) initializeQuats();
|
134
|
int status = retCubitSolvedStatus(cubit,numLayers);
|
135
|
return status<0 ? null : buildSolvedQuats(MovementUltimate.FACE_AXIS[status],mQuats);
|
136
|
}
|
137
|
|
138
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
139
|
|
140
|
ObjectShape getObjectShape(int cubit, int numLayers)
|
141
|
{
|
142
|
int variant = getCubitVariant(cubit,numLayers);
|
143
|
|
144
|
if( variant==0 )
|
145
|
{
|
146
|
double[][] vertices = new double[][]
|
147
|
{
|
148
|
{ 0.0 , 0.0 , 0.0 },
|
149
|
{ -E , E+0.5, -0.5 },
|
150
|
{-0.5 , -E , -E-0.5},
|
151
|
{ E+0.5, 0.5 , -E },
|
152
|
{ 0.0 , 1 , -2*E-1},
|
153
|
{ 0.0 , 1 , 0.0 },
|
154
|
{ -E ,-E+0.5, -0.5 },
|
155
|
{ E ,-E+0.5, -0.5 }
|
156
|
};
|
157
|
int[][] vert_indices = new int[][]
|
158
|
{
|
159
|
{6,0,5,1},
|
160
|
{0,7,3,5},
|
161
|
{0,6,2,7},
|
162
|
{4,3,5,1},
|
163
|
{4,2,7,3},
|
164
|
{4,1,6,2},
|
165
|
};
|
166
|
|
167
|
float[][] bands = new float[][] { {0.03f,17,0.5f,0.2f,5,2,2}, {0.01f, 1,0.5f,0.2f,5,2,2} };
|
168
|
int[] bandIndices = new int[] { 0,0,0,1,1,1 };
|
169
|
float[][] corners = new float[][] { { 0.013f, 0.16f } };
|
170
|
int[] cornerIndices = new int[] { 0, 0, 0, 0,-1, 0, 0, 0 };
|
171
|
float[][] centers = new float[][] { { 0.0f,-1.0f, -(SQ5+3)/2 } };
|
172
|
int[] centerIndices = new int[] { 0,0,0,0,0,0,0,0 };
|
173
|
return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
174
|
}
|
175
|
else if( variant==1 )
|
176
|
{
|
177
|
double[][] vertices = new double[][]
|
178
|
{
|
179
|
{ 0.00, 0.00, 0.00},
|
180
|
{ - 0.50,-SQ5/4 - 0.25,-SQ5/4 - 0.75},
|
181
|
{ SQ5/4 + 0.25,-SQ5/4 - 0.75, + 0.50},
|
182
|
{ SQ5/4 + 0.75, + 0.50,-SQ5/4 - 0.25},
|
183
|
{ SQ5/2 + 0.50,-SQ5/2 - 0.50,-SQ5/2 - 0.50},
|
184
|
{ SQ5/4 - 0.25, + 0.50,-SQ5/4 - 0.25},
|
185
|
{ - 0.50,-SQ5/4 - 0.25,-SQ5/4 + 0.25},
|
186
|
{ SQ5/4 + 0.25,-SQ5/4 + 0.25, + 0.50}
|
187
|
};
|
188
|
int[][] vert_indices = new int[][]
|
189
|
{
|
190
|
{6,0,5,1},
|
191
|
{0,7,3,5},
|
192
|
{0,6,2,7},
|
193
|
{1,5,3,4},
|
194
|
{3,7,2,4},
|
195
|
{2,6,1,4},
|
196
|
};
|
197
|
|
198
|
float[][] bands = new float[][] { {0.03f,17,0.5f,0.2f,5,2,2}, {0.01f, 1,0.5f,0.2f,5,2,2} };
|
199
|
int[] bandIndices = new int[] { 0,0,0,1,1,1 };
|
200
|
float[][] corners = new float[][] { { 0.013f, 0.16f } };
|
201
|
int[] cornerIndices = new int[] { 0, 0, 0, 0,-1, 0, 0, 0 };
|
202
|
float[][] centers = new float[][] { { 0.0f,-1.0f, -(SQ5+3)/2 } };
|
203
|
int[] centerIndices = new int[] { 0,0,0,0,0,0,0,0 };
|
204
|
return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
205
|
}
|
206
|
else
|
207
|
{
|
208
|
double[][] vertices = new double[][]
|
209
|
{
|
210
|
{ -E ,-E+0.5, 0.5},
|
211
|
{ E , E-0.5, -0.5},
|
212
|
{-2*E , 0.0, 0.0},
|
213
|
{ 0.5, E , -E-0.5},
|
214
|
{ -E ,-E-0.5, 0.5},
|
215
|
{ E+0.5, -0.5, -E },
|
216
|
{-2*E , -1.0, 0.0},
|
217
|
{ 1.0, 0.0,-2*E },
|
218
|
{-2*E+0.5, E , -E-0.5},
|
219
|
{ 0.5,-E-1.0, -E+0.5},
|
220
|
{ -E ,-E-0.5,-2*E-0.5}
|
221
|
};
|
222
|
int[][] vert_indices = new int[][]
|
223
|
{
|
224
|
{0,1,3,8,2}, // counterclockwise!
|
225
|
{0,4,9,5,1},
|
226
|
{ 0,2,6,4},
|
227
|
{ 1,5,7,3},
|
228
|
{10,9,4,6},
|
229
|
{10,9,5,7},
|
230
|
{10,8,3,7},
|
231
|
{10,8,2,6}
|
232
|
};
|
233
|
|
234
|
float[][] bands = new float[][] { {0.04f,17,0.5f,0.2f,5,2,2}, {0.03f,17,0.5f,0.2f,5,2,2}, {0.01f, 1,0.5f,0.2f,5,2,2} };
|
235
|
int[] bandIndices = new int[] { 0,0,1,1,2,2,2,2 };
|
236
|
float[][] corners = new float[][] { { 0.013f, 0.16f } };
|
237
|
int[] cornerIndices = new int[] { 0,0,0,0,0,0,0,0,0,0,-1 };
|
238
|
float[][] centers = new float[][] { { -(SQ5+1)/4, 0.5f, -(SQ5+5)/4 } };
|
239
|
int[] centerIndices = new int[] { 0,0,0,0,0,0,0,0,0,0,0 };
|
240
|
return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
241
|
}
|
242
|
}
|
243
|
|
244
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
245
|
|
246
|
Static4D getQuat(int cubit, int numLayers)
|
247
|
{
|
248
|
if( mQuats ==null ) initializeQuats();
|
249
|
if( mQuatIndex ==null ) mQuatIndex = new int[] { 0,6,1,2,0,4,6,5,0,1,4,9,5,2 };
|
250
|
return mQuats[mQuatIndex[cubit]];
|
251
|
}
|
252
|
|
253
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
254
|
|
255
|
int getNumCubitVariants(int numLayers)
|
256
|
{
|
257
|
return 3;
|
258
|
}
|
259
|
|
260
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
261
|
|
262
|
int getCubitVariant(int cubit, int numLayers)
|
263
|
{
|
264
|
return cubit<4 ? 0 : (cubit<8 ? 1:2);
|
265
|
}
|
266
|
|
267
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
268
|
|
269
|
float[][] getCubitPositions(int numLayers)
|
270
|
{
|
271
|
if( mCenters==null )
|
272
|
{
|
273
|
mCenters = new float[][]
|
274
|
{
|
275
|
{ 0, -1, 2*G },
|
276
|
{ 2*E,-2*E,-2*E },
|
277
|
{-2*G, 0, -1 },
|
278
|
{ 1, 2*G, 0 },
|
279
|
|
280
|
{-2*E, 2*E, 2*E },
|
281
|
{ 2*G, 0, 1 },
|
282
|
{ -1, -2*G, 0 },
|
283
|
{ 0, 1,-2*G },
|
284
|
|
285
|
{ E, (E+0.5f), (E+G) },
|
286
|
{ -(E+G), -E, (E+0.5f) },
|
287
|
{ (E+0.5f), -(E+G), E },
|
288
|
{ -E,-(E+0.5f), -(E+G) },
|
289
|
{ (E+G), E,-(E+0.5f) },
|
290
|
{-(E+0.5f), (E+G), -E }
|
291
|
};
|
292
|
}
|
293
|
|
294
|
return mCenters;
|
295
|
}
|
296
|
|
297
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
298
|
|
299
|
int getFaceColor(int cubit, int cubitface, int size)
|
300
|
{
|
301
|
if( mFaceMap==null )
|
302
|
{
|
303
|
mFaceMap = new int[][]
|
304
|
{
|
305
|
{ 25,24,35, 36,36,36,36,36 },
|
306
|
{ 27,28,29, 36,36,36,36,36 },
|
307
|
{ 31,26,30, 36,36,36,36,36 },
|
308
|
{ 32,34,33, 36,36,36,36,36 },
|
309
|
|
310
|
{ 31,32,25, 36,36,36,36,36 },
|
311
|
{ 33,28,24, 36,36,36,36,36 },
|
312
|
{ 26,35,27, 36,36,36,36,36 },
|
313
|
{ 30,29,34, 36,36,36,36,36 },
|
314
|
|
315
|
{ 8, 0,13,21, 36,36,36,36 },
|
316
|
{ 1, 2,19,23, 36,36,36,36 },
|
317
|
{ 4,11,12,15, 36,36,36,36 },
|
318
|
{ 3, 6,14,17, 36,36,36,36 },
|
319
|
{ 5, 9,22,16, 36,36,36,36 },
|
320
|
{ 7,10,20,18, 36,36,36,36 }
|
321
|
};
|
322
|
}
|
323
|
|
324
|
return mFaceMap[cubit][cubitface];
|
325
|
}
|
326
|
|
327
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
328
|
|
329
|
int getColor(int face)
|
330
|
{
|
331
|
return FACE_COLORS[face];
|
332
|
}
|
333
|
|
334
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
335
|
|
336
|
ObjectSticker retSticker(int face)
|
337
|
{
|
338
|
if( mStickers==null )
|
339
|
{
|
340
|
float[][] STICKERS = new float[][]
|
341
|
{
|
342
|
{ -0.14400357f, -0.47894150f, 0.50000000f,-0.011045523f, 0.37700626f, 0.36749030f,-0.26699730f, 0.36749026f, -0.46600536f, -0.24499352f }, // Big cubit 1st
|
343
|
{ 0.36327127f, 0.26393202f,-0.36327127f, 0.500000000f,-0.36327127f,-0.26393202f, 0.36327127f,-0.50000000f }, // Big cubit 2nd
|
344
|
{ -0.29389262f, -0.50000000f, 0.29389262f,-0.309017000f, 0.29389262f, 0.30901700f,-0.29389262f, 0.50000000f }, // Small cubit 1st
|
345
|
};
|
346
|
|
347
|
final float R1 = 0.08f;
|
348
|
final float R2 = 0.13f;
|
349
|
final float R3 = 0.11f;
|
350
|
final float[][] radii = { {R1,R1,R1,R1,R1},{R2,R2,R2,R2},{R3,R3,R3,R3} };
|
351
|
final float[] strokes = { 0.07f, 0.09f, 0.08f };
|
352
|
|
353
|
mStickers = new ObjectSticker[STICKERS.length];
|
354
|
|
355
|
for(int s=0; s<STICKERS.length; s++)
|
356
|
{
|
357
|
mStickers[s] = new ObjectSticker(STICKERS[s],null,radii[s],strokes[s]);
|
358
|
}
|
359
|
}
|
360
|
|
361
|
return mStickers[face/NUM_FACE_COLORS];
|
362
|
}
|
363
|
|
364
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
365
|
|
366
|
float returnMultiplier()
|
367
|
{
|
368
|
return 1.0f;
|
369
|
}
|
370
|
|
371
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
372
|
|
373
|
Static4D[] getQuats()
|
374
|
{
|
375
|
if( mQuats==null ) initializeQuats();
|
376
|
return mQuats;
|
377
|
}
|
378
|
|
379
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
380
|
|
381
|
int getSolvedFunctionIndex()
|
382
|
{
|
383
|
return 0;
|
384
|
}
|
385
|
|
386
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
387
|
|
388
|
boolean shouldResetTextureMaps()
|
389
|
{
|
390
|
return false;
|
391
|
}
|
392
|
|
393
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
394
|
|
395
|
int getNumFaceColors()
|
396
|
{
|
397
|
return FACE_COLORS.length;
|
398
|
}
|
399
|
|
400
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
401
|
|
402
|
float[][] getCuts(int numLayers)
|
403
|
{
|
404
|
float[] cut = new float[] {0.0f};
|
405
|
return new float[][] { cut,cut,cut,cut };
|
406
|
}
|
407
|
|
408
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
409
|
|
410
|
int getNumStickerTypes(int numLayers)
|
411
|
{
|
412
|
return 3;
|
413
|
}
|
414
|
|
415
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
416
|
|
417
|
int getNumCubitFaces()
|
418
|
{
|
419
|
return 8;
|
420
|
}
|
421
|
|
422
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
423
|
|
424
|
float getScreenRatio()
|
425
|
{
|
426
|
return 0.33f;
|
427
|
}
|
428
|
|
429
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
430
|
// PUBLIC API
|
431
|
|
432
|
public Static3D[] getRotationAxis()
|
433
|
{
|
434
|
return ROT_AXIS;
|
435
|
}
|
436
|
|
437
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
438
|
|
439
|
public Movement getMovement()
|
440
|
{
|
441
|
if( mMovement==null ) mMovement = new MovementUltimate();
|
442
|
return mMovement;
|
443
|
}
|
444
|
|
445
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
446
|
|
447
|
public int[] getBasicAngle()
|
448
|
{
|
449
|
if( mBasicAngle ==null ) mBasicAngle = new int[] { 3,3,3,3 };
|
450
|
return mBasicAngle;
|
451
|
}
|
452
|
|
453
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
454
|
|
455
|
public int getObjectName(int numLayers)
|
456
|
{
|
457
|
return R.string.ulti2;
|
458
|
}
|
459
|
|
460
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
461
|
|
462
|
public int getInventor(int numLayers)
|
463
|
{
|
464
|
return R.string.ulti2_inventor;
|
465
|
}
|
466
|
|
467
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
468
|
|
469
|
public int getComplexity(int numLayers)
|
470
|
{
|
471
|
return 6;
|
472
|
}
|
473
|
}
|