Project

General

Profile

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

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

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.metadata.Metadata;
19
import org.distorted.objectlib.helpers.ObjectVertexEffects;
20
import org.distorted.objectlib.main.InitAssets;
21
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator;
22
import org.distorted.objectlib.metadata.ListObjects;
23
import org.distorted.objectlib.shape.ShapeHexahedron;
24
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
25

    
26
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_CHANGING_SHAPEMOD;
27
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
28

    
29
///////////////////////////////////////////////////////////////////////////////////////////////////
30

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

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

    
43
  private int[][] mEdges;
44
  private int[][] mBasicAngle;
45
  private float[][] mCuts;
46
  private float[][] mPositions;
47
  private int[] mQuatIndex;
48

    
49
///////////////////////////////////////////////////////////////////////////////////////////////////
50

    
51
  public TwistyWindmill(int iconMode, Static4D quat, Static3D move, float scale, Metadata meta, InitAssets asset)
52
    {
53
    super(iconMode, meta.getNumLayers()[0], quat, move, scale, meta, asset);
54
    }
55

    
56
///////////////////////////////////////////////////////////////////////////////////////////////////
57

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

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

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

    
72
///////////////////////////////////////////////////////////////////////////////////////////////////
73

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

    
83
    return mCuts;
84
    }
85

    
86
///////////////////////////////////////////////////////////////////////////////////////////////////
87

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

    
94
///////////////////////////////////////////////////////////////////////////////////////////////////
95

    
96
  public int getTouchControlType()
97
    {
98
    return TC_CHANGING_SHAPEMOD;
99
    }
100

    
101
///////////////////////////////////////////////////////////////////////////////////////////////////
102

    
103
  public int getTouchControlSplit()
104
    {
105
    return TYPE_NOT_SPLIT;
106
    }
107

    
108
///////////////////////////////////////////////////////////////////////////////////////////////////
109

    
110
  public int[][][] getEnabled()
111
    {
112
    return null;
113
    }
114

    
115
///////////////////////////////////////////////////////////////////////////////////////////////////
116

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

    
122
///////////////////////////////////////////////////////////////////////////////////////////////////
123

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

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

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

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

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

    
166
             { 0.0f, 1.0f, 0.0f },
167
             { 0.0f,-1.0f, 0.0f },
168
         };
169
      }
170

    
171
    return mPositions;
172
    }
173

    
174
///////////////////////////////////////////////////////////////////////////////////////////////////
175

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

    
184
///////////////////////////////////////////////////////////////////////////////////////////////////
185

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

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

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

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

    
244
///////////////////////////////////////////////////////////////////////////////////////////////////
245

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

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

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

    
287
      return new ObjectShape(getVertices(variant),indices);
288
      }
289
    }
290

    
291
///////////////////////////////////////////////////////////////////////////////////////////////////
292

    
293
  public ObjectFaceShape getObjectFaceShape(int variant)
294
    {
295
    int angle = 25;
296
    float R = 0.7f;
297
    float S = 0.5f;
298

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

    
325
///////////////////////////////////////////////////////////////////////////////////////////////////
326

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

    
358
///////////////////////////////////////////////////////////////////////////////////////////////////
359

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

    
365
///////////////////////////////////////////////////////////////////////////////////////////////////
366

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

    
372
///////////////////////////////////////////////////////////////////////////////////////////////////
373

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

    
379
///////////////////////////////////////////////////////////////////////////////////////////////////
380

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

    
386
///////////////////////////////////////////////////////////////////////////////////////////////////
387

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

    
393
///////////////////////////////////////////////////////////////////////////////////////////////////
394
// PUBLIC API
395

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

    
401
///////////////////////////////////////////////////////////////////////////////////////////////////
402

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

    
415
///////////////////////////////////////////////////////////////////////////////////////////////////
416

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

    
422
///////////////////////////////////////////////////////////////////////////////////////////////////
423

    
424
  public String[][] getTutorials()
425
    {
426
    return new String[][]{
427
                          {"gb","Jh8Bg7gT3PI","Windmill Cube Tutorial","Cube Solve Hero"},
428
                          {"es","wVyJs7AboKk","Como resolver Windmill","Tutoriales Rubik"},
429
                          {"ru","vavVAuEplKI","Как собрать Мельницу","Алексей Ярыгин"},
430
                          {"fr","qiVsyF1nn7o","Résolution du Windmill Cube","asthalis"},
431
                          {"de","JCYcAd0iCKk","Windmill Cube Tutorial","Pezcraft"},
432
                          {"pl","GZI_PtcURaA","Windmill TUTORIAL PL","MrUk"},
433
                          {"br","TXNVMp70lVE","Resolução do Windmill Cube","Pedro Filho"},
434
                          {"kr","gELuvKW2Itw","윈드밀  큐브 해법 강좌","굿맨's 큐브 이야기"},
435
                          {"vn","diiy8OqqtrE","Tutorial N.16 - Windmill Cube","Duy Thích Rubik"},
436
                          {"tw","g50bcKo0RoQ","風火輪方塊解法","1hrBLD"},
437
                         };
438
    }
439
}
(59-59/59)