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.Movement12.COS54;
|
23
|
import static org.distorted.objectlib.main.Movement12.SIN54;
|
24
|
|
25
|
import java.io.InputStream;
|
26
|
|
27
|
import org.distorted.library.type.Static3D;
|
28
|
import org.distorted.library.type.Static4D;
|
29
|
import org.distorted.library.main.QuatHelper;
|
30
|
|
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
|
|
36
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
37
|
|
38
|
public class TwistyMegaminx extends TwistyMinx
|
39
|
{
|
40
|
static final float MEGA_D = 0.04f;
|
41
|
private int[] mQuatCenterIndices;
|
42
|
|
43
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
44
|
|
45
|
public TwistyMegaminx(int[] numL, Static4D quat, Static3D move, InputStream stream)
|
46
|
{
|
47
|
super(numL, quat, move, stream);
|
48
|
}
|
49
|
|
50
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
51
|
|
52
|
private void initializeCenterIndices()
|
53
|
{
|
54
|
mQuatCenterIndices = new int[] { 16, 18, 22, 1, 20, 13, 14, 15, 0, 12, 2, 3 };
|
55
|
}
|
56
|
|
57
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
58
|
|
59
|
private int numCubitsPerCorner(int numLayers)
|
60
|
{
|
61
|
return 3*((numLayers-1)/2)*((numLayers-3)/2) + 1;
|
62
|
}
|
63
|
|
64
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
65
|
|
66
|
private int numCubitsPerEdge(int numLayers)
|
67
|
{
|
68
|
return numLayers-2;
|
69
|
}
|
70
|
|
71
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
72
|
|
73
|
public int getNumStickerTypes(int[] numLayers)
|
74
|
{
|
75
|
return (numLayers[0]+3)/2;
|
76
|
}
|
77
|
|
78
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
79
|
|
80
|
public float[][] getCuts(int[] numLayers)
|
81
|
{
|
82
|
return genericGetCuts(numLayers[0],0.5f-MEGA_D);
|
83
|
}
|
84
|
|
85
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
86
|
|
87
|
private float[] computeCenter(int center, int numLayers)
|
88
|
{
|
89
|
if( mCenterCoords==null ) initializeCenterCoords();
|
90
|
float[] coords = mCenterCoords[center];
|
91
|
float A = 0.33f*numLayers;
|
92
|
|
93
|
return new float[] { A*coords[0], A*coords[1], A*coords[2] };
|
94
|
}
|
95
|
|
96
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
97
|
// Fill out mCurrCorner{X,Y,Z} by applying appropriate Quat to mBasicCorner{X,Y,Z}
|
98
|
// Appropriate one: QUATS[QUAT_INDICES[corner]].
|
99
|
|
100
|
private void computeBasicCornerVectors(int corner)
|
101
|
{
|
102
|
if( mQuatCornerIndices==null ) initializeQuatIndices();
|
103
|
if( mQuats==null ) initializeQuats();
|
104
|
if( mCurrCornerV==null || mBasicCornerV==null ) initializeCornerV();
|
105
|
|
106
|
Static4D quat = mQuats[mQuatCornerIndices[corner]];
|
107
|
|
108
|
mCurrCornerV[0] = QuatHelper.rotateVectorByQuat(mBasicCornerV[0],quat);
|
109
|
mCurrCornerV[1] = QuatHelper.rotateVectorByQuat(mBasicCornerV[1],quat);
|
110
|
mCurrCornerV[2] = QuatHelper.rotateVectorByQuat(mBasicCornerV[2],quat);
|
111
|
}
|
112
|
|
113
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
114
|
|
115
|
private float[] computeCorner(int numCubitsPerCorner, int numLayers, int corner, int part)
|
116
|
{
|
117
|
if( mCorners==null ) initializeCorners();
|
118
|
if( mCurrCornerV==null || mBasicCornerV==null ) initializeCornerV();
|
119
|
|
120
|
float D = numLayers/3.0f;
|
121
|
float[] corn = mCorners[corner];
|
122
|
|
123
|
if( part==0 )
|
124
|
{
|
125
|
return new float[] { corn[0]*D, corn[1]*D, corn[2]*D };
|
126
|
}
|
127
|
else
|
128
|
{
|
129
|
float E = 2.0f*D*(0.5f-MEGA_D)/(0.5f*(numLayers-1));
|
130
|
int N = (numCubitsPerCorner-1)/3;
|
131
|
int block = (part-1) % N;
|
132
|
int index = (part-1) / N;
|
133
|
Static4D pri = mCurrCornerV[index];
|
134
|
Static4D sec = mCurrCornerV[(index+2)%3];
|
135
|
|
136
|
int layers= (numLayers-3)/2;
|
137
|
int multP = (block % layers) + 1;
|
138
|
int multS = (block / layers);
|
139
|
|
140
|
return new float[] {
|
141
|
corn[0]*D + (pri.get0()*multP + sec.get0()*multS)*E,
|
142
|
corn[1]*D + (pri.get1()*multP + sec.get1()*multS)*E,
|
143
|
corn[2]*D + (pri.get2()*multP + sec.get2()*multS)*E
|
144
|
};
|
145
|
}
|
146
|
}
|
147
|
|
148
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
149
|
|
150
|
private int computeEdgeType(int cubit, int numCubitsPerCorner, int numCubitsPerEdge)
|
151
|
{
|
152
|
int part = (cubit - NUM_CORNERS*numCubitsPerCorner) % numCubitsPerEdge;
|
153
|
return (part+1)/2;
|
154
|
}
|
155
|
|
156
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
157
|
|
158
|
private float[] computeEdge(int numLayers, int edge, int part)
|
159
|
{
|
160
|
if( mCenterCoords==null ) initializeCenterCoords();
|
161
|
if( mCorners==null ) initializeCorners();
|
162
|
if( mEdgeMap==null ) initializeEdgeMap();
|
163
|
|
164
|
float D = numLayers/3.0f;
|
165
|
float[] c1 = mCorners[ mEdgeMap[edge][0] ];
|
166
|
float[] c2 = mCorners[ mEdgeMap[edge][1] ];
|
167
|
float x = D * (c1[0]+c2[0]) / 2;
|
168
|
float y = D * (c1[1]+c2[1]) / 2;
|
169
|
float z = D * (c1[2]+c2[2]) / 2;
|
170
|
|
171
|
if( part==0 )
|
172
|
{
|
173
|
return new float[] { x, y, z };
|
174
|
}
|
175
|
else
|
176
|
{
|
177
|
int mult = (part+1)/2;
|
178
|
int dir = (part+1)%2;
|
179
|
float[] center = mCenterCoords[ mEdgeMap[edge][dir+2] ];
|
180
|
|
181
|
float vX = D*center[0] - x;
|
182
|
float vY = D*center[1] - y;
|
183
|
float vZ = D*center[2] - z;
|
184
|
|
185
|
float A = 3*mult*D*(0.5f-MEGA_D)*COS18/((numLayers-1)*0.5f);
|
186
|
A /= (float)Math.sqrt(vX*vX+vY*vY+vZ*vZ);
|
187
|
|
188
|
return new float[] { x+A*vX, y+A*vY, z+A*vZ };
|
189
|
}
|
190
|
}
|
191
|
|
192
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
193
|
|
194
|
public float[][] getCubitPositions(int[] numLayers)
|
195
|
{
|
196
|
int numL = numLayers[0];
|
197
|
int numCubitsPerCorner = numCubitsPerCorner(numL);
|
198
|
int numCubitsPerEdge = numCubitsPerEdge(numL);
|
199
|
int numCubits = NUM_CORNERS*numCubitsPerCorner + NUM_EDGES*numCubitsPerEdge + NUM_CENTERS;
|
200
|
int index=0;
|
201
|
|
202
|
final float[][] CENTERS = new float[numCubits][];
|
203
|
|
204
|
for(int corner=0; corner<NUM_CORNERS; corner++)
|
205
|
{
|
206
|
computeBasicCornerVectors(corner);
|
207
|
|
208
|
for(int part=0; part<numCubitsPerCorner; part++, index++)
|
209
|
{
|
210
|
CENTERS[index] = computeCorner(numCubitsPerCorner,numL,corner,part);
|
211
|
}
|
212
|
}
|
213
|
|
214
|
for(int edge=0; edge<NUM_EDGES; edge++)
|
215
|
{
|
216
|
for(int part=0; part<numCubitsPerEdge; part++, index++)
|
217
|
{
|
218
|
CENTERS[index] = computeEdge(numL, edge, part );
|
219
|
}
|
220
|
}
|
221
|
|
222
|
for(int center=0; center<NUM_CENTERS; center++, index++)
|
223
|
{
|
224
|
CENTERS[index] = computeCenter(center, numL);
|
225
|
}
|
226
|
|
227
|
return CENTERS;
|
228
|
}
|
229
|
|
230
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
231
|
|
232
|
private int getQuat(int cubit, int numCubitsPerCorner, int numCubitsPerEdge)
|
233
|
{
|
234
|
if( mQuatCornerIndices==null || mQuatEdgeIndices==null ) initializeQuatIndices();
|
235
|
if( mQuatCenterIndices==null ) initializeCenterIndices();
|
236
|
|
237
|
if( cubit < NUM_CORNERS*numCubitsPerCorner )
|
238
|
{
|
239
|
int corner = cubit/numCubitsPerCorner;
|
240
|
return mQuatCornerIndices[corner];
|
241
|
}
|
242
|
|
243
|
if( cubit < NUM_CORNERS*numCubitsPerCorner + NUM_EDGES*numCubitsPerEdge )
|
244
|
{
|
245
|
int edge = (cubit-NUM_CORNERS*numCubitsPerCorner)/numCubitsPerEdge;
|
246
|
return mQuatEdgeIndices[edge];
|
247
|
}
|
248
|
|
249
|
int center = cubit - NUM_CORNERS*numCubitsPerCorner - NUM_EDGES*numCubitsPerEdge;
|
250
|
return mQuatCenterIndices[center];
|
251
|
}
|
252
|
|
253
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
254
|
|
255
|
public ObjectShape getObjectShape(int variant)
|
256
|
{
|
257
|
int[] numLayers = getNumLayers();
|
258
|
int numVariants = getNumCubitVariants(numLayers);
|
259
|
int numL = numLayers[0];
|
260
|
|
261
|
if( variant==0 )
|
262
|
{
|
263
|
float width = numL*(0.5f-MEGA_D)/(0.5f*(numL-1));
|
264
|
float A = (2*SQ3/3)*SIN54;
|
265
|
float B = 0.4f;
|
266
|
double X = width*COS18*SIN_HALFD;
|
267
|
double Y = width*SIN18;
|
268
|
double Z = width*COS18*COS_HALFD;
|
269
|
int N = numL==3 ? 1:0;
|
270
|
|
271
|
double[][] vertices = new double[][]
|
272
|
{
|
273
|
{ 0.0, 0.0 , 0.0 },
|
274
|
{ X, Y , -Z },
|
275
|
{ 0.0, 2*Y ,-2*Z },
|
276
|
{ -X, Y , -Z },
|
277
|
{ 0.0, 0.0-width, 0.0 },
|
278
|
{ X, Y-width, -Z },
|
279
|
{ 0.0, 2*Y-width,-2*Z },
|
280
|
{ -X, Y-width, -Z },
|
281
|
};
|
282
|
|
283
|
int[][] vertIndexes = new int[][]
|
284
|
{
|
285
|
{4,5,1,0},
|
286
|
{7,4,0,3},
|
287
|
{0,1,2,3},
|
288
|
{4,5,6,7},
|
289
|
{6,5,1,2},
|
290
|
{7,6,2,3}
|
291
|
};
|
292
|
|
293
|
float[][] bands = new float[][]
|
294
|
{
|
295
|
{0.04f,34,0.3f,0.2f, 3, N, 0},
|
296
|
{0.00f, 0,0.0f,0.0f, 2, N, 0}
|
297
|
};
|
298
|
|
299
|
int[] bandIndices = new int[] { 0,0,0,1,1,1};
|
300
|
float[][] corners = new float[][] { {0.04f,0.10f} };
|
301
|
int[] cornerIndices = new int[] { 0,-1,-1,-1,-1,-1,-1,-1 };
|
302
|
float[][] centers = new float[][] { {0.0f, -(float)Math.sqrt(1-A*A)*B,-A*B} };
|
303
|
int[] centerIndices = new int[] { 0,-1,-1,-1,-1,-1,-1,-1 };
|
304
|
|
305
|
return new ObjectShape(vertices,vertIndexes,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
306
|
}
|
307
|
if( variant<numVariants-1 )
|
308
|
{
|
309
|
int type = variant-1;
|
310
|
float height= numL*(0.5f-MEGA_D)*COS18/((numL-1)*0.5f);
|
311
|
float width = numL*2*MEGA_D + 2*type*height*SIN18/COS18;
|
312
|
|
313
|
double W = width/2;
|
314
|
double X = height*SIN_HALFD;
|
315
|
double Y = height*SIN18/COS18;
|
316
|
double Z = height*COS_HALFD;
|
317
|
|
318
|
double[][] vertices = new double[][]
|
319
|
{
|
320
|
{ 0.0, W , 0.0 },
|
321
|
{ X, W+Y , -Z },
|
322
|
{ 0.0, W+2*Y ,-2*Z },
|
323
|
{ -X, W+Y , -Z },
|
324
|
{ 0.0, -W , 0.0 },
|
325
|
{ X,-W-Y , -Z },
|
326
|
{ 0.0,-W-2*Y ,-2*Z },
|
327
|
{ -X,-W-Y , -Z },
|
328
|
};
|
329
|
|
330
|
int[][] vertIndexes = new int[][]
|
331
|
{
|
332
|
{4,5,1,0},
|
333
|
{7,4,0,3},
|
334
|
{7,6,2,3},
|
335
|
{6,5,1,2},
|
336
|
{0,1,2,3},
|
337
|
{4,5,6,7}
|
338
|
};
|
339
|
|
340
|
int N = numL<=5 ? 5 : 3;
|
341
|
|
342
|
float[][] bands = new float[][]
|
343
|
{
|
344
|
{0.04f,34,0.2f,0.2f,N,0,0},
|
345
|
{0.00f, 0,0.3f,0.2f,2,0,0}
|
346
|
};
|
347
|
int[] bandIndices = new int[] { 0,0,1,1,1,1};
|
348
|
float[][] corners = new float[][] { {0.04f,0.10f} };
|
349
|
int[] cornerIndices = new int[] { -1,-1,-1,-1, -1,-1,-1,-1 };
|
350
|
float[][] centers = new float[][] { {0.0f, 0.0f, (float)(-2*Z)} };
|
351
|
int[] centerIndices = new int[] { -1,-1,-1,-1, -1,-1,-1,-1 };
|
352
|
|
353
|
return new ObjectShape(vertices,vertIndexes,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
354
|
}
|
355
|
else
|
356
|
{
|
357
|
float width = 2*numL*(MEGA_D+(0.5f-MEGA_D)*SIN18);
|
358
|
final double V = 0.83; // ??
|
359
|
final double ANGLE = V*Math.PI;
|
360
|
final double cosA = Math.cos(ANGLE);
|
361
|
final double sinA = Math.sin(ANGLE);
|
362
|
|
363
|
float R = 0.5f*width/COS54;
|
364
|
float X1 = R*COS54;
|
365
|
float Y1 = R*SIN54;
|
366
|
float X2 = R*COS18;
|
367
|
float Y2 = R*SIN18;
|
368
|
|
369
|
double[][] vertices = new double[][]
|
370
|
{
|
371
|
{-X1,+Y1*sinA, Y1*cosA},
|
372
|
{-X2,-Y2*sinA,-Y2*cosA},
|
373
|
{0.0f,-R*sinA, -R*cosA},
|
374
|
{+X2,-Y2*sinA,-Y2*cosA},
|
375
|
{+X1,+Y1*sinA, Y1*cosA}
|
376
|
};
|
377
|
|
378
|
int[][] vertIndexes = new int[][]
|
379
|
{
|
380
|
{0,1,2,3,4},
|
381
|
{0,1,2,3,4}
|
382
|
};
|
383
|
|
384
|
int N = numL==3 ? 4 : 3;
|
385
|
|
386
|
float[][] bands = new float[][]
|
387
|
{
|
388
|
{0.04f,45, R/3,0.2f,N,0,0},
|
389
|
{0.00f, 0, R/3,0.2f,2,0,0}
|
390
|
};
|
391
|
|
392
|
int[] bandIndices = new int[] { 0,1 };
|
393
|
float[][] corners = new float[][] { {0.04f,0.10f} };
|
394
|
int[] cornerIndices = new int[] { -1,-1,-1,-1, -1 };
|
395
|
float[][] centers = new float[][] { {0.0f, 0.0f, 0.0f} };
|
396
|
int[] centerIndices = new int[] { -1,-1,-1,-1, -1 };
|
397
|
|
398
|
return new ObjectShape(vertices,vertIndexes,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
399
|
}
|
400
|
}
|
401
|
|
402
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
403
|
|
404
|
public Static4D getQuat(int cubit, int[] numLayers)
|
405
|
{
|
406
|
if( mQuats==null ) initializeQuats();
|
407
|
|
408
|
int numL = numLayers[0];
|
409
|
int numCubitsPerCorner = numCubitsPerCorner(numL);
|
410
|
int numCubitsPerEdge = numCubitsPerEdge(numL);
|
411
|
|
412
|
return mQuats[getQuat(cubit,numCubitsPerCorner,numCubitsPerEdge)];
|
413
|
}
|
414
|
|
415
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
416
|
|
417
|
public int getNumCubitVariants(int[] numLayers)
|
418
|
{
|
419
|
switch(numLayers[0])
|
420
|
{
|
421
|
case 3: return 3;
|
422
|
case 5: return 4;
|
423
|
}
|
424
|
|
425
|
return 3;
|
426
|
}
|
427
|
|
428
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
429
|
|
430
|
public int getCubitVariant(int cubit, int[] numLayers)
|
431
|
{
|
432
|
int numL = numLayers[0];
|
433
|
int numCubitsPerCorner = numCubitsPerCorner(numL);
|
434
|
|
435
|
if( cubit<NUM_CORNERS*numCubitsPerCorner ) return 0;
|
436
|
|
437
|
int numCubitsPerEdge = numCubitsPerEdge(numL);
|
438
|
|
439
|
if( cubit<NUM_CORNERS*numCubitsPerCorner + NUM_EDGES*numCubitsPerEdge )
|
440
|
{
|
441
|
int type = computeEdgeType(cubit,numCubitsPerCorner,numCubitsPerEdge);
|
442
|
return type+1;
|
443
|
}
|
444
|
|
445
|
return getNumCubitVariants(numLayers)-1;
|
446
|
}
|
447
|
|
448
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
449
|
|
450
|
int getCornerColor(int cubit, int cubitface, int numLayers, int numCubitsPerCorner)
|
451
|
{
|
452
|
if( mCornerFaceMap==null ) initializeCornerFaceMap();
|
453
|
if( cubitface<0 || cubitface>2 ) return -1;
|
454
|
|
455
|
int part = cubit % numCubitsPerCorner;
|
456
|
int corner= cubit / numCubitsPerCorner;
|
457
|
|
458
|
if( part==0 )
|
459
|
{
|
460
|
return mCornerFaceMap[corner][cubitface];
|
461
|
}
|
462
|
else
|
463
|
{
|
464
|
int N = (numCubitsPerCorner-1)/3;
|
465
|
int block = (part-1) % N;
|
466
|
int index = (part-1) / N;
|
467
|
|
468
|
if( block< (numLayers-3)/2 )
|
469
|
{
|
470
|
switch(index)
|
471
|
{
|
472
|
case 0: return cubitface==1 ? -1 : mCornerFaceMap[corner][cubitface];
|
473
|
case 1: return cubitface==0 ? -1 : mCornerFaceMap[corner][cubitface];
|
474
|
case 2: return cubitface==2 ? -1 : mCornerFaceMap[corner][cubitface];
|
475
|
}
|
476
|
}
|
477
|
else
|
478
|
{
|
479
|
switch(index)
|
480
|
{
|
481
|
case 0: return cubitface==0 ? mCornerFaceMap[corner][cubitface] : -1;
|
482
|
case 1: return cubitface==2 ? mCornerFaceMap[corner][cubitface] : -1;
|
483
|
case 2: return cubitface==1 ? mCornerFaceMap[corner][cubitface] : -1;
|
484
|
}
|
485
|
}
|
486
|
}
|
487
|
|
488
|
return NUM_TEXTURES;
|
489
|
}
|
490
|
|
491
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
492
|
|
493
|
int getEdgeColor(int edge, int cubitface, int numCubitsPerEdge)
|
494
|
{
|
495
|
if( cubitface<0 || cubitface>1 ) return -1;
|
496
|
|
497
|
int part = edge % numCubitsPerEdge;
|
498
|
int variant = edge / numCubitsPerEdge;
|
499
|
if( mEdgeMap==null ) initializeEdgeMap();
|
500
|
|
501
|
return (part==0 || cubitface==((part+1)%2)) ? mEdgeMap[variant][cubitface+2] : -1;
|
502
|
}
|
503
|
|
504
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
505
|
|
506
|
int getCenterColor(int center, int cubitface)
|
507
|
{
|
508
|
return cubitface>0 ? -1 : center;
|
509
|
}
|
510
|
|
511
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
512
|
|
513
|
public int getCubitFaceColor(int cubit, int face, int[] numLayers)
|
514
|
{
|
515
|
int numL = numLayers[0];
|
516
|
int numCubitsPerCorner = numCubitsPerCorner(numL);
|
517
|
int numCubitsPerEdge = numCubitsPerEdge(numL);
|
518
|
|
519
|
if( cubit < NUM_CORNERS*numCubitsPerCorner )
|
520
|
{
|
521
|
return getCornerColor(cubit,face,numL,numCubitsPerCorner);
|
522
|
}
|
523
|
else if( cubit<NUM_CORNERS*numCubitsPerCorner + NUM_EDGES*numCubitsPerEdge )
|
524
|
{
|
525
|
int edge = cubit - NUM_CORNERS*numCubitsPerCorner;
|
526
|
return getEdgeColor(edge,face,numCubitsPerEdge);
|
527
|
}
|
528
|
else
|
529
|
{
|
530
|
int center = cubit-NUM_CORNERS*numCubitsPerCorner-NUM_EDGES*numCubitsPerEdge;
|
531
|
return getCenterColor( center, face );
|
532
|
}
|
533
|
}
|
534
|
|
535
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
536
|
|
537
|
public int getVariantFaceColor(int variant, int face, int[] numLayers)
|
538
|
{
|
539
|
if( variant==0 ) return 0;
|
540
|
else
|
541
|
{
|
542
|
if( variant==getNumCubitVariants(numLayers)-1 ) return 1;
|
543
|
else return variant+1;
|
544
|
}
|
545
|
}
|
546
|
|
547
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
548
|
|
549
|
public ObjectSticker retSticker(int sticker)
|
550
|
{
|
551
|
if( mStickers==null )
|
552
|
{
|
553
|
float[][] STICKERS;
|
554
|
int[] numLayers = getNumLayers();
|
555
|
int numL = numLayers[0];
|
556
|
|
557
|
if( numL==3 )
|
558
|
{
|
559
|
STICKERS = new float[][]
|
560
|
{
|
561
|
{ -0.36327127f, -0.5f, 0.36327127f, -0.26393202f, 0.36327127f, 0.5f, -0.36327127f, 0.26393202f },
|
562
|
{ -0.29389262f, 0.4045085f, -0.47552824f, -0.1545085f, 0.0f, -0.5f, 0.47552824f, -0.1545085f, 0.29389262f, 0.4045085f },
|
563
|
{ -0.5f, -0.0914315f, 0.5f, -0.4163512f, 0.5f, 0.4163512f, -0.5f, 0.0914315f }
|
564
|
};
|
565
|
}
|
566
|
else
|
567
|
{
|
568
|
STICKERS = new float[][]
|
569
|
{
|
570
|
{ -0.36327127f, -0.5f, 0.36327127f, -0.26393202f, 0.36327127f, 0.5f, -0.36327127f, 0.26393202f },
|
571
|
{ -0.29389262f, 0.4045085f, -0.47552824f, -0.1545085f, 0.0f, -0.5f, 0.47552824f, -0.1545085f, 0.29389262f, 0.4045085f },
|
572
|
{ -0.49233657f, -0.18006028f, 0.49233657f, -0.5f, 0.49233657f, 0.5f, -0.49233657f, 0.18006028f },
|
573
|
{ -0.3002273f, -0.30490047f, 0.3002273f, -0.5f, 0.3002273f, 0.5f, -0.3002273f, 0.30490047f }
|
574
|
};
|
575
|
}
|
576
|
|
577
|
mStickers = new ObjectSticker[STICKERS.length];
|
578
|
|
579
|
final float R0 = 0.08f;
|
580
|
final float R1 = 0.10f;
|
581
|
final float R2 = 0.12f;
|
582
|
final float R3 = 0.08f;
|
583
|
|
584
|
final float[][] radii = { {R0,R0,R0,R0},{R1,R1,R1,R1,R1},{R2,R2,R2,R2},{R3,R3,R3,R3} };
|
585
|
float[] strokes = { 0.10f,0.065f,0.12f,0.08f };
|
586
|
|
587
|
if( ObjectControl.isInIconMode() )
|
588
|
{
|
589
|
float mult = numL==3 ? 1.5f : 2.2f;
|
590
|
|
591
|
strokes[0]*=mult;
|
592
|
strokes[1]*=mult;
|
593
|
strokes[2]*=mult;
|
594
|
strokes[3]*=mult;
|
595
|
strokes[4]*=mult;
|
596
|
}
|
597
|
|
598
|
for(int s=0; s<STICKERS.length; s++)
|
599
|
{
|
600
|
mStickers[s] = new ObjectSticker(STICKERS[s],null,radii[s],strokes[s]);
|
601
|
}
|
602
|
}
|
603
|
|
604
|
return mStickers[sticker];
|
605
|
}
|
606
|
|
607
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
608
|
|
609
|
public ObjectType intGetObjectType(int[] numLayers)
|
610
|
{
|
611
|
switch(numLayers[0])
|
612
|
{
|
613
|
case 3: return ObjectType.MEGA_3;
|
614
|
case 5: return ObjectType.MEGA_5;
|
615
|
}
|
616
|
return ObjectType.MEGA_3;
|
617
|
}
|
618
|
|
619
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
620
|
|
621
|
public String getObjectName()
|
622
|
{
|
623
|
switch(getNumLayers()[0])
|
624
|
{
|
625
|
case 3: return "Megaminx";
|
626
|
case 5: return "Gigaminx";
|
627
|
}
|
628
|
return "Megaminx";
|
629
|
}
|
630
|
|
631
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
632
|
|
633
|
public String getInventor()
|
634
|
{
|
635
|
switch(getNumLayers()[0])
|
636
|
{
|
637
|
case 3: return "Ferenc Szlivka";
|
638
|
case 5: return "Tyler Fox";
|
639
|
}
|
640
|
return "Ferenc Szlivka";
|
641
|
}
|
642
|
|
643
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
644
|
|
645
|
public int getYearOfInvention()
|
646
|
{
|
647
|
switch(getNumLayers()[0])
|
648
|
{
|
649
|
case 3: return 1982;
|
650
|
case 5: return 2006;
|
651
|
}
|
652
|
return 2006;
|
653
|
}
|
654
|
|
655
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
656
|
|
657
|
public int getComplexity()
|
658
|
{
|
659
|
switch(getNumLayers()[0])
|
660
|
{
|
661
|
case 3: return 7;
|
662
|
case 5: return 9;
|
663
|
}
|
664
|
return 9;
|
665
|
}
|
666
|
}
|