Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyWindmill.java @ 3bf19410

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.scrambling.ScrambleState;
30
import org.distorted.objectlib.main.ObjectType;
31
import org.distorted.objectlib.main.ShapeHexahedron;
32
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
33

    
34
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_CHANGING_SHAPEMOD;
35
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
36

    
37
///////////////////////////////////////////////////////////////////////////////////////////////////
38

    
39
public class TwistyWindmill extends ShapeHexahedron
40
{
41
  private static final float X = 1.8f;  // the cut goes from a corner and splits the opposing side 1.2 / 1.8
42
  private static final float L = (float)Math.sqrt(9+X*X);
43

    
44
  static final Static3D[] ROT_AXIS = new Static3D[]
45
         {
46
           new Static3D(  3/L, 0.0f, X/L),
47
           new Static3D( 0.0f, 1.0f,0.0f),
48
           new Static3D( -X/L, 0.0f, 3/L),
49
         };
50

    
51
  private ScrambleState[] mStates;
52
  private int[] mBasicAngle;
53
  private float[][] mCuts;
54
  private float[][] mCenters;
55
  private int[] mQuatIndex;
56

    
57
///////////////////////////////////////////////////////////////////////////////////////////////////
58

    
59
  public TwistyWindmill(int[] numL, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
60
    {
61
    super(numL, meshState, iconMode, numL[0], quat, move, scale, stream);
62
    }
63

    
64
///////////////////////////////////////////////////////////////////////////////////////////////////
65

    
66
  @Override
67
  public int getInternalColor()
68
    {
69
    return 0xff333333;
70
    }
71

    
72
///////////////////////////////////////////////////////////////////////////////////////////////////
73
// same as in a 3x3
74

    
75
  public ScrambleState[] getScrambleStates()
76
    {
77
    if( mStates==null )
78
      {
79
      int[][] m = new int[16][];
80

    
81
      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};
82

    
83
      mStates = new ScrambleState[]
84
          {
85
          new ScrambleState( new int[][] { m[ 1], m[ 2], m[ 3] } ),  //  0 0
86
          new ScrambleState( new int[][] {  null, m[ 4], m[ 5] } ),  //  1 x
87
          new ScrambleState( new int[][] { m[ 6],  null, m[ 7] } ),  //  2 y
88
          new ScrambleState( new int[][] { m[ 8], m[ 9],  null } ),  //  3 z
89
          new ScrambleState( new int[][] { m[10],  null, m[ 7] } ),  //  4 xy
90
          new ScrambleState( new int[][] { m[11], m[ 9],  null } ),  //  5 xz
91
          new ScrambleState( new int[][] {  null, m[12], m[ 5] } ),  //  6 yx
92
          new ScrambleState( new int[][] { m[ 8], m[13],  null } ),  //  7 yz
93
          new ScrambleState( new int[][] {  null, m[ 4], m[14] } ),  //  8 zx
94
          new ScrambleState( new int[][] { m[ 6],  null, m[15] } ),  //  9 zy
95
          new ScrambleState( new int[][] {  null,  null, m[ 5] } ),  // 10 xyx
96
          new ScrambleState( new int[][] {  null, m[ 4],  null } ),  // 11 xzx
97
          new ScrambleState( new int[][] {  null,  null, m[ 7] } ),  // 12 yxy
98
          new ScrambleState( new int[][] { m[ 6],  null,  null } ),  // 13 yzy
99
          new ScrambleState( new int[][] {  null, m[ 9],  null } ),  // 14 zxz
100
          new ScrambleState( new int[][] { m[ 8],  null,  null } ),  // 15 zyz
101
          };
102
      }
103

    
104
    return mStates;
105
    }
106

    
107
///////////////////////////////////////////////////////////////////////////////////////////////////
108

    
109
  public float[][] getCuts(int[] numLayers)
110
    {
111
    if( mCuts==null )
112
      {
113
      float C = 3*SQ5/10;
114
      float[] cut = new float[] {-C,+C};
115
      mCuts = new float[][] { cut,cut,cut };
116
      }
117

    
118
    return mCuts;
119
    }
120

    
121
///////////////////////////////////////////////////////////////////////////////////////////////////
122

    
123
  public boolean[][] getLayerRotatable(int[] numLayers)
124
    {
125
    boolean[] tmp = new boolean[] {true,true,true};
126
    return new boolean[][] { tmp,tmp,tmp };
127
    }
128

    
129
///////////////////////////////////////////////////////////////////////////////////////////////////
130

    
131
  public int getTouchControlType()
132
    {
133
    return TC_CHANGING_SHAPEMOD;
134
    }
135

    
136
///////////////////////////////////////////////////////////////////////////////////////////////////
137

    
138
  public int getTouchControlSplit()
139
    {
140
    return TYPE_NOT_SPLIT;
141
    }
142

    
143
///////////////////////////////////////////////////////////////////////////////////////////////////
144

    
145
  public int[][][] getEnabled()
146
    {
147
    return null;
148
    }
149

    
150
///////////////////////////////////////////////////////////////////////////////////////////////////
151

    
152
  public float[] getDist3D(int[] numLayers)
153
    {
154
    return TouchControlHexahedron.D3D;
155
    }
156

    
157
///////////////////////////////////////////////////////////////////////////////////////////////////
158

    
159
  public Static3D[] getFaceAxis()
160
    {
161
    return TouchControlHexahedron.FACE_AXIS;
162
    }
163

    
164
///////////////////////////////////////////////////////////////////////////////////////////////////
165

    
166
  public float[][] getCubitPositions(int[] numLayers)
167
    {
168
    if( mCenters==null )
169
      {
170
      final float DIS1 = -X/2 + 1.5f;
171
      final float DIS2 = -X/2;
172

    
173
      mCenters = new float[][]
174
         {
175
             { DIS1, 1.0f, 1.5f },
176
             { 1.5f, 1.0f,-DIS1 },
177
             {-DIS1, 1.0f,-1.5f },
178
             {-1.5f, 1.0f, DIS1 },
179
             { DIS1, 0.0f, 1.5f },
180
             { 1.5f, 0.0f,-DIS1 },
181
             {-DIS1, 0.0f,-1.5f },
182
             {-1.5f, 0.0f, DIS1 },
183
             { DIS1,-1.0f, 1.5f },
184
             { 1.5f,-1.0f,-DIS1 },
185
             {-DIS1,-1.0f,-1.5f },
186
             {-1.5f,-1.0f, DIS1 },
187

    
188
             { DIS2, 1.0f, 1.5f },
189
             { 1.5f, 1.0f,-DIS2 },
190
             {-DIS2, 1.0f,-1.5f },
191
             {-1.5f, 1.0f, DIS2 },
192
             { DIS2, 0.0f, 1.5f },
193
             { 1.5f, 0.0f,-DIS2 },
194
             {-DIS2, 0.0f,-1.5f },
195
             {-1.5f, 0.0f, DIS2 },
196
             { DIS2,-1.0f, 1.5f },
197
             { 1.5f,-1.0f,-DIS2 },
198
             {-DIS2,-1.0f,-1.5f },
199
             {-1.5f,-1.0f, DIS2 },
200

    
201
             { 0.0f, 1.0f, 0.0f },
202
             { 0.0f,-1.0f, 0.0f },
203
         };
204
      }
205

    
206
    return mCenters;
207
    }
208

    
209
///////////////////////////////////////////////////////////////////////////////////////////////////
210

    
211
  public Static4D getCubitQuats(int cubit, int[] numLayers)
212
    {
213
    int I0 =0; int I1 =6; int I2 =5; int I3 =4;
214
    if( mQuatIndex==null ) mQuatIndex = new int[] {I0,I1,I2,I3,I0,I1,I2,I3,I0,I1,I2,I3, I0,I1,I2,I3,I0,I1,I2,I3,I0,I1,I2,I3, 0,0 };
215
    return mObjectQuats[mQuatIndex[cubit]];
216
    }
217

    
218
///////////////////////////////////////////////////////////////////////////////////////////////////
219

    
220
  public ObjectShape getObjectShape(int variant)
221
    {
222
    if( variant==0 )
223
      {
224
      final float h = 3*X*X/(X*X+9);
225
      final float d = h*X/3;
226
      final float l = X/2;
227

    
228
      float[][] vertices =
229
          {
230
             {  -l, 0.5f, 0.0f },
231
             {   l, 0.5f, 0.0f },
232
             {   l,-0.5f, 0.0f },
233
             {  -l,-0.5f, 0.0f },
234
             { d-l, 0.5f,   -h },
235
             { d-l,-0.5f,   -h },
236
          };
237

    
238
      int[][] indices =
239
          {
240
             { 3,2,1,0 },
241
             { 0,1,4 },
242
             { 5,2,3 },
243
             { 5,3,0,4 },
244
             { 2,5,4,1 },
245
          };
246

    
247
      return new ObjectShape(vertices, indices);
248
      }
249
    else if( variant==1 )
250
      {
251
      final float h = 3*X*X/(X*X+9);
252
      final float d = h*X/3;
253
      final float H = 3*h/X;
254
      final float l = (3-X)/2;
255

    
256
      float[][] vertices =
257
          {
258
             { -l, 0.5f, 0.0f },
259
             {  l, 0.5f, 0.0f },
260
             {  l,-0.5f, 0.0f },
261
             { -l,-0.5f, 0.0f },
262
             {h-l, 0.5f,  -H  },
263
             {d+l, 0.5f,  -h  },
264
             {d+l,-0.5f,  -h  },
265
             {h-l,-0.5f,  -H  }
266
          };
267

    
268
      int[][] indices =
269
          {
270
             { 3,2,1,0 },
271
             { 0,1,5,4 },
272
             { 7,6,2,3 },
273
             { 2,6,5,1 },
274
             { 6,7,4,5 },
275
             { 7,3,0,4 }
276
          };
277

    
278
      return new ObjectShape(vertices, indices);
279
      }
280
    else
281
      {
282
      final float h = 3*X*X/(X*X+9);
283
      final float H = 3*h/X;
284
      final float x = 1.5f-H;
285
      final float y = 1.5f-h;
286

    
287
      float[][] vertices =
288
          {
289
             { -y, 0.5f, x },
290
             {  x, 0.5f, y },
291
             {  x,-0.5f, y },
292
             { -y,-0.5f, x },
293
             { -x, 0.5f,-y },
294
             {  y, 0.5f,-x },
295
             {  y,-0.5f,-x },
296
             { -x,-0.5f,-y }
297
          };
298

    
299
      int[][] indices =
300
          {
301
             { 3,2,1,0 },
302
             { 0,1,5,4 },
303
             { 7,6,2,3 },
304
             { 2,6,5,1 },
305
             { 6,7,4,5 },
306
             { 7,3,0,4 }
307
          };
308

    
309
      return new ObjectShape(vertices, indices);
310
      }
311
    }
312

    
313
///////////////////////////////////////////////////////////////////////////////////////////////////
314

    
315
  public ObjectFaceShape getObjectFaceShape(int variant)
316
    {
317
    if( variant==0 )
318
      {
319
      final float h = 3*X*X/(X*X+9);
320
      final float d = h*X/3;
321
      final float l = X/2;
322
      float h1 = isInIconMode() ? 0.001f : 0.025f;
323
      float h2 = isInIconMode() ? 0.001f : 0.020f;
324

    
325
      float[][] bands   = { {h1,20,0.2f,0.4f,5,1,1}, {h2,20,0.2f,0.4f,5,1,1} };
326
      int[] bandIndices = { 0,0,0,1,1 };
327
      float[][] corners = { {0.04f,0.09f} };
328
      int[] indices     = { 0,0,0,0,-1,-1 };
329
      float[][] centers = { { d-l, 0.0f,-h } };
330
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
331
      }
332
    else if( variant==1 )
333
      {
334
      final float h = 3*X*X/(X*X+9);
335
      final float H = 3*h/X;
336
      final float l = (3-X)/2;
337
      float h1 = isInIconMode() ? 0.001f : 0.03f;
338
      float h2 = isInIconMode() ? 0.001f : 0.02f;
339

    
340
      float[][] bands   = { {h1,20,0.2f,0.4f,5,1,1}, {h2,20,0.2f,0.4f,5,1,1} };
341
      int[] bandIndices = { 0,0,0,1,1,1 };
342
      float[][] corners = { {0.03f,0.09f} };
343
      int[] indices     = { 0,0,0,0,-1,-1,-1,-1 };
344
      float[][] centers = { {h-l, 0.5f, -H } };
345
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
346
      }
347
    else
348
      {
349
      float h1 = isInIconMode() ? 0.001f : 0.05f;
350
      float h2 = isInIconMode() ? 0.001f : 0.04f;
351
      float[][] bands   = { {h1,35,0.25f,0.7f,5,1,0}, {h2,35,0.25f,0.7f,5,1,0} };
352
      int[] bandIndices = { 1,0,0,1,1,1 };
353
      float[][] corners = { {0.04f,0.12f} };
354
      int[] indices     = { 0,0,0,0,0,0,0,0 };
355
      float[][] centers = { {0.0f, 0.0f, 0.0f } };
356
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
357
      }
358
    }
359

    
360
///////////////////////////////////////////////////////////////////////////////////////////////////
361

    
362
  public int getNumCubitVariants(int[] numLayers)
363
    {
364
    return 3;
365
    }
366

    
367
///////////////////////////////////////////////////////////////////////////////////////////////////
368

    
369
  public int getCubitVariant(int cubit, int[] numLayers)
370
    {
371
    return cubit<12 ? 0 : (cubit<24 ? 1:2);
372
    }
373

    
374
///////////////////////////////////////////////////////////////////////////////////////////////////
375

    
376
  public float getStickerRadius()
377
    {
378
    return 0.10f;
379
    }
380

    
381
///////////////////////////////////////////////////////////////////////////////////////////////////
382

    
383
  public float getStickerStroke()
384
    {
385
    return isInIconMode() ? 0.22f : 0.10f;
386
    }
387

    
388
///////////////////////////////////////////////////////////////////////////////////////////////////
389

    
390
  public float[][] getStickerAngles()
391
    {
392
    return null;
393
    }
394

    
395
///////////////////////////////////////////////////////////////////////////////////////////////////
396
// PUBLIC API
397

    
398
  public Static3D[] getRotationAxis()
399
    {
400
    return ROT_AXIS;
401
    }
402

    
403
///////////////////////////////////////////////////////////////////////////////////////////////////
404

    
405
  public int[] getBasicAngles()
406
    {
407
    if( mBasicAngle ==null ) mBasicAngle = new int[] { 4,4,4 };
408
    return mBasicAngle;
409
    }
410

    
411
///////////////////////////////////////////////////////////////////////////////////////////////////
412

    
413
  public String getShortName()
414
    {
415
    return ObjectType.WIND_3.name();
416
    }
417

    
418
///////////////////////////////////////////////////////////////////////////////////////////////////
419

    
420
  public long getSignature()
421
    {
422
    return ObjectType.WIND_3.ordinal();
423
    }
424

    
425
///////////////////////////////////////////////////////////////////////////////////////////////////
426

    
427
  public String getObjectName()
428
    {
429
    return "Windmill Cube";
430
    }
431

    
432
///////////////////////////////////////////////////////////////////////////////////////////////////
433

    
434
  public String getInventor()
435
    {
436
    return "Katsuhiko Okamoto";
437
    }
438

    
439
///////////////////////////////////////////////////////////////////////////////////////////////////
440

    
441
  public int getYearOfInvention()
442
    {
443
    return 2003;
444
    }
445

    
446
///////////////////////////////////////////////////////////////////////////////////////////////////
447

    
448
  public int getComplexity()
449
    {
450
    return 2;
451
    }
452

    
453
///////////////////////////////////////////////////////////////////////////////////////////////////
454

    
455
  public String[][] getTutorials()
456
    {
457
    return new String[][]{
458
                          {"gb","Jh8Bg7gT3PI","Windmill Cube Tutorial","Cube Solve Hero"},
459
                          {"es","wVyJs7AboKk","Como resolver Windmill","Tutoriales Rubik"},
460
                          {"ru","vavVAuEplKI","Как собрать Мельницу","Алексей Ярыгин"},
461
                          {"fr","qiVsyF1nn7o","Résolution du Windmill Cube","asthalis"},
462
                          {"de","JCYcAd0iCKk","Windmill Cube Tutorial","Pezcraft"},
463
                          {"pl","GZI_PtcURaA","Windmill TUTORIAL PL","MrUk"},
464
                          {"br","TXNVMp70lVE","Resolução do Windmill Cube","Pedro Filho"},
465
                          {"kr","gELuvKW2Itw","윈드밀  큐브 해법 강좌","굿맨's 큐브 이야기"},
466
                          {"vn","diiy8OqqtrE","Tutorial N.16 - Windmill Cube","Duy Thích Rubik"},
467
                         };
468
    }
469
}
(34-34/34)