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