Project

General

Profile

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

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

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