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