Project

General

Profile

Download (15.9 KB) Statistics
| Branch: | Revision:

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyWindmill.java @ 60bed292

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