Project

General

Profile

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

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

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.FactoryCubit;
21
import org.distorted.objectlib.helpers.ObjectFaceShape;
22
import org.distorted.objectlib.helpers.ObjectSignature;
23
import org.distorted.objectlib.helpers.ObjectVertexEffects;
24
import org.distorted.objectlib.main.ObjectSignatures;
25
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator;
26
import org.distorted.objectlib.main.InitData;
27
import org.distorted.objectlib.touchcontrol.TouchControlDodecahedron;
28
import org.distorted.objectlib.main.ObjectType;
29
import org.distorted.objectlib.helpers.ObjectShape;
30
import org.distorted.objectlib.shape.ShapeDodecahedron;
31

    
32
///////////////////////////////////////////////////////////////////////////////////////////////////
33

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

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

    
51
  private int[][] mEdges;
52
  private int[][] mBasicAngle;
53
  private float[][] mCuts;
54
  private float[][] mPositions;
55
  private int[] mQuatIndex;
56

    
57
///////////////////////////////////////////////////////////////////////////////////////////////////
58

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

    
64
///////////////////////////////////////////////////////////////////////////////////////////////////
65

    
66
  public int[][] getScrambleEdges()
67
    {
68
    if( mEdges==null ) mEdges = ScrambleEdgeGenerator.getScrambleEdgesSingle(mBasicAngle);
69
    return mEdges;
70
    }
71

    
72
///////////////////////////////////////////////////////////////////////////////////////////////////
73

    
74
  public float[][] getCubitPositions(int[] numLayers)
75
    {
76
    if( mPositions==null )
77
      {
78
      mPositions = new float[][]
79
         {
80
           {   0,  -1, 2*G },
81
           { 2*E,-2*E,-2*E },
82
           {-2*G,   0,  -1 },
83
           {   1, 2*G,   0 },
84

    
85
           {-2*E,  2*E, 2*E },
86
           { 2*G,    0,   1 },
87
           {  -1, -2*G,   0 },
88
           {   0,    1,-2*G },
89

    
90
           {        E, (E+0.5f),    (E+G) },
91
           {   -(E+G),       -E, (E+0.5f) },
92
           { (E+0.5f),   -(E+G),        E },
93
           {       -E,-(E+0.5f),   -(E+G) },
94
           {    (E+G),        E,-(E+0.5f) },
95
           {-(E+0.5f),    (E+G),       -E }
96
         };
97
      }
98

    
99
    return mPositions;
100
    }
101

    
102
///////////////////////////////////////////////////////////////////////////////////////////////////
103

    
104
  public Static4D getCubitQuats(int cubit, int[] numLayers)
105
    {
106
    if( mQuatIndex==null ) mQuatIndex = new int[] { 0,2,5,6,
107
                                                    0,8,2,1,
108
                                                    0,5,8,9,1,6 };
109
    return mObjectQuats[mQuatIndex[cubit]];
110
    }
111

    
112
///////////////////////////////////////////////////////////////////////////////////////////////////
113

    
114
  private float[][] getVertices(int variant)
115
    {
116
    if( variant==0 )
117
      {
118
      return new float[][]
119
         {
120
           { 0     , 0     , 0      },
121
           { -E    , E+0.5f, -0.5f  },
122
           {-0.5f  , -E    , -E-0.5f},
123
           { E+0.5f, 0.5f  , -E     },
124
           { 0     , 1     , -2*E-1 },
125
           { 0     , 1     , 0      },
126
           { -E    ,-E+0.5f, -0.5f  },
127
           {  E    ,-E+0.5f, -0.5f  }
128
         };
129
      }
130
    else if( variant==1 )
131
      {
132
      return new float[][]
133
         {
134
            {         0.00f,         0.00f,         0.00f},
135
            {       - 0.50f,-SQ5/4 - 0.25f,-SQ5/4 - 0.75f},
136
            { SQ5/4 + 0.25f,-SQ5/4 - 0.75f,       + 0.50f},
137
            { SQ5/4 + 0.75f,       + 0.50f,-SQ5/4 - 0.25f},
138
            { SQ5/2 + 0.50f,-SQ5/2 - 0.50f,-SQ5/2 - 0.50f},
139
            { SQ5/4 - 0.25f,       + 0.50f,-SQ5/4 - 0.25f},
140
            {       - 0.50f,-SQ5/4 - 0.25f,-SQ5/4 + 0.25f},
141
            { SQ5/4 + 0.25f,-SQ5/4 + 0.25f,       + 0.50f}
142
         };
143
      }
144
    else
145
      {
146
      return new float[][]
147
         {
148
           {  -E     ,-E+0.5f,     0.5f},
149
           {   E     , E-0.5f,    -0.5f},
150
           {-2*E     ,   0.0f,     0.0f},
151
           {     0.5f, E     ,  -E-0.5f},
152
           {  -E     ,-E-0.5f,     0.5f},
153
           {   E+0.5f,  -0.5f,  -E     },
154
           {-2*E     ,  -1.0f,     0.0f},
155
           {     1.0f,   0.0f,-2*E     },
156
           {-2*E+0.5f, E     ,  -E-0.5f},
157
           {     0.5f,-E-1.0f,  -E+0.5f},
158
           {  -E     ,-E-0.5f,-2*E-0.5f}
159
         };
160
      }
161
    }
162

    
163
///////////////////////////////////////////////////////////////////////////////////////////////////
164

    
165
  public ObjectShape getObjectShape(int variant)
166
    {
167
    if( variant==0 )
168
      {
169
      int[][] indices =
170
         {
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
      return new ObjectShape(getVertices(variant), indices);
180
      }
181
    else if( variant==1 )
182
      {
183
      int[][] indices =
184
         {
185
           {6,0,5,1},
186
           {0,7,3,5},
187
           {0,6,2,7},
188
           {1,5,3,4},
189
           {3,7,2,4},
190
           {2,6,1,4},
191
         };
192

    
193
      return new ObjectShape(getVertices(variant), indices);
194
      }
195
    else
196
      {
197
      int[][] indices =
198
         {
199
           {0,1,3,8,2},
200
           {0,4,9,5,1},
201
           { 0,2,6,4},
202
           { 1,5,7,3},
203
           {10,9,4,6},
204
           {7,5,9,10},
205
           {10,8,3,7},
206
           {6,2,8,10}
207
         };
208

    
209
      return new ObjectShape(getVertices(variant), indices);
210
      }
211
    }
212

    
213
///////////////////////////////////////////////////////////////////////////////////////////////////
214

    
215
  public ObjectFaceShape getObjectFaceShape(int variant)
216
    {
217
    if( variant==0 )
218
      {
219
      float h1 = isInIconMode() ? 0.001f : 0.05f;
220
      float h2 = isInIconMode() ? 0.001f : 0.01f;
221
      float[][] bands = { {h1,17,0.5f,0.2f,5,1,0}, {h2, 1,0.5f,0.2f,5,1,0} };
222
      int[] indices   = { 0,0,0,1,1,1 };
223
      return new ObjectFaceShape(bands,indices,null);
224
      }
225
    else if( variant==1 )
226
      {
227
      float h1 = isInIconMode() ? 0.001f : 0.05f;
228
      float h2 = isInIconMode() ? 0.001f : 0.01f;
229
      float[][] bands = { {h1,17,0.5f,0.2f,5,1,0}, {h2, 1,0.5f,0.2f,5,1,0} };
230
      int[] indices   = { 0,0,0,1,1,1 };
231
      return new ObjectFaceShape(bands,indices,null);
232
      }
233
    else
234
      {
235
      float h1 = isInIconMode() ? 0.001f : 0.03f;
236
      float h2 = isInIconMode() ? 0.001f : 0.05f;
237
      float h3 = isInIconMode() ? 0.001f : 0.01f;
238
      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} };
239
      int[] indices   = { 0,0,1,1,2,2,2,2 };
240
      return new ObjectFaceShape(bands,indices,null);
241
      }
242
    }
243

    
244
///////////////////////////////////////////////////////////////////////////////////////////////////
245

    
246
  public ObjectVertexEffects getVertexEffects(int variant)
247
    {
248
    if( variant==0 )
249
      {
250
      float[][] corners   = { { 0.013f, 0.16f } };
251
      int[] cornerIndices = { 0, 0, 0, 0,-1, 0, 0, 0 };
252
      float[][] centers   = { { 0.0f,-1.0f, -(SQ5+3)/2 } };
253
      int[] centerIndices = { 0,0,0,0,0,0,0,0 };
254
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
255
      }
256
    else if( variant==1 )
257
      {
258
      float[][] corners   = { { 0.013f, 0.16f } };
259
      int[] cornerIndices = { 0, 0, 0, 0,-1, 0, 0, 0 };
260
      float[][] centers   = { { 0.0f,-1.0f, -(SQ5+3)/2 } };
261
      int[] centerIndices = { 0,0,0,0,0,0,0,0 };
262
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
263
      }
264
    else
265
      {
266
      float[][] corners   = { { 0.013f, 0.16f } };
267
      int[] cornerIndices = { 0,0,0,0,0,0,0,0,0,0,-1 };
268
      float[][] centers   = { { -(SQ5+1)/4, 0.5f, -(SQ5+5)/4 } };
269
      int[] centerIndices = { 0,0,0,0,0,0,0,0,0,0,0 };
270
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
271
      }
272
    }
273

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

    
276
  public int getNumCubitVariants(int[] numLayers)
277
    {
278
    return 3;
279
    }
280

    
281
///////////////////////////////////////////////////////////////////////////////////////////////////
282

    
283
  public int getCubitVariant(int cubit, int[] numLayers)
284
    {
285
    return cubit<4 ? 0 : (cubit<8 ? 1:2);
286
    }
287

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

    
290
  public float[][] getCuts(int[] numLayers)
291
    {
292
    if( mCuts==null )
293
      {
294
      float[] cut = new float[] {0.0f};
295
      mCuts = new float[][] { cut,cut,cut,cut };
296
      }
297

    
298
    return mCuts;
299
    }
300

    
301
///////////////////////////////////////////////////////////////////////////////////////////////////
302

    
303
  public boolean[][] getLayerRotatable(int[] numLayers)
304
    {
305
    boolean[] tmp = new boolean[] {true,true};
306
    return new boolean[][] { tmp,tmp,tmp,tmp };
307
    }
308

    
309
///////////////////////////////////////////////////////////////////////////////////////////////////
310

    
311
  public int getTouchControlType()
312
    {
313
    return TC_DODECAHEDRON;
314
    }
315

    
316
///////////////////////////////////////////////////////////////////////////////////////////////////
317

    
318
  public int getTouchControlSplit()
319
    {
320
    return TYPE_NOT_SPLIT;
321
    }
322

    
323
///////////////////////////////////////////////////////////////////////////////////////////////////
324

    
325
  public int[][][] getEnabled()
326
    {
327
    return new int[][][]
328
      {
329
        {{2,3}},{{1,3}},{{1,3}},{{2,3}},{{0,3}},{{0,2}},{{0,2}},{{0,3}},{{1,2}},{{0,1}},{{0,1}},{{1,2}}
330
      };
331
    }
332

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

    
335
  public float[] getDist3D(int[] numLayers)
336
    {
337
    return TouchControlDodecahedron.D3D;
338
    }
339

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

    
342
  public Static3D[] getFaceAxis()
343
    {
344
    return TouchControlDodecahedron.FACE_AXIS;
345
    }
346

    
347
///////////////////////////////////////////////////////////////////////////////////////////////////
348

    
349
  public float getStickerRadius()
350
    {
351
    return 0.18f;
352
    }
353

    
354
///////////////////////////////////////////////////////////////////////////////////////////////////
355

    
356
  public float getStickerStroke()
357
    {
358
    return isInIconMode() ? 0.22f : 0.15f;
359
    }
360

    
361
///////////////////////////////////////////////////////////////////////////////////////////////////
362

    
363
  public float[][] getStickerAngles()
364
    {
365
    return null;
366
    }
367

    
368
///////////////////////////////////////////////////////////////////////////////////////////////////
369
// PUBLIC API
370

    
371
  public Static3D[] getRotationAxis()
372
    {
373
    return ROT_AXIS;
374
    }
375

    
376
///////////////////////////////////////////////////////////////////////////////////////////////////
377

    
378
  public int[][] getBasicAngles()
379
    {
380
    if( mBasicAngle ==null )
381
      {
382
      int num = getNumLayers()[0];
383
      int[] tmp = new int[num];
384
      for(int i=0; i<num; i++) tmp[i] = 3;
385
      mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
386
      }
387

    
388
    return mBasicAngle;
389
    }
390

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

    
393
  public String getShortName()
394
    {
395
    return ObjectType.ULTI_2.name();
396
    }
397

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

    
400
  public ObjectSignature getSignature()
401
    {
402
    return new ObjectSignature(ObjectSignatures.ULTI_2);
403
    }
404

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

    
407
  public String getObjectName()
408
    {
409
    return "Skewb Ultimate";
410
    }
411

    
412
///////////////////////////////////////////////////////////////////////////////////////////////////
413

    
414
  public String getInventor()
415
    {
416
    return "Tony Fisher";
417
    }
418

    
419
///////////////////////////////////////////////////////////////////////////////////////////////////
420

    
421
  public int getYearOfInvention()
422
    {
423
    return 2000;
424
    }
425

    
426
///////////////////////////////////////////////////////////////////////////////////////////////////
427

    
428
  public int getComplexity()
429
    {
430
    return 2;
431
    }
432

    
433
///////////////////////////////////////////////////////////////////////////////////////////////////
434

    
435
  public String[][] getTutorials()
436
    {
437
    return new String[][]{
438
                          {"gb","n1ikPKZxGEo","Ultimate Skewb Tutorial","BeardedCubing"},
439
                          {"es","wNL1WJ_sCfs","Resolver Skewb ULTIMATE","Cuby"},
440
                          {"ru","ifkM8Rr3Y8E","Как собрать Скьюб Ультимейт","Алексей Ярыгин"},
441
                          {"fr","r_eoNcejdrA","Résoudre le Skewb Ultimate","ValentinoCube"},
442
                          {"de","16ioOywTVvI","Skewb Ultimate - Tutorial","GerCubing"},
443
                          {"pl","8MsyPs1VB8U","Ultimate skewb TUTORIAL PL","MrUK"},
444
                          {"kr","VOt9_K48c0k","스큐브 얼티미트 공식","노케빈"},
445
                          {"vn","VOt9_K48c0k","Tutorial N.147 - Skewb Ultimate","Duy Thích Rubik"},
446
                         };
447
    }
448
}
(39-39/41)