1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2020 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 static org.distorted.objectlib.main.Movement.TYPE_SPLIT_CORNER;
|
23
|
|
24
|
import android.content.res.Resources;
|
25
|
|
26
|
import org.distorted.library.main.DistortedEffects;
|
27
|
import org.distorted.library.main.DistortedTexture;
|
28
|
import org.distorted.library.mesh.MeshSquare;
|
29
|
import org.distorted.library.type.Static3D;
|
30
|
import org.distorted.library.type.Static4D;
|
31
|
|
32
|
import org.distorted.objectlib.R;
|
33
|
import org.distorted.objectlib.main.Movement;
|
34
|
import org.distorted.objectlib.main.Movement6;
|
35
|
import org.distorted.objectlib.main.ObjectType;
|
36
|
import org.distorted.objectlib.helpers.ObjectShape;
|
37
|
import org.distorted.objectlib.helpers.ObjectSticker;
|
38
|
import org.distorted.objectlib.helpers.ScrambleState;
|
39
|
import org.distorted.objectlib.main.Twisty6;
|
40
|
|
41
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
42
|
|
43
|
public class TwistySkewb extends Twisty6
|
44
|
{
|
45
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
46
|
{
|
47
|
new Static3D(+SQ3/3,+SQ3/3,+SQ3/3),
|
48
|
new Static3D(+SQ3/3,+SQ3/3,-SQ3/3),
|
49
|
new Static3D(+SQ3/3,-SQ3/3,+SQ3/3),
|
50
|
new Static3D(+SQ3/3,-SQ3/3,-SQ3/3)
|
51
|
};
|
52
|
|
53
|
private static final int[][][] ENABLED = new int[][][]
|
54
|
{
|
55
|
{{0,1},{3,1},{2,3},{0,2}},
|
56
|
{{2,3},{3,1},{0,1},{0,2}},
|
57
|
{{1,2},{0,1},{0,3},{2,3}},
|
58
|
{{1,2},{2,3},{0,3},{0,1}},
|
59
|
{{0,3},{0,2},{1,2},{1,3}},
|
60
|
{{1,2},{0,2},{0,3},{1,3}},
|
61
|
};
|
62
|
|
63
|
private ScrambleState[] mStates;
|
64
|
private int[] mBasicAngle;
|
65
|
private Static4D[] mQuats;
|
66
|
private float[][] mCuts;
|
67
|
private boolean[][] mLayerRotatable;
|
68
|
private int[][] mCornerMap,mEdgeMap,mCenterMap;
|
69
|
private ObjectSticker[] mStickers;
|
70
|
private Movement mMovement;
|
71
|
|
72
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
73
|
|
74
|
public TwistySkewb(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
|
75
|
DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
|
76
|
{
|
77
|
super(size, 2*size-2, quat, texture, mesh, effects, moves, res, scrWidth);
|
78
|
}
|
79
|
|
80
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
81
|
|
82
|
protected ScrambleState[] getScrambleStates()
|
83
|
{
|
84
|
if( mStates==null )
|
85
|
{
|
86
|
int size = getNumLayers();
|
87
|
int[] tmp = {0,-1,0, 0,1,0, size-1,-1,0, size-1,1,0 };
|
88
|
|
89
|
mStates = new ScrambleState[]
|
90
|
{
|
91
|
new ScrambleState( new int[][] {tmp,tmp,tmp,tmp} )
|
92
|
};
|
93
|
}
|
94
|
|
95
|
return mStates;
|
96
|
}
|
97
|
|
98
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
99
|
|
100
|
protected int getResource(int numLayers)
|
101
|
{
|
102
|
switch(numLayers)
|
103
|
{
|
104
|
case 2: return R.raw.skew2;
|
105
|
case 3: return R.raw.skew3;
|
106
|
}
|
107
|
|
108
|
return 0;
|
109
|
}
|
110
|
|
111
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
112
|
|
113
|
private void initializeQuats()
|
114
|
{
|
115
|
mQuats = new Static4D[]
|
116
|
{
|
117
|
new Static4D( 0.0f, 0.0f, 0.0f, 1.0f ),
|
118
|
new Static4D( 1.0f, 0.0f, 0.0f, 0.0f ),
|
119
|
new Static4D( 0.0f, 1.0f, 0.0f, 0.0f ),
|
120
|
new Static4D( 0.0f, 0.0f, 1.0f, 0.0f ),
|
121
|
|
122
|
new Static4D( 0.5f, 0.5f, 0.5f, 0.5f ),
|
123
|
new Static4D( 0.5f, 0.5f, 0.5f, -0.5f ),
|
124
|
new Static4D( 0.5f, 0.5f, -0.5f, 0.5f ),
|
125
|
new Static4D( 0.5f, 0.5f, -0.5f, -0.5f ),
|
126
|
new Static4D( 0.5f, -0.5f, 0.5f, 0.5f ),
|
127
|
new Static4D( 0.5f, -0.5f, 0.5f, -0.5f ),
|
128
|
new Static4D( 0.5f, -0.5f, -0.5f, 0.5f ),
|
129
|
new Static4D( 0.5f, -0.5f, -0.5f, -0.5f )
|
130
|
};
|
131
|
}
|
132
|
|
133
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
134
|
|
135
|
protected int[] getSolvedQuats(int cubit, int numLayers)
|
136
|
{
|
137
|
if( mQuats==null ) initializeQuats();
|
138
|
int status = retCubitSolvedStatus(cubit,numLayers);
|
139
|
return status<0 ? null : buildSolvedQuats(Movement6.FACE_AXIS[status],mQuats);
|
140
|
}
|
141
|
|
142
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
143
|
|
144
|
private int getNumCorners()
|
145
|
{
|
146
|
return 8;
|
147
|
}
|
148
|
|
149
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
150
|
|
151
|
private int getNumEdges(int layers)
|
152
|
{
|
153
|
return (layers-2)*12;
|
154
|
}
|
155
|
|
156
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
157
|
|
158
|
private int getNumCentersPerFace(int layers)
|
159
|
{
|
160
|
return ((layers-2)*(layers-2) + (layers-1)*(layers-1));
|
161
|
}
|
162
|
|
163
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
164
|
|
165
|
protected Static4D[] getQuats()
|
166
|
{
|
167
|
if( mQuats==null ) initializeQuats();
|
168
|
return mQuats;
|
169
|
}
|
170
|
|
171
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
172
|
|
173
|
protected int getSolvedFunctionIndex()
|
174
|
{
|
175
|
return 0;
|
176
|
}
|
177
|
|
178
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
179
|
|
180
|
protected int getNumStickerTypes(int numLayers)
|
181
|
{
|
182
|
return 3;
|
183
|
}
|
184
|
|
185
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
186
|
|
187
|
protected float[][] getCuts(int numLayers)
|
188
|
{
|
189
|
if( mCuts==null )
|
190
|
{
|
191
|
float[] c = numLayers==2 ? (new float[] {0.0f}) : (new float[] {-SQ3/6,+SQ3/6});
|
192
|
mCuts = new float[][] {c,c,c,c};
|
193
|
}
|
194
|
|
195
|
return mCuts;
|
196
|
}
|
197
|
|
198
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
199
|
|
200
|
private void getLayerRotatable(int numLayers)
|
201
|
{
|
202
|
if( mLayerRotatable==null )
|
203
|
{
|
204
|
int numAxis = ROT_AXIS.length;
|
205
|
boolean[] tmp = numLayers==2 ? (new boolean[] {true,true}) : (new boolean[] {true,false,true});
|
206
|
mLayerRotatable = new boolean[numAxis][];
|
207
|
for(int i=0; i<numAxis; i++) mLayerRotatable[i] = tmp;
|
208
|
}
|
209
|
}
|
210
|
|
211
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
212
|
|
213
|
protected int getNumCubitFaces()
|
214
|
{
|
215
|
return 6;
|
216
|
}
|
217
|
|
218
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
219
|
|
220
|
protected float[][] getCubitPositions(int numLayers)
|
221
|
{
|
222
|
final float DIST_CORNER = numLayers-1;
|
223
|
final float DIST_EDGE = numLayers-1;
|
224
|
final float DIST_CENTER = numLayers-1;
|
225
|
|
226
|
final int numCorners = getNumCorners();
|
227
|
final int numEdges = getNumEdges(numLayers);
|
228
|
final int numCenters = 6*getNumCentersPerFace(numLayers);
|
229
|
|
230
|
final float[][] CENTERS = new float[numCorners+numEdges+numCenters][];
|
231
|
|
232
|
/// CORNERS //////////////////////////////////////////////
|
233
|
|
234
|
CENTERS[0] = new float[] { DIST_CORNER, DIST_CORNER, DIST_CORNER };
|
235
|
CENTERS[1] = new float[] { DIST_CORNER, DIST_CORNER,-DIST_CORNER };
|
236
|
CENTERS[2] = new float[] { DIST_CORNER,-DIST_CORNER, DIST_CORNER };
|
237
|
CENTERS[3] = new float[] { DIST_CORNER,-DIST_CORNER,-DIST_CORNER };
|
238
|
CENTERS[4] = new float[] {-DIST_CORNER, DIST_CORNER, DIST_CORNER };
|
239
|
CENTERS[5] = new float[] {-DIST_CORNER, DIST_CORNER,-DIST_CORNER };
|
240
|
CENTERS[6] = new float[] {-DIST_CORNER,-DIST_CORNER, DIST_CORNER };
|
241
|
CENTERS[7] = new float[] {-DIST_CORNER,-DIST_CORNER,-DIST_CORNER };
|
242
|
|
243
|
/// EDGES ///////////////////////////////////////////////
|
244
|
|
245
|
final float[][] edgeTable =
|
246
|
{
|
247
|
{0,+DIST_EDGE,+DIST_EDGE},
|
248
|
{+DIST_EDGE,0,+DIST_EDGE},
|
249
|
{0,-DIST_EDGE,+DIST_EDGE},
|
250
|
{-DIST_EDGE,0,+DIST_EDGE},
|
251
|
{+DIST_EDGE,+DIST_EDGE,0},
|
252
|
{+DIST_EDGE,-DIST_EDGE,0},
|
253
|
{-DIST_EDGE,-DIST_EDGE,0},
|
254
|
{-DIST_EDGE,+DIST_EDGE,0},
|
255
|
{0,+DIST_EDGE,-DIST_EDGE},
|
256
|
{+DIST_EDGE,0,-DIST_EDGE},
|
257
|
{0,-DIST_EDGE,-DIST_EDGE},
|
258
|
{-DIST_EDGE,0,-DIST_EDGE}
|
259
|
};
|
260
|
|
261
|
int index=8;
|
262
|
|
263
|
for (float[] edges : edgeTable)
|
264
|
{
|
265
|
float c = 3-numLayers;
|
266
|
|
267
|
for (int j=0; j<numLayers-2; j++, c+=2, index++)
|
268
|
{
|
269
|
CENTERS[index] = new float[] { edges[0]==0 ? c : edges[0] ,
|
270
|
edges[1]==0 ? c : edges[1] ,
|
271
|
edges[2]==0 ? c : edges[2] };
|
272
|
}
|
273
|
}
|
274
|
|
275
|
/// CENTERS //////////////////////////////////////////////
|
276
|
|
277
|
final float X= -1000.0f;
|
278
|
final float Y= -1001.0f;
|
279
|
|
280
|
final float[][] centerTable =
|
281
|
{
|
282
|
{+DIST_CENTER,X,Y},
|
283
|
{-DIST_CENTER,X,Y},
|
284
|
{X,+DIST_CENTER,Y},
|
285
|
{X,-DIST_CENTER,Y},
|
286
|
{X,Y,+DIST_CENTER},
|
287
|
{X,Y,-DIST_CENTER}
|
288
|
};
|
289
|
|
290
|
float x,y, cen0, cen1, cen2;
|
291
|
|
292
|
for( float[] centers : centerTable )
|
293
|
{
|
294
|
x = 2-numLayers;
|
295
|
|
296
|
for(int i=0; i<numLayers-1; i++, x+=2)
|
297
|
{
|
298
|
y = 2-numLayers;
|
299
|
|
300
|
for(int j=0; j<numLayers-1; j++, y+=2, index++)
|
301
|
{
|
302
|
if( centers[0]==Y ) cen0 = y;
|
303
|
else if( centers[0]==X ) cen0 = x;
|
304
|
else cen0 = centers[0];
|
305
|
|
306
|
if( centers[1]==Y ) cen1 = y;
|
307
|
else if( centers[1]==X ) cen1 = x;
|
308
|
else cen1 = centers[1];
|
309
|
|
310
|
if( centers[2]==Y ) cen2 = y;
|
311
|
else if( centers[2]==X ) cen2 = x;
|
312
|
else cen2 = centers[2];
|
313
|
|
314
|
CENTERS[index] = new float[] {cen0,cen1,cen2};
|
315
|
}
|
316
|
}
|
317
|
|
318
|
x = 3-numLayers;
|
319
|
|
320
|
for(int i=0; i<numLayers-2; i++, x+=2)
|
321
|
{
|
322
|
y = 3-numLayers;
|
323
|
|
324
|
for(int j=0; j<numLayers-2; j++, y+=2, index++)
|
325
|
{
|
326
|
if( centers[0]==Y ) cen0 = y;
|
327
|
else if( centers[0]==X ) cen0 = x;
|
328
|
else cen0 = centers[0];
|
329
|
|
330
|
if( centers[1]==Y ) cen1 = y;
|
331
|
else if( centers[1]==X ) cen1 = x;
|
332
|
else cen1 = centers[1];
|
333
|
|
334
|
if( centers[2]==Y ) cen2 = y;
|
335
|
else if( centers[2]==X ) cen2 = x;
|
336
|
else cen2 = centers[2];
|
337
|
|
338
|
CENTERS[index] = new float[] {cen0,cen1,cen2};
|
339
|
}
|
340
|
}
|
341
|
}
|
342
|
|
343
|
return CENTERS;
|
344
|
}
|
345
|
|
346
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
347
|
|
348
|
protected Static4D getQuat(int cubit, int numLayers)
|
349
|
{
|
350
|
if( mQuats==null ) initializeQuats();
|
351
|
int numCorners = getNumCorners();
|
352
|
int numEdges = getNumEdges(numLayers);
|
353
|
|
354
|
if( cubit<numCorners )
|
355
|
{
|
356
|
switch(cubit)
|
357
|
{
|
358
|
case 0: return mQuats[0]; // unit quat
|
359
|
case 1: return new Static4D( SQ2/2,0,0,SQ2/2); // 90 along X
|
360
|
case 2: return new Static4D(-SQ2/2,0,0,SQ2/2); // -90 along X
|
361
|
case 3: return mQuats[1]; // 180 along X
|
362
|
case 4: return new Static4D(0, SQ2/2,0,SQ2/2); // 90 along Y
|
363
|
case 5: return mQuats[2]; // 180 along Y
|
364
|
case 6: return mQuats[3]; // 180 along Z
|
365
|
case 7: return new Static4D(SQ2/2,0,-SQ2/2,0); // 180 along (SQ2/2,0,-SQ2/2)
|
366
|
}
|
367
|
}
|
368
|
else if( cubit<numCorners+numEdges )
|
369
|
{
|
370
|
int edge = (cubit-numCorners)/(numLayers-2);
|
371
|
|
372
|
switch(edge)
|
373
|
{
|
374
|
case 0: return mQuats[ 0];
|
375
|
case 1: return mQuats[ 5];
|
376
|
case 2: return mQuats[ 3];
|
377
|
case 3: return mQuats[11];
|
378
|
case 4: return mQuats[ 4];
|
379
|
case 5: return mQuats[ 7];
|
380
|
case 6: return mQuats[ 9];
|
381
|
case 7: return mQuats[10];
|
382
|
case 8: return mQuats[ 2];
|
383
|
case 9: return mQuats[ 8];
|
384
|
case 10: return mQuats[ 1];
|
385
|
case 11: return mQuats[ 6];
|
386
|
}
|
387
|
}
|
388
|
else
|
389
|
{
|
390
|
int center = (cubit-numCorners-numEdges)/getNumCentersPerFace(numLayers);
|
391
|
|
392
|
switch(center)
|
393
|
{
|
394
|
case 0: return new Static4D(0,-SQ2/2,0,SQ2/2); // -90 along Y
|
395
|
case 1: return new Static4D(0, SQ2/2,0,SQ2/2); // 90 along Y
|
396
|
case 2: return new Static4D( SQ2/2,0,0,SQ2/2); // 90 along X
|
397
|
case 3: return new Static4D(-SQ2/2,0,0,SQ2/2); // -90 along X
|
398
|
case 4: return mQuats[0]; // unit quaternion
|
399
|
case 5: return mQuats[1]; // 180 along X
|
400
|
}
|
401
|
}
|
402
|
|
403
|
return null;
|
404
|
}
|
405
|
|
406
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
407
|
|
408
|
protected ObjectShape getObjectShape(int cubit, int numLayers)
|
409
|
{
|
410
|
int variant = getCubitVariant(cubit,numLayers);
|
411
|
|
412
|
if( variant==0 )
|
413
|
{
|
414
|
double[][] vertices = new double[][] { {-1,0,0},{0,-1,0},{0,0,-1},{-1,-1,-1},{0,0,0} };
|
415
|
int[][] vert_indices = new int[][] { {0,1,4},{2,0,4},{1,2,4},{3,1,0},{3,2,1},{3,0,2} };
|
416
|
int N = numLayers==2 ? 7:5;
|
417
|
int E1= numLayers==2 ? 3:2;
|
418
|
int E2= numLayers==2 ? 5:3;
|
419
|
float[][] bands = new float[][] { {0.020f,35,0.16f,0.7f,N,E1,E1}, {0.000f, 0,1.00f,0.0f,3,1,E2} };
|
420
|
int[] bandIndices = new int[] { 0,0,0,1,1,1 };
|
421
|
float[][] corners = new float[][] { {0.05f,0.25f}, {0.05f,0.20f} };
|
422
|
int[] cornerIndices = new int[] { 1,1,1,0,0 };
|
423
|
float[][] centers = new float[][] { {-0.5f, -0.5f, -0.5f} };
|
424
|
int[] centerIndices = new int[] { 0,0,0,-1,0 };
|
425
|
return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
426
|
}
|
427
|
else if( variant==1 )
|
428
|
{
|
429
|
double[][] vertices = new double[][] { {-1,0,0},{1,0,0},{0,-1,0},{0,0,-1} };
|
430
|
int[][] vert_indices = new int[][] { {2,1,0},{3,0,1},{2,3,1},{3,2,0} };
|
431
|
int N = numLayers==2 ? 7:5;
|
432
|
int E = numLayers==2 ? 5:2;
|
433
|
float[][] bands = new float[][] { {0.035f,30,0.16f,0.8f,N,2,E}, {0.020f,45,0.16f,0.2f,3,1,2} };
|
434
|
int[] bandIndices = new int[] { 0,0,1,1 };
|
435
|
float[][] corners = new float[][] { {0.07f,0.20f}, {0.02f,0.30f} };
|
436
|
int[] cornerIndices = new int[] { 0,0,1,1 };
|
437
|
float[][] centers = new float[][] { {0.0f, -0.5f, -0.5f} };
|
438
|
int[] centerIndices = new int[] { 0,0,0,0 };
|
439
|
return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
440
|
}
|
441
|
else
|
442
|
{
|
443
|
double[][] vertices = new double[][] { {-1,0,0},{0,-1,0},{1,0,0},{0,1,0},{0,0,-1} };
|
444
|
int[][] vert_indices = new int[][] { {0,1,2,3},{4,1,0},{4,2,1},{4,3,2},{4,0,3} };
|
445
|
int N = numLayers==2 ? 7:6;
|
446
|
int E = numLayers==2 ? 3:1;
|
447
|
float[][] bands = new float[][] { {0.04f,35,SQ2/8,0.9f,N,E,E}, {0.000f,0,1,0.0f,3,0,0} };
|
448
|
int[] bandIndices = new int[] { 0,1,1,1,1 };
|
449
|
float[][] corners = new float[][] { {0.06f,0.15f} };
|
450
|
int[] cornerIndices = new int[] { 0,0,0,0,0 };
|
451
|
float[][] centers = new float[][] { {0,0,-0.4f} };
|
452
|
int[] centerIndices = new int[] { 0,0,0,0,-1 };
|
453
|
return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
454
|
}
|
455
|
}
|
456
|
|
457
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
458
|
|
459
|
protected int getNumCubitVariants(int numLayers)
|
460
|
{
|
461
|
return 3;
|
462
|
}
|
463
|
|
464
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
465
|
|
466
|
protected int getCubitVariant(int cubit, int numLayers)
|
467
|
{
|
468
|
int numCorners = getNumCorners();
|
469
|
if( cubit<numCorners ) return 0;
|
470
|
int numEdges = getNumEdges(numLayers);
|
471
|
return cubit<numCorners+numEdges ? 1:2;
|
472
|
}
|
473
|
|
474
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
475
|
|
476
|
protected int getFaceColor(int cubit, int cubitface, int numLayers)
|
477
|
{
|
478
|
if( mCornerMap==null || mEdgeMap==null || mCenterMap==null )
|
479
|
{
|
480
|
mCornerMap = new int[][]
|
481
|
{
|
482
|
{ 4, 2, 0, 18,18,18 },
|
483
|
{ 2, 5, 0, 18,18,18 },
|
484
|
{ 3, 4, 0, 18,18,18 },
|
485
|
{ 5, 3, 0, 18,18,18 },
|
486
|
{ 1, 2, 4, 18,18,18 },
|
487
|
{ 5, 2, 1, 18,18,18 },
|
488
|
{ 4, 3, 1, 18,18,18 },
|
489
|
{ 1, 3, 5, 18,18,18 },
|
490
|
};
|
491
|
|
492
|
mEdgeMap = new int[][]
|
493
|
{
|
494
|
{ 10, 8, 18,18,18,18 },
|
495
|
{ 6,10, 18,18,18,18 },
|
496
|
{ 10, 9, 18,18,18,18 },
|
497
|
{ 7,10, 18,18,18,18 },
|
498
|
{ 8, 6, 18,18,18,18 },
|
499
|
{ 9, 6, 18,18,18,18 },
|
500
|
{ 9, 7, 18,18,18,18 },
|
501
|
{ 8, 7, 18,18,18,18 },
|
502
|
{ 11, 8, 18,18,18,18 },
|
503
|
{ 6,11, 18,18,18,18 },
|
504
|
{ 11, 9, 18,18,18,18 },
|
505
|
{ 7,11, 18,18,18,18 }
|
506
|
};
|
507
|
|
508
|
mCenterMap = new int[][]
|
509
|
{
|
510
|
{ 12, 18,18,18,18,18 },
|
511
|
{ 13, 18,18,18,18,18 },
|
512
|
{ 14, 18,18,18,18,18 },
|
513
|
{ 15, 18,18,18,18,18 },
|
514
|
{ 16, 18,18,18,18,18 },
|
515
|
{ 17, 18,18,18,18,18 },
|
516
|
};
|
517
|
}
|
518
|
|
519
|
int numCorners = getNumCorners();
|
520
|
int numEdges = getNumEdges(numLayers);
|
521
|
|
522
|
if( cubit<numCorners )
|
523
|
{
|
524
|
return mCornerMap[cubit][cubitface];
|
525
|
}
|
526
|
else if( cubit<numCorners+numEdges )
|
527
|
{
|
528
|
int edge = (cubit-numCorners)/(numLayers-2);
|
529
|
return mEdgeMap[edge][cubitface];
|
530
|
}
|
531
|
else
|
532
|
{
|
533
|
int center = (cubit-numCorners-numEdges)/getNumCentersPerFace(numLayers);
|
534
|
return mCenterMap[center][cubitface];
|
535
|
}
|
536
|
}
|
537
|
|
538
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
539
|
|
540
|
protected ObjectSticker retSticker(int face)
|
541
|
{
|
542
|
if( mStickers==null )
|
543
|
{
|
544
|
float[][] STICKERS = new float[][]
|
545
|
{
|
546
|
{ -0.5f, 0.25f, 0.25f, -0.5f, 0.25f, 0.25f },
|
547
|
{ -0.5f, 0.00f, 0.00f, -0.5f, 0.50f, 0.0f, 0.0f, 0.5f }
|
548
|
};
|
549
|
|
550
|
final float R1 = 0.025f;
|
551
|
final float R2 = 0.025f;
|
552
|
final float R3 = 0.055f;
|
553
|
final float[][] radii = { { R1,R1,R1 },{ R2,R2,R2 },{ R3,R3,R3,R3 } };
|
554
|
final float[] strokes = { 0.045f, 0.035f, 0.035f };
|
555
|
|
556
|
mStickers = new ObjectSticker[STICKERS.length+1];
|
557
|
|
558
|
for(int s=0; s<STICKERS.length+1; s++)
|
559
|
{
|
560
|
int index = s<2 ? 0:1;
|
561
|
mStickers[s] = new ObjectSticker(STICKERS[index],null,radii[s],strokes[s]);
|
562
|
}
|
563
|
}
|
564
|
|
565
|
return mStickers[face/NUM_FACE_COLORS];
|
566
|
}
|
567
|
|
568
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
569
|
// PUBLIC API
|
570
|
|
571
|
public Static3D[] getRotationAxis()
|
572
|
{
|
573
|
return ROT_AXIS;
|
574
|
}
|
575
|
|
576
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
577
|
|
578
|
public Movement getMovement()
|
579
|
{
|
580
|
if( mMovement==null )
|
581
|
{
|
582
|
int numLayers = getNumLayers();
|
583
|
if( mCuts==null ) getCuts(numLayers);
|
584
|
getLayerRotatable(numLayers);
|
585
|
mMovement = new Movement6(ROT_AXIS,mCuts,mLayerRotatable,2*numLayers-2,TYPE_SPLIT_CORNER,ENABLED);
|
586
|
}
|
587
|
return mMovement;
|
588
|
}
|
589
|
|
590
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
591
|
|
592
|
public int[] getBasicAngle()
|
593
|
{
|
594
|
if( mBasicAngle ==null ) mBasicAngle = new int[] { 3,3,3,3 };
|
595
|
return mBasicAngle;
|
596
|
}
|
597
|
|
598
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
599
|
|
600
|
public ObjectType intGetObjectType(int numLayers)
|
601
|
{
|
602
|
switch(numLayers)
|
603
|
{
|
604
|
case 2: return ObjectType.SKEW_2;
|
605
|
case 3: return ObjectType.SKEW_3;
|
606
|
}
|
607
|
|
608
|
return ObjectType.SKEW_2;
|
609
|
}
|
610
|
|
611
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
612
|
|
613
|
public int getObjectName(int numLayers)
|
614
|
{
|
615
|
switch(numLayers)
|
616
|
{
|
617
|
case 2: return R.string.skew2;
|
618
|
case 3: return R.string.skew3;
|
619
|
}
|
620
|
return R.string.skew2;
|
621
|
}
|
622
|
|
623
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
624
|
|
625
|
public int getInventor(int numLayers)
|
626
|
{
|
627
|
switch(numLayers)
|
628
|
{
|
629
|
case 2: return R.string.skew2_inventor;
|
630
|
case 3: return R.string.skew3_inventor;
|
631
|
}
|
632
|
return R.string.skew2_inventor;
|
633
|
}
|
634
|
|
635
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
636
|
|
637
|
public int getComplexity(int numLayers)
|
638
|
{
|
639
|
switch(numLayers)
|
640
|
{
|
641
|
case 2: return 4;
|
642
|
case 3: return 8;
|
643
|
}
|
644
|
return 5;
|
645
|
}
|
646
|
}
|