1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2021 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
|
|
27
|
import org.distorted.objectlib.helpers.ObjectFaceShape;
|
28
|
import org.distorted.objectlib.helpers.ObjectSignature;
|
29
|
import org.distorted.objectlib.main.InitData;
|
30
|
import org.distorted.objectlib.main.ObjectType;
|
31
|
import org.distorted.objectlib.helpers.ObjectShape;
|
32
|
import org.distorted.objectlib.scrambling.ScrambleState;
|
33
|
|
34
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
35
|
|
36
|
public class TwistySquare2 extends TwistySquare
|
37
|
{
|
38
|
private ScrambleState[] mStates;
|
39
|
private int[] mQuatIndex;
|
40
|
private float[][] mCenters;
|
41
|
|
42
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
43
|
|
44
|
public TwistySquare2(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
|
45
|
{
|
46
|
super(data, meshState, iconMode, quat, move, scale, stream);
|
47
|
}
|
48
|
|
49
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
50
|
|
51
|
@Override
|
52
|
public int[][] getSolvedQuats()
|
53
|
{
|
54
|
return new int[][]
|
55
|
{
|
56
|
{ 2, 0,1 }, // 2 middle cubits in the first group
|
57
|
{12, 2,4,6,8,10,12,14,16,19,21,23,25, 17 }, // 12 front and back edges and corners in the second group with quat[17]
|
58
|
{12, 3,5,7,9,11,13,15,17,18,20,22,24, 23 } // 12 left and right edges and corners in the third group with quat[23]
|
59
|
};
|
60
|
}
|
61
|
|
62
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
63
|
|
64
|
public ScrambleState[] getScrambleStates()
|
65
|
{
|
66
|
if( mStates==null )
|
67
|
{
|
68
|
int[] SL_6 = new int[] { 0,1,1, 1,1,1, 0,1,1, 1,1,1, 0,1,1, 1,1,1, 0,1,1, 1,1,1, 0,1,1, 1,1,1, 0,1,1, 1,1,1};
|
69
|
int[] SL_1 = new int[] { 0,1,1, 1,1,1 };
|
70
|
int[] LO_2 = new int[] { 0,-5,2, 0,-4,2, 0,-3,2, 0,-2,2, 0,-1,2, 0,1,2, 0,2,2, 0,3,2, 0,4,2, 0,5,2, 0,5,2 };
|
71
|
int[] LO_3 = new int[] { 0,-5,3, 0,-4,3, 0,-3,3, 0,-2,3, 0,-1,3, 0,1,3, 0,2,3, 0,3,3, 0,4,3, 0,5,3, 0,5,3 };
|
72
|
int[] LO_4 = new int[] { 0,-5,4, 0,-4,4, 0,-3,4, 0,-2,4, 0,-1,4, 0,1,4, 0,2,4, 0,3,4, 0,4,4, 0,5,4, 0,5,4 };
|
73
|
|
74
|
mStates = new ScrambleState[]
|
75
|
{
|
76
|
new ScrambleState( new int[][] { LO_2, SL_6, LO_3 } ), // 0
|
77
|
new ScrambleState( new int[][] { LO_2, null, LO_3 } ), // SL
|
78
|
new ScrambleState( new int[][] { null, SL_1, LO_4 } ), // LO
|
79
|
new ScrambleState( new int[][] { LO_4, SL_1, null } ), // UP
|
80
|
new ScrambleState( new int[][] { null, SL_1, null } ), // UL
|
81
|
};
|
82
|
}
|
83
|
|
84
|
return mStates;
|
85
|
}
|
86
|
|
87
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
88
|
|
89
|
public float[][] getCubitPositions(int[] numLayers)
|
90
|
{
|
91
|
if( mCenters ==null )
|
92
|
{
|
93
|
float Y = 0.75f + X/2;
|
94
|
|
95
|
mCenters = new float[][]
|
96
|
{
|
97
|
{ 1.5f, 0.0f, 0.0f }, // 0
|
98
|
{-1.5f, 0.0f, 0.0f },
|
99
|
|
100
|
{ 0.0f, 1.0f, 1.5f }, // 2
|
101
|
{ 1.5f, 1.0f, 0.0f },
|
102
|
{ 0.0f, 1.0f,-1.5f },
|
103
|
{-1.5f, 1.0f, 0.0f },
|
104
|
{ 0.0f,-1.0f, 1.5f },
|
105
|
{ 1.5f,-1.0f, 0.0f },
|
106
|
{ 0.0f,-1.0f,-1.5f },
|
107
|
{-1.5f,-1.0f, 0.0f },
|
108
|
|
109
|
{ Y, 1.0f, 1.5f }, // 10
|
110
|
{ 1.5f, 1.0f, -Y },
|
111
|
{ -Y, 1.0f,-1.5f },
|
112
|
{-1.5f, 1.0f, Y },
|
113
|
{ Y,-1.0f, 1.5f },
|
114
|
{ 1.5f,-1.0f, -Y },
|
115
|
{ -Y,-1.0f,-1.5f },
|
116
|
{-1.5f,-1.0f, Y },
|
117
|
|
118
|
{ 1.5f, 1.0f, Y }, // 18
|
119
|
{ Y, 1.0f,-1.5f },
|
120
|
{-1.5f, 1.0f, -Y },
|
121
|
{ -Y, 1.0f, 1.5f },
|
122
|
{ 1.5f,-1.0f, Y },
|
123
|
{ Y,-1.0f,-1.5f },
|
124
|
{-1.5f,-1.0f, -Y },
|
125
|
{ -Y,-1.0f, 1.5f },
|
126
|
};
|
127
|
}
|
128
|
|
129
|
return mCenters;
|
130
|
}
|
131
|
|
132
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
133
|
|
134
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
135
|
{
|
136
|
if( mQuatIndex==null )
|
137
|
{
|
138
|
mQuatIndex = new int[]
|
139
|
{
|
140
|
0, 6,
|
141
|
0, 9, 6, 3,17,14,23,20,
|
142
|
0, 9, 6, 3, 0, 9, 6, 3,14, 23, 20, 17, 14, 23, 20, 17
|
143
|
};
|
144
|
}
|
145
|
|
146
|
return mObjectQuats[mQuatIndex[cubit]];
|
147
|
}
|
148
|
|
149
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
150
|
|
151
|
public ObjectShape getObjectShape(int variant)
|
152
|
{
|
153
|
if( variant==0 )
|
154
|
{
|
155
|
float[][] vertices =
|
156
|
{
|
157
|
{ -1.5f-X, 0.5f, 1.5f },
|
158
|
{ 0.0f, 0.5f, 1.5f },
|
159
|
{ 0.0f, 0.5f,-1.5f },
|
160
|
{ -1.5f+X, 0.5f,-1.5f },
|
161
|
{ -1.5f-X,-0.5f, 1.5f },
|
162
|
{ 0.0f,-0.5f, 1.5f },
|
163
|
{ 0.0f,-0.5f,-1.5f },
|
164
|
{ -1.5f+X,-0.5f,-1.5f }
|
165
|
};
|
166
|
|
167
|
int[][] indices =
|
168
|
{
|
169
|
{4,5,1,0},
|
170
|
{5,6,2,1},
|
171
|
{6,7,3,2},
|
172
|
{7,4,0,3},
|
173
|
{0,1,2,3},
|
174
|
{7,6,5,4}
|
175
|
};
|
176
|
|
177
|
return new ObjectShape(vertices, indices);
|
178
|
}
|
179
|
else if( variant==1 )
|
180
|
{
|
181
|
float[][] vertices =
|
182
|
{
|
183
|
{ -X, 0.5f, 0.0f },
|
184
|
{ +X, 0.5f, 0.0f },
|
185
|
{0.0f, 0.5f,-1.5f },
|
186
|
{ -X,-0.5f, 0.0f },
|
187
|
{ +X,-0.5f, 0.0f },
|
188
|
{0.0f,-0.5f,-1.5f },
|
189
|
};
|
190
|
|
191
|
int[][] indices =
|
192
|
{
|
193
|
{0,1,2},
|
194
|
{3,4,1,0},
|
195
|
{5,4,3},
|
196
|
{4,5,2,1},
|
197
|
{5,3,0,2}
|
198
|
};
|
199
|
|
200
|
return new ObjectShape(vertices, indices);
|
201
|
}
|
202
|
else
|
203
|
{
|
204
|
float[][] vertices =
|
205
|
{
|
206
|
{-0.75f+X/2, 0.5f, 0.0f },
|
207
|
{ 0.75f-X/2, 0.5f, 0.0f },
|
208
|
{-0.75f-X/2, 0.5f, -1.5f },
|
209
|
{-0.75f+X/2,-0.5f, 0.0f },
|
210
|
{ 0.75f-X/2,-0.5f, 0.0f },
|
211
|
{-0.75f-X/2,-0.5f, -1.5f }
|
212
|
};
|
213
|
int[][] indices =
|
214
|
{
|
215
|
{0,1,2},
|
216
|
{3,4,1,0},
|
217
|
{5,4,3},
|
218
|
{4,5,2,1},
|
219
|
{5,3,0,2}
|
220
|
};
|
221
|
|
222
|
return new ObjectShape(vertices, indices);
|
223
|
}
|
224
|
}
|
225
|
|
226
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
227
|
|
228
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
229
|
{
|
230
|
if( variant==0 )
|
231
|
{
|
232
|
float h1 = isInIconMode() ? 0.001f : 0.04f;
|
233
|
float h2 = isInIconMode() ? 0.001f : 0.02f;
|
234
|
float[][] bands = { {h1,35,0.2f,0.8f,5,2,1}, {h2,35,0.5f,1.0f,5,2,1}, {0.001f,35,0.3f,0.8f,5,2,1} };
|
235
|
int[] bandIndices = { 0,0,1,2,2,2 };
|
236
|
float[][] corners = { {0.03f,0.05f} };
|
237
|
int[] cornerIndices = { 0,0,0,0,0,0,0,0 };
|
238
|
float[][] centers = { { -0.75f, 0.0f, 0.0f} };
|
239
|
int[] centerIndices = { 0,0,0,0,0,0,0,0 };
|
240
|
return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
|
241
|
}
|
242
|
else if( variant==1 )
|
243
|
{
|
244
|
float h1 = isInIconMode() ? 0.001f : 0.038f;
|
245
|
float[][] bands = { {h1,35,0.5f,0.9f, 5,2,1}, {0.001f,35,0.5f,0.9f, 5,2,1} };
|
246
|
int[] bandIndices = { 0,0,0,1,1 };
|
247
|
float[][] corners = { {0.04f,0.15f} };
|
248
|
int[] cornerIndices = { 0,0,-1,0,0,-1 };
|
249
|
float[][] centers = { { 0.0f, 0.0f,-0.5f} };
|
250
|
int[] centerIndices = { 0,0,-1,0,0,-1 };
|
251
|
return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
|
252
|
}
|
253
|
else
|
254
|
{
|
255
|
float h1 = isInIconMode() ? 0.001f : 0.03f;
|
256
|
float[][] bands = { {h1,35,0.9f,1.0f, 5,2,1}, {0.001f,35,0.9f,1.0f, 5,2,1} };
|
257
|
int[] bandIndices = { 0,0,0,1,1 };
|
258
|
float[][] corners = { {0.05f,0.13f} };
|
259
|
int[] cornerIndices = { 0,0,-1,0,0,-1 };
|
260
|
float[][] centers = { { 0.0f, 0.0f,-0.5f} };
|
261
|
int[] centerIndices = { 0,0,-1,0,0,-1 };
|
262
|
return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
|
263
|
}
|
264
|
}
|
265
|
|
266
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
267
|
|
268
|
public int getNumCubitVariants(int[] numLayers)
|
269
|
{
|
270
|
return 3;
|
271
|
}
|
272
|
|
273
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
274
|
|
275
|
public int getCubitVariant(int cubit, int[] numLayers)
|
276
|
{
|
277
|
return cubit<2 ? 0 : (cubit<10 ? 1:2);
|
278
|
}
|
279
|
|
280
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
281
|
|
282
|
public float getStickerRadius()
|
283
|
{
|
284
|
return 0.12f;
|
285
|
}
|
286
|
|
287
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
288
|
|
289
|
public float getStickerStroke()
|
290
|
{
|
291
|
return isInIconMode() ? 0.20f : 0.10f;
|
292
|
}
|
293
|
|
294
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
295
|
|
296
|
public float[][] getStickerAngles()
|
297
|
{
|
298
|
return null;
|
299
|
}
|
300
|
|
301
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
302
|
// PUBLIC API
|
303
|
|
304
|
public String getShortName()
|
305
|
{
|
306
|
return ObjectType.SQU2_3.name();
|
307
|
}
|
308
|
|
309
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
310
|
|
311
|
public ObjectSignature getSignature()
|
312
|
{
|
313
|
return new ObjectSignature(ObjectType.SQU2_3);
|
314
|
}
|
315
|
|
316
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
317
|
|
318
|
public String getObjectName()
|
319
|
{
|
320
|
return "Square-2";
|
321
|
}
|
322
|
|
323
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
324
|
|
325
|
public String getInventor()
|
326
|
{
|
327
|
return "David Litwin";
|
328
|
}
|
329
|
|
330
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
331
|
|
332
|
public int getYearOfInvention()
|
333
|
{
|
334
|
return 1995;
|
335
|
}
|
336
|
|
337
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
338
|
|
339
|
public int getComplexity()
|
340
|
{
|
341
|
return 3;
|
342
|
}
|
343
|
|
344
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
345
|
|
346
|
public String[][] getTutorials()
|
347
|
{
|
348
|
return new String[][] {
|
349
|
{"gb","PPXojiFthEs","Square-2 Tutorial","SuperAntoniovivaldi"},
|
350
|
{"es","IiMwc51xKBQ","Cómo resolver Square-2","skieur cubb"},
|
351
|
{"ru","XZ6m8uF5oUk","Как собрать Square-2.","Илья Топор-Гилка"},
|
352
|
{"fr","R-m9IgYAFPA","Tutoriel: résolution du Square-2","skieur cubb"},
|
353
|
{"pl","SukHyoMzcgM","Square-2 TUTORIAL PL","MrUk"},
|
354
|
{"br","T3ts5gHLJV8","Tutorial do Square-2 1/2","Rafael Cinoto"},
|
355
|
{"br","4wwWE5Ni0Fw","Tutorial do Square-2 2/2","Rafael Cinoto"},
|
356
|
{"kr","psG9Ar4pBrc","초보자를 위한 스퀘어2 해법","SlowCuberToumai"},
|
357
|
{"vn","_37Pc8Y_-Hs","Square-2 Tutorial","VĂN CÔNG TÙNG"},
|
358
|
};
|
359
|
}
|
360
|
}
|