1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2022 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 java.io.InputStream;
|
23
|
|
24
|
import org.distorted.library.type.Static3D;
|
25
|
import org.distorted.library.type.Static4D;
|
26
|
import org.distorted.objectlib.helpers.ObjectFaceShape;
|
27
|
import org.distorted.objectlib.helpers.ObjectShape;
|
28
|
import org.distorted.objectlib.helpers.ObjectSignature;
|
29
|
import org.distorted.objectlib.main.Cubit;
|
30
|
import org.distorted.objectlib.main.InitData;
|
31
|
import org.distorted.objectlib.main.ObjectType;
|
32
|
import org.distorted.objectlib.main.ShapeHexahedron;
|
33
|
import org.distorted.objectlib.scrambling.ScrambleState;
|
34
|
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
|
35
|
|
36
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_HEXAHEDRON;
|
37
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
|
38
|
|
39
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
40
|
|
41
|
public class TwistyCrazy2x2 extends ShapeHexahedron
|
42
|
{
|
43
|
public static final int CIRCLE = 0x29;
|
44
|
|
45
|
private static final float DIAMETER_RATIO = 0.60f;
|
46
|
private static final int NUMBER_CORNER_SEGMENTS = 4;
|
47
|
|
48
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
49
|
{
|
50
|
new Static3D(1,0,0),
|
51
|
new Static3D(0,1,0),
|
52
|
new Static3D(0,0,1)
|
53
|
};
|
54
|
|
55
|
private ScrambleState[] mStates;
|
56
|
private int[][] mBasicAngle;
|
57
|
private float[][] mCuts;
|
58
|
private float[][] mPositions;
|
59
|
private int[] mQuatIndex;
|
60
|
private float[][] mOffsets;
|
61
|
|
62
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
63
|
|
64
|
public TwistyCrazy2x2(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
|
65
|
{
|
66
|
super(data, meshState, iconMode, data.getNumLayers()[0], quat, move, scale, stream);
|
67
|
}
|
68
|
|
69
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
70
|
|
71
|
@Override
|
72
|
public void adjustStickerCoords()
|
73
|
{
|
74
|
final float A = 0.50000f;
|
75
|
final float B = 0.45424f;
|
76
|
final float C = 0.11830f;
|
77
|
final float D = 0.01000f;
|
78
|
|
79
|
mStickerCoords = new float[][]
|
80
|
{
|
81
|
{ B, A,-A, A,-A,-B,-C,-B, B, C },
|
82
|
{ -A, A,-A,-A, A,-A },
|
83
|
{ -D,-D, D,-D, D, D }
|
84
|
};
|
85
|
}
|
86
|
|
87
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
88
|
|
89
|
@Override
|
90
|
public int getCubitRotationType(int cubit)
|
91
|
{
|
92
|
return cubit<8 ? Cubit.TYPE_NORMAL : ( cubit<32 ? Cubit.TYPE_FOLLOWER : Cubit.TYPE_DECIDER );
|
93
|
}
|
94
|
|
95
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
96
|
|
97
|
@Override
|
98
|
public float[] getCubitRowOffset(int cubitIndex)
|
99
|
{
|
100
|
if( mOffsets==null )
|
101
|
{
|
102
|
float[] tmp = new float[] {0,0,0};
|
103
|
int numCubits = mPositions.length;
|
104
|
mOffsets = new float[numCubits][];
|
105
|
|
106
|
for(int i=0; i<numCubits; i++)
|
107
|
{
|
108
|
switch(i)
|
109
|
{
|
110
|
case 32: mOffsets[i] = new float[] {1,0,0}; break;
|
111
|
case 33: mOffsets[i] = new float[] {0,1,0}; break;
|
112
|
case 34: mOffsets[i] = new float[] {0,0,-1};break;
|
113
|
default: mOffsets[i] = tmp;
|
114
|
}
|
115
|
}
|
116
|
}
|
117
|
|
118
|
return mOffsets[cubitIndex];
|
119
|
}
|
120
|
|
121
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
122
|
// Normal 2x2
|
123
|
|
124
|
public ScrambleState[] getScrambleStates()
|
125
|
{
|
126
|
if( mStates==null )
|
127
|
{
|
128
|
int[] m = new int[] { 0,-1,0,0,1,0,0,2,0, 1,-1,0,1,1,0,1,2,0 };
|
129
|
|
130
|
mStates = new ScrambleState[]
|
131
|
{
|
132
|
new ScrambleState( new int[][] { m,m,m } )
|
133
|
};
|
134
|
}
|
135
|
|
136
|
return mStates;
|
137
|
}
|
138
|
|
139
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
140
|
|
141
|
public float[][] getCuts(int[] numLayers)
|
142
|
{
|
143
|
if( mCuts==null )
|
144
|
{
|
145
|
float[] cut = new float[] {0};
|
146
|
mCuts = new float[][] { cut,cut,cut };
|
147
|
}
|
148
|
|
149
|
return mCuts;
|
150
|
}
|
151
|
|
152
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
153
|
|
154
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
155
|
{
|
156
|
boolean[] tmp = new boolean[] {true,true};
|
157
|
return new boolean[][] { tmp,tmp,tmp };
|
158
|
}
|
159
|
|
160
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
161
|
|
162
|
public int getTouchControlType()
|
163
|
{
|
164
|
return TC_HEXAHEDRON;
|
165
|
}
|
166
|
|
167
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
168
|
|
169
|
public int getTouchControlSplit()
|
170
|
{
|
171
|
return TYPE_NOT_SPLIT;
|
172
|
}
|
173
|
|
174
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
175
|
|
176
|
public int[][][] getEnabled()
|
177
|
{
|
178
|
return new int[][][] { {{1,2}},{{1,2}},{{0,2}},{{0,2}},{{0,1}},{{0,1}} };
|
179
|
}
|
180
|
|
181
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
182
|
|
183
|
public float[] getDist3D(int[] numLayers)
|
184
|
{
|
185
|
return TouchControlHexahedron.D3D;
|
186
|
}
|
187
|
|
188
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
189
|
|
190
|
public Static3D[] getFaceAxis()
|
191
|
{
|
192
|
return TouchControlHexahedron.FACE_AXIS;
|
193
|
}
|
194
|
|
195
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
196
|
|
197
|
public float[][] getCubitPositions(int[] numLayers)
|
198
|
{
|
199
|
if( mPositions==null )
|
200
|
{
|
201
|
final float D = 1.02f;
|
202
|
final float E = 0.50f;
|
203
|
|
204
|
mPositions = new float[][]
|
205
|
{
|
206
|
{ 0.5f, 0.5f, 0.5f},
|
207
|
{ 0.5f, 0.5f,-0.5f},
|
208
|
{ 0.5f,-0.5f, 0.5f},
|
209
|
{ 0.5f,-0.5f,-0.5f},
|
210
|
{-0.5f, 0.5f, 0.5f},
|
211
|
{-0.5f, 0.5f,-0.5f},
|
212
|
{-0.5f,-0.5f, 0.5f},
|
213
|
{-0.5f,-0.5f,-0.5f},
|
214
|
|
215
|
{ 0.5f, 0.5f, E},
|
216
|
{ 0.5f, 0.5f,-E},
|
217
|
{ 0.5f,-0.5f, E},
|
218
|
{ 0.5f,-0.5f,-E},
|
219
|
{-0.5f, 0.5f, E},
|
220
|
{-0.5f, 0.5f,-E},
|
221
|
{-0.5f,-0.5f, E},
|
222
|
{-0.5f,-0.5f,-E},
|
223
|
{ 0.5f, E, 0.5f},
|
224
|
{ 0.5f,-E, 0.5f},
|
225
|
{ 0.5f, E,-0.5f},
|
226
|
{ 0.5f,-E,-0.5f},
|
227
|
{-0.5f, E, 0.5f},
|
228
|
{-0.5f,-E, 0.5f},
|
229
|
{-0.5f, E,-0.5f},
|
230
|
{-0.5f,-E,-0.5f},
|
231
|
{ E, 0.5f, 0.5f},
|
232
|
{-E, 0.5f, 0.5f},
|
233
|
{ E, 0.5f,-0.5f},
|
234
|
{-E, 0.5f,-0.5f},
|
235
|
{ E,-0.5f, 0.5f},
|
236
|
{-E,-0.5f, 0.5f},
|
237
|
{ E,-0.5f,-0.5f},
|
238
|
{-E,-0.5f,-0.5f},
|
239
|
|
240
|
{-D ,-0.5f, 0.5f},
|
241
|
{-0.5f, -D, 0.5f},
|
242
|
{-0.5f,-0.5f, D}
|
243
|
};
|
244
|
}
|
245
|
|
246
|
return mPositions;
|
247
|
}
|
248
|
|
249
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
250
|
|
251
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
252
|
{
|
253
|
if( mQuatIndex==null ) mQuatIndex = new int[] { 0,1,17,22,4,5,8,19,
|
254
|
0,18,7,2, 9,5,8,19, 13,3,1,22, 14,23,15,11, 21,4,6,10, 17,20,12,16,
|
255
|
0, 0, 0 };
|
256
|
return mObjectQuats[mQuatIndex[cubit]];
|
257
|
}
|
258
|
|
259
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
260
|
|
261
|
private ObjectShape getCornerShape()
|
262
|
{
|
263
|
final float INIT_ALPHA = 0.0f;
|
264
|
final float STEP_CORNER= (float)((Math.PI/2)/NUMBER_CORNER_SEGMENTS);
|
265
|
final int SINGLE_ARC = NUMBER_CORNER_SEGMENTS+1;
|
266
|
final int SINGLE_INNER_ARC = (NUMBER_CORNER_SEGMENTS+1)/2;
|
267
|
final int NUM_VERTICES = 4 + 3*SINGLE_ARC + 1 + 3*SINGLE_INNER_ARC;
|
268
|
float[][] tmp = new float[SINGLE_ARC][2];
|
269
|
|
270
|
for(int i=0; i<SINGLE_ARC; i++)
|
271
|
{
|
272
|
float alpha = INIT_ALPHA + i*STEP_CORNER;
|
273
|
tmp[i][0] = (float)(DIAMETER_RATIO*Math.sin(alpha) - 0.5f);
|
274
|
tmp[i][1] = (float)(DIAMETER_RATIO*Math.cos(alpha) - 0.5f);
|
275
|
}
|
276
|
|
277
|
float[][] vertices = new float[NUM_VERTICES][];
|
278
|
|
279
|
vertices[0] = new float[] { +0.5f, +0.5f, +0.5f };
|
280
|
vertices[1] = new float[] { -0.5f, +0.5f, +0.5f };
|
281
|
vertices[2] = new float[] { +0.5f, -0.5f, +0.5f };
|
282
|
vertices[3] = new float[] { +0.5f, +0.5f, -0.5f };
|
283
|
|
284
|
for(int i=0; i<SINGLE_ARC; i++)
|
285
|
{
|
286
|
float s = tmp[i][0];
|
287
|
float c = tmp[i][1];
|
288
|
|
289
|
vertices[4 +i] = new float[] {0.5f,+s,+c};
|
290
|
vertices[4+ SINGLE_ARC+i] = new float[] {+c,0.5f,+s};
|
291
|
vertices[4+2*SINGLE_ARC+i] = new float[] {+s,+c,0.5f};
|
292
|
}
|
293
|
|
294
|
final float EXTRA = (NUMBER_CORNER_SEGMENTS%2)==0 ? 1.0f : (float)Math.cos((Math.PI/2)/(2*NUMBER_CORNER_SEGMENTS));
|
295
|
final float LEN = DIAMETER_RATIO*EXTRA;
|
296
|
final float M = (float)(LEN*Math.sin(Math.PI/4) - 0.5f);
|
297
|
vertices[4+3*SINGLE_ARC] = new float[] {M,M,M};
|
298
|
|
299
|
for(int i=0; i<SINGLE_INNER_ARC; i++)
|
300
|
{
|
301
|
float s = tmp[i][0];
|
302
|
float c = tmp[i][1];
|
303
|
|
304
|
vertices[4+3*SINGLE_ARC+1 +i] = new float[] {s,c,c};
|
305
|
vertices[4+3*SINGLE_ARC+1+ SINGLE_INNER_ARC+i] = new float[] {c,s,c};
|
306
|
vertices[4+3*SINGLE_ARC+1+2*SINGLE_INNER_ARC+i] = new float[] {c,c,s};
|
307
|
}
|
308
|
|
309
|
final int NUM_FACES = 6 + 3*NUMBER_CORNER_SEGMENTS;
|
310
|
final int NUM_VERTS = 4 + NUMBER_CORNER_SEGMENTS;
|
311
|
|
312
|
int[][] indices = new int[NUM_FACES][];
|
313
|
|
314
|
indices[0] = new int[NUM_VERTS];
|
315
|
indices[1] = new int[NUM_VERTS];
|
316
|
indices[2] = new int[NUM_VERTS];
|
317
|
|
318
|
indices[0][0] = 3;
|
319
|
indices[0][1] = 0;
|
320
|
indices[0][2] = 2;
|
321
|
indices[1][0] = 1;
|
322
|
indices[1][1] = 0;
|
323
|
indices[1][2] = 3;
|
324
|
indices[2][0] = 2;
|
325
|
indices[2][1] = 0;
|
326
|
indices[2][2] = 1;
|
327
|
|
328
|
for(int i=0; i<SINGLE_ARC; i++)
|
329
|
{
|
330
|
indices[0][3+i] = 4+i;
|
331
|
indices[1][3+i] = 4+i+ SINGLE_ARC;
|
332
|
indices[2][3+i] = 4+i+2*SINGLE_ARC;
|
333
|
}
|
334
|
|
335
|
indices[3] = new int[] { 1, 4+2*SINGLE_ARC-1, 4+3*SINGLE_ARC+1 , 4+2*SINGLE_ARC};
|
336
|
indices[4] = new int[] { 2, 4+3*SINGLE_ARC-1, 4+3*SINGLE_ARC+1+ SINGLE_INNER_ARC, 4 };
|
337
|
indices[5] = new int[] { 3, 4+ SINGLE_ARC-1, 4+3*SINGLE_ARC+1+2*SINGLE_INNER_ARC, 4+ SINGLE_ARC};
|
338
|
|
339
|
int start,i0,i1,i2,i3;
|
340
|
int MID = (NUMBER_CORNER_SEGMENTS)/2;
|
341
|
int MID2= (NUMBER_CORNER_SEGMENTS+1)/2;
|
342
|
|
343
|
if( (NUMBER_CORNER_SEGMENTS%2) == 0 )
|
344
|
{
|
345
|
start = 12;
|
346
|
indices[ 6] = new int[] { 4+3*SINGLE_ARC, 4+SINGLE_ARC+MID, 4+SINGLE_ARC+MID-1, 4+3*SINGLE_ARC+1+2*SINGLE_INNER_ARC+MID-1};
|
347
|
indices[ 7] = new int[] { 4+3*SINGLE_ARC, 4+3*SINGLE_ARC+1+MID-1, 4+SINGLE_ARC+MID+1, 4+SINGLE_ARC+MID};
|
348
|
indices[ 8] = new int[] { 4+3*SINGLE_ARC, 4+3*SINGLE_ARC+1+2*SINGLE_INNER_ARC+MID-1, 4+MID+1, 4+MID };
|
349
|
indices[ 9] = new int[] { 4+3*SINGLE_ARC, 4+MID, 4+MID-1, 4+3*SINGLE_ARC+1+SINGLE_INNER_ARC+MID-1 };
|
350
|
indices[10] = new int[] { 4+3*SINGLE_ARC, 4+2*SINGLE_ARC+MID, 4+2*SINGLE_ARC+MID-1, 4+3*SINGLE_ARC+1+MID-1 };
|
351
|
indices[11] = new int[] { 4+3*SINGLE_ARC, 4+3*SINGLE_ARC+1+SINGLE_INNER_ARC+MID-1, 4+2*SINGLE_ARC+MID+1, 4+2*SINGLE_ARC+MID };
|
352
|
}
|
353
|
else
|
354
|
{
|
355
|
start = 9;
|
356
|
indices[ 6] = new int[] { 4+3*SINGLE_ARC, 4+3*SINGLE_ARC+1+MID, 4+SINGLE_ARC+MID+1, 4+SINGLE_ARC+MID, 4+3*SINGLE_ARC+1+2*SINGLE_INNER_ARC+MID};
|
357
|
indices[ 7] = new int[] { 4+3*SINGLE_ARC, 4+3*SINGLE_ARC+1+2*SINGLE_INNER_ARC+MID, 4+MID+1, 4+MID, 4+3*SINGLE_ARC+1+SINGLE_INNER_ARC+MID};
|
358
|
indices[ 8] = new int[] { 4+3*SINGLE_ARC, 4+3*SINGLE_ARC+1+SINGLE_INNER_ARC+MID, 4+2*SINGLE_ARC+MID+1, 4+2*SINGLE_ARC+MID, 4+3*SINGLE_ARC+1+MID};
|
359
|
}
|
360
|
|
361
|
for(int j=0; j<MID2-1; j++)
|
362
|
{
|
363
|
i0 = 4+3*SINGLE_ARC+1+2*SINGLE_INNER_ARC+j;
|
364
|
i1 = 4+3*SINGLE_ARC+1+2*SINGLE_INNER_ARC+j+1;
|
365
|
i2 = 4+SINGLE_ARC+j+1;
|
366
|
i3 = 4+SINGLE_ARC+j;
|
367
|
|
368
|
indices[start+j] = new int[] {i0,i1,i2,i3};
|
369
|
|
370
|
i0 = 4+3*SINGLE_ARC+1+2*SINGLE_INNER_ARC+j+1;
|
371
|
i1 = 4+3*SINGLE_ARC+1+2*SINGLE_INNER_ARC+j;
|
372
|
i2 = 4+(SINGLE_ARC-1)-j;
|
373
|
i3 = 4+(SINGLE_ARC-1)-(j+1);
|
374
|
|
375
|
indices[start+j+(MID2-1)] = new int[] {i0,i1,i2,i3};
|
376
|
|
377
|
i0 = 4+3*SINGLE_ARC+1+j;
|
378
|
i1 = 4+3*SINGLE_ARC+1+j+1;
|
379
|
i2 = 4+2*SINGLE_ARC+j+1;
|
380
|
i3 = 4+2*SINGLE_ARC+j;
|
381
|
|
382
|
indices[start+j+2*(MID2-1)] = new int[] {i0,i1,i2,i3};
|
383
|
|
384
|
i0 = 4+3*SINGLE_ARC+1+j+1;
|
385
|
i1 = 4+3*SINGLE_ARC+1+j;
|
386
|
i2 = 4+(2*SINGLE_ARC-1)-j;
|
387
|
i3 = 4+(2*SINGLE_ARC-1)-(j+1);
|
388
|
|
389
|
indices[start+j+3*(MID2-1)] = new int[] {i0,i1,i2,i3};
|
390
|
|
391
|
i0 = 4+3*SINGLE_ARC+1+SINGLE_INNER_ARC+j;
|
392
|
i1 = 4+3*SINGLE_ARC+1+SINGLE_INNER_ARC+j+1;
|
393
|
i2 = 4+j+1;
|
394
|
i3 = 4+j;
|
395
|
|
396
|
indices[start+j+4*(MID2-1)] = new int[] {i0,i1,i2,i3};
|
397
|
|
398
|
i0 = 4+3*SINGLE_ARC+1+SINGLE_INNER_ARC+j+1;
|
399
|
i1 = 4+3*SINGLE_ARC+1+SINGLE_INNER_ARC+j;
|
400
|
i2 = 4+(3*SINGLE_ARC-1)-j;
|
401
|
i3 = 4+(3*SINGLE_ARC-1)-(j+1);
|
402
|
|
403
|
indices[start+j+5*(MID2-1)] = new int[] {i0,i1,i2,i3};
|
404
|
}
|
405
|
|
406
|
return new ObjectShape(vertices,indices);
|
407
|
}
|
408
|
|
409
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
410
|
|
411
|
private ObjectShape getSmallCircleShape()
|
412
|
{
|
413
|
final float D = 0.02f;
|
414
|
final float H = DIAMETER_RATIO-0.5f;
|
415
|
final float INIT_ALPHA = 0;
|
416
|
final float STEP_CORNER= (float)((Math.PI/2)/NUMBER_CORNER_SEGMENTS);
|
417
|
final int NUM_VERTICES = 6 + 2*(NUMBER_CORNER_SEGMENTS-1);
|
418
|
float[][] vertices = new float[NUM_VERTICES][];
|
419
|
|
420
|
vertices[0] = new float[] {-0.5f, H, 0.5f+D};
|
421
|
vertices[1] = new float[] { H,-0.5f, 0.5f+D};
|
422
|
vertices[2] = new float[] {-0.5f,-0.5f, 0.5f+D};
|
423
|
vertices[3] = new float[] {-0.5f, H,-0.5f+D};
|
424
|
vertices[4] = new float[] { H,-0.5f,-0.5f+D};
|
425
|
vertices[5] = new float[] {-0.5f,-0.5f,-0.5f+D};
|
426
|
|
427
|
for(int i=0; i<NUMBER_CORNER_SEGMENTS-1; i++)
|
428
|
{
|
429
|
float alpha = INIT_ALPHA + (i+1)*STEP_CORNER;
|
430
|
float A = (float)(DIAMETER_RATIO*Math.sin(alpha) - 0.5f);
|
431
|
float B = (float)(DIAMETER_RATIO*Math.cos(alpha) - 0.5f);
|
432
|
|
433
|
vertices[6 +i] = new float[] {A,B, 0.5f+D};
|
434
|
vertices[5+NUMBER_CORNER_SEGMENTS+i] = new float[] {A,B,-0.5f+D};
|
435
|
}
|
436
|
|
437
|
final int NUM_FACES = 4 + NUMBER_CORNER_SEGMENTS;
|
438
|
int[][] indices = new int[NUM_FACES][];
|
439
|
|
440
|
int NUMV = 2+NUMBER_CORNER_SEGMENTS;
|
441
|
indices[0] = new int[NUMV];
|
442
|
indices[0][0] = 0;
|
443
|
indices[0][1] = 2;
|
444
|
indices[0][2] = 1;
|
445
|
for(int i=3; i<NUMV; i++) indices[0][i] = 5+(NUMBER_CORNER_SEGMENTS-1)-(i-3);
|
446
|
|
447
|
indices[1] = new int[NUMV];
|
448
|
indices[1][0] = 4;
|
449
|
indices[1][1] = 5;
|
450
|
indices[1][2] = 3;
|
451
|
for(int i=3; i<NUMV; i++) indices[1][i] = 5+NUMBER_CORNER_SEGMENTS+(i-3);
|
452
|
|
453
|
indices[2] = new int[] {0,3,5,2};
|
454
|
indices[3] = new int[] {1,2,5,4};
|
455
|
|
456
|
indices[4] = new int[] {5+NUMBER_CORNER_SEGMENTS,3,0,6};
|
457
|
indices[5] = new int[] {1,4,5+2*(NUMBER_CORNER_SEGMENTS-1),5+(NUMBER_CORNER_SEGMENTS-1)};
|
458
|
|
459
|
for(int i=0; i<NUMBER_CORNER_SEGMENTS-2; i++)
|
460
|
{
|
461
|
int i0 = 6+i;
|
462
|
int i1 = 7+i;
|
463
|
int i2 = 6+NUMBER_CORNER_SEGMENTS+i;
|
464
|
int i3 = 5+NUMBER_CORNER_SEGMENTS+i;
|
465
|
|
466
|
indices[6+i] = new int[] {i0,i1,i2,i3};
|
467
|
}
|
468
|
|
469
|
return new ObjectShape(vertices,indices);
|
470
|
}
|
471
|
|
472
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
473
|
|
474
|
private ObjectShape getDeciderShape()
|
475
|
{
|
476
|
final float A = 0.5f;
|
477
|
float[][] vertices = new float[][] { {-A,-A,0},{A,-A,0},{A,A,0} };
|
478
|
int[][] indices = new int[][] { {0,1,2} };
|
479
|
|
480
|
return new ObjectShape(vertices,indices);
|
481
|
}
|
482
|
|
483
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
484
|
|
485
|
public ObjectShape getObjectShape(int variant)
|
486
|
{
|
487
|
switch(variant)
|
488
|
{
|
489
|
case 0: return getCornerShape();
|
490
|
case 1: return getSmallCircleShape();
|
491
|
case 2: return getDeciderShape();
|
492
|
}
|
493
|
|
494
|
return null;
|
495
|
}
|
496
|
|
497
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
498
|
|
499
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
500
|
{
|
501
|
if( variant==0 )
|
502
|
{
|
503
|
float h1 = isInIconMode() ? 0.001f : 0.04f;
|
504
|
float h2 = 0.001f;
|
505
|
float[][] bands = { {h1,45,0.3f,0.7f,5,0,0}, {h2,5,0.3f,0.2f,5,0,0} };
|
506
|
final int NUM_BANDS = 6+3*NUMBER_CORNER_SEGMENTS;
|
507
|
int[] bandIndices = new int[NUM_BANDS];
|
508
|
bandIndices[0] = bandIndices[1] = bandIndices[2] = 0;
|
509
|
for(int i=3; i<NUM_BANDS; i++) bandIndices[i] = 1;
|
510
|
float[][] corners = { {0.02f,0.09f} };
|
511
|
float[][] centers = { { 0.0f, 0.0f, 0.0f } };
|
512
|
final int SINGLE_ARC = NUMBER_CORNER_SEGMENTS+1;
|
513
|
final int SINGLE_INNER_ARC = (NUMBER_CORNER_SEGMENTS+1)/2;
|
514
|
final int NUM_VERTICES = 4 + 3*SINGLE_ARC + 1 + 3*SINGLE_INNER_ARC;
|
515
|
int[] indices = new int[NUM_VERTICES];
|
516
|
indices[0] = indices[1] = indices[2] = indices[3] = 0;
|
517
|
for(int i=4; i<NUM_VERTICES; i++) indices[i] = -1;
|
518
|
return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
|
519
|
}
|
520
|
else if( variant==1 )
|
521
|
{
|
522
|
float h1 = isInIconMode() ? 0.001f : 0.02f;
|
523
|
float[][] bands = { {h1,45,0.2f,0.4f,5,0,0}, {0.001f,1,0.3f,0.5f,3,0,0}, {0.001f,1,0.3f,0.5f,2,0,0} };
|
524
|
final int NUM_BANDS = 4 + NUMBER_CORNER_SEGMENTS;
|
525
|
int[] bandIndices = new int[NUM_BANDS];
|
526
|
bandIndices[0] = 0;
|
527
|
bandIndices[1] = 2;
|
528
|
bandIndices[2] = bandIndices[3] = 1;
|
529
|
for(int i=4; i<NUM_BANDS; i++) bandIndices[i] = 2;
|
530
|
float[][] corners = { {0.02f,0.09f} };
|
531
|
float[][] centers = { { 0.0f, 0.0f, 1.0f } };
|
532
|
final int NUM_VERTICES = 6 + 2*(NUMBER_CORNER_SEGMENTS-1);
|
533
|
int[] indices = new int[NUM_VERTICES];
|
534
|
for(int i=0; i<NUM_VERTICES; i++) indices[i] = -1;
|
535
|
indices[0] = indices[1] = indices[2] = 0;
|
536
|
return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
|
537
|
}
|
538
|
else
|
539
|
{
|
540
|
float h1 = 0.001f;
|
541
|
float[][] bands = { {h1,1,0.2f,0.4f,2,0,0} };
|
542
|
int[] bandIndices = new int[] {0};
|
543
|
float[][] corners = { {0.02f,0.09f} };
|
544
|
float[][] centers = { { 0.0f, 0.0f, 0.0f } };
|
545
|
int[] indices = new int[] {-1,-1,-1};
|
546
|
return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
|
547
|
}
|
548
|
}
|
549
|
|
550
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
551
|
|
552
|
public int getNumCubitVariants(int[] numLayers)
|
553
|
{
|
554
|
return 3;
|
555
|
}
|
556
|
|
557
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
558
|
|
559
|
public int getCubitVariant(int cubit, int[] numLayers)
|
560
|
{
|
561
|
return cubit<8 ? 0 : (cubit<32 ? 1:2);
|
562
|
}
|
563
|
|
564
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
565
|
|
566
|
public float getStickerRadius()
|
567
|
{
|
568
|
return 0.07f;
|
569
|
}
|
570
|
|
571
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
572
|
|
573
|
public float getStickerStroke()
|
574
|
{
|
575
|
return isInIconMode() ? 0.22f : 0.12f;
|
576
|
}
|
577
|
|
578
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
579
|
|
580
|
public float[][] getStickerAngles()
|
581
|
{
|
582
|
float D = (float)(Math.PI/4);
|
583
|
return new float[][] { { 0,0,0,-D,0 },{ 0,0,D },{0,0,0} };
|
584
|
}
|
585
|
|
586
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
587
|
// PUBLIC API
|
588
|
|
589
|
public Static3D[] getRotationAxis()
|
590
|
{
|
591
|
return ROT_AXIS;
|
592
|
}
|
593
|
|
594
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
595
|
|
596
|
public int[][] getBasicAngles()
|
597
|
{
|
598
|
if( mBasicAngle==null )
|
599
|
{
|
600
|
int[] tmp = new int[] {4,4,4};
|
601
|
mBasicAngle = new int[][] { tmp,tmp,tmp };
|
602
|
}
|
603
|
|
604
|
return mBasicAngle;
|
605
|
}
|
606
|
|
607
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
608
|
|
609
|
public String getShortName()
|
610
|
{
|
611
|
return ObjectType.CRA1_2.name();
|
612
|
}
|
613
|
|
614
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
615
|
|
616
|
public ObjectSignature getSignature()
|
617
|
{
|
618
|
return new ObjectSignature(ObjectType.CRA1_2);
|
619
|
}
|
620
|
|
621
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
622
|
|
623
|
public String getObjectName()
|
624
|
{
|
625
|
return "Circle 2x2";
|
626
|
}
|
627
|
|
628
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
629
|
|
630
|
public String getInventor()
|
631
|
{
|
632
|
return "Aleh Hladzilin";
|
633
|
}
|
634
|
|
635
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
636
|
|
637
|
public int getYearOfInvention()
|
638
|
{
|
639
|
return 2007;
|
640
|
}
|
641
|
|
642
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
643
|
|
644
|
public int getComplexity()
|
645
|
{
|
646
|
return 2;
|
647
|
}
|
648
|
|
649
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
650
|
|
651
|
public String[][] getTutorials()
|
652
|
{
|
653
|
return new String[][] {
|
654
|
{"gb","DKLIQghl66c","Circle 2x2 Demonstration","SuperAntoniovivaldi"},
|
655
|
{"es","Wq9lwfDfg4E","Resolucion Del 2X2 Crazy","RUBIKworld"},
|
656
|
{"br","K4bFs4BFdXc","Tutorial Crazy 2x2 de Sengso","Manzacuber"},
|
657
|
};
|
658
|
}
|
659
|
}
|