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