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.metadata.Metadata;
|
18
|
import org.distorted.objectlib.helpers.ObjectVertexEffects;
|
19
|
import org.distorted.objectlib.main.InitAssets;
|
20
|
import org.distorted.objectlib.metadata.ListObjects;
|
21
|
import org.distorted.objectlib.helpers.ObjectShape;
|
22
|
import org.distorted.objectlib.scrambling.ObjectScrambler;
|
23
|
|
24
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
25
|
|
26
|
public class TwistySquare1 extends TwistySquare
|
27
|
{
|
28
|
private int[] mQuatIndex;
|
29
|
private float[][] mCenters;
|
30
|
|
31
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
32
|
|
33
|
public TwistySquare1(int iconMode, Static4D quat, Static3D move, float scale, Metadata meta, InitAssets asset)
|
34
|
{
|
35
|
super(iconMode, quat, move, scale, meta, asset);
|
36
|
}
|
37
|
|
38
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
39
|
|
40
|
float getFactor()
|
41
|
{
|
42
|
return 1.0f;
|
43
|
}
|
44
|
|
45
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
46
|
|
47
|
@Override
|
48
|
public int getScrambleType()
|
49
|
{
|
50
|
return ObjectScrambler.SCRAMBLING_SQUARE1;
|
51
|
}
|
52
|
|
53
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
54
|
|
55
|
public int[][] getScrambleEdges()
|
56
|
{
|
57
|
return null;
|
58
|
}
|
59
|
|
60
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
61
|
|
62
|
public float[][] getCubitPositions(int[] numLayers)
|
63
|
{
|
64
|
if( mCenters==null )
|
65
|
{
|
66
|
mCenters = new float[][]
|
67
|
{
|
68
|
{ 1.5f, 0.0f, 0.0f },
|
69
|
{-1.5f, 0.0f, 0.0f },
|
70
|
|
71
|
{ 0.0f, 1.0f, 1.5f },
|
72
|
{ 1.5f, 1.0f, 0.0f },
|
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
|
|
80
|
{ 1.0f, 1.0f, 2.0f, 2.0f, 1.0f, 1.0f },
|
81
|
{ 1.0f, 1.0f,-2.0f, 2.0f, 1.0f,-1.0f },
|
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
|
};
|
89
|
}
|
90
|
return mCenters;
|
91
|
}
|
92
|
|
93
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
94
|
|
95
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
96
|
{
|
97
|
if( mQuatIndex ==null )
|
98
|
{
|
99
|
mQuatIndex = new int[]
|
100
|
{
|
101
|
0, 6,
|
102
|
0, 9, 6, 3, 17, 14, 23, 20,
|
103
|
0, 9, 6, 3, 14, 23, 20, 17
|
104
|
};
|
105
|
}
|
106
|
|
107
|
return mObjectQuats[mQuatIndex[cubit]];
|
108
|
}
|
109
|
|
110
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
111
|
|
112
|
private float[][] getVertices(int variant)
|
113
|
{
|
114
|
if( variant==0 )
|
115
|
{
|
116
|
return new float[][]
|
117
|
{
|
118
|
{ -1.5f-X, 0.5f, 1.5f },
|
119
|
{ 0.0f, 0.5f, 1.5f },
|
120
|
{ 0.0f, 0.5f,-1.5f },
|
121
|
{ -1.5f+X, 0.5f,-1.5f },
|
122
|
{ -1.5f-X,-0.5f, 1.5f },
|
123
|
{ 0.0f,-0.5f, 1.5f },
|
124
|
{ 0.0f,-0.5f,-1.5f },
|
125
|
{ -1.5f+X,-0.5f,-1.5f }
|
126
|
};
|
127
|
}
|
128
|
else if( variant==1 )
|
129
|
{
|
130
|
return new float[][]
|
131
|
{
|
132
|
{ -X, 0.5f, 0.0f },
|
133
|
{ +X, 0.5f, 0.0f },
|
134
|
{0.0f, 0.5f,-1.5f },
|
135
|
{ -X,-0.5f, 0.0f },
|
136
|
{ +X,-0.5f, 0.0f },
|
137
|
{0.0f,-0.5f,-1.5f },
|
138
|
};
|
139
|
}
|
140
|
else
|
141
|
{
|
142
|
return new float[][]
|
143
|
{
|
144
|
{ X-1.5f, 0.5f, 0.0f },
|
145
|
{ 0.0f, 0.5f, 0.0f },
|
146
|
{ 0.0f, 0.5f,X-1.5f },
|
147
|
{ -1.5f, 0.5f, -1.5f },
|
148
|
{ X-1.5f,-0.5f, 0.0f },
|
149
|
{ 0.0f,-0.5f, 0.0f },
|
150
|
{ 0.0f,-0.5f,X-1.5f },
|
151
|
{ -1.5f,-0.5f, -1.5f }
|
152
|
};
|
153
|
}
|
154
|
}
|
155
|
|
156
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
157
|
|
158
|
public ObjectShape getObjectShape(int variant)
|
159
|
{
|
160
|
if( variant==0 )
|
161
|
{
|
162
|
int[][] indices =
|
163
|
{
|
164
|
{4,5,1,0},
|
165
|
{5,6,2,1},
|
166
|
{6,7,3,2},
|
167
|
{7,4,0,3},
|
168
|
{0,1,2,3},
|
169
|
{7,6,5,4}
|
170
|
};
|
171
|
|
172
|
return new ObjectShape(getVertices(variant), indices);
|
173
|
}
|
174
|
else if( variant==1 )
|
175
|
{
|
176
|
int[][] indices =
|
177
|
{
|
178
|
{0,1,2},
|
179
|
{3,4,1,0},
|
180
|
{5,4,3},
|
181
|
{4,5,2,1},
|
182
|
{5,3,0,2}
|
183
|
};
|
184
|
|
185
|
return new ObjectShape(getVertices(variant), indices);
|
186
|
}
|
187
|
else
|
188
|
{
|
189
|
int[][] indices =
|
190
|
{
|
191
|
{0,1,2,3},
|
192
|
{4,5,1,0},
|
193
|
{5,6,2,1},
|
194
|
{7,4,0,3},
|
195
|
{6,7,3,2},
|
196
|
{7,6,5,4}
|
197
|
};
|
198
|
|
199
|
return new ObjectShape(getVertices(variant), indices);
|
200
|
}
|
201
|
}
|
202
|
|
203
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
204
|
|
205
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
206
|
{
|
207
|
int angle1 = 25;
|
208
|
int angle2 = 35;
|
209
|
float R = 0.2f;
|
210
|
float S = 0.8f;
|
211
|
|
212
|
if( variant==0 )
|
213
|
{
|
214
|
float h1 = isInIconMode() ? 0.001f : 0.04f;
|
215
|
float h2 = isInIconMode() ? 0.001f : 0.02f;
|
216
|
float[][] bands = { {h1,angle1,R,S,5,2,1}, {h2,angle1,R,S,5,2,1}, {0.001f,angle1,R,S,5,2,1} };
|
217
|
int[] indices = { 0,0,1,2,2,2 };
|
218
|
return new ObjectFaceShape(bands,indices,null);
|
219
|
}
|
220
|
else if( variant==1 )
|
221
|
{
|
222
|
float height = isInIconMode() ? 0.001f : 0.038f;
|
223
|
float[][] bands = { {height,angle2,R,S, 5,2,1}, {0.001f,angle2,R,S, 5,2,1} };
|
224
|
int[] indices = { 0,0,0,1,1 };
|
225
|
return new ObjectFaceShape(bands,indices,null);
|
226
|
}
|
227
|
else
|
228
|
{
|
229
|
float height = isInIconMode() ? 0.001f : 0.038f;
|
230
|
float[][] bands = { {height,angle2,R,S, 5,2,1}, {0.001f,angle2,R,S, 5,2,1} };
|
231
|
int[] indices = { 0,0,0,1,1,1 };
|
232
|
return new ObjectFaceShape(bands,indices,null);
|
233
|
}
|
234
|
}
|
235
|
|
236
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
237
|
|
238
|
public ObjectVertexEffects getVertexEffects(int variant)
|
239
|
{
|
240
|
if( variant==0 )
|
241
|
{
|
242
|
float[][] corners = { {0.03f,0.05f} };
|
243
|
int[] indices = { 0,0,0,0,0,0,0,0 };
|
244
|
float[][] centers = { { -0.75f, 0.0f, 0.0f} };
|
245
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
|
246
|
}
|
247
|
else if( variant==1 )
|
248
|
{
|
249
|
float[][] corners = { {0.04f,0.15f} };
|
250
|
int[] indices = { 0,0,-1,0,0,-1 };
|
251
|
float[][] centers = { { 0.0f, 0.0f,-0.5f} };
|
252
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
|
253
|
}
|
254
|
else
|
255
|
{
|
256
|
float[][] corners = { {0.05f,0.13f} };
|
257
|
int[] cornerIndices = { 0,0,0,-1,0,0,0,-1 };
|
258
|
float[][] centers = { { -0.5f, 0.0f,-0.5f} };
|
259
|
int[] centerIndices = { -1,0,-1,-1,-1,0,-1,-1 };
|
260
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
|
261
|
}
|
262
|
}
|
263
|
|
264
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
265
|
|
266
|
public int getNumCubitVariants(int[] numLayers)
|
267
|
{
|
268
|
return 3;
|
269
|
}
|
270
|
|
271
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
272
|
|
273
|
public int getCubitVariant(int cubit, int[] numLayers)
|
274
|
{
|
275
|
return cubit<2 ? 0 : (cubit<10 ? 1:2);
|
276
|
}
|
277
|
|
278
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
279
|
|
280
|
public float getStickerRadius()
|
281
|
{
|
282
|
return 0.12f;
|
283
|
}
|
284
|
|
285
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
286
|
|
287
|
public float getStickerStroke()
|
288
|
{
|
289
|
return isInIconMode() ? 0.20f : 0.10f;
|
290
|
}
|
291
|
|
292
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
293
|
// PUBLIC API
|
294
|
|
295
|
public String getShortName()
|
296
|
{
|
297
|
return ListObjects.SQU1_3.name();
|
298
|
}
|
299
|
|
300
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
301
|
|
302
|
public String[][] getTutorials()
|
303
|
{
|
304
|
return new String[][]{
|
305
|
{"gb","0tX-f6RLgac","How to Solve the Square-1","Z3"},
|
306
|
{"es","mGtHDWj_i1o","Resolver SQUARE-1","Cuby"},
|
307
|
{"ru","XguuJTUwJoE","Как собрать Скваер-1","Алексей Ярыгин"},
|
308
|
{"fr","knRmTSa6aHQ","Comment résoudre le Square-1 (1/3)","Valentino Cube"},
|
309
|
{"fr","y-0ZrAgzETI","Comment résoudre le Square-1 (2/3)","Valentino Cube"},
|
310
|
{"fr","tYbE9GfEokw","Comment résoudre le Square-1 (3/3)","Valentino Cube"},
|
311
|
{"de","p9DMIzNQ3b8","Square-1 Tutorial (1/2)","Pezcraft"},
|
312
|
{"de","gM6E28JGmoo","Square-1 Tutorial (2/2)","Pezcraft"},
|
313
|
{"pl","_0rsImrp9jc","Jak ułożyć: Square-1","DżoDżo"},
|
314
|
{"br","geT7SvX0DEw","Tutorial do Square-1","Pedro Filho"},
|
315
|
{"kr","NcB50lWdQzE","스퀘어1 맞추는 방법","iamzoone"},
|
316
|
{"vn","YvCZXkbZnNs","Tutorial N.120 - Square 1","Duy Thích Rubik"},
|
317
|
{"tw","5XsmL2ex5G8","SQ1\"單一公式法\"教學","不正常魔術方塊研究中心"},
|
318
|
};
|
319
|
}
|
320
|
}
|