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