Project

General

Profile

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

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

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2022 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is proprietary software licensed under an EULA which you should have received      //
7
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html        //
8
///////////////////////////////////////////////////////////////////////////////////////////////////
9

    
10
package org.distorted.objectlib.objects;
11

    
12
import org.distorted.library.type.Static3D;
13
import org.distorted.library.type.Static4D;
14

    
15
import org.distorted.objectlib.helpers.FactoryCubit;
16
import org.distorted.objectlib.helpers.ObjectFaceShape;
17
import org.distorted.objectlib.helpers.ObjectShape;
18
import org.distorted.objectlib.helpers.ObjectSignature;
19
import org.distorted.objectlib.helpers.ObjectVertexEffects;
20
import org.distorted.objectlib.main.InitAssets;
21
import org.distorted.objectlib.main.ObjectSignatures;
22
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator;
23
import org.distorted.objectlib.main.InitData;
24
import org.distorted.objectlib.main.ObjectType;
25
import org.distorted.objectlib.shape.ShapeHexahedron;
26
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
27

    
28
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_CHANGING_SHAPEMOD;
29
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
30

    
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32

    
33
public class TwistyWindmill extends ShapeHexahedron
34
{
35
  private static final float X = 1.8f;  // the cut goes from a corner and splits the opposing side 1.2 / 1.8
36
  private static final float L = (float)Math.sqrt(9+X*X);
37

    
38
  static final Static3D[] ROT_AXIS = new Static3D[]
39
         {
40
           new Static3D(  3/L, 0.0f, X/L),
41
           new Static3D( 0.0f, 1.0f,0.0f),
42
           new Static3D( -X/L, 0.0f, 3/L),
43
         };
44

    
45
  private int[][] mEdges;
46
  private int[][] mBasicAngle;
47
  private float[][] mCuts;
48
  private float[][] mPositions;
49
  private int[] mQuatIndex;
50

    
51
///////////////////////////////////////////////////////////////////////////////////////////////////
52

    
53
  public TwistyWindmill(int meshState, int iconMode, Static4D quat, Static3D move, float scale, InitData data, InitAssets asset)
54
    {
55
    super(meshState, iconMode, data.getNumLayers()[0], quat, move, scale, data, asset);
56
    }
57

    
58
///////////////////////////////////////////////////////////////////////////////////////////////////
59

    
60
  @Override
61
  public int getInternalColor()
62
    {
63
    return 0xff333333;
64
    }
65

    
66
///////////////////////////////////////////////////////////////////////////////////////////////////
67

    
68
  public int[][] getScrambleEdges()
69
    {
70
    if( mEdges==null ) mEdges = ScrambleEdgeGenerator.getScrambleEdgesCuboid(3,3,3);
71
    return mEdges;
72
    }
73

    
74
///////////////////////////////////////////////////////////////////////////////////////////////////
75

    
76
  public float[][] getCuts(int[] numLayers)
77
    {
78
    if( mCuts==null )
79
      {
80
      float C = 3*SQ5/10;
81
      float[] cut = new float[] {-C,+C};
82
      mCuts = new float[][] { cut,cut,cut };
83
      }
84

    
85
    return mCuts;
86
    }
87

    
88
///////////////////////////////////////////////////////////////////////////////////////////////////
89

    
90
  public boolean[][] getLayerRotatable(int[] numLayers)
91
    {
92
    boolean[] tmp = new boolean[] {true,true,true};
93
    return new boolean[][] { tmp,tmp,tmp };
94
    }
95

    
96
///////////////////////////////////////////////////////////////////////////////////////////////////
97

    
98
  public int getTouchControlType()
99
    {
100
    return TC_CHANGING_SHAPEMOD;
101
    }
102

    
103
///////////////////////////////////////////////////////////////////////////////////////////////////
104

    
105
  public int getTouchControlSplit()
106
    {
107
    return TYPE_NOT_SPLIT;
108
    }
109

    
110
///////////////////////////////////////////////////////////////////////////////////////////////////
111

    
112
  public int[][][] getEnabled()
113
    {
114
    return null;
115
    }
116

    
117
///////////////////////////////////////////////////////////////////////////////////////////////////
118

    
119
  public float[] getDist3D(int[] numLayers)
120
    {
121
    return TouchControlHexahedron.D3D;
122
    }
123

    
124
///////////////////////////////////////////////////////////////////////////////////////////////////
125

    
126
  public Static3D[] getFaceAxis()
127
    {
128
    return TouchControlHexahedron.FACE_AXIS;
129
    }
130

    
131
///////////////////////////////////////////////////////////////////////////////////////////////////
132

    
133
  public float[][] getCubitPositions(int[] numLayers)
134
    {
135
    if( mPositions==null )
136
      {
137
      final float DIS1 = -X/2 + 1.5f;
138
      final float DIS2 = -X/2;
139

    
140
      mPositions = new float[][]
141
         {
142
             { DIS1, 1.0f, 1.5f },
143
             { 1.5f, 1.0f,-DIS1 },
144
             {-DIS1, 1.0f,-1.5f },
145
             {-1.5f, 1.0f, DIS1 },
146
             { DIS1, 0.0f, 1.5f },
147
             { 1.5f, 0.0f,-DIS1 },
148
             {-DIS1, 0.0f,-1.5f },
149
             {-1.5f, 0.0f, DIS1 },
150
             { DIS1,-1.0f, 1.5f },
151
             { 1.5f,-1.0f,-DIS1 },
152
             {-DIS1,-1.0f,-1.5f },
153
             {-1.5f,-1.0f, DIS1 },
154

    
155
             { DIS2, 1.0f, 1.5f },
156
             { 1.5f, 1.0f,-DIS2 },
157
             {-DIS2, 1.0f,-1.5f },
158
             {-1.5f, 1.0f, DIS2 },
159
             { DIS2, 0.0f, 1.5f },
160
             { 1.5f, 0.0f,-DIS2 },
161
             {-DIS2, 0.0f,-1.5f },
162
             {-1.5f, 0.0f, DIS2 },
163
             { DIS2,-1.0f, 1.5f },
164
             { 1.5f,-1.0f,-DIS2 },
165
             {-DIS2,-1.0f,-1.5f },
166
             {-1.5f,-1.0f, DIS2 },
167

    
168
             { 0.0f, 1.0f, 0.0f },
169
             { 0.0f,-1.0f, 0.0f },
170
         };
171
      }
172

    
173
    return mPositions;
174
    }
175

    
176
///////////////////////////////////////////////////////////////////////////////////////////////////
177

    
178
  public Static4D getCubitQuats(int cubit, int[] numLayers)
179
    {
180
    if( mQuatIndex==null ) mQuatIndex = new int[] { 0,6,5,4,0,6,5,4,0,6,5,4,
181
                                                    0,6,5,4,0,6,5,4,0,6,5,4,
182
                                                    0,0 };
183
    return mObjectQuats[mQuatIndex[cubit]];
184
    }
185

    
186
///////////////////////////////////////////////////////////////////////////////////////////////////
187

    
188
  private float[][] getVertices(int variant)
189
    {
190
    if( variant==0 )
191
      {
192
      final float h = 3*X*X/(X*X+9);
193
      final float d = h*X/3;
194
      final float l = X/2;
195

    
196
      return new float[][]
197
          {
198
             {  -l, 0.5f, 0.0f },
199
             {   l, 0.5f, 0.0f },
200
             {   l,-0.5f, 0.0f },
201
             {  -l,-0.5f, 0.0f },
202
             { d-l, 0.5f,   -h },
203
             { d-l,-0.5f,   -h },
204
          };
205
      }
206
    else if( variant==1 )
207
      {
208
      final float h = 3*X*X/(X*X+9);
209
      final float d = h*X/3;
210
      final float H = 3*h/X;
211
      final float l = (3-X)/2;
212

    
213
      return new float[][]
214
          {
215
             { -l, 0.5f, 0.0f },
216
             {  l, 0.5f, 0.0f },
217
             {  l,-0.5f, 0.0f },
218
             { -l,-0.5f, 0.0f },
219
             {h-l, 0.5f,  -H  },
220
             {d+l, 0.5f,  -h  },
221
             {d+l,-0.5f,  -h  },
222
             {h-l,-0.5f,  -H  }
223
          };
224
      }
225
    else
226
      {
227
      final float h = 3*X*X/(X*X+9);
228
      final float H = 3*h/X;
229
      final float x = 1.5f-H;
230
      final float y = 1.5f-h;
231

    
232
      return new float[][]
233
          {
234
             { -y, 0.5f, x },
235
             {  x, 0.5f, y },
236
             {  x,-0.5f, y },
237
             { -y,-0.5f, x },
238
             { -x, 0.5f,-y },
239
             {  y, 0.5f,-x },
240
             {  y,-0.5f,-x },
241
             { -x,-0.5f,-y }
242
          };
243
      }
244
    }
245

    
246
///////////////////////////////////////////////////////////////////////////////////////////////////
247

    
248
  public ObjectShape getObjectShape(int variant)
249
    {
250
    if( variant==0 )
251
      {
252
      int[][] indices =
253
          {
254
             { 3,2,1,0 },
255
             { 0,1,4 },
256
             { 5,2,3 },
257
             { 5,3,0,4 },
258
             { 2,5,4,1 },
259
          };
260

    
261
      return new ObjectShape(getVertices(variant),indices);
262
      }
263
    else if( variant==1 )
264
      {
265
      int[][] indices =
266
          {
267
             { 3,2,1,0 },
268
             { 0,1,5,4 },
269
             { 7,6,2,3 },
270
             { 2,6,5,1 },
271
             { 6,7,4,5 },
272
             { 7,3,0,4 }
273
          };
274

    
275
      return new ObjectShape(getVertices(variant),indices);
276
      }
277
    else
278
      {
279
      int[][] indices =
280
          {
281
             { 3,2,1,0 },
282
             { 0,1,5,4 },
283
             { 7,6,2,3 },
284
             { 2,6,5,1 },
285
             { 6,7,4,5 },
286
             { 7,3,0,4 }
287
          };
288

    
289
      return new ObjectShape(getVertices(variant),indices);
290
      }
291
    }
292

    
293
///////////////////////////////////////////////////////////////////////////////////////////////////
294

    
295
  public ObjectFaceShape getObjectFaceShape(int variant)
296
    {
297
    if( variant==0 )
298
      {
299
      float h1 = isInIconMode() ? 0.001f : 0.025f;
300
      float h2 = isInIconMode() ? 0.001f : 0.020f;
301
      float[][] bands = { {h1,20,0.2f,0.4f,5,1,1}, {h2,20,0.2f,0.4f,5,1,1} };
302
      int[] indices   = { 0,0,0,1,1 };
303
      return new ObjectFaceShape(bands,indices,null);
304
      }
305
    else if( variant==1 )
306
      {
307
      float h1 = isInIconMode() ? 0.001f : 0.03f;
308
      float h2 = isInIconMode() ? 0.001f : 0.02f;
309
      float[][] bands = { {h1,20,0.2f,0.4f,5,1,1}, {h2,20,0.2f,0.4f,5,1,1} };
310
      int[] indices   = { 0,0,0,1,1,1 };
311
      return new ObjectFaceShape(bands,indices,null);
312
      }
313
    else
314
      {
315
      float h1 = isInIconMode() ? 0.001f : 0.05f;
316
      float h2 = isInIconMode() ? 0.001f : 0.04f;
317
      float[][] bands= { {h1,35,0.25f,0.7f,5,1,0}, {h2,35,0.25f,0.7f,5,1,0} };
318
      int[] indices  = { 1,0,0,1,1,1 };
319
      return new ObjectFaceShape(bands,indices,null);
320
      }
321
    }
322

    
323
///////////////////////////////////////////////////////////////////////////////////////////////////
324

    
325
  public ObjectVertexEffects getVertexEffects(int variant)
326
    {
327
    if( variant==0 )
328
      {
329
      final float h = 3*X*X/(X*X+9);
330
      final float d = h*X/3;
331
      final float l = X/2;
332
      float[][] corners = { {0.04f,0.09f} };
333
      int[] indices     = { 0,0,0,0,-1,-1 };
334
      float[][] centers = { { d-l, 0.0f,-h } };
335
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
336
      }
337
    else if( variant==1 )
338
      {
339
      final float h = 3*X*X/(X*X+9);
340
      final float H = 3*h/X;
341
      final float l = (3-X)/2;
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 FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
346
      }
347
    else
348
      {
349
      float[][] corners = { {0.04f,0.12f} };
350
      int[] indices     = { 0,0,0,0,0,0,0,0 };
351
      float[][] centers = { {0.0f, 0.0f, 0.0f } };
352
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
353
      }
354
    }
355

    
356
///////////////////////////////////////////////////////////////////////////////////////////////////
357

    
358
  public int getNumCubitVariants(int[] numLayers)
359
    {
360
    return 3;
361
    }
362

    
363
///////////////////////////////////////////////////////////////////////////////////////////////////
364

    
365
  public int getCubitVariant(int cubit, int[] numLayers)
366
    {
367
    return cubit<12 ? 0 : (cubit<24 ? 1:2);
368
    }
369

    
370
///////////////////////////////////////////////////////////////////////////////////////////////////
371

    
372
  public float getStickerRadius()
373
    {
374
    return 0.10f;
375
    }
376

    
377
///////////////////////////////////////////////////////////////////////////////////////////////////
378

    
379
  public float getStickerStroke()
380
    {
381
    return isInIconMode() ? 0.22f : 0.10f;
382
    }
383

    
384
///////////////////////////////////////////////////////////////////////////////////////////////////
385

    
386
  public float[][] getStickerAngles()
387
    {
388
    return null;
389
    }
390

    
391
///////////////////////////////////////////////////////////////////////////////////////////////////
392
// PUBLIC API
393

    
394
  public Static3D[] getRotationAxis()
395
    {
396
    return ROT_AXIS;
397
    }
398

    
399
///////////////////////////////////////////////////////////////////////////////////////////////////
400

    
401
  public int[][] getBasicAngles()
402
    {
403
    if( mBasicAngle ==null )
404
      {
405
      int num = getNumLayers()[0];
406
      int[] tmp = new int[num];
407
      for(int i=0; i<num; i++) tmp[i] = 4;
408
      mBasicAngle = new int[][] { tmp,tmp,tmp };
409
      }
410
    return mBasicAngle;
411
    }
412

    
413
///////////////////////////////////////////////////////////////////////////////////////////////////
414

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

    
420
///////////////////////////////////////////////////////////////////////////////////////////////////
421

    
422
  public ObjectSignature getSignature()
423
    {
424
    return new ObjectSignature(ObjectSignatures.WIND_3);
425
    }
426

    
427
///////////////////////////////////////////////////////////////////////////////////////////////////
428

    
429
  public String getObjectName()
430
    {
431
    return "Windmill Cube";
432
    }
433

    
434
///////////////////////////////////////////////////////////////////////////////////////////////////
435

    
436
  public String getInventor()
437
    {
438
    return "Katsuhiko Okamoto";
439
    }
440

    
441
///////////////////////////////////////////////////////////////////////////////////////////////////
442

    
443
  public int getYearOfInvention()
444
    {
445
    return 2003;
446
    }
447

    
448
///////////////////////////////////////////////////////////////////////////////////////////////////
449

    
450
  public int getComplexity()
451
    {
452
    return 2;
453
    }
454

    
455
///////////////////////////////////////////////////////////////////////////////////////////////////
456

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