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