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