Project

General

Profile

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

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

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.ObjectControl;
33
import org.distorted.objectlib.main.ObjectType;
34
import org.distorted.objectlib.helpers.ObjectShape;
35
import org.distorted.objectlib.scrambling.ScrambleState;
36
import org.distorted.objectlib.main.ShapeDodecahedron;
37

    
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39

    
40
public class TwistyUltimate extends ShapeDodecahedron
41
{
42
  private static final float A = (float)Math.sqrt(21*SQ5+47);
43
  private static final float B = SQ6*(5*SQ5+11)/(6*A);
44
  private static final float C = SQ6*(  SQ5+ 2)/(3*A);
45
  private static final float D = SQ3/3;
46
  private static final float E = (SQ5+1)/4;
47
  private static final float G = (SQ5+3)/4;
48

    
49
  static final Static3D[] ROT_AXIS = new Static3D[]
50
         {
51
           new Static3D( B,0,C ),
52
           new Static3D( C,B,0 ),
53
           new Static3D(-D,D,D ),
54
           new Static3D( 0,C,-B)
55
         };
56

    
57
  private ScrambleState[] mStates;
58
  private int[] mBasicAngle;
59
  private float[][] mCuts;
60
  private float[][] mCenters;
61
  private int[] mQuatIndex;
62

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

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

    
70
///////////////////////////////////////////////////////////////////////////////////////////////////
71

    
72
  public ScrambleState[] getScrambleStates()
73
    {
74
    if( mStates==null )
75
      {
76
      int[] tmp = {0,-1,0, 0,1,0, 1,-1,0, 1,1,0 };
77

    
78
      mStates = new ScrambleState[]
79
        {
80
        new ScrambleState( new int[][] {tmp,tmp,tmp,tmp} )
81
        };
82
      }
83

    
84
    return mStates;
85
    }
86

    
87
///////////////////////////////////////////////////////////////////////////////////////////////////
88

    
89
  public float[][] getCubitPositions(int[] numLayers)
90
    {
91
    if( mCenters==null )
92
      {
93
      mCenters = new float[][]
94
         {
95
           {   0,  -1, 2*G },
96
           { 2*E,-2*E,-2*E },
97
           {-2*G,   0,  -1 },
98
           {   1, 2*G,   0 },
99

    
100
           {-2*E,  2*E, 2*E },
101
           { 2*G,    0,   1 },
102
           {  -1, -2*G,   0 },
103
           {   0,    1,-2*G },
104

    
105
           {        E, (E+0.5f),    (E+G) },
106
           {   -(E+G),       -E, (E+0.5f) },
107
           { (E+0.5f),   -(E+G),        E },
108
           {       -E,-(E+0.5f),   -(E+G) },
109
           {    (E+G),        E,-(E+0.5f) },
110
           {-(E+0.5f),    (E+G),       -E }
111
         };
112
      }
113

    
114
    return mCenters;
115
    }
116

    
117
///////////////////////////////////////////////////////////////////////////////////////////////////
118

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

    
125
///////////////////////////////////////////////////////////////////////////////////////////////////
126

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

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

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

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

    
211
///////////////////////////////////////////////////////////////////////////////////////////////////
212

    
213
  public ObjectFaceShape getObjectFaceShape(int variant)
214
    {
215
    if( variant==0 )
216
      {
217
      float[][] bands     = { {0.03f,17,0.5f,0.2f,5,2,2}, {0.01f, 1,0.5f,0.2f,5,2,2} };
218
      int[] bandIndices   = { 0,0,0,1,1,1 };
219
      float[][] corners   = { { 0.013f, 0.16f } };
220
      int[] cornerIndices = { 0, 0, 0, 0,-1, 0, 0, 0 };
221
      float[][] centers   = { { 0.0f,-1.0f, -(SQ5+3)/2 } };
222
      int[] centerIndices = { 0,0,0,0,0,0,0,0 };
223
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
224
      }
225
    else if( variant==1 )
226
      {
227
      float[][] bands     = { {0.03f,17,0.5f,0.2f,5,2,2}, {0.01f, 1,0.5f,0.2f,5,2,2} };
228
      int[] bandIndices   = { 0,0,0,1,1,1 };
229
      float[][] corners   = { { 0.013f, 0.16f } };
230
      int[] cornerIndices = { 0, 0, 0, 0,-1, 0, 0, 0 };
231
      float[][] centers   = { { 0.0f,-1.0f, -(SQ5+3)/2 } };
232
      int[] centerIndices = { 0,0,0,0,0,0,0,0 };
233
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
234
      }
235
    else
236
      {
237
      float[][] bands     = { {0.04f,17,0.5f,0.2f,5,2,2}, {0.03f,17,0.5f,0.2f,5,2,2}, {0.01f, 1,0.5f,0.2f,5,2,2} };
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 ObjectControl.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 ) mBasicAngle = new int[] { 3,3,3,3 };
354
    return mBasicAngle;
355
    }
356

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

    
359
  public String getShortName()
360
    {
361
    return ObjectType.ULTI_2.name();
362
    }
363

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

    
366
  public long getSignature()
367
    {
368
    return ObjectType.ULTI_2.ordinal();
369
    }
370

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

    
373
  public String getObjectName()
374
    {
375
    return "Skewb Ultimate";
376
    }
377

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

    
380
  public String getInventor()
381
    {
382
    return "Tony Fisher";
383
    }
384

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

    
387
  public int getYearOfInvention()
388
    {
389
    return 2000;
390
    }
391

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

    
394
  public int getComplexity()
395
    {
396
    return 2;
397
    }
398

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

    
401
  public String[][] getTutorials()
402
    {
403
    return new String[][]{
404
                          {"gb","n1ikPKZxGEo","Ultimate Skewb Tutorial","BeardedCubing"},
405
                          {"es","wNL1WJ_sCfs","Resolver Skewb ULTIMATE","Cuby"},
406
                          {"ru","ifkM8Rr3Y8E","Как собрать Скьюб Ультимейт","Алексей Ярыгин"},
407
                          {"fr","r_eoNcejdrA","Résoudre le Skewb Ultimate","ValentinoCube"},
408
                          {"de","16ioOywTVvI","Skewb Ultimate - Tutorial","GerCubing"},
409
                          {"pl","8MsyPs1VB8U","Ultimate skewb TUTORIAL PL","MrUK"},
410
                          {"kr","VOt9_K48c0k","스큐브 얼티미트 공식","노케빈"},
411
                         };
412
    }
413
}
(31-31/33)