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