Project

General

Profile

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

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

1 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19
20
package org.distorted.objectlib.objects;
21
22 c9c71c3f Leszek Koltunski
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_DODECAHEDRON;
23
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
24 29b82486 Leszek Koltunski
25 82eb152a Leszek Koltunski
import java.io.InputStream;
26 29b82486 Leszek Koltunski
27
import org.distorted.library.type.Static3D;
28
import org.distorted.library.type.Static4D;
29
30 3ee1d662 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectFaceShape;
31 c9c71c3f Leszek Koltunski
import org.distorted.objectlib.touchcontrol.TouchControlDodecahedron;
32 8005e762 Leszek Koltunski
import org.distorted.objectlib.main.ObjectType;
33 198c5bf0 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectShape;
34 10b7e306 Leszek Koltunski
import org.distorted.objectlib.scrambling.ScrambleState;
35 386af988 Leszek Koltunski
import org.distorted.objectlib.main.ShapeDodecahedron;
36 29b82486 Leszek Koltunski
37
///////////////////////////////////////////////////////////////////////////////////////////////////
38
39 386af988 Leszek Koltunski
public class TwistyUltimate extends ShapeDodecahedron
40 29b82486 Leszek Koltunski
{
41
  private static final float A = (float)Math.sqrt(21*SQ5+47);
42
  private static final float B = SQ6*(5*SQ5+11)/(6*A);
43
  private static final float C = SQ6*(  SQ5+ 2)/(3*A);
44
  private static final float D = SQ3/3;
45
  private static final float E = (SQ5+1)/4;
46
  private static final float G = (SQ5+3)/4;
47
48
  static final Static3D[] ROT_AXIS = new Static3D[]
49
         {
50
           new Static3D( B,0,C ),
51
           new Static3D( C,B,0 ),
52
           new Static3D(-D,D,D ),
53
           new Static3D( 0,C,-B)
54
         };
55
56
  private ScrambleState[] mStates;
57
  private int[] mBasicAngle;
58
  private float[][] mCuts;
59 82e62580 Leszek Koltunski
  private float[][] mPositions;
60 29b82486 Leszek Koltunski
  private int[] mQuatIndex;
61
62
///////////////////////////////////////////////////////////////////////////////////////////////////
63
64 3bf19410 Leszek Koltunski
  public TwistyUltimate(int[] numL, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
65 29b82486 Leszek Koltunski
    {
66 3bf19410 Leszek Koltunski
    super(numL, meshState, iconMode, numL[0], quat, move, scale, stream);
67 29b82486 Leszek Koltunski
    }
68
69
///////////////////////////////////////////////////////////////////////////////////////////////////
70
71 f9a81f52 Leszek Koltunski
  public ScrambleState[] getScrambleStates()
72 29b82486 Leszek Koltunski
    {
73
    if( mStates==null )
74
      {
75
      int[] tmp = {0,-1,0, 0,1,0, 1,-1,0, 1,1,0 };
76
77
      mStates = new ScrambleState[]
78
        {
79
        new ScrambleState( new int[][] {tmp,tmp,tmp,tmp} )
80
        };
81
      }
82
83
    return mStates;
84
    }
85
86 d0e6cf7f Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
87
88
  public float[][] getCubitPositions(int[] numLayers)
89
    {
90 82e62580 Leszek Koltunski
    if( mPositions==null )
91 d0e6cf7f Leszek Koltunski
      {
92 82e62580 Leszek Koltunski
      mPositions = new float[][]
93 d0e6cf7f Leszek Koltunski
         {
94
           {   0,  -1, 2*G },
95
           { 2*E,-2*E,-2*E },
96
           {-2*G,   0,  -1 },
97
           {   1, 2*G,   0 },
98
99
           {-2*E,  2*E, 2*E },
100
           { 2*G,    0,   1 },
101
           {  -1, -2*G,   0 },
102
           {   0,    1,-2*G },
103
104
           {        E, (E+0.5f),    (E+G) },
105
           {   -(E+G),       -E, (E+0.5f) },
106
           { (E+0.5f),   -(E+G),        E },
107
           {       -E,-(E+0.5f),   -(E+G) },
108
           {    (E+G),        E,-(E+0.5f) },
109
           {-(E+0.5f),    (E+G),       -E }
110
         };
111
      }
112
113 82e62580 Leszek Koltunski
    return mPositions;
114 d0e6cf7f Leszek Koltunski
    }
115
116
///////////////////////////////////////////////////////////////////////////////////////////////////
117
118
  public Static4D getCubitQuats(int cubit, int[] numLayers)
119
    {
120 a4af26c1 Leszek Koltunski
    if( mQuatIndex==null ) mQuatIndex = new int[] { 0,2,5,6,
121
                                                    0,8,2,1,
122
                                                    0,5,8,9,1,6 };
123 802fe251 Leszek Koltunski
    return mObjectQuats[mQuatIndex[cubit]];
124 d0e6cf7f Leszek Koltunski
    }
125
126 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
127
128 e30c522a Leszek Koltunski
  public ObjectShape getObjectShape(int variant)
129 29b82486 Leszek Koltunski
    {
130
    if( variant==0 )
131
      {
132 4e9f2df5 Leszek Koltunski
      float[][] vertices =
133 29b82486 Leszek Koltunski
         {
134 57ef6378 Leszek Koltunski
           { 0     , 0     , 0      },
135
           { -E    , E+0.5f, -0.5f  },
136
           {-0.5f  , -E    , -E-0.5f},
137
           { E+0.5f, 0.5f  , -E     },
138
           { 0     , 1     , -2*E-1 },
139
           { 0     , 1     , 0      },
140
           { -E    ,-E+0.5f, -0.5f  },
141
           {  E    ,-E+0.5f, -0.5f  }
142 29b82486 Leszek Koltunski
         };
143 4e9f2df5 Leszek Koltunski
      int[][] indices =
144 29b82486 Leszek Koltunski
         {
145
           {6,0,5,1},
146
           {0,7,3,5},
147
           {0,6,2,7},
148 846b69f3 Leszek Koltunski
           {1,5,3,4},
149
           {3,7,2,4},
150
           {2,6,1,4},
151 29b82486 Leszek Koltunski
         };
152
153 59a971c1 Leszek Koltunski
      return new ObjectShape(vertices, indices);
154 29b82486 Leszek Koltunski
      }
155
    else if( variant==1 )
156
      {
157 4e9f2df5 Leszek Koltunski
      float[][] vertices =
158 29b82486 Leszek Koltunski
         {
159 57ef6378 Leszek Koltunski
            {         0.00f,         0.00f,         0.00f},
160
            {       - 0.50f,-SQ5/4 - 0.25f,-SQ5/4 - 0.75f},
161
            { SQ5/4 + 0.25f,-SQ5/4 - 0.75f,       + 0.50f},
162
            { SQ5/4 + 0.75f,       + 0.50f,-SQ5/4 - 0.25f},
163
            { SQ5/2 + 0.50f,-SQ5/2 - 0.50f,-SQ5/2 - 0.50f},
164
            { SQ5/4 - 0.25f,       + 0.50f,-SQ5/4 - 0.25f},
165
            {       - 0.50f,-SQ5/4 - 0.25f,-SQ5/4 + 0.25f},
166
            { SQ5/4 + 0.25f,-SQ5/4 + 0.25f,       + 0.50f}
167 29b82486 Leszek Koltunski
         };
168 4e9f2df5 Leszek Koltunski
      int[][] indices =
169 29b82486 Leszek Koltunski
         {
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 59a971c1 Leszek Koltunski
      return new ObjectShape(vertices, indices);
179 29b82486 Leszek Koltunski
      }
180
    else
181
      {
182 4e9f2df5 Leszek Koltunski
      float[][] vertices =
183 29b82486 Leszek Koltunski
         {
184 57ef6378 Leszek Koltunski
           {  -E     ,-E+0.5f,     0.5f},
185
           {   E     , E-0.5f,    -0.5f},
186
           {-2*E     ,   0.0f,     0.0f},
187
           {     0.5f, E     ,  -E-0.5f},
188
           {  -E     ,-E-0.5f,     0.5f},
189
           {   E+0.5f,  -0.5f,  -E     },
190
           {-2*E     ,  -1.0f,     0.0f},
191
           {     1.0f,   0.0f,-2*E     },
192
           {-2*E+0.5f, E     ,  -E-0.5f},
193
           {     0.5f,-E-1.0f,  -E+0.5f},
194
           {  -E     ,-E-0.5f,-2*E-0.5f}
195 29b82486 Leszek Koltunski
         };
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 59a971c1 Leszek Koltunski
      return new ObjectShape(vertices, 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 cc70f525 Leszek Koltunski
      float[][] bands     = { {h1,17,0.5f,0.2f,5,1,0}, {h2, 1,0.5f,0.2f,5,1,0} };
221 3ee1d662 Leszek Koltunski
      int[] bandIndices   = { 0,0,0,1,1,1 };
222
      float[][] corners   = { { 0.013f, 0.16f } };
223
      int[] cornerIndices = { 0, 0, 0, 0,-1, 0, 0, 0 };
224
      float[][] centers   = { { 0.0f,-1.0f, -(SQ5+3)/2 } };
225
      int[] centerIndices = { 0,0,0,0,0,0,0,0 };
226
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
227
      }
228
    else if( variant==1 )
229
      {
230 cc70f525 Leszek Koltunski
      float h1 = isInIconMode() ? 0.001f : 0.05f;
231 3bf19410 Leszek Koltunski
      float h2 = isInIconMode() ? 0.001f : 0.01f;
232 cc70f525 Leszek Koltunski
      float[][] bands     = { {h1,17,0.5f,0.2f,5,1,0}, {h2, 1,0.5f,0.2f,5,1,0} };
233 3ee1d662 Leszek Koltunski
      int[] bandIndices   = { 0,0,0,1,1,1 };
234
      float[][] corners   = { { 0.013f, 0.16f } };
235
      int[] cornerIndices = { 0, 0, 0, 0,-1, 0, 0, 0 };
236
      float[][] centers   = { { 0.0f,-1.0f, -(SQ5+3)/2 } };
237
      int[] centerIndices = { 0,0,0,0,0,0,0,0 };
238
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
239
      }
240
    else
241
      {
242 cc70f525 Leszek Koltunski
      float h1 = isInIconMode() ? 0.001f : 0.03f;
243
      float h2 = isInIconMode() ? 0.001f : 0.05f;
244 3bf19410 Leszek Koltunski
      float h3 = isInIconMode() ? 0.001f : 0.01f;
245 cc70f525 Leszek Koltunski
      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} };
246 3ee1d662 Leszek Koltunski
      int[] bandIndices   = { 0,0,1,1,2,2,2,2 };
247
      float[][] corners   = { { 0.013f, 0.16f } };
248
      int[] cornerIndices = { 0,0,0,0,0,0,0,0,0,0,-1 };
249
      float[][] centers   = { { -(SQ5+1)/4, 0.5f, -(SQ5+5)/4 } };
250
      int[] centerIndices = { 0,0,0,0,0,0,0,0,0,0,0 };
251
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
252 29b82486 Leszek Koltunski
      }
253
    }
254
255
///////////////////////////////////////////////////////////////////////////////////////////////////
256
257 e30c522a Leszek Koltunski
  public int getNumCubitVariants(int[] numLayers)
258 29b82486 Leszek Koltunski
    {
259
    return 3;
260
    }
261
262
///////////////////////////////////////////////////////////////////////////////////////////////////
263
264 e30c522a Leszek Koltunski
  public int getCubitVariant(int cubit, int[] numLayers)
265 29b82486 Leszek Koltunski
    {
266
    return cubit<4 ? 0 : (cubit<8 ? 1:2);
267
    }
268
269
///////////////////////////////////////////////////////////////////////////////////////////////////
270
271 7bbfc84f Leszek Koltunski
  public float[][] getCuts(int[] numLayers)
272 29b82486 Leszek Koltunski
    {
273
    if( mCuts==null )
274
      {
275
      float[] cut = new float[] {0.0f};
276
      mCuts = new float[][] { cut,cut,cut,cut };
277
      }
278
279
    return mCuts;
280
    }
281
282
///////////////////////////////////////////////////////////////////////////////////////////////////
283
284 59c20632 Leszek Koltunski
  public boolean[][] getLayerRotatable(int[] numLayers)
285 29b82486 Leszek Koltunski
    {
286 802fe251 Leszek Koltunski
    boolean[] tmp = new boolean[] {true,true};
287
    return new boolean[][] { tmp,tmp,tmp,tmp };
288 59c20632 Leszek Koltunski
    }
289
290
///////////////////////////////////////////////////////////////////////////////////////////////////
291
292 11fa413d Leszek Koltunski
  public int getTouchControlType()
293 59c20632 Leszek Koltunski
    {
294 c9c71c3f Leszek Koltunski
    return TC_DODECAHEDRON;
295 59c20632 Leszek Koltunski
    }
296
297
///////////////////////////////////////////////////////////////////////////////////////////////////
298
299 11fa413d Leszek Koltunski
  public int getTouchControlSplit()
300 59c20632 Leszek Koltunski
    {
301
    return TYPE_NOT_SPLIT;
302
    }
303
304
///////////////////////////////////////////////////////////////////////////////////////////////////
305
306
  public int[][][] getEnabled()
307
    {
308
    return new int[][][]
309
      {
310
        {{2,3}},{{1,3}},{{1,3}},{{2,3}},{{0,3}},{{0,2}},{{0,2}},{{0,3}},{{1,2}},{{0,1}},{{0,1}},{{1,2}}
311
      };
312
    }
313
314
///////////////////////////////////////////////////////////////////////////////////////////////////
315
316
  public float[] getDist3D(int[] numLayers)
317
    {
318 4c9ca251 Leszek Koltunski
    return TouchControlDodecahedron.D3D;
319
    }
320
321
///////////////////////////////////////////////////////////////////////////////////////////////////
322
323
  public Static3D[] getFaceAxis()
324
    {
325
    return TouchControlDodecahedron.FACE_AXIS;
326 29b82486 Leszek Koltunski
    }
327
328 d53fb890 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
329
330
  public float getStickerRadius()
331
    {
332
    return 0.18f;
333
    }
334
335
///////////////////////////////////////////////////////////////////////////////////////////////////
336
337
  public float getStickerStroke()
338
    {
339 3bf19410 Leszek Koltunski
    return isInIconMode() ? 0.22f : 0.15f;
340 d53fb890 Leszek Koltunski
    }
341
342
///////////////////////////////////////////////////////////////////////////////////////////////////
343
344
  public float[][] getStickerAngles()
345
    {
346
    return null;
347
    }
348
349 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
350
// PUBLIC API
351
352
  public Static3D[] getRotationAxis()
353
    {
354
    return ROT_AXIS;
355
    }
356
357
///////////////////////////////////////////////////////////////////////////////////////////////////
358
359 802fe251 Leszek Koltunski
  public int[] getBasicAngles()
360 29b82486 Leszek Koltunski
    {
361
    if( mBasicAngle ==null ) mBasicAngle = new int[] { 3,3,3,3 };
362
    return mBasicAngle;
363
    }
364
365 61aa85e4 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
366
367 5f54927b Leszek Koltunski
  public String getShortName()
368 61aa85e4 Leszek Koltunski
    {
369 5f54927b Leszek Koltunski
    return ObjectType.ULTI_2.name();
370
    }
371
372
///////////////////////////////////////////////////////////////////////////////////////////////////
373
374
  public long getSignature()
375
    {
376
    return ObjectType.ULTI_2.ordinal();
377 61aa85e4 Leszek Koltunski
    }
378
379 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
380
381 e26eb4e7 Leszek Koltunski
  public String getObjectName()
382 29b82486 Leszek Koltunski
    {
383 e26eb4e7 Leszek Koltunski
    return "Skewb Ultimate";
384 29b82486 Leszek Koltunski
    }
385
386
///////////////////////////////////////////////////////////////////////////////////////////////////
387
388 e26eb4e7 Leszek Koltunski
  public String getInventor()
389 29b82486 Leszek Koltunski
    {
390 e26eb4e7 Leszek Koltunski
    return "Tony Fisher";
391 29b82486 Leszek Koltunski
    }
392
393 59c20632 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
394
395 e26eb4e7 Leszek Koltunski
  public int getYearOfInvention()
396 59c20632 Leszek Koltunski
    {
397
    return 2000;
398
    }
399
400 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
401
402 e26eb4e7 Leszek Koltunski
  public int getComplexity()
403 29b82486 Leszek Koltunski
    {
404 b4223a92 Leszek Koltunski
    return 2;
405 29b82486 Leszek Koltunski
    }
406 052e0362 Leszek Koltunski
407
///////////////////////////////////////////////////////////////////////////////////////////////////
408
409
  public String[][] getTutorials()
410
    {
411
    return new String[][]{
412
                          {"gb","n1ikPKZxGEo","Ultimate Skewb Tutorial","BeardedCubing"},
413
                          {"es","wNL1WJ_sCfs","Resolver Skewb ULTIMATE","Cuby"},
414
                          {"ru","ifkM8Rr3Y8E","Как собрать Скьюб Ультимейт","Алексей Ярыгин"},
415
                          {"fr","r_eoNcejdrA","Résoudre le Skewb Ultimate","ValentinoCube"},
416
                          {"de","16ioOywTVvI","Skewb Ultimate - Tutorial","GerCubing"},
417
                          {"pl","8MsyPs1VB8U","Ultimate skewb TUTORIAL PL","MrUK"},
418
                          {"kr","VOt9_K48c0k","스큐브 얼티미트 공식","노케빈"},
419 a399e91b Leszek Koltunski
                          {"vn","VOt9_K48c0k","Tutorial N.147 - Skewb Ultimate","Duy Thích Rubik"},
420 052e0362 Leszek Koltunski
                         };
421
    }
422 29b82486 Leszek Koltunski
}