Project

General

Profile

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

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

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2022 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 org.distorted.library.type.Static3D;
23
import org.distorted.library.type.Static4D;
24
import org.distorted.objectlib.helpers.ObjectFaceShape;
25
import org.distorted.objectlib.helpers.ObjectShape;
26
import org.distorted.objectlib.scrambling.ScrambleState;
27
import org.distorted.objectlib.main.ObjectControl;
28
import org.distorted.objectlib.main.ObjectType;
29
import org.distorted.objectlib.main.ShapeHexahedron;
30
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
31

    
32
import java.io.InputStream;
33

    
34
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_CHANGING_SHAPEMOD;
35
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
36

    
37
///////////////////////////////////////////////////////////////////////////////////////////////////
38

    
39
public class TwistyAxis extends ShapeHexahedron
40
{
41
  static final Static3D[] ROT_AXIS = new Static3D[]
42
         {
43
           new Static3D(-2.0f/3, 1.0f/3, 2.0f/3),
44
           new Static3D( 1.0f/3,-2.0f/3, 2.0f/3),
45
           new Static3D( 2.0f/3, 2.0f/3, 1.0f/3),
46
         };
47

    
48
  private ScrambleState[] mStates;
49
  private int[] mBasicAngle;
50
  private float[][] mCuts;
51
  private float[][] mCenters;
52
  private int[] mQuatIndex;
53

    
54
///////////////////////////////////////////////////////////////////////////////////////////////////
55

    
56
  public TwistyAxis(int[] numL, int meshState, Static4D quat, Static3D move, float scale, InputStream stream)
57
    {
58
    super(numL, meshState, numL[0], quat, move, scale, stream);
59
    }
60

    
61
///////////////////////////////////////////////////////////////////////////////////////////////////
62

    
63
  @Override
64
  public int getInternalColor()
65
    {
66
    return 0xff222222;
67
    }
68

    
69
///////////////////////////////////////////////////////////////////////////////////////////////////
70
// same as in a 3x3
71

    
72
  public ScrambleState[] getScrambleStates()
73
    {
74
    if( mStates==null )
75
      {
76
      int[][] m = new int[16][];
77

    
78
      for(int i=0; i<16; i++) m[i] = new int[] { 0,-1,i,0,1,i,0,2,i, 1,-1,i,1,1,i,1,2,i, 2,-1,i,2,1,i,2,2,i};
79

    
80
      mStates = new ScrambleState[]
81
          {
82
          new ScrambleState( new int[][] { m[ 1], m[ 2], m[ 3] } ),  //  0 0
83
          new ScrambleState( new int[][] {  null, m[ 4], m[ 5] } ),  //  1 x
84
          new ScrambleState( new int[][] { m[ 6],  null, m[ 7] } ),  //  2 y
85
          new ScrambleState( new int[][] { m[ 8], m[ 9],  null } ),  //  3 z
86
          new ScrambleState( new int[][] { m[10],  null, m[ 7] } ),  //  4 xy
87
          new ScrambleState( new int[][] { m[11], m[ 9],  null } ),  //  5 xz
88
          new ScrambleState( new int[][] {  null, m[12], m[ 5] } ),  //  6 yx
89
          new ScrambleState( new int[][] { m[ 8], m[13],  null } ),  //  7 yz
90
          new ScrambleState( new int[][] {  null, m[ 4], m[14] } ),  //  8 zx
91
          new ScrambleState( new int[][] { m[ 6],  null, m[15] } ),  //  9 zy
92
          new ScrambleState( new int[][] {  null,  null, m[ 5] } ),  // 10 xyx
93
          new ScrambleState( new int[][] {  null, m[ 4],  null } ),  // 11 xzx
94
          new ScrambleState( new int[][] {  null,  null, m[ 7] } ),  // 12 yxy
95
          new ScrambleState( new int[][] { m[ 6],  null,  null } ),  // 13 yzy
96
          new ScrambleState( new int[][] {  null, m[ 9],  null } ),  // 14 zxz
97
          new ScrambleState( new int[][] { m[ 8],  null,  null } ),  // 15 zyz
98
          };
99
      }
100

    
101
    return mStates;
102
    }
103

    
104
///////////////////////////////////////////////////////////////////////////////////////////////////
105

    
106
  public float[][] getCuts(int[] numLayers)
107
    {
108
    if( mCuts==null )
109
      {
110
      float C = 0.5f;
111
      float[] cut = new float[] {-C,+C};
112
      mCuts = new float[][] { cut,cut,cut };
113
      }
114

    
115
    return mCuts;
116
    }
117

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

    
120
  public boolean[][] getLayerRotatable(int[] numLayers)
121
    {
122
    boolean[] tmp = new boolean[] {true,true,true};
123
    return new boolean[][] { tmp,tmp,tmp };
124
    }
125

    
126
///////////////////////////////////////////////////////////////////////////////////////////////////
127

    
128
  public int getTouchControlType()
129
    {
130
    return TC_CHANGING_SHAPEMOD;
131
    }
132

    
133
///////////////////////////////////////////////////////////////////////////////////////////////////
134

    
135
  public int getTouchControlSplit()
136
    {
137
    return TYPE_NOT_SPLIT;
138
    }
139

    
140
///////////////////////////////////////////////////////////////////////////////////////////////////
141

    
142
  public int[][][] getEnabled()
143
    {
144
    return null;
145
    }
146

    
147
///////////////////////////////////////////////////////////////////////////////////////////////////
148

    
149
  public float[] getDist3D(int[] numLayers)
150
    {
151
    return TouchControlHexahedron.D3D;
152
    }
153

    
154
///////////////////////////////////////////////////////////////////////////////////////////////////
155

    
156
  public Static3D[] getFaceAxis()
157
    {
158
    return TouchControlHexahedron.FACE_AXIS;
159
    }
160

    
161
///////////////////////////////////////////////////////////////////////////////////////////////////
162

    
163
  public float[][] getCubitPositions(int[] numLayers)
164
    {
165
    if( mCenters==null )
166
      {
167
      mCenters = new float[][]
168
         {
169
             { 1.50f, 1.50f, 0.75f},
170
             {-0.75f, 1.50f,-1.50f},
171
             { 1.50f,-0.75f,-1.50f},
172
             {-1.50f, 0.75f, 1.50f},
173
             { 0.75f,-1.50f, 1.50f},
174
             {-1.50f,-1.50f,-0.75f},
175

    
176
             {0.375f, 1.50f,-0.375f},
177
             {0.375f,0.375f,-1.50f },
178
             { 1.50f,0.375f,-0.375f},
179
             {-0.375f,-0.375f,1.50f},
180
             {-0.375f,-1.50f,0.375f},
181
             {-1.50f,-0.375f,0.375f},
182

    
183
             { 0.00f, 1.50f, 1.50f},
184
             {-1.50f, 0.00f,-1.50f},
185
             { 1.50f,-1.50f, 0.00f},
186

    
187
             {-1.50f, 1.50f, 0.00f},
188
             { 0.00f,-1.50f,-1.50f},
189
             { 1.50f, 0.00f, 1.50f},
190

    
191
             { 1.50f, 1.50f,-1.50f},
192
             {-1.50f,-1.50f, 1.50f},
193

    
194
             {-0.5f, 1.5f, 0.5f},
195
             { 0.5f,-1.5f,-0.5f},
196
             { 1.5f,-0.5f, 0.5f},
197
             {-1.5f, 0.5f,-0.5f},
198
             { 0.5f, 0.5f, 1.5f},
199
             {-0.5f,-0.5f,-1.5f},
200
         };
201
      }
202

    
203
    return mCenters;
204
    }
205

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

    
208
  public Static4D getCubitQuats(int cubit, int[] numLayers)
209
    {
210
    if( mQuatIndex==null ) mQuatIndex = new int[] {0,22,10,17,14,19, 0,22,10,17,14,19, 0,22,10, 0,22,10, 0,14, 0,14,10,19,17,22 };
211
    return mObjectQuats[mQuatIndex[cubit]];
212
    }
213

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

    
216
  public ObjectShape getObjectShape(int variant)
217
    {
218
    final float T = 1.0f/3;
219

    
220
    if( variant==0 )  // center
221
      {
222
      float[][] vertices =
223
          {
224
              { -1.0f, 0.0f, -0.25f  },
225
              {  0.0f, 0.0f, -0.75f  },
226
              {  0.0f, 0.0f,  0.75f  },
227
              {  0.0f,-1.0f, -0.25f  },
228
              {  -5*T, -2*T, -1.75f*T},
229
              { -1.0f,-1.0f, -1.25f  },
230
              {  -4*T, -4*T,  0.25f*T},
231
              {  -2*T, -5*T, -1.75f*T}
232
          };
233

    
234
      int[][] indices =
235
          {
236
              {2,1,0},
237
              {2,3,1},
238
              {4,6,2,0},
239
              {6,7,3,2},
240
              {7,5,1,3},
241
              {5,4,0,1},
242
              {7,6,4,5}
243
          };
244

    
245
      return new ObjectShape(vertices, indices);
246
      }
247
    else if( variant==1 ) // edge type 1
248
      {
249
      float[][] vertices =
250
          {
251
              {-0.375f  , 0.0f, -1.125f  },
252
              { 1.125f  , 0.0f,  0.375f  },
253
              {-0.875f  , 0.0f, -0.125f  },
254
              { 0.125f  , 0.0f,  0.875f  },
255
              {-1.625f*T, -2*T,  1.625f*T},
256
              { 0.125f  ,-1.0f, -0.125f  }
257
          };
258

    
259
      int[][] indices =
260
          {
261
              {2,3,1,0},
262
              {2,4,3},
263
              {4,5,1,3},
264
              {5,0,1},
265
              {5,4,2,0}
266
          };
267

    
268
      return new ObjectShape(vertices, indices);
269
      }
270
    else if( variant==2 ) // edge type 2
271
      {
272
      float[][] vertices =
273
          {
274
              {-1.5f  , 0.0f, 0.0f},
275
              { 0.5f  , 0.0f,-1.0f},
276
              { 1.5f  , 0.0f, 0.0f},
277
              {-0.5f  ,-1.0f, 0.0f},
278
              {-0.5f*T, -2*T, -4*T},
279
              { 0.5f*T, -4*T, -2*T},
280
          };
281

    
282
      int[][] indices =
283
          {
284
              {0,2,1},
285
              {0,3,2},
286
              {3,5,2},
287
              {1,4,0},
288
              {4,5,3,0},
289
              {5,4,1,2}
290
          };
291

    
292
      return new ObjectShape(vertices, indices);
293
      }
294
    else if( variant==3 ) // edge type 3
295
      {
296
      float[][] vertices =
297
          {
298
              {0.0f, 0.0f, -1.5f  },
299
              {1.0f, 0.0f, -0.5f  },
300
              {0.0f, 0.0f,  1.5f  },
301
              {0.0f,-1.0f,  0.5f  },
302
              { 4*T, -2*T,  0.5f*T},
303
              { 2*T, -4*T, -0.5f*T}
304
          };
305

    
306
      int[][] indices =
307
          {
308
              {0,2,1},
309
              {0,3,2},
310
              {0,5,3},
311
              {5,4,2,3},
312
              {4,1,2},
313
              {4,5,0,1}
314
          };
315

    
316
      return new ObjectShape(vertices, indices);
317
      }
318
    else if( variant==4 ) // corner type 1
319
      {
320
      float[][] vertices =
321
          {
322
              { 0.0f, 0.0f, 0.0f},
323
              {-1.5f, 0.0f, 0.0f},
324
              { 0.0f,-1.5f, 0.0f},
325
              { 0.0f, 0.0f, 1.5f},
326
              {-1.0f,-1.0f, 1.0f}
327
          };
328

    
329
      int[][] indices =
330
          {
331
              {1,3,0},
332
              {3,2,0},
333
              {2,1,0},
334
              {3,1,4},
335
              {2,3,4},
336
              {1,2,4}
337
          };
338

    
339
      return new ObjectShape(vertices, indices);
340
      }
341
    else                 // corner type 2
342
      {
343
      float[][] vertices =
344
          {
345
              {-1.0f, 0.0f, 1.0f},
346
              { 0.0f, 0.0f,-1.0f},
347
              { 1.0f, 0.0f, 0.0f},
348
              {    T, -2*T,   -T}
349
          };
350

    
351
      int[][] indices =
352
          {
353
              {0,2,1},
354
              {0,3,2},
355
              {2,3,1},
356
              {1,3,0}
357
          };
358

    
359
      return new ObjectShape(vertices, indices);
360
      }
361
    }
362

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

    
365
  public ObjectFaceShape getObjectFaceShape(int variant)
366
    {
367
    if( variant==0 )
368
      {
369
      float[][] bands   = { {0.025f,20,0.2f,0.4f,5,1,0}, {0.005f,20,0.2f,0.4f,5,1,0} };
370
      int[] bandIndices = { 0,0,1,1,1,1,1 };
371
      float[][] corners = { {0.04f,0.09f} };
372
      int[] indices     = { 0,0,0,0,-1,-1,-1,-1 };
373
      float[][] centers = { { -0.5f, -0.5f, 0.0f } };
374
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
375
      }
376
    else if( variant==1 )
377
      {
378
      float[][] bands   = { {0.025f,20,0.2f,0.4f,5,1,0}, {0.005f,20,0.2f,0.4f,5,1,0} };
379
      int[] bandIndices = { 0,1,1,1,1 };
380
      float[][] corners = { {0.04f,0.09f} };
381
      int[] indices     = { 0,0,0,0,-1,-1 };
382
      float[][] centers = { { -5.0f/24, -5.0f/6, 5.0f/24} };
383
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
384
      }
385
    else if( variant==2 )
386
      {
387
      float[][] bands   = { {0.025f,20,0.2f,0.4f,5,1,0}, {0.005f,20,0.2f,0.4f,5,1,0} };
388
      int[] bandIndices = { 0,0,1,1,1,1 };
389
      float[][] corners = { {0.04f,0.09f} };
390
      int[] indices     = { 0,0,0,0,-1,-1 };
391
      float[][] centers = { { 0.0f, -1.0f, -1.0f } };
392
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
393
      }
394
    else if( variant==3 )
395
      {
396
      float[][] bands   = { {0.025f,20,0.2f,0.4f,5,1,0}, {0.005f,20,0.2f,0.4f,5,1,0} };
397
      int[] bandIndices = { 0,0,1,1,1,1 };
398
      float[][] corners = { {0.04f,0.09f} };
399
      int[] indices     = { 0,0,0,0,-1,-1 };
400
      float[][] centers = { { 1.0f, -1.0f, 0.0f } };
401
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
402
      }
403
    else if( variant==4 )
404
      {
405
      float[][] bands   = { {0.025f,20,0.2f,0.4f,5,1,0}, {0.005f,20,0.2f,0.4f,5,1,0} };
406
      int[] bandIndices = { 0,0,0,1,1,1 };
407
      float[][] corners = { {0.03f,0.08f} };
408
      int[] indices     = { 0,0,0,0,-1 };
409
      float[][] centers = { { -1.0f, -1.0f, 1.0f } };
410
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
411
      }
412
    else
413
      {
414
      float[][] bands   = { {0.05f,35,0.25f,0.7f,5,1,0}, {0.04f,35,0.25f,0.7f,5,1,0} };
415
      int[] bandIndices = { 0,1,1,1 };
416
      float[][] corners = { {0.04f,0.12f} };
417
      int[] indices     = { 0,0,0,-1 };
418
      float[][] centers = { { 1.0f/3, -2.0f/3,-1.0f/3 } };
419
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
420
      }
421
    }
422

    
423
///////////////////////////////////////////////////////////////////////////////////////////////////
424

    
425
  public int getNumCubitVariants(int[] numLayers)
426
    {
427
    return 6;
428
    }
429

    
430
///////////////////////////////////////////////////////////////////////////////////////////////////
431

    
432
  public int getCubitVariant(int cubit, int[] numLayers)
433
    {
434
    if( cubit<6 ) return 0;
435
    if( cubit<12) return 1;
436
    if( cubit<15) return 2;
437
    if( cubit<18) return 3;
438
    if( cubit<20) return 4;
439

    
440
    return 5;
441
    }
442

    
443
///////////////////////////////////////////////////////////////////////////////////////////////////
444

    
445
  public float getStickerRadius()
446
    {
447
    return 0.13f;
448
    }
449

    
450
///////////////////////////////////////////////////////////////////////////////////////////////////
451

    
452
  public float getStickerStroke()
453
    {
454
    return ObjectControl.isInIconMode() ? 0.22f : 0.10f;
455
    }
456

    
457
///////////////////////////////////////////////////////////////////////////////////////////////////
458

    
459
  public float[][] getStickerAngles()
460
    {
461
    return null;
462
    }
463

    
464
///////////////////////////////////////////////////////////////////////////////////////////////////
465
// PUBLIC API
466

    
467
  public Static3D[] getRotationAxis()
468
    {
469
    return ROT_AXIS;
470
    }
471

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

    
474
  public String getShortName()
475
    {
476
    return ObjectType.AXIS_3.name();
477
    }
478

    
479
///////////////////////////////////////////////////////////////////////////////////////////////////
480

    
481
  public long getSignature()
482
    {
483
    return ObjectType.AXIS_3.ordinal();
484
    }
485

    
486
///////////////////////////////////////////////////////////////////////////////////////////////////
487

    
488
  public int[] getBasicAngles()
489
    {
490
    if( mBasicAngle ==null ) mBasicAngle = new int[] { 4,4,4 };
491
    return mBasicAngle;
492
    }
493

    
494
///////////////////////////////////////////////////////////////////////////////////////////////////
495

    
496
  public String getObjectName()
497
    {
498
    return "Axis Cube";
499
    }
500

    
501
///////////////////////////////////////////////////////////////////////////////////////////////////
502

    
503
  public String getInventor()
504
    {
505
    return "Aleh Hladzilin";
506
    }
507

    
508
///////////////////////////////////////////////////////////////////////////////////////////////////
509

    
510
  public int getYearOfInvention()
511
    {
512
    return 2008;
513
    }
514

    
515
///////////////////////////////////////////////////////////////////////////////////////////////////
516

    
517
  public int getComplexity()
518
    {
519
    return 2;
520
    }
521

    
522
///////////////////////////////////////////////////////////////////////////////////////////////////
523

    
524
  public String[][] getTutorials()
525
    {
526
    return new String[][]{
527
                          {"gb","DdYBkV07WpM","How to Solve the Axis Cube","Z3"},
528
                          {"es","oLWCj8-6G4Q","Resolver Axis Cube","Cuby"},
529
                          {"ru","pgPtyD7DV7A","Как собрать Аксис Куб","Алексей Ярыгин"},
530
                          {"fr","4M7cOgjZHSY","Résolution de l'Axis Cube","asthalis"},
531
                          {"de","CVPII1-sEqw","Axis Cube Tutorial","Pezcraft"},
532
                          {"pl","Yrmq0m4vjfE","Axis Cube TUTORIAL PL","MrUk"},
533
                          {"br","5HoM4_fQOM8","Como resolver o axis cube ","Gabriel Sihnel"},
534
                          {"kr","8KjHoNOGWLE","엑시스 큐브 해법","듀나메스 큐브 해법연구소"},
535
                         };
536
    }
537
}
(1-1/33)