1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2023 Leszek Koltunski //
|
3
|
// //
|
4
|
// This file is part of Magic Cube. //
|
5
|
// //
|
6
|
// Magic Cube is proprietary software licensed under an EULA which you should have received //
|
7
|
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html //
|
8
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
9
|
|
10
|
package org.distorted.objectlib.objects;
|
11
|
|
12
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_HEXAHEDRON;
|
13
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_SPLIT_EDGE_COIN;
|
14
|
|
15
|
import org.distorted.library.helpers.QuatHelper;
|
16
|
import org.distorted.library.type.Static3D;
|
17
|
import org.distorted.library.type.Static4D;
|
18
|
import org.distorted.objectlib.helpers.FactoryCubit;
|
19
|
import org.distorted.objectlib.helpers.ObjectFaceShape;
|
20
|
import org.distorted.objectlib.helpers.ObjectShape;
|
21
|
import org.distorted.objectlib.helpers.ObjectSignature;
|
22
|
import org.distorted.objectlib.helpers.ObjectVertexEffects;
|
23
|
import org.distorted.objectlib.main.InitAssets;
|
24
|
import org.distorted.objectlib.main.InitData;
|
25
|
import org.distorted.objectlib.main.ObjectSignatures;
|
26
|
import org.distorted.objectlib.main.ObjectType;
|
27
|
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator;
|
28
|
import org.distorted.objectlib.shape.ShapeHexahedron;
|
29
|
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
|
30
|
|
31
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
32
|
|
33
|
public class TwistyCoinHexahedron extends ShapeHexahedron
|
34
|
{
|
35
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
36
|
{
|
37
|
new Static3D( SQ3/3, SQ3/3, SQ3/3),
|
38
|
new Static3D( SQ3/3, SQ3/3,-SQ3/3),
|
39
|
new Static3D( SQ3/3,-SQ3/3, SQ3/3),
|
40
|
new Static3D( SQ3/3,-SQ3/3,-SQ3/3),
|
41
|
new Static3D( 1, 0, 0),
|
42
|
new Static3D( 0, 1, 0),
|
43
|
new Static3D( 0, 0, 1),
|
44
|
};
|
45
|
|
46
|
private static final int N = 5;
|
47
|
private static final float C = 0.2f;
|
48
|
private static final float D = 0.85f;
|
49
|
|
50
|
private int[][] mEdges;
|
51
|
private int[][] mBasicAngle;
|
52
|
private float[][] mCuts;
|
53
|
private float[][] mPosition;
|
54
|
private int[] mQuatIndex;
|
55
|
private boolean[][] mRotatable;
|
56
|
|
57
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
58
|
|
59
|
public TwistyCoinHexahedron(int meshState, int iconMode, Static4D quat, Static3D move, float scale, InitData data, InitAssets asset)
|
60
|
{
|
61
|
super(meshState, iconMode, data.getNumLayers()[0], quat, move, scale, data, asset);
|
62
|
}
|
63
|
|
64
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
65
|
|
66
|
public int[][] getScrambleEdges()
|
67
|
{
|
68
|
if( mEdges==null )
|
69
|
{
|
70
|
mEdges = new int[][]
|
71
|
{
|
72
|
{0,1,1,1, 2,2,3,2, 4,3,5,3, 6,4,7,4, 8,5,9,5, 10,6,11,6, 12,7,13,7, 14,8,15,8},
|
73
|
{16, 9,17, 9,18, 9, 22,11,23,11,24,11, 28,13,29,13,30,13},
|
74
|
{19,10,20,10,21,10, 25,12,26,12,27,12, 31,14,32,14,33,14},
|
75
|
{16, 9,17, 9,18, 9, 22,11,23,11,24,11, 31,14,32,14,33,14},
|
76
|
{19,10,20,10,21,10, 25,12,26,12,27,12, 28,13,29,13,30,13},
|
77
|
{16, 9,17, 9,18, 9, 25,12,26,12,27,12, 28,13,29,13,30,13},
|
78
|
{19,10,20,10,21,10, 22,11,23,11,24,11, 31,14,32,14,33,14},
|
79
|
{16, 9,17, 9,18, 9, 25,12,26,12,27,12, 31,14,32,14,33,14},
|
80
|
{19,10,20,10,21,10, 22,11,23,11,24,11, 28,13,29,13,30,13},
|
81
|
{ 0, 1, 1, 1, 4, 3, 5, 3, 8, 5, 9, 5, 12, 7,13, 7},
|
82
|
{ 2, 2, 3, 2, 6, 4, 7, 4, 10, 6,11, 6, 14, 8,15, 8},
|
83
|
{ 0, 1, 1, 1, 4, 3, 5, 3, 10, 6,11, 6, 14, 8,15, 8},
|
84
|
{ 2, 2, 3, 2, 6, 4, 7, 4, 8, 5, 9, 5, 12, 7,13, 7},
|
85
|
{ 0, 1, 1, 1, 6, 4, 7, 4, 8, 5, 9, 5, 14, 8,15, 8},
|
86
|
{ 2, 2, 3, 2, 4, 3, 5, 3, 10, 6,11, 6, 12, 7,13, 7}
|
87
|
};
|
88
|
}
|
89
|
|
90
|
return mEdges;
|
91
|
}
|
92
|
|
93
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
94
|
|
95
|
@Override
|
96
|
public int[][] getScrambleAlgorithms()
|
97
|
{
|
98
|
setUpRotatable();
|
99
|
return ScrambleEdgeGenerator.getScramblingAlgorithms(mBasicAngle, mRotatable);
|
100
|
}
|
101
|
|
102
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
103
|
|
104
|
@Override
|
105
|
public float[][] returnRotationFactor()
|
106
|
{
|
107
|
float C1 = 2.5f;
|
108
|
float C2 = 1.0f;
|
109
|
float[] f1 = new float[] { C1,C1,C1 };
|
110
|
float[] f2 = new float[] { C2,C2,C2 };
|
111
|
|
112
|
return new float[][] { f1,f1,f1,f1, f2,f2,f2 };
|
113
|
}
|
114
|
|
115
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
116
|
|
117
|
public float[][] getCuts(int[] numLayers)
|
118
|
{
|
119
|
if( mCuts==null )
|
120
|
{
|
121
|
float C1 = 0.75f*SQ3;
|
122
|
float C2 = 1.49f;
|
123
|
float[] cut1 = new float[] { -C1,C1 };
|
124
|
float[] cut2 = new float[] { -C2,C2 };
|
125
|
mCuts = new float[][] { cut1,cut1,cut1,cut1,cut2,cut2,cut2 };
|
126
|
}
|
127
|
|
128
|
return mCuts;
|
129
|
}
|
130
|
|
131
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
132
|
|
133
|
private void setUpRotatable()
|
134
|
{
|
135
|
if( mRotatable==null )
|
136
|
{
|
137
|
boolean[] tmp = new boolean[] {true,false,true};
|
138
|
mRotatable = new boolean[][] { tmp,tmp,tmp,tmp,tmp,tmp,tmp };
|
139
|
}
|
140
|
}
|
141
|
|
142
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
143
|
|
144
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
145
|
{
|
146
|
setUpRotatable();
|
147
|
return mRotatable;
|
148
|
}
|
149
|
|
150
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
151
|
|
152
|
public int getTouchControlType()
|
153
|
{
|
154
|
return TC_HEXAHEDRON;
|
155
|
}
|
156
|
|
157
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
158
|
|
159
|
public int getTouchControlSplit()
|
160
|
{
|
161
|
return TYPE_SPLIT_EDGE_COIN;
|
162
|
}
|
163
|
|
164
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
165
|
|
166
|
public int[][][] getEnabled()
|
167
|
{
|
168
|
return new int[][][]
|
169
|
{
|
170
|
{{4},{4},{4},{4},{1},{3},{2},{0}},
|
171
|
{{4},{4},{4},{4},{3},{1},{0},{2}},
|
172
|
{{5},{5},{5},{5},{1},{0},{3},{2}},
|
173
|
{{5},{5},{5},{5},{2},{3},{0},{1}},
|
174
|
{{6},{6},{6},{6},{0},{2},{1},{3}},
|
175
|
{{6},{6},{6},{6},{2},{0},{3},{1}},
|
176
|
};
|
177
|
}
|
178
|
|
179
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
180
|
|
181
|
public float[] getDist3D(int[] numLayers)
|
182
|
{
|
183
|
return TouchControlHexahedron.D3D;
|
184
|
}
|
185
|
|
186
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
187
|
|
188
|
public Static3D[] getFaceAxis()
|
189
|
{
|
190
|
return TouchControlHexahedron.FACE_AXIS;
|
191
|
}
|
192
|
|
193
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
194
|
|
195
|
public float[][] getCubitPositions(int[] numLayers)
|
196
|
{
|
197
|
if( mPosition==null )
|
198
|
{
|
199
|
final float A = 1.48f-C;
|
200
|
final float B = 1.52f;
|
201
|
final float Z = 1.50f;
|
202
|
final float E = 0.75f*D;
|
203
|
|
204
|
mPosition = new float[][]
|
205
|
{
|
206
|
{ A, A, A},
|
207
|
{ A, A,-A},
|
208
|
{ A,-A, A},
|
209
|
{ A,-A,-A},
|
210
|
{-A, A, A},
|
211
|
{-A, A,-A},
|
212
|
{-A,-A, A},
|
213
|
{-A,-A,-A},
|
214
|
|
215
|
{ 0, 0, B },
|
216
|
{ 0, 0,-B },
|
217
|
{ 0, B, 0 },
|
218
|
{ 0,-B, 0 },
|
219
|
{ B, 0, 0 },
|
220
|
{-B, 0, 0 },
|
221
|
|
222
|
{ E, E, Z},
|
223
|
{ E,-E, Z},
|
224
|
{-E, E, Z},
|
225
|
{-E,-E, Z},
|
226
|
{ E, E,-Z},
|
227
|
{ E,-E,-Z},
|
228
|
{-E, E,-Z},
|
229
|
{-E,-E,-Z},
|
230
|
{ E, Z, E},
|
231
|
{ E, Z,-E},
|
232
|
{-E, Z, E},
|
233
|
{-E, Z,-E},
|
234
|
{ E,-Z, E},
|
235
|
{ E,-Z,-E},
|
236
|
{-E,-Z, E},
|
237
|
{-E,-Z,-E},
|
238
|
{ Z, E, E},
|
239
|
{ Z, E,-E},
|
240
|
{ Z,-E, E},
|
241
|
{ Z,-E,-E},
|
242
|
{-Z, E, E},
|
243
|
{-Z, E,-E},
|
244
|
{-Z,-E, E},
|
245
|
{-Z,-E,-E},
|
246
|
};
|
247
|
}
|
248
|
|
249
|
return mPosition;
|
250
|
}
|
251
|
|
252
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
253
|
|
254
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
255
|
{
|
256
|
if( mQuatIndex==null ) mQuatIndex = new int[] {0,9,11,4,12,3,6,21,
|
257
|
0,10,1,4,2,3,
|
258
|
0,15,17,16,19,10,13,23,1,9,20,7, 11,4,6,21,2,14,18,5,12,3,8,22 };
|
259
|
return mObjectQuats[mQuatIndex[cubit]];
|
260
|
}
|
261
|
|
262
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
263
|
|
264
|
private float[] rotateVertices(float angle, float[] vector, float[] center, float[] rotAxis)
|
265
|
{
|
266
|
float[] ret = new float[4];
|
267
|
float sin = (float)Math.sin(angle/2);
|
268
|
float cos = (float)Math.cos(angle/2);
|
269
|
float[] quat= new float[] { sin*rotAxis[0], sin*rotAxis[1], sin*rotAxis[2], cos};
|
270
|
QuatHelper.rotateVectorByQuat(ret,vector,quat);
|
271
|
|
272
|
ret[0] += center[0];
|
273
|
ret[1] += center[1];
|
274
|
ret[2] += center[2];
|
275
|
|
276
|
return ret;
|
277
|
}
|
278
|
|
279
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
280
|
|
281
|
private float[][] produceCorner()
|
282
|
{
|
283
|
final float angle = (float)Math.PI/(2*N);
|
284
|
final float A = 0.3f;
|
285
|
final int N1 = 4;
|
286
|
final int N2 = N1 + N + 1;
|
287
|
final int N3 = N2 + N + 1;
|
288
|
float[][] vertices= new float[3*N+8][3];
|
289
|
|
290
|
vertices[3*N+7][0] = -A;
|
291
|
vertices[3*N+7][1] = -A;
|
292
|
vertices[3*N+7][2] = -A;
|
293
|
|
294
|
vertices[0][0] = 0;
|
295
|
vertices[0][1] = 0;
|
296
|
vertices[0][2] = 0;
|
297
|
vertices[1][0] =-2;
|
298
|
vertices[1][1] = 0;
|
299
|
vertices[1][2] = 0;
|
300
|
vertices[2][0] = 0;
|
301
|
vertices[2][1] =-2;
|
302
|
vertices[2][2] = 0;
|
303
|
vertices[3][0] = 0;
|
304
|
vertices[3][1] = 0;
|
305
|
vertices[3][2] =-2;
|
306
|
|
307
|
for(int i=0; i<=N; i++)
|
308
|
{
|
309
|
float cos1 = (float)Math.cos((N-i)*angle);
|
310
|
float sin1 = (float)Math.sin((N-i)*angle);
|
311
|
float cos2 = (float)Math.cos(( i)*angle);
|
312
|
float sin2 = (float)Math.sin(( i)*angle);
|
313
|
|
314
|
vertices[N1+i][0] = 2*D*cos1-2;
|
315
|
vertices[N1+i][1] = 2*D*sin1-2;
|
316
|
vertices[N1+i][2] = 0;
|
317
|
|
318
|
vertices[N2+i][0] = 0;
|
319
|
vertices[N2+i][1] = 2*D*sin2-2;
|
320
|
vertices[N2+i][2] = 2*D*cos2-2;
|
321
|
|
322
|
vertices[N3+i][0] = 2*D*cos2-2;
|
323
|
vertices[N3+i][1] = 0;
|
324
|
vertices[N3+i][2] = 2*D*sin2-2;
|
325
|
}
|
326
|
|
327
|
for(int i=0; i<3*N+8; i++)
|
328
|
{
|
329
|
vertices[i][0] = 0.75f*vertices[i][0] + C;
|
330
|
vertices[i][1] = 0.75f*vertices[i][1] + C;
|
331
|
vertices[i][2] = 0.75f*vertices[i][2] + C;
|
332
|
}
|
333
|
|
334
|
return vertices;
|
335
|
}
|
336
|
|
337
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
338
|
|
339
|
private float[][] produceCenter()
|
340
|
{
|
341
|
float[][] ret = new float[4*N+1][];
|
342
|
|
343
|
float[] rot = new float[] { 0,0,-1 };
|
344
|
|
345
|
float[] center1 = { 1.5f*D, 1.5f*D, 0 };
|
346
|
float[] center2 = { 1.5f*D,-1.5f*D, 0 };
|
347
|
float[] center3 = {-1.5f*D,-1.5f*D, 0 };
|
348
|
float[] center4 = {-1.5f*D, 1.5f*D, 0 };
|
349
|
|
350
|
float[] vect1 = { -1.5f*D,0,0,0 };
|
351
|
float[] vect2 = { 0, 1.5f*D,0,0 };
|
352
|
float[] vect3 = { 1.5f*D,0,0,0 };
|
353
|
float[] vect4 = { 0,-1.5f*D,0,0 };
|
354
|
|
355
|
for(int i=0; i<N; i++)
|
356
|
{
|
357
|
float angle = (float)(Math.PI/2)*i/N;
|
358
|
|
359
|
ret[i ] = rotateVertices(angle, vect1, center1, rot);
|
360
|
ret[i+ N] = rotateVertices(angle, vect2, center2, rot);
|
361
|
ret[i+2*N] = rotateVertices(angle, vect3, center3, rot);
|
362
|
ret[i+3*N] = rotateVertices(angle, vect4, center4, rot);
|
363
|
}
|
364
|
|
365
|
ret[4*N] = new float[] { 0, 0, -1.5f };
|
366
|
|
367
|
return ret;
|
368
|
}
|
369
|
|
370
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
371
|
|
372
|
private float[][] produceLeaf()
|
373
|
{
|
374
|
float[][] ret = new float[2*N+1][];
|
375
|
|
376
|
float[] rot = new float[] { 0,0,1 };
|
377
|
|
378
|
float[] center1 = {-0.75f*D,-0.75f*D, 0 };
|
379
|
float[] center2 = { 0.75f*D, 0.75f*D, 0 };
|
380
|
|
381
|
float[] vect1 = { 0, 1.5f*D, 0, 0 };
|
382
|
float[] vect2 = { 0,-1.5f*D, 0, 0 };
|
383
|
|
384
|
for(int i=0; i<N; i++)
|
385
|
{
|
386
|
float angle = (float)(Math.PI/2)*i/N;
|
387
|
|
388
|
ret[ N-1-i] = rotateVertices(angle, vect1, center1, rot);
|
389
|
ret[2*N-1-i] = rotateVertices(angle, vect2, center2, rot);
|
390
|
}
|
391
|
|
392
|
ret[2*N] = new float[] { 0, 0, -1.5f/10 };
|
393
|
|
394
|
return ret;
|
395
|
}
|
396
|
|
397
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
398
|
|
399
|
private float[][] getVertices(int variant)
|
400
|
{
|
401
|
if( variant==0 ) return produceCorner();
|
402
|
else if( variant==1 ) return produceCenter();
|
403
|
else return produceLeaf();
|
404
|
}
|
405
|
|
406
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
407
|
|
408
|
private int[][] produceCornerShape()
|
409
|
{
|
410
|
int[][] indices = new int[3*N+9][];
|
411
|
|
412
|
indices[0] = new int[N+4];
|
413
|
indices[1] = new int[N+4];
|
414
|
indices[2] = new int[N+4];
|
415
|
|
416
|
indices[0][0] = 2;
|
417
|
indices[0][1] = 0;
|
418
|
indices[0][2] = 1;
|
419
|
indices[1][0] = 3;
|
420
|
indices[1][1] = 0;
|
421
|
indices[1][2] = 2;
|
422
|
indices[2][0] = 1;
|
423
|
indices[2][1] = 0;
|
424
|
indices[2][2] = 3;
|
425
|
|
426
|
int N1 = 4;
|
427
|
int N2 = N1 + N + 1;
|
428
|
int N3 = N2 + N + 1;
|
429
|
|
430
|
for(int i=0; i<=N; i++)
|
431
|
{
|
432
|
indices[0][i+3] = N1 + i;
|
433
|
indices[1][i+3] = N2 + i;
|
434
|
indices[2][i+3] = N3 + i;
|
435
|
}
|
436
|
|
437
|
for(int i=0; i<N; i++)
|
438
|
{
|
439
|
indices[3*i+3] = new int[] { N1+i+1, N1+i, 3*N+7 };
|
440
|
indices[3*i+4] = new int[] { N2+i+1, N2+i, 3*N+7 };
|
441
|
indices[3*i+5] = new int[] { N3+i+1, N3+i, 3*N+7 };
|
442
|
}
|
443
|
|
444
|
indices[3*N+3] = new int[] { 2 , 4+ N, 3*N+7 };
|
445
|
indices[3*N+4] = new int[] { 5 +N, 2 , 3*N+7 };
|
446
|
indices[3*N+5] = new int[] { 5+2*N, 3 , 3*N+7 };
|
447
|
indices[3*N+6] = new int[] { 3 , 6+2*N, 3*N+7 };
|
448
|
indices[3*N+7] = new int[] { 1 , 6+3*N, 3*N+7 };
|
449
|
indices[3*N+8] = new int[] { 4 , 1 , 3*N+7 };
|
450
|
|
451
|
return indices;
|
452
|
}
|
453
|
|
454
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
455
|
|
456
|
private int[][] produceCenterShape()
|
457
|
{
|
458
|
int[][] ret = new int[1+4*N][];
|
459
|
|
460
|
ret[0] = new int[4*N];
|
461
|
for(int i=0; i<4*N; i++) ret[0][i] = 4*N-1-i;
|
462
|
|
463
|
for(int i=0; i<N; i++)
|
464
|
{
|
465
|
ret[i+1] = new int[3];
|
466
|
ret[i+1][0] = i;
|
467
|
ret[i+1][1] = i+1;
|
468
|
ret[i+1][2] = 4*N;
|
469
|
|
470
|
ret[N+i+1] = new int[3];
|
471
|
ret[N+i+1][0] = N+i;
|
472
|
ret[N+i+1][1] = N+i+1;
|
473
|
ret[N+i+1][2] = 4*N;
|
474
|
|
475
|
ret[2*N+i+1] = new int[3];
|
476
|
ret[2*N+i+1][0] = 2*N+i;
|
477
|
ret[2*N+i+1][1] = 2*N+i+1;
|
478
|
ret[2*N+i+1][2] = 4*N;
|
479
|
|
480
|
ret[3*N+i+1] = new int[3];
|
481
|
ret[3*N+i+1][0] = 3*N+i;
|
482
|
ret[3*N+i+1][1] = i<N-1 ? 3*N+i+1 : 0;
|
483
|
ret[3*N+i+1][2] = 4*N;
|
484
|
}
|
485
|
|
486
|
return ret;
|
487
|
}
|
488
|
|
489
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
490
|
|
491
|
private int[][] produceLeafShape()
|
492
|
{
|
493
|
int[][] ret = new int[2*N+1][];
|
494
|
|
495
|
ret[0] = new int[2*N];
|
496
|
for(int i=0; i<2*N; i++) ret[0][i] = i;
|
497
|
|
498
|
for(int i=1; i<=N-1; i++)
|
499
|
{
|
500
|
ret[i] = new int[3];
|
501
|
ret[i][0] = i;
|
502
|
ret[i][1] = i-1;
|
503
|
ret[i][2] = 2*N;
|
504
|
|
505
|
ret[N-1+i] = new int[3];
|
506
|
ret[N-1+i][0] = N+i;
|
507
|
ret[N-1+i][1] = N+i-1;
|
508
|
ret[N-1+i][2] = 2*N;
|
509
|
}
|
510
|
|
511
|
ret[2*N-1] = new int[] { N, N-1, 2*N };
|
512
|
ret[2*N ] = new int[] { 0,2*N-1, 2*N };
|
513
|
|
514
|
return ret;
|
515
|
}
|
516
|
|
517
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
518
|
|
519
|
public ObjectShape getObjectShape(int variant)
|
520
|
{
|
521
|
if( variant==0 )
|
522
|
{
|
523
|
int[][] indices = produceCornerShape();
|
524
|
return new ObjectShape(getVertices(variant), indices);
|
525
|
}
|
526
|
else if( variant==1 )
|
527
|
{
|
528
|
int[][] indices = produceCenterShape();
|
529
|
return new ObjectShape(getVertices(variant), indices);
|
530
|
}
|
531
|
else
|
532
|
{
|
533
|
int[][] indices = produceLeafShape();
|
534
|
return new ObjectShape(getVertices(variant), indices);
|
535
|
}
|
536
|
}
|
537
|
|
538
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
539
|
|
540
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
541
|
{
|
542
|
if( variant==0 )
|
543
|
{
|
544
|
float h1 = isInIconMode() ? 0.0001f : 0.03f;
|
545
|
float h2 = isInIconMode() ? 0.0001f : 0.01f;
|
546
|
float[][] bands = { {h1,35,0.2f,0.4f,5,2,1}, {h2,35,0.2f,0.4f,2,0,0} };
|
547
|
int num = 3*N+9;
|
548
|
int[] indices = new int[num];
|
549
|
for(int i=3; i<num; i++) indices[i] = 1;
|
550
|
float S = 1-SQ2/2 - C;
|
551
|
float[] convexCenter = {-S,-S,-S };
|
552
|
return new ObjectFaceShape(bands,indices,convexCenter);
|
553
|
}
|
554
|
else if( variant==1 )
|
555
|
{
|
556
|
float h1 = isInIconMode() ? 0.0001f : 0.001f;
|
557
|
float h2 = 0.0001f;
|
558
|
float[][] bands = { {h1,5,0.2f,0.4f,5,0,0}, {h2,5,0.05f,0.1f,2,0,0} };
|
559
|
int num = 1+4*N;
|
560
|
int[] indices = new int[num];
|
561
|
for(int i=1; i<num; i++) indices[i] = 1;
|
562
|
return new ObjectFaceShape(bands,indices,null);
|
563
|
}
|
564
|
else
|
565
|
{
|
566
|
float h1 = isInIconMode() ? 0.0001f : 0.015f;
|
567
|
float h2 = isInIconMode() ? 0.0001f : 0.001f;
|
568
|
float[][] bands = { {h1,25,0.250f,0.7f,5,0,0}, {h2,25,0.125f,0.2f,2,0,0} };
|
569
|
int num = 1+2*N;
|
570
|
int[] indices = new int[num];
|
571
|
for(int i=1; i<num; i++) indices[i] = 1;
|
572
|
return new ObjectFaceShape(bands,indices,null);
|
573
|
}
|
574
|
}
|
575
|
|
576
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
577
|
|
578
|
public ObjectVertexEffects getVertexEffects(int variant)
|
579
|
{
|
580
|
if( variant==0 )
|
581
|
{
|
582
|
float[][] corners = { {0.05f,0.15f} };
|
583
|
int num = 8+3*N;
|
584
|
int[] indices = new int[num];
|
585
|
for(int i=1; i<num; i++) indices[i] = -1;
|
586
|
float[][] centers = {{ 0,0,0 }};
|
587
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
|
588
|
}
|
589
|
else if( variant==1 )
|
590
|
{
|
591
|
float[][] corners = { {0.05f,0.20f} };
|
592
|
int num = 1+4*N;
|
593
|
int[] indices = new int[num];
|
594
|
for(int i=0; i<num; i++) indices[i] = -1;
|
595
|
float[][] centers = { { 0,0,0 } };
|
596
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
|
597
|
}
|
598
|
else
|
599
|
{
|
600
|
float[][] corners = { {0.05f,0.20f} };
|
601
|
int num = 1+2*N;
|
602
|
int[] indices = new int[num];
|
603
|
for(int i=0; i<num; i++) indices[i] = -1;
|
604
|
float[][] centers = { { 0,0,0 } };
|
605
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
|
606
|
}
|
607
|
}
|
608
|
|
609
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
610
|
|
611
|
public int getNumCubitVariants(int[] numLayers)
|
612
|
{
|
613
|
return 3;
|
614
|
}
|
615
|
|
616
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
617
|
|
618
|
public int getCubitVariant(int cubit, int[] numLayers)
|
619
|
{
|
620
|
return cubit<8 ? 0 : (cubit<14 ? 1:2);
|
621
|
}
|
622
|
|
623
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
624
|
|
625
|
public float getStickerRadius()
|
626
|
{
|
627
|
return 0.12f;
|
628
|
}
|
629
|
|
630
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
631
|
|
632
|
public float getStickerStroke()
|
633
|
{
|
634
|
return isInIconMode() ? 0.23f : 0.12f;
|
635
|
}
|
636
|
|
637
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
638
|
// ditto, manually provide the sticker coordinates.
|
639
|
|
640
|
@Override
|
641
|
public void adjustStickerCoords()
|
642
|
{
|
643
|
float A = 0.38f;
|
644
|
float B = 0.24f;
|
645
|
float C = 0.50f;
|
646
|
float D = 0.00f;
|
647
|
|
648
|
mStickerCoords = new float[][][]
|
649
|
{
|
650
|
{ { A,-C}, { A, A}, {-C, A}, {-C, B}, {B,-C} },
|
651
|
{ { C, D}, { D, C}, {-C, D}, { D,-C} },
|
652
|
{ { C,-C}, {-C, C} }
|
653
|
};
|
654
|
}
|
655
|
|
656
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
657
|
|
658
|
public float[][] getStickerAngles()
|
659
|
{
|
660
|
float D = (float)(Math.PI/4);
|
661
|
return new float[][] { { 0,0,0,-D,0 },{-D,-D,-D,-D},{D,D} };
|
662
|
}
|
663
|
|
664
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
665
|
// PUBLIC API
|
666
|
|
667
|
public Static3D[] getRotationAxis()
|
668
|
{
|
669
|
return ROT_AXIS;
|
670
|
}
|
671
|
|
672
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
673
|
|
674
|
public int[][] getBasicAngles()
|
675
|
{
|
676
|
if( mBasicAngle ==null )
|
677
|
{
|
678
|
int[] tmp1 = {3,3,3};
|
679
|
int[] tmp2 = {4,4,4};
|
680
|
mBasicAngle = new int[][] { tmp1,tmp1,tmp1,tmp1,tmp2,tmp2,tmp2 };
|
681
|
}
|
682
|
|
683
|
return mBasicAngle;
|
684
|
}
|
685
|
|
686
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
687
|
|
688
|
public String getShortName()
|
689
|
{
|
690
|
return ObjectType.COIH_3.name();
|
691
|
}
|
692
|
|
693
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
694
|
|
695
|
public ObjectSignature getSignature()
|
696
|
{
|
697
|
return new ObjectSignature(ObjectSignatures.COIH_3);
|
698
|
}
|
699
|
|
700
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
701
|
|
702
|
public String getObjectName()
|
703
|
{
|
704
|
return "Ancient Coin Cube";
|
705
|
}
|
706
|
|
707
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
708
|
|
709
|
public String getInventor()
|
710
|
{
|
711
|
return "Yukang Wu";
|
712
|
}
|
713
|
|
714
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
715
|
|
716
|
public int getYearOfInvention()
|
717
|
{
|
718
|
return 2018;
|
719
|
}
|
720
|
|
721
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
722
|
|
723
|
public int getComplexity()
|
724
|
{
|
725
|
return 0;
|
726
|
}
|
727
|
|
728
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
729
|
|
730
|
public String[][] getTutorials()
|
731
|
{
|
732
|
return new String[][] {
|
733
|
{"gb","8hPxLbZDSLQ","Chinese Coin Cube","CanChrisSolve"},
|
734
|
{"es","rK0_IsjoZqM","Ancient Coin Cube","R de Rubik"},
|
735
|
{"ru","HVZj2vBxD5A","Как собрать Коин Куб","Алексей Ярыгин"},
|
736
|
{"pl","yaNeIw4C5Uk","Ancient coin cube TUTORIAL PL","MrUK"},
|
737
|
};
|
738
|
}
|
739
|
}
|