Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyVoid.java @ 5d09301e

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2022 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is proprietary software licensed under an EULA which you should have received      //
7
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html        //
8
///////////////////////////////////////////////////////////////////////////////////////////////////
9

    
10
package org.distorted.objectlib.objects;
11

    
12
import org.distorted.library.type.Static3D;
13
import org.distorted.library.type.Static4D;
14
import org.distorted.objectlib.helpers.ObjectFaceShape;
15
import org.distorted.objectlib.helpers.ObjectShape;
16
import org.distorted.objectlib.helpers.ObjectSignature;
17
import org.distorted.objectlib.main.InitData;
18
import org.distorted.objectlib.scrambling.ScrambleState;
19
import org.distorted.objectlib.main.ObjectType;
20
import org.distorted.objectlib.main.ShapeHexahedron;
21
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
22

    
23
import java.io.InputStream;
24

    
25
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_HEXAHEDRON;
26
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
27

    
28
///////////////////////////////////////////////////////////////////////////////////////////////////
29

    
30
public class TwistyVoid extends ShapeHexahedron
31
{
32
  static final Static3D[] ROT_AXIS = new Static3D[]
33
         {
34
           new Static3D(1,0,0),
35
           new Static3D(0,1,0),
36
           new Static3D(0,0,1)
37
         };
38

    
39
  private ScrambleState[] mStates;
40
  private int[][] mBasicAngle;
41
  private float[][] mCuts;
42
  private float[][] mPositions;
43
  private int[] mQuatIndex;
44

    
45
///////////////////////////////////////////////////////////////////////////////////////////////////
46

    
47
  public TwistyVoid(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
48
    {
49
    super(data, meshState, iconMode, data.getNumLayers()[0], quat, move, scale, stream);
50
    }
51

    
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53

    
54
  @Override
55
  public void adjustStickerCoords()
56
    {
57
    final float A = 0.497f;
58
    final float B = 0.38950402f;
59
    final float C = 0.25900806f;
60
    final float D = 0.51f;
61

    
62
    mStickerCoords = new float[][]
63
          {
64
             { -0.5f, -0.5f, A, -0.5f, -0.5f, A },
65
             { -C, -B, D, -B, D, B, -C, B }
66
          };
67
    }
68

    
69
///////////////////////////////////////////////////////////////////////////////////////////////////
70

    
71
  @Override
72
  public int getInternalColor()
73
    {
74
    return 0xff222222;
75
    }
76

    
77
///////////////////////////////////////////////////////////////////////////////////////////////////
78
// Normal 3x3, but without the 180 deg move of the middle layer.
79
// We need to rotate the middle layer here (by swiping it is not possible) because otherwise the
80
// phantom centers would always stay at their initial positions which would defeat the point here.
81

    
82
  public ScrambleState[] getScrambleStates()
83
    {
84
    if( mStates==null )
85
      {
86
      int[][] m = new int[16][];
87

    
88
      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, 2,-1,i,2,1,i,2,2,i};
89

    
90
      mStates = new ScrambleState[]
91
          {
92
          new ScrambleState( new int[][] { m[ 1], m[ 2], m[ 3] } ),  //  0 0
93
          new ScrambleState( new int[][] {  null, m[ 4], m[ 5] } ),  //  1 x
94
          new ScrambleState( new int[][] { m[ 6],  null, m[ 7] } ),  //  2 y
95
          new ScrambleState( new int[][] { m[ 8], m[ 9],  null } ),  //  3 z
96
          new ScrambleState( new int[][] { m[10],  null, m[ 7] } ),  //  4 xy
97
          new ScrambleState( new int[][] { m[11], m[ 9],  null } ),  //  5 xz
98
          new ScrambleState( new int[][] {  null, m[12], m[ 5] } ),  //  6 yx
99
          new ScrambleState( new int[][] { m[ 8], m[13],  null } ),  //  7 yz
100
          new ScrambleState( new int[][] {  null, m[ 4], m[14] } ),  //  8 zx
101
          new ScrambleState( new int[][] { m[ 6],  null, m[15] } ),  //  9 zy
102
          new ScrambleState( new int[][] {  null,  null, m[ 5] } ),  // 10 xyx
103
          new ScrambleState( new int[][] {  null, m[ 4],  null } ),  // 11 xzx
104
          new ScrambleState( new int[][] {  null,  null, m[ 7] } ),  // 12 yxy
105
          new ScrambleState( new int[][] { m[ 6],  null,  null } ),  // 13 yzy
106
          new ScrambleState( new int[][] {  null, m[ 9],  null } ),  // 14 zxz
107
          new ScrambleState( new int[][] { m[ 8],  null,  null } ),  // 15 zyz
108
          };
109
      }
110

    
111
    return mStates;
112
    }
113

    
114
///////////////////////////////////////////////////////////////////////////////////////////////////
115

    
116
  public float[][] getCuts(int[] numLayers)
117
    {
118
    if( mCuts==null )
119
      {
120
      float C = 0.5f;
121
      float[] cut = new float[] {-C,+C};
122
      mCuts = new float[][] { cut,cut,cut };
123
      }
124

    
125
    return mCuts;
126
    }
127

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

    
130
  public boolean[][] getLayerRotatable(int[] numLayers)
131
    {
132
    boolean[] tmp = new boolean[] {true,false,true};
133
    return new boolean[][] { tmp,tmp,tmp };
134
    }
135

    
136
///////////////////////////////////////////////////////////////////////////////////////////////////
137

    
138
  public int getTouchControlType()
139
    {
140
    return TC_HEXAHEDRON;
141
    }
142

    
143
///////////////////////////////////////////////////////////////////////////////////////////////////
144

    
145
  public int getTouchControlSplit()
146
    {
147
    return TYPE_NOT_SPLIT;
148
    }
149

    
150
///////////////////////////////////////////////////////////////////////////////////////////////////
151

    
152
  public int[][][] getEnabled()
153
    {
154
    return new int[][][] { {{1,2}},{{1,2}},{{0,2}},{{0,2}},{{0,1}},{{0,1}} };
155
    }
156

    
157
///////////////////////////////////////////////////////////////////////////////////////////////////
158

    
159
  public float[] getDist3D(int[] numLayers)
160
    {
161
    return TouchControlHexahedron.D3D;
162
    }
163

    
164
///////////////////////////////////////////////////////////////////////////////////////////////////
165

    
166
  public Static3D[] getFaceAxis()
167
    {
168
    return TouchControlHexahedron.FACE_AXIS;
169
    }
170

    
171
///////////////////////////////////////////////////////////////////////////////////////////////////
172

    
173
  public float[][] getCubitPositions(int[] numLayers)
174
    {
175
    if( mPositions==null )
176
      {
177
      mPositions = new float[][]
178
         {
179
             { 1.0f, 1.0f, 1.0f},
180
             { 1.0f, 1.0f,-1.0f},
181
             { 1.0f,-1.0f, 1.0f},
182
             { 1.0f,-1.0f,-1.0f},
183
             {-1.0f, 1.0f, 1.0f},
184
             {-1.0f, 1.0f,-1.0f},
185
             {-1.0f,-1.0f, 1.0f},
186
             {-1.0f,-1.0f,-1.0f},
187

    
188
             { 1.0f, 1.0f, 0.0f},
189
             { 1.0f,-1.0f, 0.0f},
190
             { 1.0f, 0.0f, 1.0f},
191
             { 1.0f, 0.0f,-1.0f},
192
             {-1.0f, 1.0f, 0.0f},
193
             {-1.0f,-1.0f, 0.0f},
194
             {-1.0f, 0.0f, 1.0f},
195
             {-1.0f, 0.0f,-1.0f},
196
             { 0.0f, 1.0f, 1.0f},
197
             { 0.0f, 1.0f,-1.0f},
198
             { 0.0f,-1.0f, 1.0f},
199
             { 0.0f,-1.0f,-1.0f},
200
         };
201
      }
202

    
203
    return mPositions;
204
    }
205

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

    
208
  public Static4D getCubitQuats(int cubit, int[] numLayers)
209
    {
210
    if( mQuatIndex==null ) mQuatIndex = new int[] {0,1,17,22,4,5,8,19,  1,3,0,2,10,11,4,5,9,15,7,19 };
211
    return mObjectQuats[mQuatIndex[cubit]];
212
    }
213

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

    
216
  public ObjectShape getObjectShape(int variant)
217
    {
218
    if( variant==0 )  // corner
219
      {
220
      final float X = 0.3f;
221
      final double A = 54*Math.PI/180;
222
      final float COS = (float)Math.cos(A);
223
      final float SIN = (float)Math.sin(A);
224

    
225
      float[][] vertices =
226
          {
227
              { -0.5f, -0.5f, -0.5f },
228
              { -0.5f, -0.5f, +0.5f },
229
              { -0.5f, +0.5f, -0.5f },
230
              { +0.5f, -0.5f, -0.5f },
231
              { +0.5f, +0.5f, -0.5f },
232
              { +0.5f, -0.5f, +0.5f },
233
              { -0.5f, +0.5f, +0.5f },
234
              { +0.5f, +0.5f, -0.5f+X },
235
              { +0.5f, -0.5f+X, +0.5f },
236
              { -0.5f+X, +0.5f, +0.5f },
237
              { SIN-0.5f, 0.5f, COS-0.5f },
238
              { COS-0.5f, 0.5f, SIN-0.5f },
239
              { COS-0.5f, SIN-0.5f, 0.5f },
240
              { SIN-0.5f, COS-0.5f, 0.5f },
241
              { 0.5f, COS-0.5f, SIN-0.5f },
242
              { 0.5f, SIN-0.5f, COS-0.5f },
243
          };
244

    
245
      int[][] indices =
246
          {
247
              {6,1,5,8,13,12,9},
248
              {5,3,4,7,15,14,8},
249
              {4,2,6,9,11,10,7},
250
              {0,1,6,2},
251
              {0,3,5,1},
252
              {0,2,4,3},
253
              {9,12,11},
254
              {8,14,13},
255
              {7,10,15},
256
              {10,11,12,13,14,15}
257
          };
258

    
259
      return new ObjectShape(vertices, indices);
260
      }
261
    else                // edge
262
      {
263
      final float A = 0.13f;
264
      final float B = 0.18f;
265
      final float C = 0.52f;
266

    
267
      float[][] vertices =
268
          {
269
              {    C, 0.5f,    C},
270
              { 0.5f, 0.5f,-0.5f},
271
              {    C,-0.5f,    C},
272
              { 0.5f,-0.5f,-0.5f},
273
              {-0.5f, 0.5f, 0.5f},
274
              {-0.5f, 0.5f,-0.5f},
275
              {-0.5f,-0.5f, 0.5f},
276
              {-0.5f,-0.5f,-0.5f},
277

    
278
              {-0.5f+A, 0.25f, 0.5f},
279
              {-0.5f+B, 0.00f, 0.5f},
280
              {-0.5f+A,-0.25f, 0.5f},
281

    
282
              {-0.5f+A, 0.25f,-0.5f+A},
283
              {-0.5f+B, 0.00f,-0.5f+B},
284
              {-0.5f+A,-0.25f,-0.5f+A},
285

    
286
              { 0.5f  , 0.25f,-0.5f+A},
287
              { 0.5f  , 0.00f,-0.5f+B},
288
              { 0.5f  ,-0.25f,-0.5f+A},
289
          };
290

    
291
      int[][] indices =
292
          {
293
              {6,2,0,4,8,9,10},
294
              {1,0,2,3,16,15,14},
295
              {4,0,1,5},
296
              {2,6,7,3},
297

    
298
              {11,8,4,5},
299
              {12,9,8,11},
300
              {13,10,9,12},
301
              {7,6,10,13},
302
              {13,16,3,7},
303
              {12,15,16,13},
304
              {11,14,15,12},
305
              {5,1,14,11}
306
          };
307

    
308
      return new ObjectShape(vertices, indices);
309
      }
310
    }
311

    
312
///////////////////////////////////////////////////////////////////////////////////////////////////
313

    
314
  public ObjectFaceShape getObjectFaceShape(int variant)
315
    {
316
    if( variant==0 )
317
      {
318
      float h1 = isInIconMode() ? 0.001f : 0.015f;
319
      float h2 = isInIconMode() ? 0.001f : 0.010f;
320
      float h3 = isInIconMode() ? 0.001f : 0.030f;
321
      float[][] bands   = { {h1,20,0.2f,0.4f,5,1,0}, {h2,5,0.3f,0.2f,5,0,0}, {h3,8,0.3f,0.2f,6,0,0} };
322
      int[] bandIndices = { 0,0,0,1,1,1,1,1,1,2 };
323
      float[][] corners = { {0.02f,0.09f} };
324
      int[] indices     = { -1,0,0,0,0,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1 };
325
      float[][] centers = { { -0.5f, -0.5f, -0.5f } };
326
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
327
      }
328
    else
329
      {
330
      float h1 = isInIconMode() ? 0.001f : 0.01f;
331
      float[][] bands   = { {h1,5,0.2f,0.4f,5,1,0}, {0.001f,1,0.3f,0.5f,5,0,0}, {0.001f,1,0.3f,0.5f,5,0,0} };
332
      int[] bandIndices = { 0,0,1,1,2,2,2,2,2,2,2,2 };
333
      float[][] corners = { {0.02f,0.09f} };
334
      int[] indices     = { 0,-1,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 };
335
      float[][] centers = { { 0.0f, 0.0f, 0.0f } };
336
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
337
      }
338
    }
339

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

    
342
  public int getNumCubitVariants(int[] numLayers)
343
    {
344
    return 2;
345
    }
346

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

    
349
  public int getCubitVariant(int cubit, int[] numLayers)
350
    {
351
    return cubit<8 ? 0:1;
352
    }
353

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

    
356
  public float getStickerRadius()
357
    {
358
    return 0.05f;
359
    }
360

    
361
///////////////////////////////////////////////////////////////////////////////////////////////////
362

    
363
  public float getStickerStroke()
364
    {
365
    return isInIconMode() ? 0.22f : 0.12f;
366
    }
367

    
368
///////////////////////////////////////////////////////////////////////////////////////////////////
369

    
370
  public float[][] getStickerAngles()
371
    {
372
    float D = (float)(Math.PI/6);
373
    return new float[][] { { 0,D,0 },{ 0,0,0,-D } };
374
    }
375

    
376
///////////////////////////////////////////////////////////////////////////////////////////////////
377
// PUBLIC API
378

    
379
  public Static3D[] getRotationAxis()
380
    {
381
    return ROT_AXIS;
382
    }
383

    
384
///////////////////////////////////////////////////////////////////////////////////////////////////
385

    
386
  public int[][] getBasicAngles()
387
    {
388
    if( mBasicAngle ==null )
389
      {
390
      int num = getNumLayers()[0];
391
      int[] tmp = new int[num];
392
      for(int i=0; i<num; i++) tmp[i] = 4;
393
      mBasicAngle = new int[][] { tmp,tmp,tmp };
394
      }
395

    
396
    return mBasicAngle;
397
    }
398

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

    
401
  public String getShortName()
402
    {
403
    return ObjectType.VOID_3.name();
404
    }
405

    
406
///////////////////////////////////////////////////////////////////////////////////////////////////
407

    
408
  public ObjectSignature getSignature()
409
    {
410
    return new ObjectSignature(ObjectType.VOID_3);
411
    }
412

    
413
///////////////////////////////////////////////////////////////////////////////////////////////////
414

    
415
  public String getObjectName()
416
    {
417
    return "Void Cube";
418
    }
419

    
420
///////////////////////////////////////////////////////////////////////////////////////////////////
421

    
422
  public String getInventor()
423
    {
424
    return "Katsuhiko Okamoto";
425
    }
426

    
427
///////////////////////////////////////////////////////////////////////////////////////////////////
428

    
429
  public int getYearOfInvention()
430
    {
431
    return 2012;
432
    }
433

    
434
///////////////////////////////////////////////////////////////////////////////////////////////////
435

    
436
  public int getComplexity()
437
    {
438
    return 2;
439
    }
440

    
441
///////////////////////////////////////////////////////////////////////////////////////////////////
442

    
443
  public String[][] getTutorials()
444
    {
445
    return new String[][]{
446
                          {"gb","3sLMpQrX_dU","How to Solve the Void Cube","Z3"},
447
                          {"gb","EB0bmcI1RnM","aVOIDing parity: Void Cube","SuperAntoniovivaldi"},
448
                          {"es","tDV4vmo7Qz4","Resolver 3x3 Void (Hueco)","Cuby"},
449
                          {"ru","BCa6Zh8-I_g","Как собрать Войд-Куб","RBcuber"},
450
                          {"fr","yqSyPu5ciAc","Résoudre le Void Cube","TwinsCuber"},
451
                          {"de","1mh-jRrcP0w","Void Cube: Parity intuitiv lösen","rofrisch"},
452
                          {"br","uTC01oMGBJ8","3x3 Void cube Tutorial","Cubo vicio"},
453
                          {"kr","eCfepw1gVBA","보이드 큐브(홀큐브)","듀나메스 큐브 해법연구소"},
454
                         };
455
    }
456
}
(35-35/36)