1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2022 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.helpers.ObjectShape;
|
29
|
import org.distorted.objectlib.helpers.ObjectSignature;
|
30
|
import org.distorted.objectlib.main.InitData;
|
31
|
import org.distorted.objectlib.scrambling.ScrambleState;
|
32
|
import org.distorted.objectlib.main.ObjectType;
|
33
|
import org.distorted.objectlib.main.ShapeHexahedron;
|
34
|
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
|
35
|
|
36
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_CHANGING_SHAPEMOD;
|
37
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
|
38
|
|
39
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
40
|
|
41
|
public class TwistyWindmill extends ShapeHexahedron
|
42
|
{
|
43
|
private static final float X = 1.8f; // the cut goes from a corner and splits the opposing side 1.2 / 1.8
|
44
|
private static final float L = (float)Math.sqrt(9+X*X);
|
45
|
|
46
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
47
|
{
|
48
|
new Static3D( 3/L, 0.0f, X/L),
|
49
|
new Static3D( 0.0f, 1.0f,0.0f),
|
50
|
new Static3D( -X/L, 0.0f, 3/L),
|
51
|
};
|
52
|
|
53
|
private ScrambleState[] mStates;
|
54
|
private int[][] mBasicAngle;
|
55
|
private float[][] mCuts;
|
56
|
private float[][] mPositions;
|
57
|
private int[] mQuatIndex;
|
58
|
|
59
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
60
|
|
61
|
public TwistyWindmill(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
|
62
|
{
|
63
|
super(data, meshState, iconMode, data.getNumLayers()[0], quat, move, scale, stream);
|
64
|
}
|
65
|
|
66
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
67
|
|
68
|
@Override
|
69
|
public int getInternalColor()
|
70
|
{
|
71
|
return 0xff333333;
|
72
|
}
|
73
|
|
74
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
75
|
// same as in a 3x3
|
76
|
|
77
|
public ScrambleState[] getScrambleStates()
|
78
|
{
|
79
|
if( mStates==null )
|
80
|
{
|
81
|
int[][] m = new int[16][];
|
82
|
|
83
|
for(int i=0; i<16; i++) m[i] = new int[] { 0,-1,i,0,1,i,0,2,i, 1,-1,i,1,1,i,1,2,i, 2,-1,i,2,1,i,2,2,i};
|
84
|
|
85
|
mStates = new ScrambleState[]
|
86
|
{
|
87
|
new ScrambleState( new int[][] { m[ 1], m[ 2], m[ 3] } ), // 0 0
|
88
|
new ScrambleState( new int[][] { null, m[ 4], m[ 5] } ), // 1 x
|
89
|
new ScrambleState( new int[][] { m[ 6], null, m[ 7] } ), // 2 y
|
90
|
new ScrambleState( new int[][] { m[ 8], m[ 9], null } ), // 3 z
|
91
|
new ScrambleState( new int[][] { m[10], null, m[ 7] } ), // 4 xy
|
92
|
new ScrambleState( new int[][] { m[11], m[ 9], null } ), // 5 xz
|
93
|
new ScrambleState( new int[][] { null, m[12], m[ 5] } ), // 6 yx
|
94
|
new ScrambleState( new int[][] { m[ 8], m[13], null } ), // 7 yz
|
95
|
new ScrambleState( new int[][] { null, m[ 4], m[14] } ), // 8 zx
|
96
|
new ScrambleState( new int[][] { m[ 6], null, m[15] } ), // 9 zy
|
97
|
new ScrambleState( new int[][] { null, null, m[ 5] } ), // 10 xyx
|
98
|
new ScrambleState( new int[][] { null, m[ 4], null } ), // 11 xzx
|
99
|
new ScrambleState( new int[][] { null, null, m[ 7] } ), // 12 yxy
|
100
|
new ScrambleState( new int[][] { m[ 6], null, null } ), // 13 yzy
|
101
|
new ScrambleState( new int[][] { null, m[ 9], null } ), // 14 zxz
|
102
|
new ScrambleState( new int[][] { m[ 8], null, null } ), // 15 zyz
|
103
|
};
|
104
|
}
|
105
|
|
106
|
return mStates;
|
107
|
}
|
108
|
|
109
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
110
|
|
111
|
public float[][] getCuts(int[] numLayers)
|
112
|
{
|
113
|
if( mCuts==null )
|
114
|
{
|
115
|
float C = 3*SQ5/10;
|
116
|
float[] cut = new float[] {-C,+C};
|
117
|
mCuts = new float[][] { cut,cut,cut };
|
118
|
}
|
119
|
|
120
|
return mCuts;
|
121
|
}
|
122
|
|
123
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
124
|
|
125
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
126
|
{
|
127
|
boolean[] tmp = new boolean[] {true,true,true};
|
128
|
return new boolean[][] { tmp,tmp,tmp };
|
129
|
}
|
130
|
|
131
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
132
|
|
133
|
public int getTouchControlType()
|
134
|
{
|
135
|
return TC_CHANGING_SHAPEMOD;
|
136
|
}
|
137
|
|
138
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
139
|
|
140
|
public int getTouchControlSplit()
|
141
|
{
|
142
|
return TYPE_NOT_SPLIT;
|
143
|
}
|
144
|
|
145
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
146
|
|
147
|
public int[][][] getEnabled()
|
148
|
{
|
149
|
return null;
|
150
|
}
|
151
|
|
152
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
153
|
|
154
|
public float[] getDist3D(int[] numLayers)
|
155
|
{
|
156
|
return TouchControlHexahedron.D3D;
|
157
|
}
|
158
|
|
159
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
160
|
|
161
|
public Static3D[] getFaceAxis()
|
162
|
{
|
163
|
return TouchControlHexahedron.FACE_AXIS;
|
164
|
}
|
165
|
|
166
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
167
|
|
168
|
public float[][] getCubitPositions(int[] numLayers)
|
169
|
{
|
170
|
if( mPositions==null )
|
171
|
{
|
172
|
final float DIS1 = -X/2 + 1.5f;
|
173
|
final float DIS2 = -X/2;
|
174
|
|
175
|
mPositions = new float[][]
|
176
|
{
|
177
|
{ DIS1, 1.0f, 1.5f },
|
178
|
{ 1.5f, 1.0f,-DIS1 },
|
179
|
{-DIS1, 1.0f,-1.5f },
|
180
|
{-1.5f, 1.0f, DIS1 },
|
181
|
{ DIS1, 0.0f, 1.5f },
|
182
|
{ 1.5f, 0.0f,-DIS1 },
|
183
|
{-DIS1, 0.0f,-1.5f },
|
184
|
{-1.5f, 0.0f, DIS1 },
|
185
|
{ DIS1,-1.0f, 1.5f },
|
186
|
{ 1.5f,-1.0f,-DIS1 },
|
187
|
{-DIS1,-1.0f,-1.5f },
|
188
|
{-1.5f,-1.0f, DIS1 },
|
189
|
|
190
|
{ DIS2, 1.0f, 1.5f },
|
191
|
{ 1.5f, 1.0f,-DIS2 },
|
192
|
{-DIS2, 1.0f,-1.5f },
|
193
|
{-1.5f, 1.0f, DIS2 },
|
194
|
{ DIS2, 0.0f, 1.5f },
|
195
|
{ 1.5f, 0.0f,-DIS2 },
|
196
|
{-DIS2, 0.0f,-1.5f },
|
197
|
{-1.5f, 0.0f, DIS2 },
|
198
|
{ DIS2,-1.0f, 1.5f },
|
199
|
{ 1.5f,-1.0f,-DIS2 },
|
200
|
{-DIS2,-1.0f,-1.5f },
|
201
|
{-1.5f,-1.0f, DIS2 },
|
202
|
|
203
|
{ 0.0f, 1.0f, 0.0f },
|
204
|
{ 0.0f,-1.0f, 0.0f },
|
205
|
};
|
206
|
}
|
207
|
|
208
|
return mPositions;
|
209
|
}
|
210
|
|
211
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
212
|
|
213
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
214
|
{
|
215
|
if( mQuatIndex==null ) mQuatIndex = new int[] { 0,6,5,4,0,6,5,4,0,6,5,4,
|
216
|
0,6,5,4,0,6,5,4,0,6,5,4,
|
217
|
0,0 };
|
218
|
return mObjectQuats[mQuatIndex[cubit]];
|
219
|
}
|
220
|
|
221
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
222
|
|
223
|
public ObjectShape getObjectShape(int variant)
|
224
|
{
|
225
|
if( variant==0 )
|
226
|
{
|
227
|
final float h = 3*X*X/(X*X+9);
|
228
|
final float d = h*X/3;
|
229
|
final float l = X/2;
|
230
|
|
231
|
float[][] vertices =
|
232
|
{
|
233
|
{ -l, 0.5f, 0.0f },
|
234
|
{ l, 0.5f, 0.0f },
|
235
|
{ l,-0.5f, 0.0f },
|
236
|
{ -l,-0.5f, 0.0f },
|
237
|
{ d-l, 0.5f, -h },
|
238
|
{ d-l,-0.5f, -h },
|
239
|
};
|
240
|
|
241
|
int[][] indices =
|
242
|
{
|
243
|
{ 3,2,1,0 },
|
244
|
{ 0,1,4 },
|
245
|
{ 5,2,3 },
|
246
|
{ 5,3,0,4 },
|
247
|
{ 2,5,4,1 },
|
248
|
};
|
249
|
|
250
|
return new ObjectShape(vertices, indices);
|
251
|
}
|
252
|
else if( variant==1 )
|
253
|
{
|
254
|
final float h = 3*X*X/(X*X+9);
|
255
|
final float d = h*X/3;
|
256
|
final float H = 3*h/X;
|
257
|
final float l = (3-X)/2;
|
258
|
|
259
|
float[][] vertices =
|
260
|
{
|
261
|
{ -l, 0.5f, 0.0f },
|
262
|
{ l, 0.5f, 0.0f },
|
263
|
{ l,-0.5f, 0.0f },
|
264
|
{ -l,-0.5f, 0.0f },
|
265
|
{h-l, 0.5f, -H },
|
266
|
{d+l, 0.5f, -h },
|
267
|
{d+l,-0.5f, -h },
|
268
|
{h-l,-0.5f, -H }
|
269
|
};
|
270
|
|
271
|
int[][] indices =
|
272
|
{
|
273
|
{ 3,2,1,0 },
|
274
|
{ 0,1,5,4 },
|
275
|
{ 7,6,2,3 },
|
276
|
{ 2,6,5,1 },
|
277
|
{ 6,7,4,5 },
|
278
|
{ 7,3,0,4 }
|
279
|
};
|
280
|
|
281
|
return new ObjectShape(vertices, indices);
|
282
|
}
|
283
|
else
|
284
|
{
|
285
|
final float h = 3*X*X/(X*X+9);
|
286
|
final float H = 3*h/X;
|
287
|
final float x = 1.5f-H;
|
288
|
final float y = 1.5f-h;
|
289
|
|
290
|
float[][] vertices =
|
291
|
{
|
292
|
{ -y, 0.5f, x },
|
293
|
{ x, 0.5f, y },
|
294
|
{ x,-0.5f, y },
|
295
|
{ -y,-0.5f, x },
|
296
|
{ -x, 0.5f,-y },
|
297
|
{ y, 0.5f,-x },
|
298
|
{ y,-0.5f,-x },
|
299
|
{ -x,-0.5f,-y }
|
300
|
};
|
301
|
|
302
|
int[][] indices =
|
303
|
{
|
304
|
{ 3,2,1,0 },
|
305
|
{ 0,1,5,4 },
|
306
|
{ 7,6,2,3 },
|
307
|
{ 2,6,5,1 },
|
308
|
{ 6,7,4,5 },
|
309
|
{ 7,3,0,4 }
|
310
|
};
|
311
|
|
312
|
return new ObjectShape(vertices, indices);
|
313
|
}
|
314
|
}
|
315
|
|
316
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
317
|
|
318
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
319
|
{
|
320
|
if( variant==0 )
|
321
|
{
|
322
|
final float h = 3*X*X/(X*X+9);
|
323
|
final float d = h*X/3;
|
324
|
final float l = X/2;
|
325
|
float h1 = isInIconMode() ? 0.001f : 0.025f;
|
326
|
float h2 = isInIconMode() ? 0.001f : 0.020f;
|
327
|
|
328
|
float[][] bands = { {h1,20,0.2f,0.4f,5,1,1}, {h2,20,0.2f,0.4f,5,1,1} };
|
329
|
int[] bandIndices = { 0,0,0,1,1 };
|
330
|
float[][] corners = { {0.04f,0.09f} };
|
331
|
int[] indices = { 0,0,0,0,-1,-1 };
|
332
|
float[][] centers = { { d-l, 0.0f,-h } };
|
333
|
return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
|
334
|
}
|
335
|
else if( variant==1 )
|
336
|
{
|
337
|
final float h = 3*X*X/(X*X+9);
|
338
|
final float H = 3*h/X;
|
339
|
final float l = (3-X)/2;
|
340
|
float h1 = isInIconMode() ? 0.001f : 0.03f;
|
341
|
float h2 = isInIconMode() ? 0.001f : 0.02f;
|
342
|
|
343
|
float[][] bands = { {h1,20,0.2f,0.4f,5,1,1}, {h2,20,0.2f,0.4f,5,1,1} };
|
344
|
int[] bandIndices = { 0,0,0,1,1,1 };
|
345
|
float[][] corners = { {0.03f,0.09f} };
|
346
|
int[] indices = { 0,0,0,0,-1,-1,-1,-1 };
|
347
|
float[][] centers = { {h-l, 0.5f, -H } };
|
348
|
return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
|
349
|
}
|
350
|
else
|
351
|
{
|
352
|
float h1 = isInIconMode() ? 0.001f : 0.05f;
|
353
|
float h2 = isInIconMode() ? 0.001f : 0.04f;
|
354
|
float[][] bands = { {h1,35,0.25f,0.7f,5,1,0}, {h2,35,0.25f,0.7f,5,1,0} };
|
355
|
int[] bandIndices = { 1,0,0,1,1,1 };
|
356
|
float[][] corners = { {0.04f,0.12f} };
|
357
|
int[] indices = { 0,0,0,0,0,0,0,0 };
|
358
|
float[][] centers = { {0.0f, 0.0f, 0.0f } };
|
359
|
return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
|
360
|
}
|
361
|
}
|
362
|
|
363
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
364
|
|
365
|
public int getNumCubitVariants(int[] numLayers)
|
366
|
{
|
367
|
return 3;
|
368
|
}
|
369
|
|
370
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
371
|
|
372
|
public int getCubitVariant(int cubit, int[] numLayers)
|
373
|
{
|
374
|
return cubit<12 ? 0 : (cubit<24 ? 1:2);
|
375
|
}
|
376
|
|
377
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
378
|
|
379
|
public float getStickerRadius()
|
380
|
{
|
381
|
return 0.10f;
|
382
|
}
|
383
|
|
384
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
385
|
|
386
|
public float getStickerStroke()
|
387
|
{
|
388
|
return isInIconMode() ? 0.22f : 0.10f;
|
389
|
}
|
390
|
|
391
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
392
|
|
393
|
public float[][] getStickerAngles()
|
394
|
{
|
395
|
return null;
|
396
|
}
|
397
|
|
398
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
399
|
// PUBLIC API
|
400
|
|
401
|
public Static3D[] getRotationAxis()
|
402
|
{
|
403
|
return ROT_AXIS;
|
404
|
}
|
405
|
|
406
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
407
|
|
408
|
public int[][] getBasicAngles()
|
409
|
{
|
410
|
if( mBasicAngle ==null )
|
411
|
{
|
412
|
int num = getNumLayers()[0];
|
413
|
int[] tmp = new int[num];
|
414
|
for(int i=0; i<num; i++) tmp[i] = 4;
|
415
|
mBasicAngle = new int[][] { tmp,tmp,tmp };
|
416
|
}
|
417
|
return mBasicAngle;
|
418
|
}
|
419
|
|
420
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
421
|
|
422
|
public String getShortName()
|
423
|
{
|
424
|
return ObjectType.WIND_3.name();
|
425
|
}
|
426
|
|
427
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
428
|
|
429
|
public ObjectSignature getSignature()
|
430
|
{
|
431
|
return new ObjectSignature(ObjectType.WIND_3);
|
432
|
}
|
433
|
|
434
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
435
|
|
436
|
public String getObjectName()
|
437
|
{
|
438
|
return "Windmill Cube";
|
439
|
}
|
440
|
|
441
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
442
|
|
443
|
public String getInventor()
|
444
|
{
|
445
|
return "Katsuhiko Okamoto";
|
446
|
}
|
447
|
|
448
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
449
|
|
450
|
public int getYearOfInvention()
|
451
|
{
|
452
|
return 2003;
|
453
|
}
|
454
|
|
455
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
456
|
|
457
|
public int getComplexity()
|
458
|
{
|
459
|
return 2;
|
460
|
}
|
461
|
|
462
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
463
|
|
464
|
public String[][] getTutorials()
|
465
|
{
|
466
|
return new String[][]{
|
467
|
{"gb","Jh8Bg7gT3PI","Windmill Cube Tutorial","Cube Solve Hero"},
|
468
|
{"es","wVyJs7AboKk","Como resolver Windmill","Tutoriales Rubik"},
|
469
|
{"ru","vavVAuEplKI","Как собрать Мельницу","Алексей Ярыгин"},
|
470
|
{"fr","qiVsyF1nn7o","Résolution du Windmill Cube","asthalis"},
|
471
|
{"de","JCYcAd0iCKk","Windmill Cube Tutorial","Pezcraft"},
|
472
|
{"pl","GZI_PtcURaA","Windmill TUTORIAL PL","MrUk"},
|
473
|
{"br","TXNVMp70lVE","Resolução do Windmill Cube","Pedro Filho"},
|
474
|
{"kr","gELuvKW2Itw","윈드밀 큐브 해법 강좌","굿맨's 큐브 이야기"},
|
475
|
{"vn","diiy8OqqtrE","Tutorial N.16 - Windmill Cube","Duy Thích Rubik"},
|
476
|
};
|
477
|
}
|
478
|
}
|