Project

General

Profile

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

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

1
///////////////////////////////////////////////////////////////////////////////////////////////////
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
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_DODECAHEDRON;
23
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
24

    
25
import java.io.InputStream;
26

    
27
import org.distorted.library.type.Static3D;
28
import org.distorted.library.type.Static4D;
29

    
30
import org.distorted.objectlib.helpers.ObjectFaceShape;
31
import org.distorted.objectlib.touchcontrol.TouchControlDodecahedron;
32
import org.distorted.objectlib.main.ObjectType;
33
import org.distorted.objectlib.helpers.ObjectShape;
34
import org.distorted.objectlib.scrambling.ScrambleState;
35
import org.distorted.objectlib.main.ShapeDodecahedron;
36

    
37
///////////////////////////////////////////////////////////////////////////////////////////////////
38

    
39
public class TwistyUltimate extends ShapeDodecahedron
40
{
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
  private float[][] mCenters;
60
  private int[] mQuatIndex;
61

    
62
///////////////////////////////////////////////////////////////////////////////////////////////////
63

    
64
  public TwistyUltimate(int[] numL, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
65
    {
66
    super(numL, meshState, iconMode, numL[0], quat, move, scale, stream);
67
    }
68

    
69
///////////////////////////////////////////////////////////////////////////////////////////////////
70

    
71
  public ScrambleState[] getScrambleStates()
72
    {
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
///////////////////////////////////////////////////////////////////////////////////////////////////
87

    
88
  public float[][] getCubitPositions(int[] numLayers)
89
    {
90
    if( mCenters==null )
91
      {
92
      mCenters = new float[][]
93
         {
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
    return mCenters;
114
    }
115

    
116
///////////////////////////////////////////////////////////////////////////////////////////////////
117

    
118
  public Static4D getCubitQuats(int cubit, int[] numLayers)
119
    {
120
    if( mQuatIndex==null ) mQuatIndex = new int[] { 0,2,5,6,0,8,2,1,0,5,8,9,1,6 };
121
    return mObjectQuats[mQuatIndex[cubit]];
122
    }
123

    
124
///////////////////////////////////////////////////////////////////////////////////////////////////
125

    
126
  public ObjectShape getObjectShape(int variant)
127
    {
128
    if( variant==0 )
129
      {
130
      float[][] vertices =
131
         {
132
           { 0     , 0     , 0      },
133
           { -E    , E+0.5f, -0.5f  },
134
           {-0.5f  , -E    , -E-0.5f},
135
           { E+0.5f, 0.5f  , -E     },
136
           { 0     , 1     , -2*E-1 },
137
           { 0     , 1     , 0      },
138
           { -E    ,-E+0.5f, -0.5f  },
139
           {  E    ,-E+0.5f, -0.5f  }
140
         };
141
      int[][] indices =
142
         {
143
           {6,0,5,1},
144
           {0,7,3,5},
145
           {0,6,2,7},
146
           {1,5,3,4},
147
           {3,7,2,4},
148
           {2,6,1,4},
149
         };
150

    
151
      return new ObjectShape(vertices, indices);
152
      }
153
    else if( variant==1 )
154
      {
155
      float[][] vertices =
156
         {
157
            {         0.00f,         0.00f,         0.00f},
158
            {       - 0.50f,-SQ5/4 - 0.25f,-SQ5/4 - 0.75f},
159
            { SQ5/4 + 0.25f,-SQ5/4 - 0.75f,       + 0.50f},
160
            { SQ5/4 + 0.75f,       + 0.50f,-SQ5/4 - 0.25f},
161
            { SQ5/2 + 0.50f,-SQ5/2 - 0.50f,-SQ5/2 - 0.50f},
162
            { SQ5/4 - 0.25f,       + 0.50f,-SQ5/4 - 0.25f},
163
            {       - 0.50f,-SQ5/4 - 0.25f,-SQ5/4 + 0.25f},
164
            { SQ5/4 + 0.25f,-SQ5/4 + 0.25f,       + 0.50f}
165
         };
166
      int[][] indices =
167
         {
168
           {6,0,5,1},
169
           {0,7,3,5},
170
           {0,6,2,7},
171
           {1,5,3,4},
172
           {3,7,2,4},
173
           {2,6,1,4},
174
         };
175

    
176
      return new ObjectShape(vertices, indices);
177
      }
178
    else
179
      {
180
      float[][] vertices =
181
         {
182
           {  -E     ,-E+0.5f,     0.5f},
183
           {   E     , E-0.5f,    -0.5f},
184
           {-2*E     ,   0.0f,     0.0f},
185
           {     0.5f, E     ,  -E-0.5f},
186
           {  -E     ,-E-0.5f,     0.5f},
187
           {   E+0.5f,  -0.5f,  -E     },
188
           {-2*E     ,  -1.0f,     0.0f},
189
           {     1.0f,   0.0f,-2*E     },
190
           {-2*E+0.5f, E     ,  -E-0.5f},
191
           {     0.5f,-E-1.0f,  -E+0.5f},
192
           {  -E     ,-E-0.5f,-2*E-0.5f}
193
         };
194
      int[][] indices =
195
         {
196
           {0,1,3,8,2},
197
           {0,4,9,5,1},
198
           { 0,2,6,4},
199
           { 1,5,7,3},
200
           {10,9,4,6},
201
           {7,5,9,10},
202
           {10,8,3,7},
203
           {6,2,8,10}
204
         };
205

    
206
      return new ObjectShape(vertices, indices);
207
      }
208
    }
209

    
210
///////////////////////////////////////////////////////////////////////////////////////////////////
211

    
212
  public ObjectFaceShape getObjectFaceShape(int variant)
213
    {
214
    if( variant==0 )
215
      {
216
      float h1 = isInIconMode() ? 0.001f : 0.03f;
217
      float h2 = isInIconMode() ? 0.001f : 0.01f;
218
      float[][] bands     = { {h1,17,0.5f,0.2f,5,2,2}, {h2, 1,0.5f,0.2f,5,2,2} };
219
      int[] bandIndices   = { 0,0,0,1,1,1 };
220
      float[][] corners   = { { 0.013f, 0.16f } };
221
      int[] cornerIndices = { 0, 0, 0, 0,-1, 0, 0, 0 };
222
      float[][] centers   = { { 0.0f,-1.0f, -(SQ5+3)/2 } };
223
      int[] centerIndices = { 0,0,0,0,0,0,0,0 };
224
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
225
      }
226
    else if( variant==1 )
227
      {
228
      float h1 = isInIconMode() ? 0.001f : 0.03f;
229
      float h2 = isInIconMode() ? 0.001f : 0.01f;
230
      float[][] bands     = { {h1,17,0.5f,0.2f,5,2,2}, {h2, 1,0.5f,0.2f,5,2,2} };
231
      int[] bandIndices   = { 0,0,0,1,1,1 };
232
      float[][] corners   = { { 0.013f, 0.16f } };
233
      int[] cornerIndices = { 0, 0, 0, 0,-1, 0, 0, 0 };
234
      float[][] centers   = { { 0.0f,-1.0f, -(SQ5+3)/2 } };
235
      int[] centerIndices = { 0,0,0,0,0,0,0,0 };
236
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
237
      }
238
    else
239
      {
240
      float h1 = isInIconMode() ? 0.001f : 0.04f;
241
      float h2 = isInIconMode() ? 0.001f : 0.03f;
242
      float h3 = isInIconMode() ? 0.001f : 0.01f;
243
      float[][] bands     = { {h1,17,0.5f,0.2f,5,2,2}, {h2,17,0.5f,0.2f,5,2,2}, {h3, 1,0.5f,0.2f,5,2,2} };
244
      int[] bandIndices   = { 0,0,1,1,2,2,2,2 };
245
      float[][] corners   = { { 0.013f, 0.16f } };
246
      int[] cornerIndices = { 0,0,0,0,0,0,0,0,0,0,-1 };
247
      float[][] centers   = { { -(SQ5+1)/4, 0.5f, -(SQ5+5)/4 } };
248
      int[] centerIndices = { 0,0,0,0,0,0,0,0,0,0,0 };
249
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
250
      }
251
    }
252

    
253
///////////////////////////////////////////////////////////////////////////////////////////////////
254

    
255
  public int getNumCubitVariants(int[] numLayers)
256
    {
257
    return 3;
258
    }
259

    
260
///////////////////////////////////////////////////////////////////////////////////////////////////
261

    
262
  public int getCubitVariant(int cubit, int[] numLayers)
263
    {
264
    return cubit<4 ? 0 : (cubit<8 ? 1:2);
265
    }
266

    
267
///////////////////////////////////////////////////////////////////////////////////////////////////
268

    
269
  public float[][] getCuts(int[] numLayers)
270
    {
271
    if( mCuts==null )
272
      {
273
      float[] cut = new float[] {0.0f};
274
      mCuts = new float[][] { cut,cut,cut,cut };
275
      }
276

    
277
    return mCuts;
278
    }
279

    
280
///////////////////////////////////////////////////////////////////////////////////////////////////
281

    
282
  public boolean[][] getLayerRotatable(int[] numLayers)
283
    {
284
    boolean[] tmp = new boolean[] {true,true};
285
    return new boolean[][] { tmp,tmp,tmp,tmp };
286
    }
287

    
288
///////////////////////////////////////////////////////////////////////////////////////////////////
289

    
290
  public int getTouchControlType()
291
    {
292
    return TC_DODECAHEDRON;
293
    }
294

    
295
///////////////////////////////////////////////////////////////////////////////////////////////////
296

    
297
  public int getTouchControlSplit()
298
    {
299
    return TYPE_NOT_SPLIT;
300
    }
301

    
302
///////////////////////////////////////////////////////////////////////////////////////////////////
303

    
304
  public int[][][] getEnabled()
305
    {
306
    return new int[][][]
307
      {
308
        {{2,3}},{{1,3}},{{1,3}},{{2,3}},{{0,3}},{{0,2}},{{0,2}},{{0,3}},{{1,2}},{{0,1}},{{0,1}},{{1,2}}
309
      };
310
    }
311

    
312
///////////////////////////////////////////////////////////////////////////////////////////////////
313

    
314
  public float[] getDist3D(int[] numLayers)
315
    {
316
    return TouchControlDodecahedron.D3D;
317
    }
318

    
319
///////////////////////////////////////////////////////////////////////////////////////////////////
320

    
321
  public Static3D[] getFaceAxis()
322
    {
323
    return TouchControlDodecahedron.FACE_AXIS;
324
    }
325

    
326
///////////////////////////////////////////////////////////////////////////////////////////////////
327

    
328
  public float getStickerRadius()
329
    {
330
    return 0.18f;
331
    }
332

    
333
///////////////////////////////////////////////////////////////////////////////////////////////////
334

    
335
  public float getStickerStroke()
336
    {
337
    return isInIconMode() ? 0.22f : 0.15f;
338
    }
339

    
340
///////////////////////////////////////////////////////////////////////////////////////////////////
341

    
342
  public float[][] getStickerAngles()
343
    {
344
    return null;
345
    }
346

    
347
///////////////////////////////////////////////////////////////////////////////////////////////////
348
// PUBLIC API
349

    
350
  public Static3D[] getRotationAxis()
351
    {
352
    return ROT_AXIS;
353
    }
354

    
355
///////////////////////////////////////////////////////////////////////////////////////////////////
356

    
357
  public int[] getBasicAngles()
358
    {
359
    if( mBasicAngle ==null ) mBasicAngle = new int[] { 3,3,3,3 };
360
    return mBasicAngle;
361
    }
362

    
363
///////////////////////////////////////////////////////////////////////////////////////////////////
364

    
365
  public String getShortName()
366
    {
367
    return ObjectType.ULTI_2.name();
368
    }
369

    
370
///////////////////////////////////////////////////////////////////////////////////////////////////
371

    
372
  public long getSignature()
373
    {
374
    return ObjectType.ULTI_2.ordinal();
375
    }
376

    
377
///////////////////////////////////////////////////////////////////////////////////////////////////
378

    
379
  public String getObjectName()
380
    {
381
    return "Skewb Ultimate";
382
    }
383

    
384
///////////////////////////////////////////////////////////////////////////////////////////////////
385

    
386
  public String getInventor()
387
    {
388
    return "Tony Fisher";
389
    }
390

    
391
///////////////////////////////////////////////////////////////////////////////////////////////////
392

    
393
  public int getYearOfInvention()
394
    {
395
    return 2000;
396
    }
397

    
398
///////////////////////////////////////////////////////////////////////////////////////////////////
399

    
400
  public int getComplexity()
401
    {
402
    return 2;
403
    }
404

    
405
///////////////////////////////////////////////////////////////////////////////////////////////////
406

    
407
  public String[][] getTutorials()
408
    {
409
    return new String[][]{
410
                          {"gb","n1ikPKZxGEo","Ultimate Skewb Tutorial","BeardedCubing"},
411
                          {"es","wNL1WJ_sCfs","Resolver Skewb ULTIMATE","Cuby"},
412
                          {"ru","ifkM8Rr3Y8E","Как собрать Скьюб Ультимейт","Алексей Ярыгин"},
413
                          {"fr","r_eoNcejdrA","Résoudre le Skewb Ultimate","ValentinoCube"},
414
                          {"de","16ioOywTVvI","Skewb Ultimate - Tutorial","GerCubing"},
415
                          {"pl","8MsyPs1VB8U","Ultimate skewb TUTORIAL PL","MrUK"},
416
                          {"kr","VOt9_K48c0k","스큐브 얼티미트 공식","노케빈"},
417
                          {"vn","VOt9_K48c0k","Tutorial N.147 - Skewb Ultimate","Duy Thích Rubik"},
418
                         };
419
    }
420
}
(32-32/34)