Project

General

Profile

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

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

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.helpers.ObjectSignature;
32
import org.distorted.objectlib.main.InitData;
33
import org.distorted.objectlib.touchcontrol.TouchControlDodecahedron;
34
import org.distorted.objectlib.main.ObjectType;
35
import org.distorted.objectlib.helpers.ObjectShape;
36
import org.distorted.objectlib.scrambling.ScrambleState;
37
import org.distorted.objectlib.main.ShapeDodecahedron;
38

    
39
///////////////////////////////////////////////////////////////////////////////////////////////////
40

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

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

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

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

    
66
  public TwistyUltimate(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
67
    {
68
    super(data, meshState, iconMode, data.getNumLayers()[0], quat, move, scale, stream);
69
    }
70

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

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

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

    
85
    return mStates;
86
    }
87

    
88
///////////////////////////////////////////////////////////////////////////////////////////////////
89

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

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

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

    
115
    return mPositions;
116
    }
117

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

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

    
128
///////////////////////////////////////////////////////////////////////////////////////////////////
129

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

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

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

    
210
      return new ObjectShape(vertices, indices);
211
      }
212
    }
213

    
214
///////////////////////////////////////////////////////////////////////////////////////////////////
215

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

    
257
///////////////////////////////////////////////////////////////////////////////////////////////////
258

    
259
  public int getNumCubitVariants(int[] numLayers)
260
    {
261
    return 3;
262
    }
263

    
264
///////////////////////////////////////////////////////////////////////////////////////////////////
265

    
266
  public int getCubitVariant(int cubit, int[] numLayers)
267
    {
268
    return cubit<4 ? 0 : (cubit<8 ? 1:2);
269
    }
270

    
271
///////////////////////////////////////////////////////////////////////////////////////////////////
272

    
273
  public float[][] getCuts(int[] numLayers)
274
    {
275
    if( mCuts==null )
276
      {
277
      float[] cut = new float[] {0.0f};
278
      mCuts = new float[][] { cut,cut,cut,cut };
279
      }
280

    
281
    return mCuts;
282
    }
283

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

    
286
  public boolean[][] getLayerRotatable(int[] numLayers)
287
    {
288
    boolean[] tmp = new boolean[] {true,true};
289
    return new boolean[][] { tmp,tmp,tmp,tmp };
290
    }
291

    
292
///////////////////////////////////////////////////////////////////////////////////////////////////
293

    
294
  public int getTouchControlType()
295
    {
296
    return TC_DODECAHEDRON;
297
    }
298

    
299
///////////////////////////////////////////////////////////////////////////////////////////////////
300

    
301
  public int getTouchControlSplit()
302
    {
303
    return TYPE_NOT_SPLIT;
304
    }
305

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

    
308
  public int[][][] getEnabled()
309
    {
310
    return new int[][][]
311
      {
312
        {{2,3}},{{1,3}},{{1,3}},{{2,3}},{{0,3}},{{0,2}},{{0,2}},{{0,3}},{{1,2}},{{0,1}},{{0,1}},{{1,2}}
313
      };
314
    }
315

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

    
318
  public float[] getDist3D(int[] numLayers)
319
    {
320
    return TouchControlDodecahedron.D3D;
321
    }
322

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

    
325
  public Static3D[] getFaceAxis()
326
    {
327
    return TouchControlDodecahedron.FACE_AXIS;
328
    }
329

    
330
///////////////////////////////////////////////////////////////////////////////////////////////////
331

    
332
  public float getStickerRadius()
333
    {
334
    return 0.18f;
335
    }
336

    
337
///////////////////////////////////////////////////////////////////////////////////////////////////
338

    
339
  public float getStickerStroke()
340
    {
341
    return isInIconMode() ? 0.22f : 0.15f;
342
    }
343

    
344
///////////////////////////////////////////////////////////////////////////////////////////////////
345

    
346
  public float[][] getStickerAngles()
347
    {
348
    return null;
349
    }
350

    
351
///////////////////////////////////////////////////////////////////////////////////////////////////
352
// PUBLIC API
353

    
354
  public Static3D[] getRotationAxis()
355
    {
356
    return ROT_AXIS;
357
    }
358

    
359
///////////////////////////////////////////////////////////////////////////////////////////////////
360

    
361
  public int[][] getBasicAngles()
362
    {
363
    if( mBasicAngle ==null )
364
      {
365
      int num = getNumLayers()[0];
366
      int[] tmp = new int[num];
367
      for(int i=0; i<num; i++) tmp[i] = 3;
368
      mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
369
      }
370

    
371
    return mBasicAngle;
372
    }
373

    
374
///////////////////////////////////////////////////////////////////////////////////////////////////
375

    
376
  public String getShortName()
377
    {
378
    return ObjectType.ULTI_2.name();
379
    }
380

    
381
///////////////////////////////////////////////////////////////////////////////////////////////////
382

    
383
  public ObjectSignature getSignature()
384
    {
385
    return new ObjectSignature(ObjectType.ULTI_2);
386
    }
387

    
388
///////////////////////////////////////////////////////////////////////////////////////////////////
389

    
390
  public String getObjectName()
391
    {
392
    return "Skewb Ultimate";
393
    }
394

    
395
///////////////////////////////////////////////////////////////////////////////////////////////////
396

    
397
  public String getInventor()
398
    {
399
    return "Tony Fisher";
400
    }
401

    
402
///////////////////////////////////////////////////////////////////////////////////////////////////
403

    
404
  public int getYearOfInvention()
405
    {
406
    return 2000;
407
    }
408

    
409
///////////////////////////////////////////////////////////////////////////////////////////////////
410

    
411
  public int getComplexity()
412
    {
413
    return 2;
414
    }
415

    
416
///////////////////////////////////////////////////////////////////////////////////////////////////
417

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