1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2020 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 org.distorted.library.type.Static3D;
|
13
|
import org.distorted.library.type.Static4D;
|
14
|
import org.distorted.objectlib.helpers.FactoryCubit;
|
15
|
import org.distorted.objectlib.helpers.ObjectFaceShape;
|
16
|
import org.distorted.objectlib.helpers.ObjectShape;
|
17
|
import org.distorted.objectlib.metadata.Metadata;
|
18
|
import org.distorted.objectlib.helpers.ObjectVertexEffects;
|
19
|
import org.distorted.objectlib.main.InitAssets;
|
20
|
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator;
|
21
|
import org.distorted.objectlib.metadata.ListObjects;
|
22
|
import org.distorted.objectlib.shape.ShapeHexahedron;
|
23
|
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
|
24
|
|
25
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_CHANGING_SHAPEMOD;
|
26
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
|
27
|
|
28
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
29
|
|
30
|
public class TwistyContainer extends ShapeHexahedron
|
31
|
{
|
32
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
33
|
{
|
34
|
new Static3D( SQ6/3,-SQ3/3, 0.0f),
|
35
|
new Static3D( SQ6/3, SQ3/3, 0.0f),
|
36
|
new Static3D( 0.0f,-SQ3/3, SQ6/3),
|
37
|
new Static3D( 0.0f, SQ3/3, SQ6/3)
|
38
|
};
|
39
|
|
40
|
private int[][] mEdges;
|
41
|
private int[][] mBasicAngle;
|
42
|
private float[][] mCuts;
|
43
|
private int[][] mFaceMap;
|
44
|
|
45
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
46
|
|
47
|
public TwistyContainer(int iconMode, Static4D quat, Static3D move, float scale, Metadata meta, InitAssets asset)
|
48
|
{
|
49
|
super(iconMode, meta.getNumLayers()[0], quat, move, scale, meta, asset);
|
50
|
}
|
51
|
|
52
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
53
|
|
54
|
@Override
|
55
|
public float[][] returnRotationFactor()
|
56
|
{
|
57
|
float C = 1.3f;
|
58
|
float[] f = new float[] {C,C};
|
59
|
return new float[][] { f,f,f,f };
|
60
|
}
|
61
|
|
62
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
63
|
// we want colorful insides
|
64
|
|
65
|
@Override
|
66
|
public int getCubitFaceMap(int cubit, int face)
|
67
|
{
|
68
|
if( mFaceMap==null )
|
69
|
{
|
70
|
mFaceMap = new int[][]
|
71
|
{
|
72
|
{ 3, 3, 3, 3, 3, 3},
|
73
|
{ 2, 2, 2, 2, 2, 2},
|
74
|
|
75
|
{ 0, 5, 5, 0, 0, 5},
|
76
|
{ 5, 1, 1, 5, 5, 1},
|
77
|
{ 1, 4, 4, 1, 1, 4},
|
78
|
{ 4, 0, 0, 4, 4, 0},
|
79
|
|
80
|
{ 4, 4, 4, 4, 4, 4},
|
81
|
{ 4, 4, 4, 4, 4, 4},
|
82
|
{ 0, 0, 0, 0, 0, 0},
|
83
|
{ 0, 0, 0, 0, 0, 0},
|
84
|
{ 5, 5, 5, 5, 5, 5},
|
85
|
{ 5, 5, 5, 5, 5, 5},
|
86
|
{ 1, 1, 1, 1, 1, 1},
|
87
|
{ 1, 1, 1, 1, 1, 1},
|
88
|
};
|
89
|
}
|
90
|
|
91
|
return mFaceMap[cubit][face];
|
92
|
}
|
93
|
|
94
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
95
|
|
96
|
public int[][] getScrambleEdges()
|
97
|
{
|
98
|
if( mEdges==null ) mEdges = ScrambleEdgeGenerator.getScrambleEdgesSingle(mBasicAngle);
|
99
|
return mEdges;
|
100
|
}
|
101
|
|
102
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
103
|
|
104
|
public float[][] getCuts(int[] numLayers)
|
105
|
{
|
106
|
if( mCuts==null )
|
107
|
{
|
108
|
float[] c = {0};
|
109
|
mCuts = new float[][] {c,c,c,c};
|
110
|
}
|
111
|
|
112
|
return mCuts;
|
113
|
}
|
114
|
|
115
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
116
|
|
117
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
118
|
{
|
119
|
boolean[] tmp = {true,true};
|
120
|
return new boolean[][] { tmp,tmp,tmp,tmp };
|
121
|
}
|
122
|
|
123
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
124
|
|
125
|
public int getTouchControlType()
|
126
|
{
|
127
|
return TC_CHANGING_SHAPEMOD;
|
128
|
}
|
129
|
|
130
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
131
|
|
132
|
public int getTouchControlSplit()
|
133
|
{
|
134
|
return TYPE_NOT_SPLIT;
|
135
|
}
|
136
|
|
137
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
138
|
|
139
|
public int[][][] getEnabled()
|
140
|
{
|
141
|
return null;
|
142
|
}
|
143
|
|
144
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
145
|
|
146
|
public float[] getDist3D(int[] numLayers)
|
147
|
{
|
148
|
return new float[] { 0.5f,0.5f,SQ2/2,SQ2/2,0.5f,0.5f};
|
149
|
}
|
150
|
|
151
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
152
|
|
153
|
public Static3D[] getFaceAxis()
|
154
|
{
|
155
|
return TouchControlHexahedron.FACE_AXIS;
|
156
|
}
|
157
|
|
158
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
159
|
|
160
|
public float[][] getCubitPositions(int[] numLayers)
|
161
|
{
|
162
|
return new float[][]
|
163
|
{
|
164
|
{ 0.0f, -SQ2, 0.0f},
|
165
|
{ 0.0f, SQ2, 0.0f},
|
166
|
|
167
|
{ 1.0f, 0.0f,-1.0f},
|
168
|
{-1.0f, 0.0f,-1.0f},
|
169
|
{-1.0f, 0.0f, 1.0f},
|
170
|
{ 1.0f, 0.0f, 1.0f},
|
171
|
|
172
|
{ 0.0f,-SQ2/2, 1.0f},
|
173
|
{ 0.0f, SQ2/2, 1.0f},
|
174
|
{ 1.0f,-SQ2/2, 0.0f},
|
175
|
{ 1.0f, SQ2/2, 0.0f},
|
176
|
{ 0.0f,-SQ2/2,-1.0f},
|
177
|
{ 0.0f, SQ2/2,-1.0f},
|
178
|
{-1.0f,-SQ2/2, 0.0f},
|
179
|
{-1.0f, SQ2/2, 0.0f},
|
180
|
};
|
181
|
}
|
182
|
|
183
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
184
|
|
185
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
186
|
{
|
187
|
switch(cubit)
|
188
|
{
|
189
|
case 0: return mObjectQuats[ 0];
|
190
|
case 1: return mObjectQuats[10];
|
191
|
|
192
|
case 2: return mObjectQuats[ 0];
|
193
|
case 3: return new Static4D( 0.0f, SQ2/2, 0.0f,-SQ2/2);
|
194
|
case 4: return mObjectQuats[11];
|
195
|
case 5: return new Static4D( 0.0f, SQ2/2, 0.0f, SQ2/2);
|
196
|
|
197
|
case 6: return mObjectQuats[ 0];
|
198
|
case 7: return new Static4D( 0.0f, 0.0f, 1.0f, 0.0f);
|
199
|
case 8: return new Static4D( 0.0f, SQ2/2, 0.0f,-SQ2/2);
|
200
|
case 9: return mObjectQuats[10];
|
201
|
case 10: return mObjectQuats[11];
|
202
|
case 11: return new Static4D( 1.0f, 0.0f, 0.0f, 0.0f);
|
203
|
case 12: return new Static4D( 0.0f, SQ2/2, 0.0f, SQ2/2);
|
204
|
case 13: return mObjectQuats[ 9];
|
205
|
}
|
206
|
|
207
|
return null;
|
208
|
}
|
209
|
|
210
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
211
|
|
212
|
private float[][] getVertices(int variant)
|
213
|
{
|
214
|
if( variant==0 )
|
215
|
{
|
216
|
return new float[][] { {-1,0,1},{1,0,1},{1,0,-1},{-1,0,-1},{0,SQ2,0} };
|
217
|
}
|
218
|
else if( variant==1 )
|
219
|
{
|
220
|
return new float[][] { {-1,0,1},{0,0,1},{-1,0,0},{0,SQ2,0},{0,-SQ2,0} };
|
221
|
}
|
222
|
else
|
223
|
{
|
224
|
return new float[][] { {-1,-SQ2/2,0},{1,-SQ2/2,0},{0,SQ2/2,0},{0,SQ2/2,-1} };
|
225
|
}
|
226
|
}
|
227
|
|
228
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
229
|
|
230
|
public ObjectShape getObjectShape(int variant)
|
231
|
{
|
232
|
if( variant==0 )
|
233
|
{
|
234
|
int[][] indices = { {3,2,1,0},{0,1,4},{1,2,4},{2,3,4},{3,0,4} };
|
235
|
return new ObjectShape(getVertices(variant), indices);
|
236
|
}
|
237
|
else if( variant==1 )
|
238
|
{
|
239
|
int[][] indices = { {4,3,1},{4,2,3},{2,0,3},{3,0,1},{1,0,4},{0,2,4} };
|
240
|
return new ObjectShape(getVertices(variant), indices);
|
241
|
}
|
242
|
else
|
243
|
{
|
244
|
int[][] indices = { {0,1,2},{0,2,3},{1,3,2},{1,0,3} };
|
245
|
return new ObjectShape(getVertices(variant), indices);
|
246
|
}
|
247
|
}
|
248
|
|
249
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
250
|
|
251
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
252
|
{
|
253
|
if( variant==0 )
|
254
|
{
|
255
|
float h1 = isInIconMode() ? 0.001f : 0.05f;
|
256
|
float h2 = isInIconMode() ? 0.001f : 0.01f;
|
257
|
float[][] bands = { {h1,35,0.26f,0.7f,5,1,1}, {h2,15,0.1f,0.7f,5,1,1} };
|
258
|
int[] bandIndices = { 0,1,1,1,1 };
|
259
|
return new ObjectFaceShape(bands,bandIndices,null);
|
260
|
}
|
261
|
else if( variant==1 )
|
262
|
{
|
263
|
float h1 = isInIconMode() ? 0.001f : 0.04f;
|
264
|
float h2 = isInIconMode() ? 0.001f : 0.01f;
|
265
|
float[][] bands = { {h1,25,0.26f,0.7f,5,1,1}, {h2,15,0.1f,0.7f,5,1,1} };
|
266
|
int[] bandIndices = { 0,0,1,1,1,1 };
|
267
|
return new ObjectFaceShape(bands,bandIndices,null);
|
268
|
}
|
269
|
else
|
270
|
{
|
271
|
float h1 = isInIconMode() ? 0.001f : 0.05f;
|
272
|
float h2 = isInIconMode() ? 0.001f : 0.01f;
|
273
|
float[][] bands = { {h1,35,0.26f,0.7f,5,1,1}, {h2,15,0.1f,0.7f,5,1,1} };
|
274
|
int[] bandIndices = { 0,1,1,1 };
|
275
|
return new ObjectFaceShape(bands,bandIndices,null);
|
276
|
}
|
277
|
}
|
278
|
|
279
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
280
|
|
281
|
public ObjectVertexEffects getVertexEffects(int variant)
|
282
|
{
|
283
|
if( variant==0 )
|
284
|
{
|
285
|
float[][] corners = { {0.03f,0.20f} };
|
286
|
int[] indices = { 0,0,0,0,-1 };
|
287
|
float[][] centers = { { 0.0f, SQ2, 0.0f} };
|
288
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
|
289
|
}
|
290
|
else if( variant==1 )
|
291
|
{
|
292
|
float[][] corners = { {0.03f,0.20f} };
|
293
|
int[] indices = { -1,0,0,0,0 };
|
294
|
float[][] centers = { {-1,0,1} };
|
295
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
|
296
|
}
|
297
|
else
|
298
|
{
|
299
|
float[][] corners = { {0.03f,0.20f} };
|
300
|
int[] indices = { 0,0,0,-1 };
|
301
|
float[][] centers = { {0.0f, SQ2/2, -1.0f} };
|
302
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
|
303
|
}
|
304
|
}
|
305
|
|
306
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
307
|
|
308
|
public int getNumCubitVariants(int[] numLayers)
|
309
|
{
|
310
|
return 3;
|
311
|
}
|
312
|
|
313
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
314
|
|
315
|
public int getCubitVariant(int cubit, int[] numLayers)
|
316
|
{
|
317
|
return cubit<2 ? 0 : (cubit<6 ? 1:2);
|
318
|
}
|
319
|
|
320
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
321
|
|
322
|
public float getStickerRadius()
|
323
|
{
|
324
|
return 0.10f;
|
325
|
}
|
326
|
|
327
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
328
|
|
329
|
public float getStickerStroke()
|
330
|
{
|
331
|
return isInIconMode() ? 0.20f : 0.06f;
|
332
|
}
|
333
|
|
334
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
335
|
|
336
|
public float[][][] getStickerAngles()
|
337
|
{
|
338
|
return null;
|
339
|
}
|
340
|
|
341
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
342
|
// PUBLIC API
|
343
|
|
344
|
public Static3D[] getRotationAxis()
|
345
|
{
|
346
|
return ROT_AXIS;
|
347
|
}
|
348
|
|
349
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
350
|
|
351
|
public int[][] getBasicAngles()
|
352
|
{
|
353
|
if( mBasicAngle ==null )
|
354
|
{
|
355
|
int num = getNumLayers()[0];
|
356
|
int[] tmp = new int[num];
|
357
|
for(int i=0; i<num; i++) tmp[i] = 3;
|
358
|
mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
|
359
|
}
|
360
|
|
361
|
return mBasicAngle;
|
362
|
}
|
363
|
|
364
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
365
|
|
366
|
public String getShortName()
|
367
|
{
|
368
|
return ListObjects.CONT_2.name();
|
369
|
}
|
370
|
|
371
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
372
|
|
373
|
public String[][] getTutorials()
|
374
|
{
|
375
|
return new String[][] {
|
376
|
{"gb","THndZ2H7OO4","Container Cube Tutorial","SuperAntoniovivaldi"},
|
377
|
{"es","8K2PeCAcpNU","Tutorial Container Puzzle","GioMart"},
|
378
|
{"ru","rh3rMuESOIM","Как собрать Container cube","RubicsGuide"},
|
379
|
{"fr","V4lmnbLjUdc","Résolution du Container Cube","skieur cubb"},
|
380
|
{"de","TRJEIgcda0Y","Container Cube Tutorial","Pezcraft"},
|
381
|
{"pl","jdJpUc-LaKY","Container Cube TUTORIAL PL","MrUK"},
|
382
|
{"br","44JnUyGTAD8","Tutorial do Cubo Container","Cubo vicio"},
|
383
|
{"kr","6HJKHLxaIPk","컨테이너 큐브 해법 강좌","굿맨's 큐브 이야기"},
|
384
|
{"vn","RLD9srIrDcI","Tutorial N.97 - Container","Duy Thích Rubik"},
|
385
|
{"tw","w8waAaHnxVY","Container Cube Tutorial","不正常魔術方塊研究中心"},
|
386
|
};
|
387
|
}
|
388
|
}
|