Project

General

Profile

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

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

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