Project

General

Profile

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

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

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
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
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 F = (SQ5-1)/4;
49
  private static final float G = (SQ5+3)/4;
50

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

    
59
  private ScrambleState[] mStates;
60
  private int[] mBasicAngle;
61
  private Static4D[] mQuats;
62
  private float[][] mCuts;
63
  private int[][] mFaceMap;
64
  private float[][] mCenters;
65
  private int[] mQuatIndex;
66

    
67
///////////////////////////////////////////////////////////////////////////////////////////////////
68

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

    
74
///////////////////////////////////////////////////////////////////////////////////////////////////
75

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

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

    
88
    return mStates;
89
    }
90

    
91
///////////////////////////////////////////////////////////////////////////////////////////////////
92

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

    
112
///////////////////////////////////////////////////////////////////////////////////////////////////
113

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

    
121
///////////////////////////////////////////////////////////////////////////////////////////////////
122

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

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

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

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

    
207
///////////////////////////////////////////////////////////////////////////////////////////////////
208

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

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

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

    
252
///////////////////////////////////////////////////////////////////////////////////////////////////
253

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

    
259
///////////////////////////////////////////////////////////////////////////////////////////////////
260

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

    
266
///////////////////////////////////////////////////////////////////////////////////////////////////
267

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

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

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

    
293
    return mCenters;
294
    }
295

    
296
///////////////////////////////////////////////////////////////////////////////////////////////////
297

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

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

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

    
311
///////////////////////////////////////////////////////////////////////////////////////////////////
312

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

    
321
    return mCuts;
322
    }
323

    
324
///////////////////////////////////////////////////////////////////////////////////////////////////
325

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

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

    
337
    return layerRotatable;
338
    }
339

    
340
///////////////////////////////////////////////////////////////////////////////////////////////////
341

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

    
347
///////////////////////////////////////////////////////////////////////////////////////////////////
348

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

    
354
///////////////////////////////////////////////////////////////////////////////////////////////////
355

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

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

    
366
  public float[] getDist3D(int[] numLayers)
367
    {
368
    return TouchControlDodecahedron.D3D;
369
    }
370

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

    
373
  public Static3D[] getFaceAxis()
374
    {
375
    return TouchControlDodecahedron.FACE_AXIS;
376
    }
377

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

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

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

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

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

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

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

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

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

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

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

    
429
///////////////////////////////////////////////////////////////////////////////////////////////////
430
// PUBLIC API
431

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

    
437
///////////////////////////////////////////////////////////////////////////////////////////////////
438

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

    
445
///////////////////////////////////////////////////////////////////////////////////////////////////
446

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

    
452
///////////////////////////////////////////////////////////////////////////////////////////////////
453

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

    
459
///////////////////////////////////////////////////////////////////////////////////////////////////
460

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

    
466
///////////////////////////////////////////////////////////////////////////////////////////////////
467

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

    
473
///////////////////////////////////////////////////////////////////////////////////////////////////
474

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