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
|
import org.distorted.objectlib.scrambling.ObjectScrambler;
|
25
|
|
26
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
27
|
|
28
|
public class TwistySquare1 extends TwistySquare
|
29
|
{
|
30
|
private int[] mQuatIndex;
|
31
|
private float[][] mCenters;
|
32
|
|
33
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
34
|
|
35
|
public TwistySquare1(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 1.0f;
|
45
|
}
|
46
|
|
47
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
48
|
|
49
|
@Override
|
50
|
public int getScrambleType()
|
51
|
{
|
52
|
return ObjectScrambler.SCRAMBLING_SQUARE1;
|
53
|
}
|
54
|
|
55
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
56
|
|
57
|
public int[][] getScrambleEdges()
|
58
|
{
|
59
|
return null;
|
60
|
}
|
61
|
|
62
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
63
|
|
64
|
public float[][] getCubitPositions(int[] numLayers)
|
65
|
{
|
66
|
if( mCenters==null )
|
67
|
{
|
68
|
mCenters = new float[][]
|
69
|
{
|
70
|
{ 1.5f, 0.0f, 0.0f },
|
71
|
{-1.5f, 0.0f, 0.0f },
|
72
|
|
73
|
{ 0.0f, 1.0f, 1.5f },
|
74
|
{ 1.5f, 1.0f, 0.0f },
|
75
|
{ 0.0f, 1.0f,-1.5f },
|
76
|
{-1.5f, 1.0f, 0.0f },
|
77
|
{ 0.0f,-1.0f, 1.5f },
|
78
|
{ 1.5f,-1.0f, 0.0f },
|
79
|
{ 0.0f,-1.0f,-1.5f },
|
80
|
{-1.5f,-1.0f, 0.0f },
|
81
|
|
82
|
{ 1.0f, 1.0f, 2.0f, 2.0f, 1.0f, 1.0f },
|
83
|
{ 1.0f, 1.0f,-2.0f, 2.0f, 1.0f,-1.0f },
|
84
|
{-1.0f, 1.0f,-2.0f,-2.0f, 1.0f,-1.0f },
|
85
|
{-1.0f, 1.0f, 2.0f,-2.0f, 1.0f, 1.0f },
|
86
|
{ 1.0f,-1.0f, 2.0f, 2.0f,-1.0f, 1.0f },
|
87
|
{ 1.0f,-1.0f,-2.0f, 2.0f,-1.0f,-1.0f },
|
88
|
{-1.0f,-1.0f,-2.0f,-2.0f,-1.0f,-1.0f },
|
89
|
{-1.0f,-1.0f, 2.0f,-2.0f,-1.0f, 1.0f }
|
90
|
};
|
91
|
}
|
92
|
return mCenters;
|
93
|
}
|
94
|
|
95
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
96
|
|
97
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
98
|
{
|
99
|
if( mQuatIndex ==null )
|
100
|
{
|
101
|
mQuatIndex = new int[]
|
102
|
{
|
103
|
0, 6,
|
104
|
0, 9, 6, 3, 17, 14, 23, 20,
|
105
|
0, 9, 6, 3, 14, 23, 20, 17
|
106
|
};
|
107
|
}
|
108
|
|
109
|
return mObjectQuats[mQuatIndex[cubit]];
|
110
|
}
|
111
|
|
112
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
113
|
|
114
|
private float[][] getVertices(int variant)
|
115
|
{
|
116
|
if( variant==0 )
|
117
|
{
|
118
|
return new float[][]
|
119
|
{
|
120
|
{ -1.5f-X, 0.5f, 1.5f },
|
121
|
{ 0.0f, 0.5f, 1.5f },
|
122
|
{ 0.0f, 0.5f,-1.5f },
|
123
|
{ -1.5f+X, 0.5f,-1.5f },
|
124
|
{ -1.5f-X,-0.5f, 1.5f },
|
125
|
{ 0.0f,-0.5f, 1.5f },
|
126
|
{ 0.0f,-0.5f,-1.5f },
|
127
|
{ -1.5f+X,-0.5f,-1.5f }
|
128
|
};
|
129
|
}
|
130
|
else if( variant==1 )
|
131
|
{
|
132
|
return new float[][]
|
133
|
{
|
134
|
{ -X, 0.5f, 0.0f },
|
135
|
{ +X, 0.5f, 0.0f },
|
136
|
{0.0f, 0.5f,-1.5f },
|
137
|
{ -X,-0.5f, 0.0f },
|
138
|
{ +X,-0.5f, 0.0f },
|
139
|
{0.0f,-0.5f,-1.5f },
|
140
|
};
|
141
|
}
|
142
|
else
|
143
|
{
|
144
|
return new float[][]
|
145
|
{
|
146
|
{ X-1.5f, 0.5f, 0.0f },
|
147
|
{ 0.0f, 0.5f, 0.0f },
|
148
|
{ 0.0f, 0.5f,X-1.5f },
|
149
|
{ -1.5f, 0.5f, -1.5f },
|
150
|
{ X-1.5f,-0.5f, 0.0f },
|
151
|
{ 0.0f,-0.5f, 0.0f },
|
152
|
{ 0.0f,-0.5f,X-1.5f },
|
153
|
{ -1.5f,-0.5f, -1.5f }
|
154
|
};
|
155
|
}
|
156
|
}
|
157
|
|
158
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
159
|
|
160
|
public ObjectShape getObjectShape(int variant)
|
161
|
{
|
162
|
if( variant==0 )
|
163
|
{
|
164
|
int[][] indices =
|
165
|
{
|
166
|
{4,5,1,0},
|
167
|
{5,6,2,1},
|
168
|
{6,7,3,2},
|
169
|
{7,4,0,3},
|
170
|
{0,1,2,3},
|
171
|
{7,6,5,4}
|
172
|
};
|
173
|
|
174
|
return new ObjectShape(getVertices(variant), indices);
|
175
|
}
|
176
|
else if( variant==1 )
|
177
|
{
|
178
|
int[][] indices =
|
179
|
{
|
180
|
{0,1,2},
|
181
|
{3,4,1,0},
|
182
|
{5,4,3},
|
183
|
{4,5,2,1},
|
184
|
{5,3,0,2}
|
185
|
};
|
186
|
|
187
|
return new ObjectShape(getVertices(variant), indices);
|
188
|
}
|
189
|
else
|
190
|
{
|
191
|
int[][] indices =
|
192
|
{
|
193
|
{0,1,2,3},
|
194
|
{4,5,1,0},
|
195
|
{5,6,2,1},
|
196
|
{7,4,0,3},
|
197
|
{6,7,3,2},
|
198
|
{7,6,5,4}
|
199
|
};
|
200
|
|
201
|
return new ObjectShape(getVertices(variant), indices);
|
202
|
}
|
203
|
}
|
204
|
|
205
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
206
|
|
207
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
208
|
{
|
209
|
int angle1 = 25;
|
210
|
int angle2 = 35;
|
211
|
float R = 0.2f;
|
212
|
float S = 0.8f;
|
213
|
|
214
|
if( variant==0 )
|
215
|
{
|
216
|
float h1 = isInIconMode() ? 0.001f : 0.04f;
|
217
|
float h2 = isInIconMode() ? 0.001f : 0.02f;
|
218
|
float[][] bands = { {h1,angle1,R,S,5,2,1}, {h2,angle1,R,S,5,2,1}, {0.001f,angle1,R,S,5,2,1} };
|
219
|
int[] indices = { 0,0,1,2,2,2 };
|
220
|
return new ObjectFaceShape(bands,indices,null);
|
221
|
}
|
222
|
else if( variant==1 )
|
223
|
{
|
224
|
float height = isInIconMode() ? 0.001f : 0.038f;
|
225
|
float[][] bands = { {height,angle2,R,S, 5,2,1}, {0.001f,angle2,R,S, 5,2,1} };
|
226
|
int[] indices = { 0,0,0,1,1 };
|
227
|
return new ObjectFaceShape(bands,indices,null);
|
228
|
}
|
229
|
else
|
230
|
{
|
231
|
float height = isInIconMode() ? 0.001f : 0.038f;
|
232
|
float[][] bands = { {height,angle2,R,S, 5,2,1}, {0.001f,angle2,R,S, 5,2,1} };
|
233
|
int[] indices = { 0,0,0,1,1,1 };
|
234
|
return new ObjectFaceShape(bands,indices,null);
|
235
|
}
|
236
|
}
|
237
|
|
238
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
239
|
|
240
|
public ObjectVertexEffects getVertexEffects(int variant)
|
241
|
{
|
242
|
if( variant==0 )
|
243
|
{
|
244
|
float[][] corners = { {0.03f,0.05f} };
|
245
|
int[] indices = { 0,0,0,0,0,0,0,0 };
|
246
|
float[][] centers = { { -0.75f, 0.0f, 0.0f} };
|
247
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
|
248
|
}
|
249
|
else if( variant==1 )
|
250
|
{
|
251
|
float[][] corners = { {0.04f,0.15f} };
|
252
|
int[] indices = { 0,0,-1,0,0,-1 };
|
253
|
float[][] centers = { { 0.0f, 0.0f,-0.5f} };
|
254
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
|
255
|
}
|
256
|
else
|
257
|
{
|
258
|
float[][] corners = { {0.05f,0.13f} };
|
259
|
int[] cornerIndices = { 0,0,0,-1,0,0,0,-1 };
|
260
|
float[][] centers = { { -0.5f, 0.0f,-0.5f} };
|
261
|
int[] centerIndices = { -1,0,-1,-1,-1,0,-1,-1 };
|
262
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
|
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
|
// PUBLIC API
|
296
|
|
297
|
public String getShortName()
|
298
|
{
|
299
|
return ObjectType.SQU1_3.name();
|
300
|
}
|
301
|
|
302
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
303
|
|
304
|
public ObjectSignature getSignature()
|
305
|
{
|
306
|
return new ObjectSignature(ObjectSignatures.SQU1_3);
|
307
|
}
|
308
|
|
309
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
310
|
|
311
|
public String getObjectName()
|
312
|
{
|
313
|
return "Square-1";
|
314
|
}
|
315
|
|
316
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
317
|
|
318
|
public String getInventor()
|
319
|
{
|
320
|
return "V. Kopsky, K. Hrsel";
|
321
|
}
|
322
|
|
323
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
324
|
|
325
|
public int getYearOfInvention()
|
326
|
{
|
327
|
return 1990;
|
328
|
}
|
329
|
|
330
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
331
|
|
332
|
public int getComplexity()
|
333
|
{
|
334
|
return 3;
|
335
|
}
|
336
|
|
337
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
338
|
|
339
|
public String[][] getTutorials()
|
340
|
{
|
341
|
return new String[][]{
|
342
|
{"gb","0tX-f6RLgac","How to Solve the Square-1","Z3"},
|
343
|
{"es","mGtHDWj_i1o","Resolver SQUARE-1","Cuby"},
|
344
|
{"ru","XguuJTUwJoE","Как собрать Скваер-1","Алексей Ярыгин"},
|
345
|
{"fr","knRmTSa6aHQ","Comment résoudre le Square-1 (1/3)","Valentino Cube"},
|
346
|
{"fr","y-0ZrAgzETI","Comment résoudre le Square-1 (2/3)","Valentino Cube"},
|
347
|
{"fr","tYbE9GfEokw","Comment résoudre le Square-1 (3/3)","Valentino Cube"},
|
348
|
{"de","p9DMIzNQ3b8","Square-1 Tutorial (1/2)","Pezcraft"},
|
349
|
{"de","gM6E28JGmoo","Square-1 Tutorial (2/2)","Pezcraft"},
|
350
|
{"pl","_0rsImrp9jc","Jak ułożyć: Square-1","DżoDżo"},
|
351
|
{"br","geT7SvX0DEw","Tutorial do Square-1","Pedro Filho"},
|
352
|
{"kr","NcB50lWdQzE","스퀘어1 맞추는 방법","iamzoone"},
|
353
|
{"vn","YvCZXkbZnNs","Tutorial N.120 - Square 1","Duy Thích Rubik"},
|
354
|
{"tw","5XsmL2ex5G8","SQ1\"單一公式法\"教學","不正常魔術方塊研究中心"},
|
355
|
};
|
356
|
}
|
357
|
}
|