Project

General

Profile

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

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

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 java.io.InputStream;
13

    
14
import org.distorted.library.type.Static3D;
15
import org.distorted.library.type.Static4D;
16

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

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

    
32
///////////////////////////////////////////////////////////////////////////////////////////////////
33

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

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

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

    
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53

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

    
59
///////////////////////////////////////////////////////////////////////////////////////////////////
60

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

    
67
///////////////////////////////////////////////////////////////////////////////////////////////////
68

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

    
75
///////////////////////////////////////////////////////////////////////////////////////////////////
76

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

    
86
    return mCuts;
87
    }
88

    
89
///////////////////////////////////////////////////////////////////////////////////////////////////
90

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

    
97
///////////////////////////////////////////////////////////////////////////////////////////////////
98

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

    
104
///////////////////////////////////////////////////////////////////////////////////////////////////
105

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

    
111
///////////////////////////////////////////////////////////////////////////////////////////////////
112

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

    
118
///////////////////////////////////////////////////////////////////////////////////////////////////
119

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

    
125
///////////////////////////////////////////////////////////////////////////////////////////////////
126

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

    
132
///////////////////////////////////////////////////////////////////////////////////////////////////
133

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

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

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

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

    
174
    return mPositions;
175
    }
176

    
177
///////////////////////////////////////////////////////////////////////////////////////////////////
178

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

    
187
///////////////////////////////////////////////////////////////////////////////////////////////////
188

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

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

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

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

    
247
///////////////////////////////////////////////////////////////////////////////////////////////////
248

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

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

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

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

    
294
///////////////////////////////////////////////////////////////////////////////////////////////////
295

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

    
324
///////////////////////////////////////////////////////////////////////////////////////////////////
325

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

    
357
///////////////////////////////////////////////////////////////////////////////////////////////////
358

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

    
364
///////////////////////////////////////////////////////////////////////////////////////////////////
365

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

    
371
///////////////////////////////////////////////////////////////////////////////////////////////////
372

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

    
378
///////////////////////////////////////////////////////////////////////////////////////////////////
379

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

    
385
///////////////////////////////////////////////////////////////////////////////////////////////////
386

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

    
392
///////////////////////////////////////////////////////////////////////////////////////////////////
393
// PUBLIC API
394

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

    
400
///////////////////////////////////////////////////////////////////////////////////////////////////
401

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

    
414
///////////////////////////////////////////////////////////////////////////////////////////////////
415

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

    
421
///////////////////////////////////////////////////////////////////////////////////////////////////
422

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

    
428
///////////////////////////////////////////////////////////////////////////////////////////////////
429

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

    
435
///////////////////////////////////////////////////////////////////////////////////////////////////
436

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

    
442
///////////////////////////////////////////////////////////////////////////////////////////////////
443

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

    
449
///////////////////////////////////////////////////////////////////////////////////////////////////
450

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

    
456
///////////////////////////////////////////////////////////////////////////////////////////////////
457

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