Project

General

Profile

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

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

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// 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
///////////////////////////////////////////////////////////////////////////////////////////////////
9

    
10
package org.distorted.objectlib.objects;
11

    
12
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_DODECAHEDRON;
13
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
14

    
15
import java.io.InputStream;
16

    
17
import org.distorted.library.type.Static3D;
18
import org.distorted.library.type.Static4D;
19

    
20
import org.distorted.objectlib.helpers.ObjectFaceShape;
21
import org.distorted.objectlib.helpers.ObjectSignature;
22
import org.distorted.objectlib.main.InitData;
23
import org.distorted.objectlib.touchcontrol.TouchControlDodecahedron;
24
import org.distorted.objectlib.main.ObjectType;
25
import org.distorted.objectlib.helpers.ObjectShape;
26
import org.distorted.objectlib.scrambling.ScrambleState;
27
import org.distorted.objectlib.main.ShapeDodecahedron;
28

    
29
///////////////////////////////////////////////////////////////////////////////////////////////////
30

    
31
public class TwistyUltimate extends ShapeDodecahedron
32
{
33
  private static final float A = (float)Math.sqrt(21*SQ5+47);
34
  private static final float B = SQ6*(5*SQ5+11)/(6*A);
35
  private static final float C = SQ6*(  SQ5+ 2)/(3*A);
36
  private static final float D = SQ3/3;
37
  private static final float E = (SQ5+1)/4;
38
  private static final float G = (SQ5+3)/4;
39

    
40
  static final Static3D[] ROT_AXIS = new Static3D[]
41
         {
42
           new Static3D( B,0,C ),
43
           new Static3D( C,B,0 ),
44
           new Static3D(-D,D,D ),
45
           new Static3D( 0,C,-B)
46
         };
47

    
48
  private ScrambleState[] mStates;
49
  private int[][] mBasicAngle;
50
  private float[][] mCuts;
51
  private float[][] mPositions;
52
  private int[] mQuatIndex;
53

    
54
///////////////////////////////////////////////////////////////////////////////////////////////////
55

    
56
  public TwistyUltimate(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
57
    {
58
    super(data, meshState, iconMode, data.getNumLayers()[0], quat, move, scale, stream);
59
    }
60

    
61
///////////////////////////////////////////////////////////////////////////////////////////////////
62

    
63
  public ScrambleState[] getScrambleStates()
64
    {
65
    if( mStates==null )
66
      {
67
      int[] tmp = {0,-1,0, 0,1,0, 1,-1,0, 1,1,0 };
68

    
69
      mStates = new ScrambleState[]
70
        {
71
        new ScrambleState( new int[][] {tmp,tmp,tmp,tmp} )
72
        };
73
      }
74

    
75
    return mStates;
76
    }
77

    
78
///////////////////////////////////////////////////////////////////////////////////////////////////
79

    
80
  public float[][] getCubitPositions(int[] numLayers)
81
    {
82
    if( mPositions==null )
83
      {
84
      mPositions = new float[][]
85
         {
86
           {   0,  -1, 2*G },
87
           { 2*E,-2*E,-2*E },
88
           {-2*G,   0,  -1 },
89
           {   1, 2*G,   0 },
90

    
91
           {-2*E,  2*E, 2*E },
92
           { 2*G,    0,   1 },
93
           {  -1, -2*G,   0 },
94
           {   0,    1,-2*G },
95

    
96
           {        E, (E+0.5f),    (E+G) },
97
           {   -(E+G),       -E, (E+0.5f) },
98
           { (E+0.5f),   -(E+G),        E },
99
           {       -E,-(E+0.5f),   -(E+G) },
100
           {    (E+G),        E,-(E+0.5f) },
101
           {-(E+0.5f),    (E+G),       -E }
102
         };
103
      }
104

    
105
    return mPositions;
106
    }
107

    
108
///////////////////////////////////////////////////////////////////////////////////////////////////
109

    
110
  public Static4D getCubitQuats(int cubit, int[] numLayers)
111
    {
112
    if( mQuatIndex==null ) mQuatIndex = new int[] { 0,2,5,6,
113
                                                    0,8,2,1,
114
                                                    0,5,8,9,1,6 };
115
    return mObjectQuats[mQuatIndex[cubit]];
116
    }
117

    
118
///////////////////////////////////////////////////////////////////////////////////////////////////
119

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

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

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

    
200
      return new ObjectShape(vertices, indices);
201
      }
202
    }
203

    
204
///////////////////////////////////////////////////////////////////////////////////////////////////
205

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

    
247
///////////////////////////////////////////////////////////////////////////////////////////////////
248

    
249
  public int getNumCubitVariants(int[] numLayers)
250
    {
251
    return 3;
252
    }
253

    
254
///////////////////////////////////////////////////////////////////////////////////////////////////
255

    
256
  public int getCubitVariant(int cubit, int[] numLayers)
257
    {
258
    return cubit<4 ? 0 : (cubit<8 ? 1:2);
259
    }
260

    
261
///////////////////////////////////////////////////////////////////////////////////////////////////
262

    
263
  public float[][] getCuts(int[] numLayers)
264
    {
265
    if( mCuts==null )
266
      {
267
      float[] cut = new float[] {0.0f};
268
      mCuts = new float[][] { cut,cut,cut,cut };
269
      }
270

    
271
    return mCuts;
272
    }
273

    
274
///////////////////////////////////////////////////////////////////////////////////////////////////
275

    
276
  public boolean[][] getLayerRotatable(int[] numLayers)
277
    {
278
    boolean[] tmp = new boolean[] {true,true};
279
    return new boolean[][] { tmp,tmp,tmp,tmp };
280
    }
281

    
282
///////////////////////////////////////////////////////////////////////////////////////////////////
283

    
284
  public int getTouchControlType()
285
    {
286
    return TC_DODECAHEDRON;
287
    }
288

    
289
///////////////////////////////////////////////////////////////////////////////////////////////////
290

    
291
  public int getTouchControlSplit()
292
    {
293
    return TYPE_NOT_SPLIT;
294
    }
295

    
296
///////////////////////////////////////////////////////////////////////////////////////////////////
297

    
298
  public int[][][] getEnabled()
299
    {
300
    return new int[][][]
301
      {
302
        {{2,3}},{{1,3}},{{1,3}},{{2,3}},{{0,3}},{{0,2}},{{0,2}},{{0,3}},{{1,2}},{{0,1}},{{0,1}},{{1,2}}
303
      };
304
    }
305

    
306
///////////////////////////////////////////////////////////////////////////////////////////////////
307

    
308
  public float[] getDist3D(int[] numLayers)
309
    {
310
    return TouchControlDodecahedron.D3D;
311
    }
312

    
313
///////////////////////////////////////////////////////////////////////////////////////////////////
314

    
315
  public Static3D[] getFaceAxis()
316
    {
317
    return TouchControlDodecahedron.FACE_AXIS;
318
    }
319

    
320
///////////////////////////////////////////////////////////////////////////////////////////////////
321

    
322
  public float getStickerRadius()
323
    {
324
    return 0.18f;
325
    }
326

    
327
///////////////////////////////////////////////////////////////////////////////////////////////////
328

    
329
  public float getStickerStroke()
330
    {
331
    return isInIconMode() ? 0.22f : 0.15f;
332
    }
333

    
334
///////////////////////////////////////////////////////////////////////////////////////////////////
335

    
336
  public float[][] getStickerAngles()
337
    {
338
    return null;
339
    }
340

    
341
///////////////////////////////////////////////////////////////////////////////////////////////////
342
// PUBLIC API
343

    
344
  public Static3D[] getRotationAxis()
345
    {
346
    return ROT_AXIS;
347
    }
348

    
349
///////////////////////////////////////////////////////////////////////////////////////////////////
350

    
351
  public int[][] getBasicAngles()
352
    {
353
    if( mBasicAngle ==null )
354
      {
355
      int num = getNumLayers()[0];
356
      int[] tmp = new int[num];
357
      for(int i=0; i<num; i++) tmp[i] = 3;
358
      mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
359
      }
360

    
361
    return mBasicAngle;
362
    }
363

    
364
///////////////////////////////////////////////////////////////////////////////////////////////////
365

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

    
371
///////////////////////////////////////////////////////////////////////////////////////////////////
372

    
373
  public ObjectSignature getSignature()
374
    {
375
    return new ObjectSignature(ObjectType.ULTI_2);
376
    }
377

    
378
///////////////////////////////////////////////////////////////////////////////////////////////////
379

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

    
385
///////////////////////////////////////////////////////////////////////////////////////////////////
386

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

    
392
///////////////////////////////////////////////////////////////////////////////////////////////////
393

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

    
399
///////////////////////////////////////////////////////////////////////////////////////////////////
400

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

    
406
///////////////////////////////////////////////////////////////////////////////////////////////////
407

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