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 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.InitData;
|
30
|
import org.distorted.objectlib.scrambling.ScrambleState;
|
31
|
import org.distorted.objectlib.main.ObjectType;
|
32
|
import org.distorted.objectlib.main.ShapeHexahedron;
|
33
|
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
|
34
|
|
35
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_CHANGING_SHAPEMOD;
|
36
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
|
37
|
|
38
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
39
|
|
40
|
public class TwistyContainer extends ShapeHexahedron
|
41
|
{
|
42
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
43
|
{
|
44
|
new Static3D( SQ6/3,-SQ3/3, 0.0f),
|
45
|
new Static3D( SQ6/3, SQ3/3, 0.0f),
|
46
|
new Static3D( 0.0f,-SQ3/3, SQ6/3),
|
47
|
new Static3D( 0.0f, SQ3/3, SQ6/3)
|
48
|
};
|
49
|
|
50
|
private ScrambleState[] mStates;
|
51
|
private int[][] mBasicAngle;
|
52
|
private float[][] mCuts;
|
53
|
private int[][] mFaceMap;
|
54
|
|
55
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
56
|
|
57
|
public TwistyContainer(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
|
58
|
{
|
59
|
super(data, meshState, iconMode, data.getNumLayers()[0], quat, move, scale, stream);
|
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 ScrambleState[] getScrambleStates()
|
97
|
{
|
98
|
if( mStates==null )
|
99
|
{
|
100
|
int[] tmp = {0,-1,0, 0,1,0, 1,-1,0, 1,1,0 };
|
101
|
|
102
|
mStates = new ScrambleState[]
|
103
|
{
|
104
|
new ScrambleState( new int[][] {tmp,tmp,tmp,tmp} )
|
105
|
};
|
106
|
}
|
107
|
|
108
|
return mStates;
|
109
|
}
|
110
|
|
111
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
112
|
|
113
|
public float[][] getCuts(int[] numLayers)
|
114
|
{
|
115
|
if( mCuts==null )
|
116
|
{
|
117
|
float[] c = {0};
|
118
|
mCuts = new float[][] {c,c,c,c};
|
119
|
}
|
120
|
|
121
|
return mCuts;
|
122
|
}
|
123
|
|
124
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
125
|
|
126
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
127
|
{
|
128
|
boolean[] tmp = {true,true};
|
129
|
return new boolean[][] { tmp,tmp,tmp,tmp };
|
130
|
}
|
131
|
|
132
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
133
|
|
134
|
public int getTouchControlType()
|
135
|
{
|
136
|
return TC_CHANGING_SHAPEMOD;
|
137
|
}
|
138
|
|
139
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
140
|
|
141
|
public int getTouchControlSplit()
|
142
|
{
|
143
|
return TYPE_NOT_SPLIT;
|
144
|
}
|
145
|
|
146
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
147
|
|
148
|
public int[][][] getEnabled()
|
149
|
{
|
150
|
return null;
|
151
|
}
|
152
|
|
153
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
154
|
|
155
|
public float[] getDist3D(int[] numLayers)
|
156
|
{
|
157
|
return new float[] { 0.5f,0.5f,SQ2/2,SQ2/2,0.5f,0.5f};
|
158
|
}
|
159
|
|
160
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
161
|
|
162
|
public Static3D[] getFaceAxis()
|
163
|
{
|
164
|
return TouchControlHexahedron.FACE_AXIS;
|
165
|
}
|
166
|
|
167
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
168
|
|
169
|
public float[][] getCubitPositions(int[] numLayers)
|
170
|
{
|
171
|
return new float[][]
|
172
|
{
|
173
|
{ 0.0f, -SQ2, 0.0f},
|
174
|
{ 0.0f, +SQ2, 0.0f},
|
175
|
|
176
|
{ 1.0f, 0.0f,-1.0f},
|
177
|
{-1.0f, 0.0f,-1.0f},
|
178
|
{-1.0f, 0.0f, 1.0f},
|
179
|
{ 1.0f, 0.0f, 1.0f},
|
180
|
|
181
|
{ 0.0f,-SQ2/2, 1.0f},
|
182
|
{ 0.0f,+SQ2/2, 1.0f},
|
183
|
{ 1.0f,-SQ2/2, 0.0f},
|
184
|
{ 1.0f, SQ2/2, 0.0f},
|
185
|
{ 0.0f,-SQ2/2,-1.0f},
|
186
|
{ 0.0f,+SQ2/2,-1.0f},
|
187
|
{-1.0f,-SQ2/2, 0.0f},
|
188
|
{-1.0f, SQ2/2, 0.0f},
|
189
|
};
|
190
|
}
|
191
|
|
192
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
193
|
|
194
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
195
|
{
|
196
|
switch(cubit)
|
197
|
{
|
198
|
case 0: return mObjectQuats[ 0];
|
199
|
case 1: return mObjectQuats[10];
|
200
|
|
201
|
case 2: return mObjectQuats[ 0];
|
202
|
case 3: return new Static4D( 0.0f, SQ2/2, 0.0f,-SQ2/2);
|
203
|
case 4: return mObjectQuats[11];
|
204
|
case 5: return new Static4D( 0.0f, SQ2/2, 0.0f, SQ2/2);
|
205
|
|
206
|
case 6: return mObjectQuats[ 0];
|
207
|
case 7: return new Static4D( 0.0f, 0.0f, 1.0f, 0.0f);
|
208
|
case 8: return new Static4D( 0.0f, SQ2/2, 0.0f,-SQ2/2);
|
209
|
case 9: return mObjectQuats[10];
|
210
|
case 10: return mObjectQuats[11];
|
211
|
case 11: return new Static4D( 1.0f, 0.0f, 0.0f, 0.0f);
|
212
|
case 12: return new Static4D( 0.0f, SQ2/2, 0.0f, SQ2/2);
|
213
|
case 13: return mObjectQuats[ 9];
|
214
|
}
|
215
|
|
216
|
return null;
|
217
|
}
|
218
|
|
219
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
220
|
|
221
|
public ObjectShape getObjectShape(int variant)
|
222
|
{
|
223
|
if( variant==0 )
|
224
|
{
|
225
|
float[][] vertices= { {-1,0,1},{1,0,1},{1,0,-1},{-1,0,-1},{0,SQ2,0} };
|
226
|
int[][] indices = { {3,2,1,0},{0,1,4},{1,2,4},{2,3,4},{3,0,4} };
|
227
|
return new ObjectShape(vertices, indices);
|
228
|
}
|
229
|
else if( variant==1 )
|
230
|
{
|
231
|
float[][] vertices= { {-1,0,1},{0,0,1},{-1,0,0},{0,SQ2,0},{0,-SQ2,0} };
|
232
|
int[][] indices = { {4,3,1},{4,2,3},{2,0,3},{3,0,1},{1,0,4},{0,2,4} };
|
233
|
return new ObjectShape(vertices, indices);
|
234
|
}
|
235
|
else
|
236
|
{
|
237
|
float[][] vertices= { {-1,-SQ2/2,0},{1,-SQ2/2,0},{0,SQ2/2,0},{0,SQ2/2,-1} };
|
238
|
int[][] indices = { {0,1,2},{0,2,3},{1,3,2},{1,0,3} };
|
239
|
return new ObjectShape(vertices, indices);
|
240
|
}
|
241
|
}
|
242
|
|
243
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
244
|
|
245
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
246
|
{
|
247
|
if( variant==0 )
|
248
|
{
|
249
|
float h1 = isInIconMode() ? 0.001f : 0.05f;
|
250
|
float h2 = isInIconMode() ? 0.001f : 0.01f;
|
251
|
float[][] bands = { {h1,35,0.26f,0.7f,5,1,1}, {h2,15,0.1f,0.7f,5,1,1} };
|
252
|
int[] bandIndices = { 0,1,1,1,1 };
|
253
|
float[][] corners = { {0.03f,0.20f} };
|
254
|
int[] indices = { 0,0,0,0,-1 };
|
255
|
float[][] centers = { { 0.0f, SQ2, 0.0f} };
|
256
|
return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
|
257
|
}
|
258
|
else if( variant==1 )
|
259
|
{
|
260
|
float h1 = isInIconMode() ? 0.001f : 0.04f;
|
261
|
float h2 = isInIconMode() ? 0.001f : 0.01f;
|
262
|
float[][] bands = { {h1,25,0.26f,0.7f,5,1,1}, {h2,15,0.1f,0.7f,5,1,1} };
|
263
|
int[] bandIndices = { 0,0,1,1,1,1 };
|
264
|
float[][] corners = { {0.03f,0.20f} };
|
265
|
int[] indices = { -1,0,0,0,0 };
|
266
|
float[][] centers = { {-1,0,1} };
|
267
|
return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,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
|
float[][] corners = { {0.03f,0.20f} };
|
276
|
int[] indices = { 0,0,0,-1 };
|
277
|
float[][] centers = { {0.0f, SQ2/2, -1.0f} };
|
278
|
return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
|
279
|
}
|
280
|
}
|
281
|
|
282
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
283
|
|
284
|
public int getNumCubitVariants(int[] numLayers)
|
285
|
{
|
286
|
return 3;
|
287
|
}
|
288
|
|
289
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
290
|
|
291
|
public int getCubitVariant(int cubit, int[] numLayers)
|
292
|
{
|
293
|
return cubit<2 ? 0 : (cubit<6 ? 1:2);
|
294
|
}
|
295
|
|
296
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
297
|
|
298
|
public float getStickerRadius()
|
299
|
{
|
300
|
return 0.10f;
|
301
|
}
|
302
|
|
303
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
304
|
|
305
|
public float getStickerStroke()
|
306
|
{
|
307
|
return isInIconMode() ? 0.20f : 0.06f;
|
308
|
}
|
309
|
|
310
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
311
|
|
312
|
public float[][] getStickerAngles()
|
313
|
{
|
314
|
return null;
|
315
|
}
|
316
|
|
317
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
318
|
// PUBLIC API
|
319
|
|
320
|
public Static3D[] getRotationAxis()
|
321
|
{
|
322
|
return ROT_AXIS;
|
323
|
}
|
324
|
|
325
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
326
|
|
327
|
public int[][] getBasicAngles()
|
328
|
{
|
329
|
if( mBasicAngle ==null )
|
330
|
{
|
331
|
int num = getNumLayers()[0];
|
332
|
int[] tmp = new int[num];
|
333
|
for(int i=0; i<num; i++) tmp[i] = 3;
|
334
|
mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
|
335
|
}
|
336
|
|
337
|
return mBasicAngle;
|
338
|
}
|
339
|
|
340
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
341
|
|
342
|
public String getShortName()
|
343
|
{
|
344
|
return ObjectType.CONT_2.name();
|
345
|
}
|
346
|
|
347
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
348
|
|
349
|
public ObjectSignature getSignature()
|
350
|
{
|
351
|
return new ObjectSignature(ObjectType.CONT_2);
|
352
|
}
|
353
|
|
354
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
355
|
|
356
|
public String getObjectName()
|
357
|
{
|
358
|
return "Container";
|
359
|
}
|
360
|
|
361
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
362
|
|
363
|
public String getInventor()
|
364
|
{
|
365
|
return "Tony Fisher";
|
366
|
}
|
367
|
|
368
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
369
|
|
370
|
public int getYearOfInvention()
|
371
|
{
|
372
|
return 1998;
|
373
|
}
|
374
|
|
375
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
376
|
|
377
|
public int getComplexity()
|
378
|
{
|
379
|
return 2;
|
380
|
}
|
381
|
|
382
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
383
|
|
384
|
public String[][] getTutorials()
|
385
|
{
|
386
|
return new String[][] {
|
387
|
{"gb","THndZ2H7OO4","Container Cube Tutorial","SuperAntoniovivaldi"},
|
388
|
{"es","8K2PeCAcpNU","Tutorial Container Puzzle","GioMart"},
|
389
|
{"ru","rh3rMuESOIM","Как собрать Container cube","RubicsGuide"},
|
390
|
{"fr","V4lmnbLjUdc","Résolution du Container Cube","skieur cubb"},
|
391
|
{"de","TRJEIgcda0Y","Container Cube Tutorial","Pezcraft"},
|
392
|
{"pl","jdJpUc-LaKY","Container Cube TUTORIAL PL","MrUK"},
|
393
|
{"br","44JnUyGTAD8","Tutorial do Cubo Container","Cubo vicio"},
|
394
|
{"kr","6HJKHLxaIPk","컨테이너 큐브 해법 강좌","굿맨's 큐브 이야기"},
|
395
|
{"vn","RLD9srIrDcI","Tutorial N.97 - Container","Duy Thích Rubik"},
|
396
|
};
|
397
|
}
|
398
|
}
|