Project

General

Profile

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

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

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