Project

General

Profile

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

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

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

    
243
///////////////////////////////////////////////////////////////////////////////////////////////////
244

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

    
273
///////////////////////////////////////////////////////////////////////////////////////////////////
274

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

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

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

    
287
///////////////////////////////////////////////////////////////////////////////////////////////////
288

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

    
297
    return mCuts;
298
    }
299

    
300
///////////////////////////////////////////////////////////////////////////////////////////////////
301

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

    
308
///////////////////////////////////////////////////////////////////////////////////////////////////
309

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

    
315
///////////////////////////////////////////////////////////////////////////////////////////////////
316

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

    
322
///////////////////////////////////////////////////////////////////////////////////////////////////
323

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

    
332
///////////////////////////////////////////////////////////////////////////////////////////////////
333

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

    
339
///////////////////////////////////////////////////////////////////////////////////////////////////
340

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

    
346
///////////////////////////////////////////////////////////////////////////////////////////////////
347

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

    
353
///////////////////////////////////////////////////////////////////////////////////////////////////
354

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

    
360
///////////////////////////////////////////////////////////////////////////////////////////////////
361

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

    
367
///////////////////////////////////////////////////////////////////////////////////////////////////
368
// PUBLIC API
369

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

    
375
///////////////////////////////////////////////////////////////////////////////////////////////////
376

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

    
387
    return mBasicAngle;
388
    }
389

    
390
///////////////////////////////////////////////////////////////////////////////////////////////////
391

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

    
397
///////////////////////////////////////////////////////////////////////////////////////////////////
398

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

    
404
///////////////////////////////////////////////////////////////////////////////////////////////////
405

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

    
411
///////////////////////////////////////////////////////////////////////////////////////////////////
412

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

    
418
///////////////////////////////////////////////////////////////////////////////////////////////////
419

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

    
425
///////////////////////////////////////////////////////////////////////////////////////////////////
426

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

    
432
///////////////////////////////////////////////////////////////////////////////////////////////////
433

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