Project

General

Profile

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

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

1 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6 6133be67 Leszek Koltunski
// 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 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
9
10
package org.distorted.objectlib.objects;
11
12 c9c71c3f Leszek Koltunski
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_DODECAHEDRON;
13
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
14 29b82486 Leszek Koltunski
15
import org.distorted.library.type.Static3D;
16
import org.distorted.library.type.Static4D;
17
18 84a17011 Leszek Koltunski
import org.distorted.objectlib.helpers.FactoryCubit;
19 3ee1d662 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectFaceShape;
20 ae9d9227 leszek
import org.distorted.objectlib.metadata.Metadata;
21 84a17011 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectVertexEffects;
22 cf93ea4e Leszek Koltunski
import org.distorted.objectlib.main.InitAssets;
23 9ba7f3f6 Leszek Koltunski
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator;
24 c9c71c3f Leszek Koltunski
import org.distorted.objectlib.touchcontrol.TouchControlDodecahedron;
25 361fd0de leszek
import org.distorted.objectlib.metadata.ListObjects;
26 198c5bf0 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectShape;
27 b31249d6 Leszek Koltunski
import org.distorted.objectlib.shape.ShapeDodecahedron;
28 29b82486 Leszek Koltunski
29
///////////////////////////////////////////////////////////////////////////////////////////////////
30
31 386af988 Leszek Koltunski
public class TwistyUltimate extends ShapeDodecahedron
32 29b82486 Leszek Koltunski
{
33
  private static final float A = (float)Math.sqrt(21*SQ5+47);
34
  private static final float B = SQ6*(5*SQ5+11)/(6*A);
35
  private static final float C = SQ6*(  SQ5+ 2)/(3*A);
36
  private static final float D = SQ3/3;
37
  private static final float E = (SQ5+1)/4;
38
  private static final float G = (SQ5+3)/4;
39
40
  static final Static3D[] ROT_AXIS = new Static3D[]
41
         {
42
           new Static3D( B,0,C ),
43
           new Static3D( C,B,0 ),
44
           new Static3D(-D,D,D ),
45
           new Static3D( 0,C,-B)
46
         };
47
48 9ba7f3f6 Leszek Koltunski
  private int[][] mEdges;
49 beee90ab Leszek Koltunski
  private int[][] mBasicAngle;
50 29b82486 Leszek Koltunski
  private float[][] mCuts;
51 82e62580 Leszek Koltunski
  private float[][] mPositions;
52 29b82486 Leszek Koltunski
  private int[] mQuatIndex;
53
54
///////////////////////////////////////////////////////////////////////////////////////////////////
55
56 ae9d9227 leszek
  public TwistyUltimate(int iconMode, Static4D quat, Static3D move, float scale, Metadata meta, InitAssets asset)
57 29b82486 Leszek Koltunski
    {
58 ae9d9227 leszek
    super(iconMode, meta.getNumLayers()[0], quat, move, scale, meta, asset);
59 29b82486 Leszek Koltunski
    }
60
61
///////////////////////////////////////////////////////////////////////////////////////////////////
62
63 9ba7f3f6 Leszek Koltunski
  public int[][] getScrambleEdges()
64 29b82486 Leszek Koltunski
    {
65 9ba7f3f6 Leszek Koltunski
    if( mEdges==null ) mEdges = ScrambleEdgeGenerator.getScrambleEdgesSingle(mBasicAngle);
66
    return mEdges;
67 29b82486 Leszek Koltunski
    }
68
69 d0e6cf7f Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
70
71
  public float[][] getCubitPositions(int[] numLayers)
72
    {
73 82e62580 Leszek Koltunski
    if( mPositions==null )
74 d0e6cf7f Leszek Koltunski
      {
75 82e62580 Leszek Koltunski
      mPositions = new float[][]
76 d0e6cf7f Leszek Koltunski
         {
77
           {   0,  -1, 2*G },
78
           { 2*E,-2*E,-2*E },
79
           {-2*G,   0,  -1 },
80
           {   1, 2*G,   0 },
81
82
           {-2*E,  2*E, 2*E },
83
           { 2*G,    0,   1 },
84
           {  -1, -2*G,   0 },
85
           {   0,    1,-2*G },
86
87
           {        E, (E+0.5f),    (E+G) },
88
           {   -(E+G),       -E, (E+0.5f) },
89
           { (E+0.5f),   -(E+G),        E },
90
           {       -E,-(E+0.5f),   -(E+G) },
91
           {    (E+G),        E,-(E+0.5f) },
92
           {-(E+0.5f),    (E+G),       -E }
93
         };
94
      }
95
96 82e62580 Leszek Koltunski
    return mPositions;
97 d0e6cf7f Leszek Koltunski
    }
98
99
///////////////////////////////////////////////////////////////////////////////////////////////////
100
101
  public Static4D getCubitQuats(int cubit, int[] numLayers)
102
    {
103 a4af26c1 Leszek Koltunski
    if( mQuatIndex==null ) mQuatIndex = new int[] { 0,2,5,6,
104
                                                    0,8,2,1,
105
                                                    0,5,8,9,1,6 };
106 802fe251 Leszek Koltunski
    return mObjectQuats[mQuatIndex[cubit]];
107 d0e6cf7f Leszek Koltunski
    }
108
109 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
110
111 84a17011 Leszek Koltunski
  private float[][] getVertices(int variant)
112 29b82486 Leszek Koltunski
    {
113
    if( variant==0 )
114
      {
115 84a17011 Leszek Koltunski
      return new float[][]
116 29b82486 Leszek Koltunski
         {
117 57ef6378 Leszek Koltunski
           { 0     , 0     , 0      },
118
           { -E    , E+0.5f, -0.5f  },
119
           {-0.5f  , -E    , -E-0.5f},
120
           { E+0.5f, 0.5f  , -E     },
121
           { 0     , 1     , -2*E-1 },
122
           { 0     , 1     , 0      },
123
           { -E    ,-E+0.5f, -0.5f  },
124
           {  E    ,-E+0.5f, -0.5f  }
125 29b82486 Leszek Koltunski
         };
126
      }
127
    else if( variant==1 )
128
      {
129 84a17011 Leszek Koltunski
      return new float[][]
130 29b82486 Leszek Koltunski
         {
131 57ef6378 Leszek Koltunski
            {         0.00f,         0.00f,         0.00f},
132
            {       - 0.50f,-SQ5/4 - 0.25f,-SQ5/4 - 0.75f},
133
            { SQ5/4 + 0.25f,-SQ5/4 - 0.75f,       + 0.50f},
134
            { SQ5/4 + 0.75f,       + 0.50f,-SQ5/4 - 0.25f},
135
            { SQ5/2 + 0.50f,-SQ5/2 - 0.50f,-SQ5/2 - 0.50f},
136
            { SQ5/4 - 0.25f,       + 0.50f,-SQ5/4 - 0.25f},
137
            {       - 0.50f,-SQ5/4 - 0.25f,-SQ5/4 + 0.25f},
138
            { SQ5/4 + 0.25f,-SQ5/4 + 0.25f,       + 0.50f}
139 29b82486 Leszek Koltunski
         };
140
      }
141
    else
142
      {
143 84a17011 Leszek Koltunski
      return new float[][]
144 29b82486 Leszek Koltunski
         {
145 57ef6378 Leszek Koltunski
           {  -E     ,-E+0.5f,     0.5f},
146
           {   E     , E-0.5f,    -0.5f},
147
           {-2*E     ,   0.0f,     0.0f},
148
           {     0.5f, E     ,  -E-0.5f},
149
           {  -E     ,-E-0.5f,     0.5f},
150
           {   E+0.5f,  -0.5f,  -E     },
151
           {-2*E     ,  -1.0f,     0.0f},
152
           {     1.0f,   0.0f,-2*E     },
153
           {-2*E+0.5f, E     ,  -E-0.5f},
154
           {     0.5f,-E-1.0f,  -E+0.5f},
155
           {  -E     ,-E-0.5f,-2*E-0.5f}
156 29b82486 Leszek Koltunski
         };
157 84a17011 Leszek Koltunski
      }
158
    }
159
160
///////////////////////////////////////////////////////////////////////////////////////////////////
161
162
  public ObjectShape getObjectShape(int variant)
163
    {
164
    if( variant==0 )
165
      {
166
      int[][] indices =
167
         {
168
           {6,0,5,1},
169
           {0,7,3,5},
170
           {0,6,2,7},
171
           {1,5,3,4},
172
           {3,7,2,4},
173
           {2,6,1,4},
174
         };
175
176
      return new ObjectShape(getVertices(variant), indices);
177
      }
178
    else if( variant==1 )
179
      {
180
      int[][] indices =
181
         {
182
           {6,0,5,1},
183
           {0,7,3,5},
184
           {0,6,2,7},
185
           {1,5,3,4},
186
           {3,7,2,4},
187
           {2,6,1,4},
188
         };
189
190
      return new ObjectShape(getVertices(variant), indices);
191
      }
192
    else
193
      {
194 4e9f2df5 Leszek Koltunski
      int[][] indices =
195 29b82486 Leszek Koltunski
         {
196 4e9f2df5 Leszek Koltunski
           {0,1,3,8,2},
197 29b82486 Leszek Koltunski
           {0,4,9,5,1},
198
           { 0,2,6,4},
199
           { 1,5,7,3},
200
           {10,9,4,6},
201 846b69f3 Leszek Koltunski
           {7,5,9,10},
202 29b82486 Leszek Koltunski
           {10,8,3,7},
203 846b69f3 Leszek Koltunski
           {6,2,8,10}
204 29b82486 Leszek Koltunski
         };
205
206 84a17011 Leszek Koltunski
      return new ObjectShape(getVertices(variant), indices);
207 3ee1d662 Leszek Koltunski
      }
208
    }
209
210
///////////////////////////////////////////////////////////////////////////////////////////////////
211
212
  public ObjectFaceShape getObjectFaceShape(int variant)
213
    {
214 347f6cc1 Leszek Koltunski
    int angle = 25;
215
    float R = 0.7f;
216
    float S = 0.5f;
217
218 3ee1d662 Leszek Koltunski
    if( variant==0 )
219
      {
220 cc70f525 Leszek Koltunski
      float h1 = isInIconMode() ? 0.001f : 0.05f;
221 3bf19410 Leszek Koltunski
      float h2 = isInIconMode() ? 0.001f : 0.01f;
222 347f6cc1 Leszek Koltunski
      float[][] bands = { {h1,angle,R,S,5,1,0}, {h2,angle,R,S,5,1,0} };
223 84a17011 Leszek Koltunski
      int[] indices   = { 0,0,0,1,1,1 };
224
      return new ObjectFaceShape(bands,indices,null);
225
      }
226
    else if( variant==1 )
227
      {
228
      float h1 = isInIconMode() ? 0.001f : 0.05f;
229
      float h2 = isInIconMode() ? 0.001f : 0.01f;
230 347f6cc1 Leszek Koltunski
      float[][] bands = { {h1,angle,R,S,5,1,0}, {h2,angle,R,S,5,1,0} };
231 84a17011 Leszek Koltunski
      int[] indices   = { 0,0,0,1,1,1 };
232
      return new ObjectFaceShape(bands,indices,null);
233
      }
234
    else
235
      {
236
      float h1 = isInIconMode() ? 0.001f : 0.03f;
237
      float h2 = isInIconMode() ? 0.001f : 0.05f;
238
      float h3 = isInIconMode() ? 0.001f : 0.01f;
239 347f6cc1 Leszek Koltunski
      float[][] bands = { {h1,angle,R,S,5,1,0}, {h2,angle,R,S,5,1,0}, {h3,angle,R,S,5,1,0} };
240 84a17011 Leszek Koltunski
      int[] indices   = { 0,0,1,1,2,2,2,2 };
241
      return new ObjectFaceShape(bands,indices,null);
242
      }
243
    }
244
245
///////////////////////////////////////////////////////////////////////////////////////////////////
246
247
  public ObjectVertexEffects getVertexEffects(int variant)
248
    {
249
    if( variant==0 )
250
      {
251 3ee1d662 Leszek Koltunski
      float[][] corners   = { { 0.013f, 0.16f } };
252
      int[] cornerIndices = { 0, 0, 0, 0,-1, 0, 0, 0 };
253
      float[][] centers   = { { 0.0f,-1.0f, -(SQ5+3)/2 } };
254
      int[] centerIndices = { 0,0,0,0,0,0,0,0 };
255 84a17011 Leszek Koltunski
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
256 3ee1d662 Leszek Koltunski
      }
257
    else if( variant==1 )
258
      {
259
      float[][] corners   = { { 0.013f, 0.16f } };
260
      int[] cornerIndices = { 0, 0, 0, 0,-1, 0, 0, 0 };
261
      float[][] centers   = { { 0.0f,-1.0f, -(SQ5+3)/2 } };
262
      int[] centerIndices = { 0,0,0,0,0,0,0,0 };
263 84a17011 Leszek Koltunski
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
264 3ee1d662 Leszek Koltunski
      }
265
    else
266
      {
267
      float[][] corners   = { { 0.013f, 0.16f } };
268
      int[] cornerIndices = { 0,0,0,0,0,0,0,0,0,0,-1 };
269
      float[][] centers   = { { -(SQ5+1)/4, 0.5f, -(SQ5+5)/4 } };
270
      int[] centerIndices = { 0,0,0,0,0,0,0,0,0,0,0 };
271 84a17011 Leszek Koltunski
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
272 29b82486 Leszek Koltunski
      }
273
    }
274
275
///////////////////////////////////////////////////////////////////////////////////////////////////
276
277 e30c522a Leszek Koltunski
  public int getNumCubitVariants(int[] numLayers)
278 29b82486 Leszek Koltunski
    {
279
    return 3;
280
    }
281
282
///////////////////////////////////////////////////////////////////////////////////////////////////
283
284 e30c522a Leszek Koltunski
  public int getCubitVariant(int cubit, int[] numLayers)
285 29b82486 Leszek Koltunski
    {
286
    return cubit<4 ? 0 : (cubit<8 ? 1:2);
287
    }
288
289
///////////////////////////////////////////////////////////////////////////////////////////////////
290
291 7bbfc84f Leszek Koltunski
  public float[][] getCuts(int[] numLayers)
292 29b82486 Leszek Koltunski
    {
293
    if( mCuts==null )
294
      {
295
      float[] cut = new float[] {0.0f};
296
      mCuts = new float[][] { cut,cut,cut,cut };
297
      }
298
299
    return mCuts;
300
    }
301
302
///////////////////////////////////////////////////////////////////////////////////////////////////
303
304 59c20632 Leszek Koltunski
  public boolean[][] getLayerRotatable(int[] numLayers)
305 29b82486 Leszek Koltunski
    {
306 802fe251 Leszek Koltunski
    boolean[] tmp = new boolean[] {true,true};
307
    return new boolean[][] { tmp,tmp,tmp,tmp };
308 59c20632 Leszek Koltunski
    }
309
310
///////////////////////////////////////////////////////////////////////////////////////////////////
311
312 11fa413d Leszek Koltunski
  public int getTouchControlType()
313 59c20632 Leszek Koltunski
    {
314 c9c71c3f Leszek Koltunski
    return TC_DODECAHEDRON;
315 59c20632 Leszek Koltunski
    }
316
317
///////////////////////////////////////////////////////////////////////////////////////////////////
318
319 11fa413d Leszek Koltunski
  public int getTouchControlSplit()
320 59c20632 Leszek Koltunski
    {
321
    return TYPE_NOT_SPLIT;
322
    }
323
324
///////////////////////////////////////////////////////////////////////////////////////////////////
325
326
  public int[][][] getEnabled()
327
    {
328
    return new int[][][]
329
      {
330
        {{2,3}},{{1,3}},{{1,3}},{{2,3}},{{0,3}},{{0,2}},{{0,2}},{{0,3}},{{1,2}},{{0,1}},{{0,1}},{{1,2}}
331
      };
332
    }
333
334
///////////////////////////////////////////////////////////////////////////////////////////////////
335
336
  public float[] getDist3D(int[] numLayers)
337
    {
338 4c9ca251 Leszek Koltunski
    return TouchControlDodecahedron.D3D;
339
    }
340
341
///////////////////////////////////////////////////////////////////////////////////////////////////
342
343
  public Static3D[] getFaceAxis()
344
    {
345
    return TouchControlDodecahedron.FACE_AXIS;
346 29b82486 Leszek Koltunski
    }
347
348 d53fb890 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
349
350
  public float getStickerRadius()
351
    {
352
    return 0.18f;
353
    }
354
355
///////////////////////////////////////////////////////////////////////////////////////////////////
356
357
  public float getStickerStroke()
358
    {
359 3bf19410 Leszek Koltunski
    return isInIconMode() ? 0.22f : 0.15f;
360 d53fb890 Leszek Koltunski
    }
361
362
///////////////////////////////////////////////////////////////////////////////////////////////////
363
364 ebe8c08e leszek
  public float[][][] getStickerAngles()
365 d53fb890 Leszek Koltunski
    {
366
    return null;
367
    }
368
369 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
370
// PUBLIC API
371
372
  public Static3D[] getRotationAxis()
373
    {
374
    return ROT_AXIS;
375
    }
376
377
///////////////////////////////////////////////////////////////////////////////////////////////////
378
379 beee90ab Leszek Koltunski
  public int[][] getBasicAngles()
380 29b82486 Leszek Koltunski
    {
381 beee90ab Leszek Koltunski
    if( mBasicAngle ==null )
382
      {
383
      int num = getNumLayers()[0];
384
      int[] tmp = new int[num];
385
      for(int i=0; i<num; i++) tmp[i] = 3;
386
      mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
387
      }
388
389 29b82486 Leszek Koltunski
    return mBasicAngle;
390
    }
391
392 61aa85e4 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
393
394 5f54927b Leszek Koltunski
  public String getShortName()
395 61aa85e4 Leszek Koltunski
    {
396 361fd0de leszek
    return ListObjects.ULTI_2.name();
397 5f54927b Leszek Koltunski
    }
398
399 052e0362 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
400
401
  public String[][] getTutorials()
402
    {
403
    return new String[][]{
404
                          {"gb","n1ikPKZxGEo","Ultimate Skewb Tutorial","BeardedCubing"},
405
                          {"es","wNL1WJ_sCfs","Resolver Skewb ULTIMATE","Cuby"},
406
                          {"ru","ifkM8Rr3Y8E","Как собрать Скьюб Ультимейт","Алексей Ярыгин"},
407
                          {"fr","r_eoNcejdrA","Résoudre le Skewb Ultimate","ValentinoCube"},
408
                          {"de","16ioOywTVvI","Skewb Ultimate - Tutorial","GerCubing"},
409
                          {"pl","8MsyPs1VB8U","Ultimate skewb TUTORIAL PL","MrUK"},
410
                          {"kr","VOt9_K48c0k","스큐브 얼티미트 공식","노케빈"},
411 a399e91b Leszek Koltunski
                          {"vn","VOt9_K48c0k","Tutorial N.147 - Skewb Ultimate","Duy Thích Rubik"},
412 052e0362 Leszek Koltunski
                         };
413
    }
414 29b82486 Leszek Koltunski
}