Project

General

Profile

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

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

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 org.distorted.library.type.Static3D;
16
import org.distorted.library.type.Static4D;
17

    
18
import org.distorted.objectlib.helpers.FactoryCubit;
19
import org.distorted.objectlib.helpers.ObjectFaceShape;
20
import org.distorted.objectlib.helpers.ObjectSignature;
21
import org.distorted.objectlib.helpers.ObjectVertexEffects;
22
import org.distorted.objectlib.main.InitAssets;
23
import org.distorted.objectlib.main.ObjectSignatures;
24
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator;
25
import org.distorted.objectlib.main.InitData;
26
import org.distorted.objectlib.touchcontrol.TouchControlDodecahedron;
27
import org.distorted.objectlib.main.ObjectType;
28
import org.distorted.objectlib.helpers.ObjectShape;
29
import org.distorted.objectlib.shape.ShapeDodecahedron;
30

    
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32

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

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

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

    
56
///////////////////////////////////////////////////////////////////////////////////////////////////
57

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

    
63
///////////////////////////////////////////////////////////////////////////////////////////////////
64

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

    
71
///////////////////////////////////////////////////////////////////////////////////////////////////
72

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

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

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

    
98
    return mPositions;
99
    }
100

    
101
///////////////////////////////////////////////////////////////////////////////////////////////////
102

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

    
111
///////////////////////////////////////////////////////////////////////////////////////////////////
112

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

    
162
///////////////////////////////////////////////////////////////////////////////////////////////////
163

    
164
  public ObjectShape getObjectShape(int variant)
165
    {
166
    if( variant==0 )
167
      {
168
      int[][] indices =
169
         {
170
           {6,0,5,1},
171
           {0,7,3,5},
172
           {0,6,2,7},
173
           {1,5,3,4},
174
           {3,7,2,4},
175
           {2,6,1,4},
176
         };
177

    
178
      return new ObjectShape(getVertices(variant), indices);
179
      }
180
    else if( variant==1 )
181
      {
182
      int[][] indices =
183
         {
184
           {6,0,5,1},
185
           {0,7,3,5},
186
           {0,6,2,7},
187
           {1,5,3,4},
188
           {3,7,2,4},
189
           {2,6,1,4},
190
         };
191

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

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

    
212
///////////////////////////////////////////////////////////////////////////////////////////////////
213

    
214
  public ObjectFaceShape getObjectFaceShape(int variant)
215
    {
216
    int angle = 25;
217
    float R = 0.7f;
218
    float S = 0.5f;
219

    
220
    if( variant==0 )
221
      {
222
      float h1 = isInIconMode() ? 0.001f : 0.05f;
223
      float h2 = isInIconMode() ? 0.001f : 0.01f;
224
      float[][] bands = { {h1,angle,R,S,5,1,0}, {h2,angle,R,S,5,1,0} };
225
      int[] indices   = { 0,0,0,1,1,1 };
226
      return new ObjectFaceShape(bands,indices,null);
227
      }
228
    else if( variant==1 )
229
      {
230
      float h1 = isInIconMode() ? 0.001f : 0.05f;
231
      float h2 = isInIconMode() ? 0.001f : 0.01f;
232
      float[][] bands = { {h1,angle,R,S,5,1,0}, {h2,angle,R,S,5,1,0} };
233
      int[] indices   = { 0,0,0,1,1,1 };
234
      return new ObjectFaceShape(bands,indices,null);
235
      }
236
    else
237
      {
238
      float h1 = isInIconMode() ? 0.001f : 0.03f;
239
      float h2 = isInIconMode() ? 0.001f : 0.05f;
240
      float h3 = isInIconMode() ? 0.001f : 0.01f;
241
      float[][] bands = { {h1,angle,R,S,5,1,0}, {h2,angle,R,S,5,1,0}, {h3,angle,R,S,5,1,0} };
242
      int[] indices   = { 0,0,1,1,2,2,2,2 };
243
      return new ObjectFaceShape(bands,indices,null);
244
      }
245
    }
246

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

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

    
277
///////////////////////////////////////////////////////////////////////////////////////////////////
278

    
279
  public int getNumCubitVariants(int[] numLayers)
280
    {
281
    return 3;
282
    }
283

    
284
///////////////////////////////////////////////////////////////////////////////////////////////////
285

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

    
291
///////////////////////////////////////////////////////////////////////////////////////////////////
292

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

    
301
    return mCuts;
302
    }
303

    
304
///////////////////////////////////////////////////////////////////////////////////////////////////
305

    
306
  public boolean[][] getLayerRotatable(int[] numLayers)
307
    {
308
    boolean[] tmp = new boolean[] {true,true};
309
    return new boolean[][] { tmp,tmp,tmp,tmp };
310
    }
311

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

    
314
  public int getTouchControlType()
315
    {
316
    return TC_DODECAHEDRON;
317
    }
318

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

    
321
  public int getTouchControlSplit()
322
    {
323
    return TYPE_NOT_SPLIT;
324
    }
325

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

    
328
  public int[][][] getEnabled()
329
    {
330
    return new int[][][]
331
      {
332
        {{2,3}},{{1,3}},{{1,3}},{{2,3}},{{0,3}},{{0,2}},{{0,2}},{{0,3}},{{1,2}},{{0,1}},{{0,1}},{{1,2}}
333
      };
334
    }
335

    
336
///////////////////////////////////////////////////////////////////////////////////////////////////
337

    
338
  public float[] getDist3D(int[] numLayers)
339
    {
340
    return TouchControlDodecahedron.D3D;
341
    }
342

    
343
///////////////////////////////////////////////////////////////////////////////////////////////////
344

    
345
  public Static3D[] getFaceAxis()
346
    {
347
    return TouchControlDodecahedron.FACE_AXIS;
348
    }
349

    
350
///////////////////////////////////////////////////////////////////////////////////////////////////
351

    
352
  public float getStickerRadius()
353
    {
354
    return 0.18f;
355
    }
356

    
357
///////////////////////////////////////////////////////////////////////////////////////////////////
358

    
359
  public float getStickerStroke()
360
    {
361
    return isInIconMode() ? 0.22f : 0.15f;
362
    }
363

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

    
366
  public float[][] getStickerAngles()
367
    {
368
    return null;
369
    }
370

    
371
///////////////////////////////////////////////////////////////////////////////////////////////////
372
// PUBLIC API
373

    
374
  public Static3D[] getRotationAxis()
375
    {
376
    return ROT_AXIS;
377
    }
378

    
379
///////////////////////////////////////////////////////////////////////////////////////////////////
380

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

    
391
    return mBasicAngle;
392
    }
393

    
394
///////////////////////////////////////////////////////////////////////////////////////////////////
395

    
396
  public String getShortName()
397
    {
398
    return ObjectType.ULTI_2.name();
399
    }
400

    
401
///////////////////////////////////////////////////////////////////////////////////////////////////
402

    
403
  public ObjectSignature getSignature()
404
    {
405
    return new ObjectSignature(ObjectSignatures.ULTI_2);
406
    }
407

    
408
///////////////////////////////////////////////////////////////////////////////////////////////////
409

    
410
  public String getObjectName()
411
    {
412
    return "Skewb Ultimate";
413
    }
414

    
415
///////////////////////////////////////////////////////////////////////////////////////////////////
416

    
417
  public String getInventor()
418
    {
419
    return "Tony Fisher";
420
    }
421

    
422
///////////////////////////////////////////////////////////////////////////////////////////////////
423

    
424
  public int getYearOfInvention()
425
    {
426
    return 2000;
427
    }
428

    
429
///////////////////////////////////////////////////////////////////////////////////////////////////
430

    
431
  public int getComplexity()
432
    {
433
    return 2;
434
    }
435

    
436
///////////////////////////////////////////////////////////////////////////////////////////////////
437

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