1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2021 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_CUBOID;
|
13
|
|
14
|
import java.io.InputStream;
|
15
|
|
16
|
import org.distorted.library.effect.EffectName;
|
17
|
import org.distorted.library.main.DistortedLibrary;
|
18
|
import org.distorted.library.type.Static3D;
|
19
|
import org.distorted.library.type.Static4D;
|
20
|
|
21
|
import org.distorted.objectlib.helpers.FactoryBandagedCubit;
|
22
|
import org.distorted.objectlib.helpers.ObjectFaceShape;
|
23
|
import org.distorted.objectlib.helpers.ObjectSignature;
|
24
|
import org.distorted.objectlib.helpers.ObjectVertexEffects;
|
25
|
import org.distorted.objectlib.main.InitData;
|
26
|
import org.distorted.objectlib.helpers.ObjectShape;
|
27
|
import org.distorted.objectlib.main.ObjectType;
|
28
|
|
29
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
30
|
|
31
|
public class TwistyBandagedCuboid extends TwistyBandagedAbstract
|
32
|
{
|
33
|
private static final String OBJECT_NAME = "LOCAL_BANDAGED";
|
34
|
|
35
|
private static final int CUBIT_111 = 0;
|
36
|
private static final int CUBIT_211 = 1;
|
37
|
private static final int CUBIT_311 = 2;
|
38
|
private static final int CUBIT_221 = 3;
|
39
|
private static final int CUBIT_222 = 4;
|
40
|
private static final int CUBIT_OTH = 5;
|
41
|
|
42
|
private static final int[][] mDims = new int[][]
|
43
|
{
|
44
|
{1,1,1}, // has to be X>=Z>=Y so that all
|
45
|
{2,1,1}, // the faces are horizontal
|
46
|
{3,1,1},
|
47
|
{2,1,2},
|
48
|
{2,2,2},
|
49
|
};
|
50
|
|
51
|
public static final float[][] POS_1 = new float[][]
|
52
|
{
|
53
|
{-1.0f, -1.0f, +0.0f,
|
54
|
-1.0f, -1.0f, +1.0f,
|
55
|
-1.0f, 0.0f, +0.0f,
|
56
|
-1.0f, 0.0f, +1.0f,
|
57
|
0.0f, -1.0f, +0.0f,
|
58
|
0.0f, -1.0f, +1.0f,
|
59
|
0.0f, 0.0f, +0.0f,
|
60
|
0.0f, 0.0f, +1.0f},
|
61
|
{-1.0f, +1.0f, +1.0f},
|
62
|
{-1.0f, +1.0f, +0.0f},
|
63
|
{-1.0f, +1.0f, -1.0f},
|
64
|
{ 0.0f, +1.0f, +1.0f},
|
65
|
{ 0.0f, +1.0f, +0.0f},
|
66
|
{ 0.0f, +1.0f, -1.0f},
|
67
|
{ 1.0f, +1.0f, +1.0f},
|
68
|
{ 1.0f, +1.0f, +0.0f},
|
69
|
{ 1.0f, +1.0f, -1.0f},
|
70
|
{ 1.0f, 0.0f, +1.0f},
|
71
|
{ 1.0f, 0.0f, +0.0f},
|
72
|
{ 1.0f, 0.0f, -1.0f},
|
73
|
{ 1.0f, -1.0f, +1.0f},
|
74
|
{ 1.0f, -1.0f, +0.0f},
|
75
|
{ 1.0f, -1.0f, -1.0f},
|
76
|
{-1.0f, -1.0f, -1.0f},
|
77
|
{-1.0f, 0.0f, -1.0f},
|
78
|
{ 0.0f, -1.0f, -1.0f},
|
79
|
{ 0.0f, 0.0f, -1.0f}
|
80
|
};
|
81
|
|
82
|
public static final float[][] POS_2 = new float[][]
|
83
|
{
|
84
|
{ 0.0f, +1.0f, 1.0f, 0.0f, +1.0f, 0.0f, 0.0f, +1.0f, -1.0f},
|
85
|
{-1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, -1.0f, 0.0f},
|
86
|
{-1.0f, +1.0f, +1.0f},
|
87
|
{-1.0f, +1.0f, 0.0f},
|
88
|
{-1.0f, +1.0f, -1.0f},
|
89
|
{-1.0f, 0.0f, +1.0f},
|
90
|
{-1.0f, 0.0f, 0.0f},
|
91
|
{-1.0f, 0.0f, -1.0f},
|
92
|
{-1.0f, -1.0f, +1.0f},
|
93
|
{-1.0f, -1.0f, -1.0f},
|
94
|
{+1.0f, +1.0f, +1.0f},
|
95
|
{+1.0f, +1.0f, 0.0f},
|
96
|
{+1.0f, +1.0f, -1.0f},
|
97
|
{+1.0f, 0.0f, +1.0f},
|
98
|
{+1.0f, 0.0f, 0.0f},
|
99
|
{+1.0f, 0.0f, -1.0f},
|
100
|
{+1.0f, -1.0f, +1.0f},
|
101
|
{+1.0f, -1.0f, -1.0f},
|
102
|
{ 0.0f, 0.0f, +1.0f},
|
103
|
{ 0.0f, -1.0f, +1.0f},
|
104
|
{ 0.0f, 0.0f, -1.0f},
|
105
|
{ 0.0f, -1.0f, -1.0f}
|
106
|
};
|
107
|
|
108
|
public static final float[][] POS_3 = new float[][]
|
109
|
{
|
110
|
{-1.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f},
|
111
|
{ 1.0f, 0.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 0.0f},
|
112
|
{-1.0f, -1.0f, -1.0f, -1.0f, -1.0f, 0.0f, 0.0f, -1.0f, -1.0f, 0.0f, -1.0f, 0.0f},
|
113
|
{ 1.0f, 1.0f, 1.0f},
|
114
|
{ 1.0f, 0.0f, 1.0f},
|
115
|
{ 1.0f, -1.0f, 1.0f},
|
116
|
{-1.0f, -1.0f, 1.0f},
|
117
|
{ 0.0f, -1.0f, 1.0f},
|
118
|
{ 1.0f, -1.0f, 0.0f},
|
119
|
{ 1.0f, -1.0f, -1.0f},
|
120
|
{-1.0f, 1.0f, -1.0f},
|
121
|
{-1.0f, 1.0f, 0.0f},
|
122
|
{ 0.0f, 1.0f, -1.0f},
|
123
|
{ 0.0f, 1.0f, 0.0f},
|
124
|
{-1.0f, 0.0f, -1.0f},
|
125
|
{-1.0f, 0.0f, 0.0f},
|
126
|
{ 0.0f, 0.0f, -1.0f}
|
127
|
};
|
128
|
|
129
|
public static final float[][] POS_4 = new float[][]
|
130
|
{
|
131
|
{ 1.0f, 1.0f, -1.0f},
|
132
|
{-1.0f, -1.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f},
|
133
|
{-1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f},
|
134
|
{-1.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f},
|
135
|
{-1.0f, -1.0f, -1.0f, 0.0f, -1.0f, -1.0f},
|
136
|
{-1.0f, 1.0f, 0.0f, -1.0f, 1.0f, 1.0f},
|
137
|
{ 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f},
|
138
|
{ 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f},
|
139
|
{-1.0f, -1.0f, 1.0f, -1.0f, 0.0f, 1.0f},
|
140
|
{ 0.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f},
|
141
|
{ 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 1.0f},
|
142
|
{ 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 0.0f},
|
143
|
{ 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, -1.0f}
|
144
|
};
|
145
|
|
146
|
private int[] mCubitVariantMap;
|
147
|
private int[] mTypeVariantMap;
|
148
|
private Static4D[] mInitQuats;
|
149
|
|
150
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
151
|
|
152
|
public static int getType(String shortName, String longName)
|
153
|
{
|
154
|
if( shortName.equals(ObjectType.BAN1_3.name()) ||
|
155
|
shortName.equals(ObjectType.BAN2_3.name()) ||
|
156
|
shortName.equals(ObjectType.BAN3_3.name()) ||
|
157
|
shortName.equals(ObjectType.BAN4_3.name()) ) return 2;
|
158
|
|
159
|
if( longName.equals(OBJECT_NAME) ) return 1;
|
160
|
|
161
|
return 0;
|
162
|
}
|
163
|
|
164
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
165
|
|
166
|
public TwistyBandagedCuboid(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
|
167
|
{
|
168
|
super(data, meshState, iconMode, (data.getNumLayers()[0]+data.getNumLayers()[1]+data.getNumLayers()[2])/3.0f, quat, move, scale, stream);
|
169
|
}
|
170
|
|
171
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
172
|
|
173
|
private int getType(float[] pos)
|
174
|
{
|
175
|
switch(pos.length)
|
176
|
{
|
177
|
case 3: return CUBIT_111;
|
178
|
case 6: return CUBIT_211;
|
179
|
case 9: boolean x1 = (pos[0]==pos[3] && pos[0]==pos[6]);
|
180
|
boolean y1 = (pos[1]==pos[4] && pos[1]==pos[7]);
|
181
|
boolean z1 = (pos[2]==pos[5] && pos[2]==pos[8]);
|
182
|
return ( (x1&&y1) || (x1&&z1) || (y1&&z1) ) ? CUBIT_311 : CUBIT_OTH;
|
183
|
case 12: float x = (pos[0]+pos[3]+pos[6]+pos[ 9])/4;
|
184
|
float y = (pos[1]+pos[4]+pos[7]+pos[10])/4;
|
185
|
float z = (pos[2]+pos[5]+pos[8]+pos[11])/4;
|
186
|
float d1 = (pos[0]-x)*(pos[0]-x) + (pos[ 1]-y)*(pos[ 1]-y) + (pos[ 2]-z)*(pos[ 2]-z);
|
187
|
float d2 = (pos[3]-x)*(pos[3]-x) + (pos[ 4]-y)*(pos[ 4]-y) + (pos[ 5]-z)*(pos[ 5]-z);
|
188
|
float d3 = (pos[6]-x)*(pos[6]-x) + (pos[ 7]-y)*(pos[ 7]-y) + (pos[ 8]-z)*(pos[ 8]-z);
|
189
|
float d4 = (pos[9]-x)*(pos[9]-x) + (pos[10]-y)*(pos[10]-y) + (pos[11]-z)*(pos[11]-z);
|
190
|
return ( d1==0.5f && d2==0.5f && d3==0.5f && d4==0.5f ) ? CUBIT_221 : CUBIT_OTH;
|
191
|
case 24: float x3 = pos[0];
|
192
|
float y3 = pos[1];
|
193
|
float z3 = pos[2];
|
194
|
float x4=-10,y4=-10,z4=-10;
|
195
|
int i;
|
196
|
|
197
|
for(i=0; i<8; i++)
|
198
|
{
|
199
|
if( pos[3*i]!=x3 && pos[3*i+1]!=y3 && pos[3*i+2]!=z3 )
|
200
|
{
|
201
|
x4 = pos[3*i ];
|
202
|
y4 = pos[3*i+1];
|
203
|
z4 = pos[3*i+2];
|
204
|
break;
|
205
|
}
|
206
|
}
|
207
|
if( i==9 ) return CUBIT_OTH;
|
208
|
|
209
|
float dX = x4-x3;
|
210
|
float dY = y4-y3;
|
211
|
float dZ = z4-z3;
|
212
|
|
213
|
if( (dX==1.0f || dX==-1.0f) && (dY==1.0f || dY==-1.0f) && (dZ==1.0f || dZ==-1.0f) )
|
214
|
{
|
215
|
for(i=0; i<8; i++)
|
216
|
{
|
217
|
if( (pos[3*i ]!=x3 && pos[3*i ]!=x4) ||
|
218
|
(pos[3*i+1]!=y3 && pos[3*i+1]!=y4) ||
|
219
|
(pos[3*i+2]!=z3 && pos[3*i+2]!=z4) ) return CUBIT_OTH;
|
220
|
}
|
221
|
|
222
|
return CUBIT_222;
|
223
|
}
|
224
|
|
225
|
default: return CUBIT_OTH;
|
226
|
}
|
227
|
}
|
228
|
|
229
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
230
|
|
231
|
private int getQuatIndex(int cubit)
|
232
|
{
|
233
|
float[][] positions = getPositions();
|
234
|
int len = positions.length;
|
235
|
|
236
|
if( cubit>=0 && cubit<len )
|
237
|
{
|
238
|
float[] pos = positions[cubit];
|
239
|
int type = getType(pos);
|
240
|
|
241
|
switch(type)
|
242
|
{
|
243
|
case CUBIT_222:
|
244
|
case CUBIT_111: return 0;
|
245
|
case CUBIT_211:
|
246
|
case CUBIT_311: return (pos[1]==pos[4]) ? (pos[0]==pos[3] ? 2 : 0) : 3;
|
247
|
case CUBIT_221: if( pos[0]==pos[3] && pos[0]==pos[6] ) return 3;
|
248
|
if( pos[1]==pos[4] && pos[1]==pos[7] ) return 0;
|
249
|
if( pos[2]==pos[5] && pos[2]==pos[8] ) return 1;
|
250
|
}
|
251
|
}
|
252
|
|
253
|
return 0;
|
254
|
}
|
255
|
|
256
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
257
|
|
258
|
private int[] getDim(int variant)
|
259
|
{
|
260
|
int type,numTypes = mDims.length;
|
261
|
for(type=0; type<numTypes; type++) if( mTypeVariantMap[type]==variant ) break;
|
262
|
return type<numTypes ? mDims[type] : null;
|
263
|
}
|
264
|
|
265
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
266
|
|
267
|
private void produceTmpShape(int variant)
|
268
|
{
|
269
|
float[][] positions = getPositions();
|
270
|
int cubit,numCubits = positions.length;
|
271
|
|
272
|
for(cubit=0; cubit<numCubits; cubit++)
|
273
|
{
|
274
|
if( mCubitVariantMap[cubit]==variant ) break;
|
275
|
}
|
276
|
|
277
|
if( cubit>=numCubits )
|
278
|
{
|
279
|
android.util.Log.e("D", "unknown variant: "+variant);
|
280
|
}
|
281
|
else
|
282
|
{
|
283
|
FactoryBandagedCubit factory = FactoryBandagedCubit.getInstance();
|
284
|
mTmpShapes[variant] = factory.createIrregularShape(variant,positions[cubit]);
|
285
|
}
|
286
|
}
|
287
|
|
288
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
289
|
// PUBLIC API
|
290
|
|
291
|
public int getTouchControlType()
|
292
|
{
|
293
|
return TC_CUBOID;
|
294
|
}
|
295
|
|
296
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
297
|
|
298
|
public ObjectShape getObjectShape(int variant)
|
299
|
{
|
300
|
if( getDim(variant)!=null )
|
301
|
{
|
302
|
int[][] indices =
|
303
|
{
|
304
|
{2,3,1,0},
|
305
|
{7,6,4,5},
|
306
|
{4,0,1,5},
|
307
|
{7,3,2,6},
|
308
|
{6,2,0,4},
|
309
|
{3,7,5,1},
|
310
|
};
|
311
|
|
312
|
return new ObjectShape( getVertices(variant), indices);
|
313
|
}
|
314
|
|
315
|
if( mTmpShapes==null ) mTmpShapes = new ObjectShape[mNumVariants];
|
316
|
if( mTmpShapes[variant]==null ) produceTmpShape(variant);
|
317
|
return mTmpShapes[variant];
|
318
|
}
|
319
|
|
320
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
321
|
|
322
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
323
|
{
|
324
|
int[] numLayers = getNumLayers();
|
325
|
int size = (numLayers[0]+numLayers[1]+numLayers[2])/3;
|
326
|
int[] dim = getDim(variant);
|
327
|
|
328
|
if( dim!=null )
|
329
|
{
|
330
|
int X = dim[0];
|
331
|
int Y = dim[1];
|
332
|
int Z = dim[2];
|
333
|
|
334
|
float height = isInIconMode() ? 0.001f : size<=5 ? 0.048f : 0.020f;
|
335
|
int[] bandIndices= { 0,0,1,1,2,2 };
|
336
|
|
337
|
int maxXY = Math.max(X,Y);
|
338
|
int maxXZ = Math.max(X,Z);
|
339
|
int maxYZ = Math.max(Y,Z);
|
340
|
|
341
|
int angle = 45;
|
342
|
float R = 0.25f;
|
343
|
float S = 0.50f;
|
344
|
float N = size<=4 ? 5 : size<=5 ? 4 : 3;
|
345
|
|
346
|
float[][] bands =
|
347
|
{
|
348
|
{height/maxYZ,angle,R,S,N,0,0},
|
349
|
{height/maxXZ,angle,R,S,N,0,0},
|
350
|
{height/maxXY,angle,R,S,N,0,0}
|
351
|
};
|
352
|
|
353
|
return new ObjectFaceShape(bands,bandIndices,null);
|
354
|
}
|
355
|
|
356
|
FactoryBandagedCubit factory = FactoryBandagedCubit.getInstance();
|
357
|
return factory.createIrregularFaceShape(variant, isInIconMode() );
|
358
|
}
|
359
|
|
360
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
361
|
|
362
|
public ObjectVertexEffects getVertexEffects(int variant)
|
363
|
{
|
364
|
int[] numLayers = getNumLayers();
|
365
|
int size = (numLayers[0]+numLayers[1]+numLayers[2])/3;
|
366
|
boolean round = (DistortedLibrary.fastCompilationTF() && size<=5 && !isInIconMode());
|
367
|
|
368
|
if( getDim(variant)!=null )
|
369
|
{
|
370
|
float[][] vertices = getVertices(variant);
|
371
|
float strength = -0.04f;
|
372
|
|
373
|
float[][] variables =
|
374
|
{
|
375
|
{ 0, strength*vertices[0][0], strength*vertices[0][1], strength*vertices[0][2], 1 },
|
376
|
{ 0, strength*vertices[1][0], strength*vertices[1][1], strength*vertices[1][2], 1 },
|
377
|
{ 0, strength*vertices[2][0], strength*vertices[2][1], strength*vertices[2][2], 1 },
|
378
|
{ 0, strength*vertices[3][0], strength*vertices[3][1], strength*vertices[3][2], 1 },
|
379
|
{ 0, strength*vertices[4][0], strength*vertices[4][1], strength*vertices[4][2], 1 },
|
380
|
{ 0, strength*vertices[5][0], strength*vertices[5][1], strength*vertices[5][2], 1 },
|
381
|
{ 0, strength*vertices[6][0], strength*vertices[6][1], strength*vertices[6][2], 1 },
|
382
|
{ 0, strength*vertices[7][0], strength*vertices[7][1], strength*vertices[7][2], 1 },
|
383
|
};
|
384
|
|
385
|
String name = EffectName.DEFORM.name();
|
386
|
float[] reg = {0,0,0,0.15f};
|
387
|
|
388
|
String[] names = {name,name,name,name,name,name,name,name};
|
389
|
float[][] regions = {reg,reg,reg,reg,reg,reg,reg,reg};
|
390
|
boolean[] uses = {round,round,round,round,round,round,round,round};
|
391
|
|
392
|
return new ObjectVertexEffects(names,variables,vertices,regions,uses);
|
393
|
}
|
394
|
|
395
|
FactoryBandagedCubit factory = FactoryBandagedCubit.getInstance();
|
396
|
return factory.createVertexEffects(variant,round);
|
397
|
}
|
398
|
|
399
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
400
|
|
401
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
402
|
{
|
403
|
if( mInitQuats ==null )
|
404
|
{
|
405
|
mInitQuats = new Static4D[]
|
406
|
{
|
407
|
new Static4D( 0.0f, 0.0f, 0.0f, 1.0f), // NULL
|
408
|
new Static4D( SQ2/2, 0.0f, 0.0f, -SQ2/2), // X
|
409
|
new Static4D( 0.0f, SQ2/2, 0.0f, -SQ2/2), // Y
|
410
|
new Static4D( 0.0f, 0.0f, SQ2/2, -SQ2/2), // Z
|
411
|
new Static4D( -0.5f, +0.5f, -0.5f, +0.5f), // ZX
|
412
|
new Static4D( +0.5f, +0.5f, +0.5f, -0.5f), // YX
|
413
|
};
|
414
|
}
|
415
|
|
416
|
return mInitQuats[getQuatIndex(cubit)];
|
417
|
}
|
418
|
|
419
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
420
|
|
421
|
public int getNumCubitVariants(int[] numLayers)
|
422
|
{
|
423
|
if( mNumVariants==0 )
|
424
|
{
|
425
|
float[][] positions = getPositions();
|
426
|
boolean C111=false;
|
427
|
boolean C211=false;
|
428
|
boolean C311=false;
|
429
|
boolean C221=false;
|
430
|
boolean C222=false;
|
431
|
|
432
|
int numCubits = positions.length;
|
433
|
mCubitVariantMap = new int[numCubits];
|
434
|
|
435
|
int numTypes = mDims.length;
|
436
|
mTypeVariantMap = new int[numTypes];
|
437
|
for(int i=0; i<numTypes; i++) mTypeVariantMap[i] = -1;
|
438
|
|
439
|
for (int cubit=0; cubit<numCubits; cubit++)
|
440
|
{
|
441
|
int type = getType(positions[cubit]);
|
442
|
|
443
|
switch (type)
|
444
|
{
|
445
|
case CUBIT_111: if (!C111) { C111 = true; mTypeVariantMap[CUBIT_111]=mNumVariants++; }
|
446
|
mCubitVariantMap[cubit]=mTypeVariantMap[CUBIT_111];
|
447
|
break;
|
448
|
case CUBIT_211: if (!C211) { C211 = true; mTypeVariantMap[CUBIT_211]=mNumVariants++; }
|
449
|
mCubitVariantMap[cubit]=mTypeVariantMap[CUBIT_211];
|
450
|
break;
|
451
|
case CUBIT_311: if (!C311) { C311 = true; mTypeVariantMap[CUBIT_311]=mNumVariants++; }
|
452
|
mCubitVariantMap[cubit]=mTypeVariantMap[CUBIT_311];
|
453
|
break;
|
454
|
case CUBIT_221: if (!C221) { C221 = true; mTypeVariantMap[CUBIT_221]=mNumVariants++; }
|
455
|
mCubitVariantMap[cubit]=mTypeVariantMap[CUBIT_221];
|
456
|
break;
|
457
|
case CUBIT_222: if (!C222) { C222 = true; mTypeVariantMap[CUBIT_222]=mNumVariants++; }
|
458
|
mCubitVariantMap[cubit]=mTypeVariantMap[CUBIT_222];
|
459
|
break;
|
460
|
default : mCubitVariantMap[cubit] = mNumVariants++;
|
461
|
}
|
462
|
}
|
463
|
|
464
|
FactoryBandagedCubit factory = FactoryBandagedCubit.getInstance();
|
465
|
factory.prepare(mNumVariants,numLayers[0],numLayers[1],numLayers[2]);
|
466
|
}
|
467
|
|
468
|
return mNumVariants;
|
469
|
}
|
470
|
|
471
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
472
|
|
473
|
public int getCubitVariant(int cubit, int[] numLayers)
|
474
|
{
|
475
|
return mCubitVariantMap[cubit];
|
476
|
}
|
477
|
|
478
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
479
|
|
480
|
private float[][] getVertices(int variant)
|
481
|
{
|
482
|
int[] dim = getDim(variant);
|
483
|
|
484
|
if( dim!=null )
|
485
|
{
|
486
|
int X = dim[0];
|
487
|
int Y = dim[1];
|
488
|
int Z = dim[2];
|
489
|
|
490
|
return new float[][]
|
491
|
{
|
492
|
{ 0.5f*X, 0.5f*Y, 0.5f*Z},
|
493
|
{ 0.5f*X, 0.5f*Y,-0.5f*Z},
|
494
|
{ 0.5f*X,-0.5f*Y, 0.5f*Z},
|
495
|
{ 0.5f*X,-0.5f*Y,-0.5f*Z},
|
496
|
{-0.5f*X, 0.5f*Y, 0.5f*Z},
|
497
|
{-0.5f*X, 0.5f*Y,-0.5f*Z},
|
498
|
{-0.5f*X,-0.5f*Y, 0.5f*Z},
|
499
|
{-0.5f*X,-0.5f*Y,-0.5f*Z}
|
500
|
};
|
501
|
}
|
502
|
|
503
|
if( mTmpShapes==null ) mTmpShapes = new ObjectShape[mNumVariants];
|
504
|
if( mTmpShapes[variant]==null ) produceTmpShape(variant);
|
505
|
return mTmpShapes[variant].getVertices();
|
506
|
}
|
507
|
|
508
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
509
|
// PUBLIC API
|
510
|
|
511
|
public float getStickerRadius()
|
512
|
{
|
513
|
return 0.10f;
|
514
|
}
|
515
|
|
516
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
517
|
|
518
|
public float getStickerStroke()
|
519
|
{
|
520
|
return isInIconMode() ? 0.16f : 0.08f;
|
521
|
}
|
522
|
|
523
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
524
|
|
525
|
public String getShortName()
|
526
|
{
|
527
|
if( mPosition==null ) mPosition = getInitData().getPos();
|
528
|
|
529
|
if( mPosition==POS_1 ) return ObjectType.BAN1_3.name();
|
530
|
if( mPosition==POS_2 ) return ObjectType.BAN2_3.name();
|
531
|
if( mPosition==POS_3 ) return ObjectType.BAN3_3.name();
|
532
|
if( mPosition==POS_4 ) return ObjectType.BAN4_3.name();
|
533
|
|
534
|
if( mSignature==null ) mSignature = getSignature();
|
535
|
int[] numLayers = getNumLayers();
|
536
|
int number = 100*numLayers[0]+10*numLayers[1]+numLayers[2];
|
537
|
|
538
|
return number+"_"+mSignature.getString();
|
539
|
}
|
540
|
|
541
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
542
|
|
543
|
public ObjectSignature getSignature()
|
544
|
{
|
545
|
if( mSignature==null )
|
546
|
{
|
547
|
int[] numLayers = getNumLayers();
|
548
|
mSignature = new ObjectSignature(numLayers[0],numLayers[1],numLayers[2],mPosition);
|
549
|
}
|
550
|
return mSignature;
|
551
|
}
|
552
|
|
553
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
554
|
|
555
|
public String getObjectName()
|
556
|
{
|
557
|
if( mPosition==null ) mPosition = getInitData().getPos();
|
558
|
|
559
|
if( mPosition==POS_1 ) return "Fused Cube";
|
560
|
if( mPosition==POS_2 ) return "2Bar Cube";
|
561
|
if( mPosition==POS_3 ) return "Bandaged Cube C";
|
562
|
if( mPosition==POS_4 ) return "BiCube";
|
563
|
|
564
|
return OBJECT_NAME;
|
565
|
}
|
566
|
|
567
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
568
|
|
569
|
public String getInventor()
|
570
|
{
|
571
|
if( mPosition==null ) mPosition = getInitData().getPos();
|
572
|
|
573
|
if( mPosition==POS_1 ) return "Ting Huang";
|
574
|
if( mPosition==POS_2 ) return "Unknown";
|
575
|
if( mPosition==POS_3 ) return "Andreas Nortmann";
|
576
|
if( mPosition==POS_4 ) return "Uwe Meffert";
|
577
|
|
578
|
return "??";
|
579
|
}
|
580
|
|
581
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
582
|
|
583
|
public int getYearOfInvention()
|
584
|
{
|
585
|
if( mPosition==null ) mPosition = getInitData().getPos();
|
586
|
|
587
|
if( mPosition==POS_1 ) return 2011;
|
588
|
if( mPosition==POS_2 ) return 0;
|
589
|
if( mPosition==POS_3 ) return 2005;
|
590
|
if( mPosition==POS_4 ) return 1999;
|
591
|
|
592
|
return 0;
|
593
|
}
|
594
|
|
595
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
596
|
|
597
|
public int getComplexity()
|
598
|
{
|
599
|
if( mPosition==null ) mPosition = getInitData().getPos();
|
600
|
|
601
|
if( mPosition==POS_1 ) return 1;
|
602
|
if( mPosition==POS_2 ) return 2;
|
603
|
if( mPosition==POS_3 ) return 2;
|
604
|
if( mPosition==POS_4 ) return 3;
|
605
|
|
606
|
return 4;
|
607
|
}
|
608
|
|
609
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
610
|
|
611
|
public String[][] getTutorials()
|
612
|
{
|
613
|
if( mPosition==null ) mPosition = getInitData().getPos();
|
614
|
|
615
|
if( mPosition==POS_1 )
|
616
|
{
|
617
|
return new String[][]{
|
618
|
{"gb","F_iJk_IvpVo","Bandaged Cube","CanChrisSolve"},
|
619
|
{"es","_lTgw5aEFOg","Tutorial 3x3 Fuse Cube","QBAndo"},
|
620
|
{"ru","raYDwFEXIq4","Как собрать Fused Cube","Алексей Ярыгин"},
|
621
|
{"fr","9Cfi4rhKzIw","Tutoriel: résolution du Fused Cube","Skieur Cubb"},
|
622
|
{"pl","0PcUoGxQa6s","Bandaged 3x3 v.A cube","MrUK"},
|
623
|
{"kr","1RePOLrzJNE","밴디지 타입 A 해법","듀나메스 큐브 해법연구소"},
|
624
|
{"vn","vg4J0U0n1oA","Tutorial N.1 - Bandaged VA","Duy Thích Rubik"},
|
625
|
};
|
626
|
}
|
627
|
if( mPosition==POS_2 )
|
628
|
{
|
629
|
return new String[][]{
|
630
|
{"ru","lS_EK0PMWI8","Как собрать 2-bar Cube","Алексей Ярыгин"},
|
631
|
{"pl","tX8ubTLh6p8","Bandaged 3x3 (Two bar)","MrUK"},
|
632
|
{"kr","NE6XuC1r8xw","밴디지 큐브","Denzel Washington"},
|
633
|
};
|
634
|
}
|
635
|
if( mPosition==POS_3 )
|
636
|
{
|
637
|
return new String[][]{
|
638
|
{"gb","7UiCVGygUT4","Bandage Cube C Tutorial","PolyakB"},
|
639
|
{"ru","gXenRA92Wdc","Как собрать Bandaged 3x3 Type C","YG Cuber"},
|
640
|
{"pl","sKfdFLm79Zs","Bandaged 3x3 v.C cube","MrUK"},
|
641
|
{"kr","BcCFgeFy6Ec","밴디지 타입 C 해법","듀나메스 큐브 해법연구소"},
|
642
|
{"vn","9674LLkPSog","Tutorial N.2 - Bandaged VC","Duy Thích Rubik"},
|
643
|
};
|
644
|
}
|
645
|
if( mPosition==POS_4 )
|
646
|
{
|
647
|
return new String[][]{
|
648
|
{"gb","AnpdIKICBpM","Trying to Solve a Bandaged Cube","RedKB"},
|
649
|
{"es","cUyo5fycrvI","Tutorial Bandaged Cube en español","Rafa Garcia Benacazon"},
|
650
|
{"ru","-MTzeEJptsg","Как собрать bandaged Cube B","стратегия знаний"},
|
651
|
{"fr","3rsfIJ3roT0","Tutoriel: résolution du Bicube","Skieur Cubb"},
|
652
|
{"de","sqWVRwkXX9w","Bandaged Cube - Tutorial","GerCubing"},
|
653
|
{"pl","XcHzTvVR6Po","Bandaged 3x3 v.B cube","MrUK"},
|
654
|
{"kr","1gsoijF_5q0","BiCube Tutorial (해법)","듀나메스 큐브 해법연구소"},
|
655
|
{"vn","ZCJDaF4jEbc","Tutorial N.3 - BiCube","Duy Thích Rubik"},
|
656
|
};
|
657
|
}
|
658
|
|
659
|
return null;
|
660
|
}
|
661
|
}
|