Project

General

Profile

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

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

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.helpers.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 F = (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 Static4D[] mQuats;
61
  private float[][] mCuts;
62
  private int[][] mFaceMap;
63
  private float[][] mCenters;
64
  private int[] mQuatIndex;
65

    
66
///////////////////////////////////////////////////////////////////////////////////////////////////
67

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

    
73
///////////////////////////////////////////////////////////////////////////////////////////////////
74

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

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

    
87
    return mStates;
88
    }
89

    
90
///////////////////////////////////////////////////////////////////////////////////////////////////
91

    
92
  private void initializeQuats()
93
    {
94
    mQuats = new Static4D[]
95
         {
96
         new Static4D( 0.0f, 0.0f, 0.0f, 1.0f ),
97
         new Static4D(-0.5f, 0.5f, 0.5f, 0.5f ),
98
         new Static4D( 0.5f,-0.5f,-0.5f, 0.5f ),
99
         new Static4D( 0.0f,    F,   -E, 0.5f ),
100
         new Static4D( 0.0f,   -F,    E, 0.5f ),
101
         new Static4D(    E, 0.0f,    F, 0.5f ),
102
         new Static4D(   -E, 0.0f,   -F, 0.5f ),
103
         new Static4D(    F,    E, 0.0f, 0.5f ),
104
         new Static4D(   -F,   -E, 0.0f, 0.5f ),
105
         new Static4D(    E,    F,-0.5f, 0.0f ),
106
         new Static4D( 0.5f,   -E,    F, 0.0f ),
107
         new Static4D(    F, 0.5f,    E, 0.0f )
108
         };
109
    }
110

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

    
113
  public int[] getSolvedQuats(int cubit, int[] numLayers)
114
    {
115
    if( mQuats==null ) initializeQuats();
116
    int status = retCubitSolvedStatus(cubit,numLayers);
117
    return status<0 ? null : buildSolvedQuats(TouchControlDodecahedron.FACE_AXIS[status],mQuats);
118
    }
119

    
120
///////////////////////////////////////////////////////////////////////////////////////////////////
121

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

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

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

    
202
      return new ObjectShape(vertices, indices, 4);
203
      }
204
    }
205

    
206
///////////////////////////////////////////////////////////////////////////////////////////////////
207

    
208
  public ObjectFaceShape getObjectFaceShape(int variant)
209
    {
210
    if( variant==0 )
211
      {
212
      float[][] bands     = { {0.03f,17,0.5f,0.2f,5,2,2}, {0.01f, 1,0.5f,0.2f,5,2,2} };
213
      int[] bandIndices   = { 0,0,0,1,1,1 };
214
      float[][] corners   = { { 0.013f, 0.16f } };
215
      int[] cornerIndices = { 0, 0, 0, 0,-1, 0, 0, 0 };
216
      float[][] centers   = { { 0.0f,-1.0f, -(SQ5+3)/2 } };
217
      int[] centerIndices = { 0,0,0,0,0,0,0,0 };
218
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
219
      }
220
    else if( variant==1 )
221
      {
222
      float[][] bands     = { {0.03f,17,0.5f,0.2f,5,2,2}, {0.01f, 1,0.5f,0.2f,5,2,2} };
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
231
      {
232
      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} };
233
      int[] bandIndices   = { 0,0,1,1,2,2,2,2 };
234
      float[][] corners   = { { 0.013f, 0.16f } };
235
      int[] cornerIndices = { 0,0,0,0,0,0,0,0,0,0,-1 };
236
      float[][] centers   = { { -(SQ5+1)/4, 0.5f, -(SQ5+5)/4 } };
237
      int[] centerIndices = { 0,0,0,0,0,0,0,0,0,0,0 };
238
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
239
      }
240
    }
241

    
242
///////////////////////////////////////////////////////////////////////////////////////////////////
243

    
244
  public Static4D getQuat(int cubit, int[] numLayers)
245
    {
246
    if( mQuats     ==null ) initializeQuats();
247
    if( mQuatIndex ==null ) mQuatIndex = new int[] { 0,6,1,2,0,4,6,5,0,1,4,9,5,2 };
248
    return mQuats[mQuatIndex[cubit]];
249
    }
250

    
251
///////////////////////////////////////////////////////////////////////////////////////////////////
252

    
253
  public int getNumCubitVariants(int[] numLayers)
254
    {
255
    return 3;
256
    }
257

    
258
///////////////////////////////////////////////////////////////////////////////////////////////////
259

    
260
  public int getCubitVariant(int cubit, int[] numLayers)
261
    {
262
    return cubit<4 ? 0 : (cubit<8 ? 1:2);
263
    }
264

    
265
///////////////////////////////////////////////////////////////////////////////////////////////////
266

    
267
  public float[][] getCubitPositions(int[] numLayers)
268
    {
269
    if( mCenters==null )
270
      {
271
      mCenters = new float[][]
272
         {
273
           {   0,  -1, 2*G },
274
           { 2*E,-2*E,-2*E },
275
           {-2*G,   0,  -1 },
276
           {   1, 2*G,   0 },
277

    
278
           {-2*E,  2*E, 2*E },
279
           { 2*G,    0,   1 },
280
           {  -1, -2*G,   0 },
281
           {   0,    1,-2*G },
282

    
283
           {        E, (E+0.5f),    (E+G) },
284
           {   -(E+G),       -E, (E+0.5f) },
285
           { (E+0.5f),   -(E+G),        E },
286
           {       -E,-(E+0.5f),   -(E+G) },
287
           {    (E+G),        E,-(E+0.5f) },
288
           {-(E+0.5f),    (E+G),       -E }
289
         };
290
      }
291

    
292
    return mCenters;
293
    }
294

    
295
///////////////////////////////////////////////////////////////////////////////////////////////////
296

    
297
  public Static4D[] getQuats()
298
    {
299
    if( mQuats==null ) initializeQuats();
300
    return mQuats;
301
    }
302

    
303
///////////////////////////////////////////////////////////////////////////////////////////////////
304

    
305
  public int getSolvedFunctionIndex()
306
    {
307
    return 0;
308
    }
309

    
310
///////////////////////////////////////////////////////////////////////////////////////////////////
311

    
312
  public float[][] getCuts(int[] numLayers)
313
    {
314
    if( mCuts==null )
315
      {
316
      float[] cut = new float[] {0.0f};
317
      mCuts = new float[][] { cut,cut,cut,cut };
318
      }
319

    
320
    return mCuts;
321
    }
322

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

    
325
  public boolean[][] getLayerRotatable(int[] numLayers)
326
    {
327
    int numAxis = ROT_AXIS.length;
328
    boolean[][] layerRotatable = new boolean[numAxis][];
329

    
330
    for(int i=0; i<numAxis; i++)
331
      {
332
      layerRotatable[i] = new boolean[numLayers[i]];
333
      for(int j=0; j<numLayers[i]; j++) layerRotatable[i][j] = true;
334
      }
335

    
336
    return layerRotatable;
337
    }
338

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

    
341
  public int getTouchControlType()
342
    {
343
    return TC_DODECAHEDRON;
344
    }
345

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

    
348
  public int getTouchControlSplit()
349
    {
350
    return TYPE_NOT_SPLIT;
351
    }
352

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

    
355
  public int[][][] getEnabled()
356
    {
357
    return new int[][][]
358
      {
359
        {{2,3}},{{1,3}},{{1,3}},{{2,3}},{{0,3}},{{0,2}},{{0,2}},{{0,3}},{{1,2}},{{0,1}},{{0,1}},{{1,2}}
360
      };
361
    }
362

    
363
///////////////////////////////////////////////////////////////////////////////////////////////////
364

    
365
  public float[] getDist3D(int[] numLayers)
366
    {
367
    return null;
368
    }
369

    
370
///////////////////////////////////////////////////////////////////////////////////////////////////
371

    
372
  public int getNumCubitFaces()
373
    {
374
    return 8;
375
    }
376

    
377
///////////////////////////////////////////////////////////////////////////////////////////////////
378

    
379
  public int getCubitFaceColor(int cubit, int face, int[] numLayers)
380
    {
381
    if( mFaceMap==null )
382
      {
383
      mFaceMap = new int[][]
384
         {
385
           {  1, 0,11, -1,-1,-1,-1,-1 },
386
           {  3, 4, 5, -1,-1,-1,-1,-1 },
387
           {  7, 2, 6, -1,-1,-1,-1,-1 },
388
           {  8,10, 9, -1,-1,-1,-1,-1 },
389

    
390
           {  7, 8, 1, -1,-1,-1,-1,-1 },
391
           {  9, 4, 0, -1,-1,-1,-1,-1 },
392
           {  2,11, 3, -1,-1,-1,-1,-1 },
393
           {  6, 5,10, -1,-1,-1,-1,-1 },
394

    
395
           {  8, 0, 1, 9, -1,-1,-1,-1 },
396
           {  1, 2, 7,11, -1,-1,-1,-1 },
397
           {  4,11, 0, 3, -1,-1,-1,-1 },
398
           {  3, 6, 2, 5, -1,-1,-1,-1 },
399
           {  5, 9,10, 4, -1,-1,-1,-1 },
400
           {  7,10, 8, 6, -1,-1,-1,-1 }
401
         };
402
      }
403

    
404
    return mFaceMap[cubit][face];
405
    }
406

    
407
///////////////////////////////////////////////////////////////////////////////////////////////////
408

    
409
  public float getStickerRadius()
410
    {
411
    return 0.18f;
412
    }
413

    
414
///////////////////////////////////////////////////////////////////////////////////////////////////
415

    
416
  public float getStickerStroke()
417
    {
418
    return ObjectControl.isInIconMode() ? 0.22f : 0.15f;
419
    }
420

    
421
///////////////////////////////////////////////////////////////////////////////////////////////////
422

    
423
  public float[][] getStickerAngles()
424
    {
425
    return null;
426
    }
427

    
428
///////////////////////////////////////////////////////////////////////////////////////////////////
429
// PUBLIC API
430

    
431
  public Static3D[] getRotationAxis()
432
    {
433
    return ROT_AXIS;
434
    }
435

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

    
438
  public int[] getBasicAngle()
439
    {
440
    if( mBasicAngle ==null ) mBasicAngle = new int[] { 3,3,3,3 };
441
    return mBasicAngle;
442
    }
443

    
444
///////////////////////////////////////////////////////////////////////////////////////////////////
445

    
446
  public ObjectType intGetObjectType(int[] numLayers)
447
    {
448
    return ObjectType.ULTI_2;
449
    }
450

    
451
///////////////////////////////////////////////////////////////////////////////////////////////////
452

    
453
  public String getObjectName()
454
    {
455
    return "Skewb Ultimate";
456
    }
457

    
458
///////////////////////////////////////////////////////////////////////////////////////////////////
459

    
460
  public String getInventor()
461
    {
462
    return "Tony Fisher";
463
    }
464

    
465
///////////////////////////////////////////////////////////////////////////////////////////////////
466

    
467
  public int getYearOfInvention()
468
    {
469
    return 2000;
470
    }
471

    
472
///////////////////////////////////////////////////////////////////////////////////////////////////
473

    
474
  public int getComplexity()
475
    {
476
    return 2;
477
    }
478
}
(26-26/26)