Project

General

Profile

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

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

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