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.objectlib.objects;
|
21
|
|
22
|
import static org.distorted.objectlib.main.Movement.MOVEMENT_HEXAHEDRON;
|
23
|
import static org.distorted.objectlib.main.Movement.TYPE_NOT_SPLIT;
|
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.ObjectControl;
|
31
|
import org.distorted.objectlib.main.ObjectType;
|
32
|
import org.distorted.objectlib.helpers.ObjectShape;
|
33
|
import org.distorted.objectlib.helpers.ObjectSticker;
|
34
|
import org.distorted.objectlib.helpers.ScrambleState;
|
35
|
import org.distorted.objectlib.main.Twisty6;
|
36
|
|
37
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
38
|
|
39
|
public class TwistyMirror extends Twisty6
|
40
|
{
|
41
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
42
|
{
|
43
|
new Static3D(1,0,0),
|
44
|
new Static3D(0,1,0),
|
45
|
new Static3D(0,0,1)
|
46
|
};
|
47
|
|
48
|
private static final int[] FACE_COLORS = new int[] { COLOR_WHITE };
|
49
|
private static final float DX = 0.10f;
|
50
|
private static final float DY = 0.25f;
|
51
|
private static final float DZ = 0.40f;
|
52
|
|
53
|
private static final float[][] SEQ2 = new float[][]
|
54
|
{
|
55
|
{1-DX,1-DY},{1+DX,1-DY},{1-DX,1+DY},{1+DX,1+DY},
|
56
|
{1-DX,1-DZ},{1+DX,1-DZ},{1-DX,1+DZ},{1+DX,1+DZ},
|
57
|
{1-DZ,1-DY},{1+DZ,1-DY},{1-DZ,1+DY},{1+DZ,1+DY},
|
58
|
};
|
59
|
|
60
|
private static final float[][] SEQ3 = new float[][]
|
61
|
{
|
62
|
{1 ,1 },{1-DX,1-DY},{1 ,1-DY},{1+DX,1-DY},{1-DX,1 },
|
63
|
{1+DX,1 },{1-DX,1+DY},{1 ,1+DY},{1+DX,1+DY},{1-DX,1-DZ},
|
64
|
{1 ,1-DZ},{1+DX,1-DZ},{1-DX,1 },{1+DX,1 },{1-DX,1+DZ},
|
65
|
{1 ,1+DZ},{1+DX,1+DZ},{1-DZ,1-DY},{1 ,1-DY},{1+DZ,1-DY},
|
66
|
{1-DZ,1 },{1+DZ,1 },{1-DZ,1+DY},{1 ,1+DY},{1+DZ,1+DY},
|
67
|
};
|
68
|
|
69
|
private ScrambleState[] mStates;
|
70
|
private Static4D[] mQuats;
|
71
|
private float[][] mCuts;
|
72
|
private int[] mBasicAngle;
|
73
|
private ObjectSticker[] mStickers;
|
74
|
private float[][] mPositions;
|
75
|
|
76
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
77
|
|
78
|
public TwistyMirror(int[] numL, Static4D quat, Static3D move, InputStream stream)
|
79
|
{
|
80
|
super(numL, numL[0], quat, move, stream);
|
81
|
}
|
82
|
|
83
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
84
|
|
85
|
public ScrambleState[] getScrambleStates()
|
86
|
{
|
87
|
if( mStates==null )
|
88
|
{
|
89
|
int[] numLayers = getNumLayers();
|
90
|
int[][] m = new int[16][];
|
91
|
for(int i=1; i<16; i++) m[i] = createEdges(numLayers[0],i);
|
92
|
|
93
|
mStates = new ScrambleState[]
|
94
|
{
|
95
|
new ScrambleState( new int[][] { m[ 1], m[ 2], m[ 3] } ), // 0
|
96
|
new ScrambleState( new int[][] { null, m[ 4], m[ 5] } ), // x
|
97
|
new ScrambleState( new int[][] { m[ 6], null, m[ 7] } ), // y
|
98
|
new ScrambleState( new int[][] { m[ 8], m[ 8], null } ), // z
|
99
|
new ScrambleState( new int[][] { m[10], null, m[ 7] } ), // xy
|
100
|
new ScrambleState( new int[][] { m[11], m[ 9], null } ), // xz
|
101
|
new ScrambleState( new int[][] { null, m[12], m[ 5] } ), // yx
|
102
|
new ScrambleState( new int[][] { m[ 8], m[13], null } ), // yz
|
103
|
new ScrambleState( new int[][] { null, m[ 4], m[14] } ), // zx
|
104
|
new ScrambleState( new int[][] { m[ 6], null, m[15] } ), // zy
|
105
|
new ScrambleState( new int[][] { null, null, m[ 5] } ), // xyx
|
106
|
new ScrambleState( new int[][] { null, m[ 4], null } ), // xzx
|
107
|
new ScrambleState( new int[][] { null, null, m[ 7] } ), // yxy
|
108
|
new ScrambleState( new int[][] { m[ 6], null, null } ), // yzy
|
109
|
new ScrambleState( new int[][] { null, m[ 9], null } ), // zxz
|
110
|
new ScrambleState( new int[][] { m[ 8], null, null } ), // zyz
|
111
|
};
|
112
|
}
|
113
|
|
114
|
return mStates;
|
115
|
}
|
116
|
|
117
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
118
|
|
119
|
private int[] createEdges(int size, int vertex)
|
120
|
{
|
121
|
int[] ret = new int[9*size];
|
122
|
|
123
|
for(int l=0; l<size; l++)
|
124
|
{
|
125
|
ret[9*l ] = l;
|
126
|
ret[9*l+1] =-1;
|
127
|
ret[9*l+2] = vertex;
|
128
|
ret[9*l+3] = l;
|
129
|
ret[9*l+4] = 1;
|
130
|
ret[9*l+5] = vertex;
|
131
|
ret[9*l+6] = l;
|
132
|
ret[9*l+7] = 2;
|
133
|
ret[9*l+8] = vertex;
|
134
|
}
|
135
|
|
136
|
return ret;
|
137
|
}
|
138
|
|
139
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
140
|
|
141
|
private void initializeQuats()
|
142
|
{
|
143
|
mQuats = new Static4D[]
|
144
|
{
|
145
|
new Static4D( 0.0f, 0.0f, 0.0f, 1.0f),
|
146
|
new Static4D( 1.0f, 0.0f, 0.0f, 0.0f),
|
147
|
new Static4D( 0.0f, 1.0f, 0.0f, 0.0f),
|
148
|
new Static4D( 0.0f, 0.0f, 1.0f, 0.0f),
|
149
|
|
150
|
new Static4D( SQ2/2, SQ2/2, 0.0f , 0.0f),
|
151
|
new Static4D( SQ2/2, -SQ2/2, 0.0f , 0.0f),
|
152
|
new Static4D( SQ2/2, 0.0f, SQ2/2, 0.0f),
|
153
|
new Static4D(-SQ2/2, 0.0f, SQ2/2, 0.0f),
|
154
|
new Static4D( SQ2/2, 0.0f, 0.0f, SQ2/2),
|
155
|
new Static4D( SQ2/2, 0.0f, 0.0f, -SQ2/2),
|
156
|
new Static4D( 0.0f, SQ2/2, SQ2/2, 0.0f),
|
157
|
new Static4D( 0.0f, SQ2/2, -SQ2/2, 0.0f),
|
158
|
new Static4D( 0.0f, SQ2/2, 0.0f, SQ2/2),
|
159
|
new Static4D( 0.0f, SQ2/2, 0.0f, -SQ2/2),
|
160
|
new Static4D( 0.0f, 0.0f, SQ2/2, SQ2/2),
|
161
|
new Static4D( 0.0f, 0.0f, SQ2/2, -SQ2/2),
|
162
|
|
163
|
new Static4D( 0.5f, 0.5f, 0.5f, 0.5f),
|
164
|
new Static4D( 0.5f, 0.5f, -0.5f, 0.5f),
|
165
|
new Static4D( 0.5f, 0.5f, -0.5f, -0.5f),
|
166
|
new Static4D( 0.5f, -0.5f, 0.5f, -0.5f),
|
167
|
new Static4D( -0.5f, -0.5f, -0.5f, 0.5f),
|
168
|
new Static4D( -0.5f, 0.5f, -0.5f, -0.5f),
|
169
|
new Static4D( -0.5f, 0.5f, 0.5f, -0.5f),
|
170
|
new Static4D( -0.5f, 0.5f, 0.5f, 0.5f)
|
171
|
};
|
172
|
}
|
173
|
|
174
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
175
|
// we cannot do this the standard, automatic way because there's only 1 color in the FACE_COLORS
|
176
|
// table and retCubitSolvedStatus() always returns -1,-1 or 0.
|
177
|
|
178
|
public int[] getSolvedQuats(int cubit, int[] numLayers)
|
179
|
{
|
180
|
if( numLayers[0]==3 )
|
181
|
{
|
182
|
switch(cubit)
|
183
|
{
|
184
|
case 4:
|
185
|
case 21: return new int[] {1,8,9};
|
186
|
case 10:
|
187
|
case 15: return new int[] {2,12,13};
|
188
|
case 12:
|
189
|
case 13: return new int[] {3,14,15};
|
190
|
}
|
191
|
}
|
192
|
|
193
|
return null;
|
194
|
}
|
195
|
|
196
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
197
|
|
198
|
public int getCubitFaceColor(int cubit, int face, int[] numLayers)
|
199
|
{
|
200
|
return 0;
|
201
|
}
|
202
|
|
203
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
204
|
|
205
|
public int getVariantFaceColor(int variant, int face, int[] numLayers)
|
206
|
{
|
207
|
int numL = numLayers[0];
|
208
|
|
209
|
if( numL==2 )
|
210
|
{
|
211
|
switch(face)
|
212
|
{
|
213
|
case 0: if( variant==4 ) return 11;
|
214
|
if( variant==5 ) return 10;
|
215
|
if( variant==6 ) return 9;
|
216
|
if( variant==7 ) return 8;
|
217
|
return -1;
|
218
|
case 1: if( variant==0 ) return 11;
|
219
|
if( variant==1 ) return 10;
|
220
|
if( variant==2 ) return 9;
|
221
|
if( variant==3 ) return 8;
|
222
|
return -1;
|
223
|
case 2: if( variant==3 ) return 4;
|
224
|
if( variant==7 ) return 5;
|
225
|
if( variant==2 ) return 6;
|
226
|
if( variant==6 ) return 7;
|
227
|
return -1;
|
228
|
case 3: if( variant==1 ) return 4;
|
229
|
if( variant==5 ) return 5;
|
230
|
if( variant==0 ) return 6;
|
231
|
if( variant==4 ) return 7;
|
232
|
return -1;
|
233
|
case 4: if( variant==3 ) return 0;
|
234
|
if( variant==7 ) return 1;
|
235
|
if( variant==1 ) return 2;
|
236
|
if( variant==5 ) return 3;
|
237
|
return -1;
|
238
|
case 5: if( variant==2 ) return 0;
|
239
|
if( variant==6 ) return 1;
|
240
|
if( variant==0 ) return 2;
|
241
|
if( variant==4 ) return 3;
|
242
|
return -1;
|
243
|
}
|
244
|
}
|
245
|
if( numL==3 )
|
246
|
{
|
247
|
switch(face)
|
248
|
{
|
249
|
case 0: if( variant==17 ) return 24;
|
250
|
if( variant==18 ) return 23;
|
251
|
if( variant==19 ) return 22;
|
252
|
if( variant==20 ) return 21;
|
253
|
if( variant==21 ) return 0;
|
254
|
if( variant==22 ) return 20;
|
255
|
if( variant==23 ) return 19;
|
256
|
if( variant==24 ) return 18;
|
257
|
if( variant==25 ) return 17;
|
258
|
return -1;
|
259
|
case 1: if( variant== 0 ) return 24;
|
260
|
if( variant== 1 ) return 23;
|
261
|
if( variant== 2 ) return 22;
|
262
|
if( variant== 3 ) return 21;
|
263
|
if( variant== 4 ) return 0;
|
264
|
if( variant== 5 ) return 20;
|
265
|
if( variant== 6 ) return 19;
|
266
|
if( variant== 7 ) return 18;
|
267
|
if( variant== 8 ) return 17;
|
268
|
return -1;
|
269
|
case 2: if( variant== 6 ) return 14;
|
270
|
if( variant==14 ) return 2; // theoretically should have been 15, but this must have gotten collapsed in the Factory
|
271
|
if( variant==23 ) return 16;
|
272
|
if( variant== 7 ) return 12;
|
273
|
if( variant==15 ) return 0;
|
274
|
if( variant==24 ) return 13;
|
275
|
if( variant== 8 ) return 9;
|
276
|
if( variant==16 ) return 20; // ditto, theoretically 10
|
277
|
if( variant==25 ) return 11;
|
278
|
return -1;
|
279
|
case 3: if( variant== 0 ) return 14;
|
280
|
if( variant== 9 ) return 2; // ditto, theoretically 15
|
281
|
if( variant==17 ) return 16;
|
282
|
if( variant== 1 ) return 12;
|
283
|
if( variant==10 ) return 0;
|
284
|
if( variant==18 ) return 13;
|
285
|
if( variant== 2 ) return 9;
|
286
|
if( variant==11 ) return 20; // ditto, theoretically 10
|
287
|
if( variant==19 ) return 11;
|
288
|
return -1;
|
289
|
case 4: if( variant== 8 ) return 1;
|
290
|
if( variant==16 ) return 2;
|
291
|
if( variant==25 ) return 3;
|
292
|
if( variant== 5 ) return 4;
|
293
|
if( variant==13 ) return 0;
|
294
|
if( variant==22 ) return 5;
|
295
|
if( variant== 2 ) return 6;
|
296
|
if( variant==11 ) return 7;
|
297
|
if( variant==19 ) return 8;
|
298
|
return -1;
|
299
|
case 5: if( variant== 6 ) return 1;
|
300
|
if( variant==14 ) return 2;
|
301
|
if( variant==23 ) return 3;
|
302
|
if( variant== 3 ) return 4;
|
303
|
if( variant==12 ) return 0;
|
304
|
if( variant==20 ) return 5;
|
305
|
if( variant== 0 ) return 6;
|
306
|
if( variant== 9 ) return 7;
|
307
|
if( variant==17 ) return 8;
|
308
|
return -1;
|
309
|
}
|
310
|
}
|
311
|
|
312
|
return 0;
|
313
|
}
|
314
|
|
315
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
316
|
|
317
|
private float returnStroke(float x, float y)
|
318
|
{
|
319
|
return 0.08f/(Math.max(x,y));
|
320
|
}
|
321
|
|
322
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
323
|
|
324
|
private float[] generateStrokes(int numLayers)
|
325
|
{
|
326
|
if( numLayers==2 )
|
327
|
{
|
328
|
int LEN = SEQ2.length;
|
329
|
float[] tmp = new float[LEN];
|
330
|
for(int i=0; i<LEN; i++) tmp[i] = returnStroke(SEQ2[i][0],SEQ2[i][1]);
|
331
|
return tmp;
|
332
|
}
|
333
|
else
|
334
|
{
|
335
|
int LEN = SEQ3.length;
|
336
|
float[] tmp = new float[LEN];
|
337
|
for(int i=0; i<LEN; i++) tmp[i] = returnStroke(SEQ3[i][0],SEQ3[i][1]);
|
338
|
return tmp;
|
339
|
}
|
340
|
}
|
341
|
|
342
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
343
|
|
344
|
private float[] returnSticker(float x, float y)
|
345
|
{
|
346
|
float H = 0.5f;
|
347
|
|
348
|
if( x<y ) { float D=H*x/y; return new float[] {-D,-H,+D,-H,+D,+H,-D,+H}; }
|
349
|
else { float D=H*y/x; return new float[] {-H,-D,+H,-D,+H,+D,-H,+D}; }
|
350
|
}
|
351
|
|
352
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
353
|
|
354
|
private float[][] generateStickers(int numLayers)
|
355
|
{
|
356
|
if( numLayers==2 )
|
357
|
{
|
358
|
int LEN = SEQ2.length;
|
359
|
float[][] tmp = new float[LEN][];
|
360
|
for(int i=0; i<LEN; i++) tmp[i] = returnSticker(SEQ2[i][0],SEQ2[i][1]);
|
361
|
return tmp;
|
362
|
}
|
363
|
else
|
364
|
{
|
365
|
int LEN = SEQ3.length;
|
366
|
float[][] tmp = new float[LEN][];
|
367
|
for(int i=0; i<LEN; i++) tmp[i] = returnSticker(SEQ3[i][0],SEQ3[i][1]);
|
368
|
return tmp;
|
369
|
}
|
370
|
}
|
371
|
|
372
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
373
|
|
374
|
public ObjectSticker retSticker(int sticker)
|
375
|
{
|
376
|
if( mStickers==null )
|
377
|
{
|
378
|
int[] numLayers = getNumLayers();
|
379
|
int numL = numLayers[0];
|
380
|
final float[][] STICKERS = generateStickers(numL);
|
381
|
final int NUM_STICKERS = STICKERS.length;
|
382
|
final float radius = 0.10f;
|
383
|
final float[] radii = {radius,radius,radius,radius};
|
384
|
float[] STROKES = generateStrokes(numL);
|
385
|
|
386
|
if( ObjectControl.isInIconMode() )
|
387
|
{
|
388
|
int len = STROKES.length;
|
389
|
float mult = numL==2 ? 1.8f: 2.0f;
|
390
|
for(int i=0; i<len; i++) STROKES[i]*=mult;
|
391
|
}
|
392
|
|
393
|
mStickers = new ObjectSticker[NUM_STICKERS];
|
394
|
|
395
|
for(int i=0; i<NUM_STICKERS; i++)
|
396
|
{
|
397
|
mStickers[i] = new ObjectSticker(STICKERS[i],null,radii,STROKES[i]);
|
398
|
}
|
399
|
}
|
400
|
|
401
|
return mStickers[sticker];
|
402
|
}
|
403
|
|
404
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
405
|
|
406
|
public int getNumStickerTypes(int[] numLayers)
|
407
|
{
|
408
|
return numLayers[0]==2 ? SEQ2.length : SEQ3.length;
|
409
|
}
|
410
|
|
411
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
412
|
|
413
|
private int getRow(int cubit, int numLayers, int dim)
|
414
|
{
|
415
|
return (int)(mPositions[cubit][dim] + 0.5f*(numLayers-1));
|
416
|
}
|
417
|
|
418
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
419
|
|
420
|
public ObjectShape getObjectShape(int variant)
|
421
|
{
|
422
|
int extraI, extraV, num, numL = getNumLayers()[0];
|
423
|
float height;
|
424
|
|
425
|
switch(numL)
|
426
|
{
|
427
|
case 2 : num = 6; extraI = 2; extraV = 2; height = 0.045f; break;
|
428
|
case 3 : num = 5; extraI = 2; extraV = 2; height = 0.045f; break;
|
429
|
case 4 : num = 5; extraI = 1; extraV = 1; height = 0.045f; break;
|
430
|
default: num = 5; extraI = 0; extraV = 0; height = 0.045f; break;
|
431
|
}
|
432
|
|
433
|
int xrow = getRow(variant,numL,0); // cubit == variant
|
434
|
int yrow = getRow(variant,numL,1);
|
435
|
int zrow = getRow(variant,numL,2);
|
436
|
|
437
|
float XL = -0.5f + (xrow== 0 ? DX : 0);
|
438
|
float XR = +0.5f + (xrow==numL-1 ? DX : 0);
|
439
|
float YL = -0.5f - (yrow== 0 ? DY : 0);
|
440
|
float YR = +0.5f - (yrow==numL-1 ? DY : 0);
|
441
|
float ZL = -0.5f - (zrow== 0 ? DZ : 0);
|
442
|
float ZR = +0.5f - (zrow==numL-1 ? DZ : 0);
|
443
|
|
444
|
double[][] vertices = new double[][]
|
445
|
{
|
446
|
{ XR, YR, ZR },
|
447
|
{ XR, YR, ZL },
|
448
|
{ XR, YL, ZR },
|
449
|
{ XR, YL, ZL },
|
450
|
{ XL, YR, ZR },
|
451
|
{ XL, YR, ZL },
|
452
|
{ XL, YL, ZR },
|
453
|
{ XL, YL, ZL },
|
454
|
};
|
455
|
|
456
|
int[][] vert_indices = new int[][]
|
457
|
{
|
458
|
{2,3,1,0},
|
459
|
{7,6,4,5},
|
460
|
{4,0,1,5},
|
461
|
{7,3,2,6},
|
462
|
{6,2,0,4},
|
463
|
{3,7,5,1}
|
464
|
};
|
465
|
|
466
|
float[][] bands = new float[][] { {height,35,0.5f,0.7f,num,extraI,extraV} };
|
467
|
int[] bandIndices = new int[] { 0,0,0,0,0,0};
|
468
|
float[][] corners = new float[][] { {0.036f,0.12f} };
|
469
|
int[] cornerIndices = new int[] { 0,0,0,0,0,0,0,0 };
|
470
|
float[][] centers = new float[][] { {0.0f, 0.0f, 0.0f} };
|
471
|
int[] centerIndices = new int[] { 0,0,0,0,0,0,0,0 };
|
472
|
|
473
|
return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
474
|
}
|
475
|
|
476
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
477
|
|
478
|
public Static4D getQuat(int cubit, int[] numLayers)
|
479
|
{
|
480
|
if( mQuats ==null ) initializeQuats();
|
481
|
return mQuats[0];
|
482
|
}
|
483
|
|
484
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
485
|
|
486
|
public int getNumCubitVariants(int[] numLayers)
|
487
|
{
|
488
|
int numL = numLayers[0];
|
489
|
return 6*numL*numL - 12*numL + 8;
|
490
|
}
|
491
|
|
492
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
493
|
|
494
|
public int getCubitVariant(int cubit, int[] numLayers)
|
495
|
{
|
496
|
return cubit;
|
497
|
}
|
498
|
|
499
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
500
|
|
501
|
public int getColor(int face)
|
502
|
{
|
503
|
return FACE_COLORS[face];
|
504
|
}
|
505
|
|
506
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
507
|
|
508
|
public float[][] getCubitPositions(int[] numLayers)
|
509
|
{
|
510
|
if( mPositions==null )
|
511
|
{
|
512
|
int numL = numLayers[0];
|
513
|
int numCubits = numL>1 ? 6*numL*numL - 12*numL + 8 : 1;
|
514
|
mPositions = new float[numCubits][];
|
515
|
|
516
|
float diff = 0.5f*(numL-1);
|
517
|
int currentPosition = 0;
|
518
|
|
519
|
for(int x = 0; x<numL; x++)
|
520
|
for(int y = 0; y<numL; y++)
|
521
|
for(int z = 0; z<numL; z++)
|
522
|
if( x==0 || x==numL-1 || y==0 || y==numL-1 || z==0 || z==numL-1 )
|
523
|
{
|
524
|
mPositions[currentPosition++] = new float[] {x-diff,y-diff,z-diff};
|
525
|
}
|
526
|
}
|
527
|
|
528
|
return mPositions;
|
529
|
}
|
530
|
|
531
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
532
|
|
533
|
public Static4D[] getQuats()
|
534
|
{
|
535
|
if( mQuats ==null ) initializeQuats();
|
536
|
return mQuats;
|
537
|
}
|
538
|
|
539
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
540
|
|
541
|
public int getNumFaceColors()
|
542
|
{
|
543
|
return 1;
|
544
|
}
|
545
|
|
546
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
547
|
|
548
|
public float[][] getCuts(int[] numLayers)
|
549
|
{
|
550
|
if( mCuts==null )
|
551
|
{
|
552
|
int numL = numLayers[0];
|
553
|
mCuts = new float[3][numL-1];
|
554
|
|
555
|
for(int i=0; i<numL-1; i++)
|
556
|
{
|
557
|
float cut = (2-numL)*0.5f + i;
|
558
|
mCuts[0][i] = cut;
|
559
|
mCuts[1][i] = cut;
|
560
|
mCuts[2][i] = cut;
|
561
|
}
|
562
|
}
|
563
|
|
564
|
return mCuts;
|
565
|
}
|
566
|
|
567
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
568
|
|
569
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
570
|
{
|
571
|
int numAxis = ROT_AXIS.length;
|
572
|
boolean[][] layerRotatable = new boolean[numAxis][];
|
573
|
|
574
|
for(int i=0; i<numAxis; i++)
|
575
|
{
|
576
|
layerRotatable[i] = new boolean[numLayers[i]];
|
577
|
for(int j=0; j<numLayers[i]; j++) layerRotatable[i][j] = true;
|
578
|
}
|
579
|
|
580
|
return layerRotatable;
|
581
|
}
|
582
|
|
583
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
584
|
|
585
|
public int getMovementType()
|
586
|
{
|
587
|
return MOVEMENT_HEXAHEDRON;
|
588
|
}
|
589
|
|
590
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
591
|
|
592
|
public int getMovementSplit()
|
593
|
{
|
594
|
return TYPE_NOT_SPLIT;
|
595
|
}
|
596
|
|
597
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
598
|
|
599
|
public int[][][] getEnabled()
|
600
|
{
|
601
|
return new int[][][]
|
602
|
{
|
603
|
{{1,2}},{{1,2}},{{0,2}},{{0,2}},{{0,1}},{{0,1}},
|
604
|
};
|
605
|
}
|
606
|
|
607
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
608
|
|
609
|
public float[] getDist3D(int[] numLayers)
|
610
|
{
|
611
|
return null;
|
612
|
}
|
613
|
|
614
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
615
|
|
616
|
public int getSolvedFunctionIndex()
|
617
|
{
|
618
|
return 0;
|
619
|
}
|
620
|
|
621
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
622
|
|
623
|
public int getNumCubitFaces()
|
624
|
{
|
625
|
return 6;
|
626
|
}
|
627
|
|
628
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
629
|
// PUBLIC API
|
630
|
|
631
|
public Static3D[] getRotationAxis()
|
632
|
{
|
633
|
return ROT_AXIS;
|
634
|
}
|
635
|
|
636
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
637
|
|
638
|
public int[] getBasicAngle()
|
639
|
{
|
640
|
if( mBasicAngle==null ) mBasicAngle = new int[] { 4,4,4 };
|
641
|
return mBasicAngle;
|
642
|
}
|
643
|
|
644
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
645
|
|
646
|
public ObjectType intGetObjectType(int[] numLayers)
|
647
|
{
|
648
|
switch(numLayers[0])
|
649
|
{
|
650
|
case 2: return ObjectType.MIRR_2;
|
651
|
case 3: return ObjectType.MIRR_3;
|
652
|
}
|
653
|
|
654
|
return ObjectType.MIRR_2;
|
655
|
}
|
656
|
|
657
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
658
|
|
659
|
public String getObjectName()
|
660
|
{
|
661
|
switch(getNumLayers()[0])
|
662
|
{
|
663
|
case 2: return "Pocket Mirror";
|
664
|
case 3: return "Mirror Cube";
|
665
|
}
|
666
|
return "Pocket Mirror";
|
667
|
}
|
668
|
|
669
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
670
|
|
671
|
public String getInventor()
|
672
|
{
|
673
|
switch(getNumLayers()[0])
|
674
|
{
|
675
|
case 2: return "Thomas de Bruin";
|
676
|
case 3: return "Hidetoshi Takeji";
|
677
|
}
|
678
|
return "Hidetoshi Takeji";
|
679
|
}
|
680
|
|
681
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
682
|
|
683
|
public int getYearOfInvention()
|
684
|
{
|
685
|
switch(getNumLayers()[0])
|
686
|
{
|
687
|
case 2: return 2007;
|
688
|
case 3: return 2006;
|
689
|
}
|
690
|
return 2006;
|
691
|
}
|
692
|
|
693
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
694
|
|
695
|
public int getComplexity()
|
696
|
{
|
697
|
switch(getNumLayers()[0])
|
698
|
{
|
699
|
case 2: return 5;
|
700
|
case 3: return 7;
|
701
|
}
|
702
|
return 7;
|
703
|
}
|
704
|
}
|