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.main.ObjectControl;
|
29
|
import org.distorted.objectlib.main.ObjectType;
|
30
|
import org.distorted.objectlib.helpers.ObjectShape;
|
31
|
import org.distorted.objectlib.helpers.ScrambleState;
|
32
|
|
33
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
34
|
|
35
|
public class TwistySquare2 extends TwistySquare
|
36
|
{
|
37
|
private ScrambleState[] mStates;
|
38
|
private int[] mQuatNumber;
|
39
|
private float[][] mCenters;
|
40
|
|
41
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
42
|
|
43
|
public TwistySquare2(int[] numL, int meshState, Static4D quat, Static3D move, float scale, InputStream stream)
|
44
|
{
|
45
|
super(numL, meshState, quat, move, scale, stream);
|
46
|
}
|
47
|
|
48
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
49
|
|
50
|
public ScrambleState[] getScrambleStates()
|
51
|
{
|
52
|
if( mStates==null )
|
53
|
{
|
54
|
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};
|
55
|
int[] SL_1 = new int[] { 0,1,1, 1,1,1 };
|
56
|
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 };
|
57
|
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 };
|
58
|
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 };
|
59
|
|
60
|
mStates = new ScrambleState[]
|
61
|
{
|
62
|
new ScrambleState( new int[][] { LO_2, SL_6, LO_3 } ), // 0
|
63
|
new ScrambleState( new int[][] { LO_2, null, LO_3 } ), // SL
|
64
|
new ScrambleState( new int[][] { null, SL_1, LO_4 } ), // LO
|
65
|
new ScrambleState( new int[][] { LO_4, SL_1, null } ), // UP
|
66
|
new ScrambleState( new int[][] { null, SL_1, null } ), // UL
|
67
|
};
|
68
|
}
|
69
|
|
70
|
return mStates;
|
71
|
}
|
72
|
|
73
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
74
|
|
75
|
public int[] getSolvedQuats(int cubit, int[] numLayers)
|
76
|
{
|
77
|
return null;
|
78
|
}
|
79
|
|
80
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
81
|
|
82
|
public ObjectShape getObjectShape(int variant)
|
83
|
{
|
84
|
if( variant==0 )
|
85
|
{
|
86
|
float[][] vertices =
|
87
|
{
|
88
|
{ -1.5f-X, 0.5f, 1.5f },
|
89
|
{ 0.0f, 0.5f, 1.5f },
|
90
|
{ 0.0f, 0.5f,-1.5f },
|
91
|
{ -1.5f+X, 0.5f,-1.5f },
|
92
|
{ -1.5f-X,-0.5f, 1.5f },
|
93
|
{ 0.0f,-0.5f, 1.5f },
|
94
|
{ 0.0f,-0.5f,-1.5f },
|
95
|
{ -1.5f+X,-0.5f,-1.5f }
|
96
|
};
|
97
|
|
98
|
int[][] indices =
|
99
|
{
|
100
|
{4,5,1,0},
|
101
|
{5,6,2,1},
|
102
|
{6,7,3,2},
|
103
|
{7,4,0,3},
|
104
|
{0,1,2,3},
|
105
|
{4,5,6,7}
|
106
|
};
|
107
|
|
108
|
return new ObjectShape(vertices, indices);
|
109
|
}
|
110
|
else if( variant==1 )
|
111
|
{
|
112
|
float[][] vertices =
|
113
|
{
|
114
|
{ -X, 0.5f, 0.0f },
|
115
|
{ +X, 0.5f, 0.0f },
|
116
|
{0.0f, 0.5f,-1.5f },
|
117
|
{ -X,-0.5f, 0.0f },
|
118
|
{ +X,-0.5f, 0.0f },
|
119
|
{0.0f,-0.5f,-1.5f },
|
120
|
};
|
121
|
|
122
|
int[][] indices =
|
123
|
{
|
124
|
{0,1,2},
|
125
|
{3,4,1,0},
|
126
|
{3,4,5},
|
127
|
{4,5,2,1},
|
128
|
{5,3,0,2}
|
129
|
};
|
130
|
|
131
|
return new ObjectShape(vertices, indices);
|
132
|
}
|
133
|
else
|
134
|
{
|
135
|
float[][] vertices =
|
136
|
{
|
137
|
{-0.75f+X/2, 0.5f, 0.0f },
|
138
|
{ 0.75f-X/2, 0.5f, 0.0f },
|
139
|
{-0.75f-X/2, 0.5f, -1.5f },
|
140
|
{-0.75f+X/2,-0.5f, 0.0f },
|
141
|
{ 0.75f-X/2,-0.5f, 0.0f },
|
142
|
{-0.75f-X/2,-0.5f, -1.5f }
|
143
|
};
|
144
|
int[][] indices =
|
145
|
{
|
146
|
{0,1,2},
|
147
|
{3,4,1,0},
|
148
|
{5,4,3},
|
149
|
{4,5,2,1},
|
150
|
{5,3,0,2}
|
151
|
};
|
152
|
|
153
|
return new ObjectShape(vertices, indices);
|
154
|
}
|
155
|
}
|
156
|
|
157
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
158
|
|
159
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
160
|
{
|
161
|
if( variant==0 )
|
162
|
{
|
163
|
float[][] bands = { {0.040f,35,0.8f,1.0f,5,2,1}, {0.020f,35,0.8f,1.0f,5,2,1}, {0.001f,35,0.8f,1.0f,5,2,1} };
|
164
|
int[] bandIndices = { 2,2,1,1,0,2 };
|
165
|
float[][] corners = { {0.03f,0.05f} };
|
166
|
int[] cornerIndices = { 0,0,0,0,0,0,0,0 };
|
167
|
float[][] centers = { { -0.75f, 0.0f, 0.0f} };
|
168
|
int[] centerIndices = { 0,0,0,0,0,0,0,0 };
|
169
|
return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
|
170
|
}
|
171
|
else if( variant==1 )
|
172
|
{
|
173
|
float[][] bands = { {0.038f,35,0.5f,0.9f, 5,2,1}, {0.001f,35,0.5f,0.9f, 5,2,1} };
|
174
|
int[] bandIndices = { 0,1,0,1,1 };
|
175
|
float[][] corners = { {0.04f,0.15f} };
|
176
|
int[] cornerIndices = { 0,0,-1,0,0,-1 };
|
177
|
float[][] centers = { { 0.0f, 0.0f,-0.5f} };
|
178
|
int[] centerIndices = { 0,0,-1,0,0,-1 };
|
179
|
return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
|
180
|
}
|
181
|
else
|
182
|
{
|
183
|
float[][] bands = { {0.030f,35,0.9f,1.0f, 5,2,1}, {0.001f,35,0.9f,1.0f, 5,2,1} };
|
184
|
int[] bandIndices = { 0,0,0,1,1 };
|
185
|
float[][] corners = { {0.05f,0.13f} };
|
186
|
int[] cornerIndices = { 0,0,-1,0,0,-1 };
|
187
|
float[][] centers = { { 0.0f, 0.0f,-0.5f} };
|
188
|
int[] centerIndices = { 0,0,-1,0,0,-1 };
|
189
|
return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
|
190
|
}
|
191
|
}
|
192
|
|
193
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
194
|
|
195
|
public Static4D getQuat(int cubit, int[] numLayers)
|
196
|
{
|
197
|
if( mQuats==null ) initializeQuats();
|
198
|
|
199
|
if( mQuatNumber ==null )
|
200
|
{
|
201
|
mQuatNumber = new int[]
|
202
|
{
|
203
|
0, 6,
|
204
|
0, 9, 6, 3, 18, 15, 12, 21,
|
205
|
0, 9, 6, 3, 0, 9, 6, 3,
|
206
|
15, 12, 21, 18, 15, 12, 21, 18
|
207
|
};
|
208
|
}
|
209
|
|
210
|
return mQuats[mQuatNumber[cubit]];
|
211
|
}
|
212
|
|
213
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
214
|
|
215
|
public int getNumCubitVariants(int[] numLayers)
|
216
|
{
|
217
|
return 3;
|
218
|
}
|
219
|
|
220
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
221
|
|
222
|
public int getCubitVariant(int cubit, int[] numLayers)
|
223
|
{
|
224
|
return cubit<2 ? 0 : (cubit<10 ? 1:2);
|
225
|
}
|
226
|
|
227
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
228
|
|
229
|
public float[][] getCubitPositions(int[] numLayers)
|
230
|
{
|
231
|
if( mCenters ==null )
|
232
|
{
|
233
|
float Y = 0.75f + X/2;
|
234
|
|
235
|
mCenters = new float[][]
|
236
|
{
|
237
|
{ 1.5f, 0.0f, 0.0f },
|
238
|
{-1.5f, 0.0f, 0.0f },
|
239
|
|
240
|
{ 0.0f, 1.0f, 1.5f },
|
241
|
{ 1.5f, 1.0f, 0.0f },
|
242
|
{ 0.0f, 1.0f,-1.5f },
|
243
|
{-1.5f, 1.0f, 0.0f },
|
244
|
{ 0.0f,-1.0f, 1.5f },
|
245
|
{ 1.5f,-1.0f, 0.0f },
|
246
|
{ 0.0f,-1.0f,-1.5f },
|
247
|
{-1.5f,-1.0f, 0.0f },
|
248
|
|
249
|
{ Y, 1.0f, 1.5f },
|
250
|
{ 1.5f, 1.0f, -Y },
|
251
|
{ -Y, 1.0f,-1.5f },
|
252
|
{-1.5f, 1.0f, Y },
|
253
|
{ Y,-1.0f, 1.5f },
|
254
|
{ 1.5f,-1.0f, -Y },
|
255
|
{ -Y,-1.0f,-1.5f },
|
256
|
{-1.5f,-1.0f, Y },
|
257
|
|
258
|
{ 1.5f, 1.0f, Y },
|
259
|
{ Y, 1.0f,-1.5f },
|
260
|
{-1.5f, 1.0f, -Y },
|
261
|
{ -Y, 1.0f, 1.5f },
|
262
|
{ 1.5f,-1.0f, Y },
|
263
|
{ Y,-1.0f,-1.5f },
|
264
|
{-1.5f,-1.0f, -Y },
|
265
|
{ -Y,-1.0f, 1.5f },
|
266
|
};
|
267
|
}
|
268
|
|
269
|
return mCenters;
|
270
|
}
|
271
|
|
272
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
273
|
|
274
|
public int getSolvedFunctionIndex()
|
275
|
{
|
276
|
return 3;
|
277
|
}
|
278
|
|
279
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
280
|
|
281
|
public float getStickerRadius()
|
282
|
{
|
283
|
return 0.12f;
|
284
|
}
|
285
|
|
286
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
287
|
|
288
|
public float getStickerStroke()
|
289
|
{
|
290
|
return ObjectControl.isInIconMode() ? 0.20f : 0.10f;
|
291
|
}
|
292
|
|
293
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
294
|
|
295
|
public float[][] getStickerAngles()
|
296
|
{
|
297
|
return null;
|
298
|
}
|
299
|
|
300
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
301
|
// PUBLIC API
|
302
|
|
303
|
public ObjectType intGetObjectType(int[] numLayers)
|
304
|
{
|
305
|
return ObjectType.SQU2_3;
|
306
|
}
|
307
|
|
308
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
309
|
|
310
|
public String getObjectName()
|
311
|
{
|
312
|
return "Square-2";
|
313
|
}
|
314
|
|
315
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
316
|
|
317
|
public String getInventor()
|
318
|
{
|
319
|
return "David Litwin";
|
320
|
}
|
321
|
|
322
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
323
|
|
324
|
public int getYearOfInvention()
|
325
|
{
|
326
|
return 1995;
|
327
|
}
|
328
|
|
329
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
330
|
|
331
|
public int getComplexity()
|
332
|
{
|
333
|
return 3;
|
334
|
}
|
335
|
}
|