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.main.ObjectControl;
|
28
|
import org.distorted.objectlib.main.ObjectType;
|
29
|
import org.distorted.objectlib.helpers.ObjectShape;
|
30
|
import org.distorted.objectlib.helpers.ObjectSticker;
|
31
|
import org.distorted.objectlib.helpers.ScrambleState;
|
32
|
|
33
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
34
|
|
35
|
public class TwistySquare2 extends TwistySquare
|
36
|
{
|
37
|
private static final int NUM_STICKERS = 6;
|
38
|
|
39
|
private ScrambleState[] mStates;
|
40
|
private int[] mQuatNumber;
|
41
|
private float[][] mCenters;
|
42
|
private int[][] mStickerColor;
|
43
|
private int[][] mStickerType;
|
44
|
private ObjectSticker[] mStickers;
|
45
|
|
46
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
47
|
|
48
|
public TwistySquare2(int[] numL, Static4D quat, Static3D move, float scale, InputStream stream)
|
49
|
{
|
50
|
super(numL, quat, move, scale, stream);
|
51
|
}
|
52
|
|
53
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
54
|
|
55
|
public ScrambleState[] getScrambleStates()
|
56
|
{
|
57
|
if( mStates==null )
|
58
|
{
|
59
|
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};
|
60
|
int[] SL_1 = new int[] { 0,1,1, 1,1,1 };
|
61
|
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 };
|
62
|
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 };
|
63
|
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 };
|
64
|
|
65
|
mStates = new ScrambleState[]
|
66
|
{
|
67
|
new ScrambleState( new int[][] { LO_2, SL_6, LO_3 } ), // 0
|
68
|
new ScrambleState( new int[][] { LO_2, null, LO_3 } ), // SL
|
69
|
new ScrambleState( new int[][] { null, SL_1, LO_4 } ), // LO
|
70
|
new ScrambleState( new int[][] { LO_4, SL_1, null } ), // UP
|
71
|
new ScrambleState( new int[][] { null, SL_1, null } ), // UL
|
72
|
};
|
73
|
}
|
74
|
|
75
|
return mStates;
|
76
|
}
|
77
|
|
78
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
79
|
|
80
|
public int[] getSolvedQuats(int cubit, int[] numLayers)
|
81
|
{
|
82
|
return null;
|
83
|
}
|
84
|
|
85
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
86
|
|
87
|
public ObjectShape getObjectShape(int variant)
|
88
|
{
|
89
|
if( variant==0 )
|
90
|
{
|
91
|
double[][] vertices = new double[][]
|
92
|
{
|
93
|
{ -1.5-X, 0.5, 1.5 },
|
94
|
{ 0.0, 0.5, 1.5 },
|
95
|
{ 0.0, 0.5,-1.5 },
|
96
|
{ -1.5+X, 0.5,-1.5 },
|
97
|
{ -1.5-X,-0.5, 1.5 },
|
98
|
{ 0.0,-0.5, 1.5 },
|
99
|
{ 0.0,-0.5,-1.5 },
|
100
|
{ -1.5+X,-0.5,-1.5 }
|
101
|
};
|
102
|
|
103
|
int[][] vert_indices = new int[][]
|
104
|
{
|
105
|
{0,1,2,3},
|
106
|
{4,5,6,7},
|
107
|
{4,5,1,0},
|
108
|
{5,6,2,1},
|
109
|
{6,7,3,2},
|
110
|
{7,4,0,3}
|
111
|
};
|
112
|
|
113
|
float[][] bands = new float[][] { {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} };
|
114
|
int[] bandIndices = new int[] { 2,2,1,1,0,2 };
|
115
|
float[][] corners = new float[][] { {0.03f,0.05f} };
|
116
|
int[] cornerIndices = new int[] { 0,0,0,0,0,0,0,0 };
|
117
|
float[][] centers = new float[][] { { -0.75f, 0.0f, 0.0f} };
|
118
|
int[] centerIndices = new int[] { 0,0,0,0,0,0,0,0 };
|
119
|
return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
120
|
}
|
121
|
else if( variant==1 )
|
122
|
{
|
123
|
double[][] vertices = new double[][]
|
124
|
{
|
125
|
{ -X, 0.5, 0.0 },
|
126
|
{ +X, 0.5, 0.0 },
|
127
|
{0.0, 0.5,-1.5 },
|
128
|
{ -X,-0.5, 0.0 },
|
129
|
{ +X,-0.5, 0.0 },
|
130
|
{0.0,-0.5,-1.5 },
|
131
|
};
|
132
|
|
133
|
int[][] vert_indices = new int[][]
|
134
|
{
|
135
|
{0,1,2},
|
136
|
{3,4,5},
|
137
|
{3,4,1,0},
|
138
|
{4,5,2,1},
|
139
|
{5,3,0,2}
|
140
|
};
|
141
|
|
142
|
float[][] bands = new float[][] { {0.038f,35,0.5f,0.9f, 5,2,1}, {0.001f,35,0.5f,0.9f, 5,2,1} };
|
143
|
int[] bandIndices = new int[] { 0,1,0,1,1 };
|
144
|
float[][] corners = new float[][] { {0.04f,0.15f} };
|
145
|
int[] cornerIndices = new int[] { 0,0,-1,0,0,-1 };
|
146
|
float[][] centers = new float[][] { { 0.0f, 0.0f,-0.5f} };
|
147
|
int[] centerIndices = new int[] { 0,0,-1,0,0,-1 };
|
148
|
return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
149
|
}
|
150
|
else
|
151
|
{
|
152
|
double[][] vertices = new double[][]
|
153
|
{
|
154
|
{-0.75f+X/2, 0.5, 0.0 },
|
155
|
{ 0.75f-X/2, 0.5, 0.0 },
|
156
|
{-0.75f-X/2, 0.5, -1.5 },
|
157
|
{-0.75f+X/2,-0.5, 0.0 },
|
158
|
{ 0.75f-X/2,-0.5, 0.0 },
|
159
|
{-0.75f-X/2,-0.5, -1.5 }
|
160
|
};
|
161
|
int[][] vert_indices = new int[][]
|
162
|
{
|
163
|
{0,1,2},
|
164
|
{5,4,3},
|
165
|
{3,4,1,0},
|
166
|
{4,5,2,1},
|
167
|
{5,3,0,2}
|
168
|
};
|
169
|
|
170
|
float[][] bands = new float[][] { {0.030f,35,0.9f,1.0f, 5,2,1}, {0.001f,35,0.9f,1.0f, 5,2,1} };
|
171
|
int[] bandIndices = new int[] { 0,0,0,1,1 };
|
172
|
float[][] corners = new float[][] { {0.05f,0.13f} };
|
173
|
int[] cornerIndices = new int[] { 0,0,-1,0,0,-1 };
|
174
|
float[][] centers = new float[][] { { 0.0f, 0.0f,-0.5f} };
|
175
|
int[] centerIndices = new int[] { 0,0,-1,0,0,-1 };
|
176
|
return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
177
|
}
|
178
|
}
|
179
|
|
180
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
181
|
|
182
|
public Static4D getQuat(int cubit, int[] numLayers)
|
183
|
{
|
184
|
if( mQuats==null ) initializeQuats();
|
185
|
|
186
|
if( mQuatNumber ==null )
|
187
|
{
|
188
|
mQuatNumber = new int[]
|
189
|
{
|
190
|
0, 6,
|
191
|
0, 9, 6, 3, 18, 15, 12, 21,
|
192
|
0, 9, 6, 3, 0, 9, 6, 3,
|
193
|
15, 12, 21, 18, 15, 12, 21, 18
|
194
|
};
|
195
|
}
|
196
|
|
197
|
return mQuats[mQuatNumber[cubit]];
|
198
|
}
|
199
|
|
200
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
201
|
|
202
|
public int getNumCubitVariants(int[] numLayers)
|
203
|
{
|
204
|
return 3;
|
205
|
}
|
206
|
|
207
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
208
|
|
209
|
public int getCubitVariant(int cubit, int[] numLayers)
|
210
|
{
|
211
|
return cubit<2 ? 0 : (cubit<10 ? 1:2);
|
212
|
}
|
213
|
|
214
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
215
|
|
216
|
public ObjectSticker retSticker(int sticker)
|
217
|
{
|
218
|
if( mStickers==null )
|
219
|
{
|
220
|
float[][] STICKERS = new float[][]
|
221
|
{
|
222
|
{ -0.5f, -0.26289170f, 0.5f, -0.26289170f, 0.5f, 0.26289170f, -0.5f, 0.26289170f }, // middle front
|
223
|
{ -0.5f, -0.16666667f, 0.5f, -0.16666667f, 0.5f, 0.16666667f, -0.5f, 0.16666667f }, // middle right
|
224
|
{ -0.5f, -0.45534182f, 0.5f, -0.45534182f, 0.5f, 0.45534182f, -0.5f, 0.45534182f }, // middle back
|
225
|
{ -0.20096192f, -0.25f, 0.20096192f, -0.25f, 0.0f, 0.5f }, // edge top
|
226
|
{ -0.40192384f, -0.5f, 0.40192384f, -0.5f, 0.40192384f, 0.5f, -0.40192384f, 0.5f }, // edge face
|
227
|
{ -0.11602539f, -0.25f, 0.4330127f, -0.25f, -0.3169873f, 0.5f } // corner top
|
228
|
};
|
229
|
|
230
|
final float R1 = 0.06f;
|
231
|
final float R2 = 0.04f;
|
232
|
final float R3 = 0.11f;
|
233
|
final float R4 = 0.03f;
|
234
|
final float R5 = 0.11f;
|
235
|
final float R6 = 0.025f;
|
236
|
final float[][] radii = { {R1,R1,R1,R1},{R2,R2,R2,R2},{R3,R3,R3,R3},{R4,R4,R4},{R5,R5,R5,R5},{R6,R6,R6} };
|
237
|
float[] strokes = { 0.05f,0.04f,0.09f,0.05f,0.08f,0.06f };
|
238
|
|
239
|
if( ObjectControl.isInIconMode() )
|
240
|
{
|
241
|
float mult = 2.0f;
|
242
|
strokes[0]*=mult;
|
243
|
strokes[1]*=mult;
|
244
|
strokes[2]*=mult;
|
245
|
strokes[3]*=mult;
|
246
|
strokes[4]*=mult;
|
247
|
strokes[5]*=mult;
|
248
|
}
|
249
|
|
250
|
mStickers = new ObjectSticker[NUM_STICKERS];
|
251
|
|
252
|
for(int s=0; s<NUM_STICKERS; s++)
|
253
|
{
|
254
|
mStickers[s] = new ObjectSticker(STICKERS[s],null,radii[s],strokes[s]);
|
255
|
}
|
256
|
}
|
257
|
|
258
|
return mStickers[sticker];
|
259
|
}
|
260
|
|
261
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
262
|
|
263
|
public float[][] getCubitPositions(int[] numLayers)
|
264
|
{
|
265
|
if( mCenters ==null )
|
266
|
{
|
267
|
float Y = 0.75f + X/2;
|
268
|
|
269
|
mCenters = new float[][]
|
270
|
{
|
271
|
{ 1.5f, 0.0f, 0.0f },
|
272
|
{-1.5f, 0.0f, 0.0f },
|
273
|
|
274
|
{ 0.0f, 1.0f, 1.5f },
|
275
|
{ 1.5f, 1.0f, 0.0f },
|
276
|
{ 0.0f, 1.0f,-1.5f },
|
277
|
{-1.5f, 1.0f, 0.0f },
|
278
|
{ 0.0f,-1.0f, 1.5f },
|
279
|
{ 1.5f,-1.0f, 0.0f },
|
280
|
{ 0.0f,-1.0f,-1.5f },
|
281
|
{-1.5f,-1.0f, 0.0f },
|
282
|
|
283
|
{ Y, 1.0f, 1.5f },
|
284
|
{ 1.5f, 1.0f, -Y },
|
285
|
{ -Y, 1.0f,-1.5f },
|
286
|
{-1.5f, 1.0f, Y },
|
287
|
{ Y,-1.0f, 1.5f },
|
288
|
{ 1.5f,-1.0f, -Y },
|
289
|
{ -Y,-1.0f,-1.5f },
|
290
|
{-1.5f,-1.0f, Y },
|
291
|
|
292
|
{ 1.5f, 1.0f, Y },
|
293
|
{ Y, 1.0f,-1.5f },
|
294
|
{-1.5f, 1.0f, -Y },
|
295
|
{ -Y, 1.0f, 1.5f },
|
296
|
{ 1.5f,-1.0f, Y },
|
297
|
{ Y,-1.0f,-1.5f },
|
298
|
{-1.5f,-1.0f, -Y },
|
299
|
{ -Y,-1.0f, 1.5f },
|
300
|
};
|
301
|
}
|
302
|
|
303
|
return mCenters;
|
304
|
}
|
305
|
|
306
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
307
|
|
308
|
public int getSolvedFunctionIndex()
|
309
|
{
|
310
|
return 3;
|
311
|
}
|
312
|
|
313
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
314
|
|
315
|
public int getNumStickerTypes(int[] numLayers)
|
316
|
{
|
317
|
return NUM_STICKERS;
|
318
|
}
|
319
|
|
320
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
321
|
|
322
|
public int getVariantFaceColor(int variant, int face, int[] numLayers)
|
323
|
{
|
324
|
if( mStickerType==null )
|
325
|
{
|
326
|
mStickerType = new int[][]
|
327
|
{
|
328
|
{ -1,-1, 0, 1, 2,-1 },
|
329
|
{ 3,-1, 4,-1,-1,-1 },
|
330
|
{ 5, 5, 2,-1,-1,-1 },
|
331
|
};
|
332
|
}
|
333
|
|
334
|
return mStickerType[variant][face];
|
335
|
}
|
336
|
|
337
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
338
|
|
339
|
public int getCubitFaceColor(int cubit, int face, int[] numLayers)
|
340
|
{
|
341
|
if( mStickerColor==null )
|
342
|
{
|
343
|
// YELLOW 0 WHITE 1 BLUE 2 GREEN 3 RED 4 ORANGE 5
|
344
|
mStickerColor = new int[][]
|
345
|
{
|
346
|
{-1,-1, 4, 0, 5,-1 }, // 0
|
347
|
{-1,-1, 5, 1, 4,-1 },
|
348
|
|
349
|
{ 2,-1, 4,-1,-1,-1 }, // 2
|
350
|
{ 2,-1, 0,-1,-1,-1 },
|
351
|
{ 2,-1, 5,-1,-1,-1 },
|
352
|
{ 2,-1, 1,-1,-1,-1 },
|
353
|
{ 3,-1, 4,-1,-1,-1 },
|
354
|
{ 3,-1, 0,-1,-1,-1 },
|
355
|
{ 3,-1, 5,-1,-1,-1 },
|
356
|
{ 3,-1, 1,-1,-1,-1 },
|
357
|
|
358
|
{ 2,-1, 4,-1,-1,-1 }, // 10
|
359
|
{ 2,-1, 0,-1,-1,-1 },
|
360
|
{ 2,-1, 5,-1,-1,-1 },
|
361
|
{ 2,-1, 1,-1,-1,-1 },
|
362
|
{-1, 3, 4,-1,-1,-1 },
|
363
|
{-1, 3, 0,-1,-1,-1 },
|
364
|
{-1, 3, 5,-1,-1,-1 },
|
365
|
{-1, 3, 1,-1,-1,-1 },
|
366
|
|
367
|
{-1, 2, 0,-1,-1,-1 }, // 18
|
368
|
{-1, 2, 5,-1,-1,-1 },
|
369
|
{-1, 2, 1,-1,-1,-1 },
|
370
|
{-1, 2, 4,-1,-1,-1 },
|
371
|
{ 3,-1, 0,-1,-1,-1 },
|
372
|
{ 3,-1, 5,-1,-1,-1 },
|
373
|
{ 3,-1, 1,-1,-1,-1 },
|
374
|
{ 3,-1, 4,-1,-1,-1 },
|
375
|
};
|
376
|
}
|
377
|
|
378
|
return mStickerColor[cubit][face];
|
379
|
}
|
380
|
|
381
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
382
|
// PUBLIC API
|
383
|
|
384
|
public ObjectType intGetObjectType(int[] numLayers)
|
385
|
{
|
386
|
return ObjectType.SQU2_3;
|
387
|
}
|
388
|
|
389
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
390
|
|
391
|
public String getObjectName()
|
392
|
{
|
393
|
return "Square-2";
|
394
|
}
|
395
|
|
396
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
397
|
|
398
|
public String getInventor()
|
399
|
{
|
400
|
return "David Litwin";
|
401
|
}
|
402
|
|
403
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
404
|
|
405
|
public int getYearOfInvention()
|
406
|
{
|
407
|
return 1995;
|
408
|
}
|
409
|
|
410
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
411
|
|
412
|
public int getComplexity()
|
413
|
{
|
414
|
return 7;
|
415
|
}
|
416
|
}
|