Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyVoid.java @ 0b431d71

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.helpers.ObjectSignature;
27
import org.distorted.objectlib.scrambling.ScrambleState;
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_HEXAHEDRON;
35
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
36

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

    
39
public class TwistyVoid extends ShapeHexahedron
40
{
41
  static final Static3D[] ROT_AXIS = new Static3D[]
42
         {
43
           new Static3D(1,0,0),
44
           new Static3D(0,1,0),
45
           new Static3D(0,0,1)
46
         };
47

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

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

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

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

    
63
  @Override
64
  public void adjustStickerCoords()
65
    {
66
    final float A = 0.497f;
67
    final float B = 0.38950402f;
68
    final float C = 0.25900806f;
69
    final float D = 0.51f;
70

    
71
    mStickerCoords = new float[][]
72
          {
73
             { -0.5f, -0.5f, A, -0.5f, -0.5f, A },
74
             { -C, -B, D, -B, D, B, -C, B }
75
          };
76
    }
77

    
78
///////////////////////////////////////////////////////////////////////////////////////////////////
79

    
80
  @Override
81
  public int getInternalColor()
82
    {
83
    return 0xff222222;
84
    }
85

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

    
91
  public ScrambleState[] getScrambleStates()
92
    {
93
    if( mStates==null )
94
      {
95
      int[][] m = new int[16][];
96

    
97
      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};
98

    
99
      mStates = new ScrambleState[]
100
          {
101
          new ScrambleState( new int[][] { m[ 1], m[ 2], m[ 3] } ),  //  0 0
102
          new ScrambleState( new int[][] {  null, m[ 4], m[ 5] } ),  //  1 x
103
          new ScrambleState( new int[][] { m[ 6],  null, m[ 7] } ),  //  2 y
104
          new ScrambleState( new int[][] { m[ 8], m[ 9],  null } ),  //  3 z
105
          new ScrambleState( new int[][] { m[10],  null, m[ 7] } ),  //  4 xy
106
          new ScrambleState( new int[][] { m[11], m[ 9],  null } ),  //  5 xz
107
          new ScrambleState( new int[][] {  null, m[12], m[ 5] } ),  //  6 yx
108
          new ScrambleState( new int[][] { m[ 8], m[13],  null } ),  //  7 yz
109
          new ScrambleState( new int[][] {  null, m[ 4], m[14] } ),  //  8 zx
110
          new ScrambleState( new int[][] { m[ 6],  null, m[15] } ),  //  9 zy
111
          new ScrambleState( new int[][] {  null,  null, m[ 5] } ),  // 10 xyx
112
          new ScrambleState( new int[][] {  null, m[ 4],  null } ),  // 11 xzx
113
          new ScrambleState( new int[][] {  null,  null, m[ 7] } ),  // 12 yxy
114
          new ScrambleState( new int[][] { m[ 6],  null,  null } ),  // 13 yzy
115
          new ScrambleState( new int[][] {  null, m[ 9],  null } ),  // 14 zxz
116
          new ScrambleState( new int[][] { m[ 8],  null,  null } ),  // 15 zyz
117
          };
118
      }
119

    
120
    return mStates;
121
    }
122

    
123
///////////////////////////////////////////////////////////////////////////////////////////////////
124

    
125
  public float[][] getCuts(int[] numLayers)
126
    {
127
    if( mCuts==null )
128
      {
129
      float C = 0.5f;
130
      float[] cut = new float[] {-C,+C};
131
      mCuts = new float[][] { cut,cut,cut };
132
      }
133

    
134
    return mCuts;
135
    }
136

    
137
///////////////////////////////////////////////////////////////////////////////////////////////////
138

    
139
  public boolean[][] getLayerRotatable(int[] numLayers)
140
    {
141
    boolean[] tmp = new boolean[] {true,false,true};
142
    return new boolean[][] { tmp,tmp,tmp };
143
    }
144

    
145
///////////////////////////////////////////////////////////////////////////////////////////////////
146

    
147
  public int getTouchControlType()
148
    {
149
    return TC_HEXAHEDRON;
150
    }
151

    
152
///////////////////////////////////////////////////////////////////////////////////////////////////
153

    
154
  public int getTouchControlSplit()
155
    {
156
    return TYPE_NOT_SPLIT;
157
    }
158

    
159
///////////////////////////////////////////////////////////////////////////////////////////////////
160

    
161
  public int[][][] getEnabled()
162
    {
163
    return new int[][][] { {{1,2}},{{1,2}},{{0,2}},{{0,2}},{{0,1}},{{0,1}} };
164
    }
165

    
166
///////////////////////////////////////////////////////////////////////////////////////////////////
167

    
168
  public float[] getDist3D(int[] numLayers)
169
    {
170
    return TouchControlHexahedron.D3D;
171
    }
172

    
173
///////////////////////////////////////////////////////////////////////////////////////////////////
174

    
175
  public Static3D[] getFaceAxis()
176
    {
177
    return TouchControlHexahedron.FACE_AXIS;
178
    }
179

    
180
///////////////////////////////////////////////////////////////////////////////////////////////////
181

    
182
  public float[][] getCubitPositions(int[] numLayers)
183
    {
184
    if( mPositions==null )
185
      {
186
      mPositions = new float[][]
187
         {
188
             { 1.0f, 1.0f, 1.0f},
189
             { 1.0f, 1.0f,-1.0f},
190
             { 1.0f,-1.0f, 1.0f},
191
             { 1.0f,-1.0f,-1.0f},
192
             {-1.0f, 1.0f, 1.0f},
193
             {-1.0f, 1.0f,-1.0f},
194
             {-1.0f,-1.0f, 1.0f},
195
             {-1.0f,-1.0f,-1.0f},
196

    
197
             { 1.0f, 1.0f, 0.0f},
198
             { 1.0f,-1.0f, 0.0f},
199
             { 1.0f, 0.0f, 1.0f},
200
             { 1.0f, 0.0f,-1.0f},
201
             {-1.0f, 1.0f, 0.0f},
202
             {-1.0f,-1.0f, 0.0f},
203
             {-1.0f, 0.0f, 1.0f},
204
             {-1.0f, 0.0f,-1.0f},
205
             { 0.0f, 1.0f, 1.0f},
206
             { 0.0f, 1.0f,-1.0f},
207
             { 0.0f,-1.0f, 1.0f},
208
             { 0.0f,-1.0f,-1.0f},
209
         };
210
      }
211

    
212
    return mPositions;
213
    }
214

    
215
///////////////////////////////////////////////////////////////////////////////////////////////////
216

    
217
  public Static4D getCubitQuats(int cubit, int[] numLayers)
218
    {
219
    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 };
220
    return mObjectQuats[mQuatIndex[cubit]];
221
    }
222

    
223
///////////////////////////////////////////////////////////////////////////////////////////////////
224

    
225
  public ObjectShape getObjectShape(int variant)
226
    {
227
    if( variant==0 )  // corner
228
      {
229
      final float X = 0.3f;
230
      final double A = 54*Math.PI/180;
231
      final float COS = (float)Math.cos(A);
232
      final float SIN = (float)Math.sin(A);
233

    
234
      float[][] vertices =
235
          {
236
              { -0.5f, -0.5f, -0.5f },
237
              { -0.5f, -0.5f, +0.5f },
238
              { -0.5f, +0.5f, -0.5f },
239
              { +0.5f, -0.5f, -0.5f },
240
              { +0.5f, +0.5f, -0.5f },
241
              { +0.5f, -0.5f, +0.5f },
242
              { -0.5f, +0.5f, +0.5f },
243
              { +0.5f, +0.5f, -0.5f+X },
244
              { +0.5f, -0.5f+X, +0.5f },
245
              { -0.5f+X, +0.5f, +0.5f },
246
              { SIN-0.5f, 0.5f, COS-0.5f },
247
              { COS-0.5f, 0.5f, SIN-0.5f },
248
              { COS-0.5f, SIN-0.5f, 0.5f },
249
              { SIN-0.5f, COS-0.5f, 0.5f },
250
              { 0.5f, COS-0.5f, SIN-0.5f },
251
              { 0.5f, SIN-0.5f, COS-0.5f },
252
          };
253

    
254
      int[][] indices =
255
          {
256
              {6,1,5,8,13,12,9},
257
              {5,3,4,7,15,14,8},
258
              {4,2,6,9,11,10,7},
259
              {0,1,6,2},
260
              {0,3,5,1},
261
              {0,2,4,3},
262
              {9,12,11},
263
              {8,14,13},
264
              {7,10,15},
265
              {10,11,12,13,14,15}
266
          };
267

    
268
      return new ObjectShape(vertices, indices);
269
      }
270
    else                // edge
271
      {
272
      final float A = 0.13f;
273
      final float B = 0.18f;
274
      final float C = 0.52f;
275

    
276
      float[][] vertices =
277
          {
278
              {    C, 0.5f,    C},
279
              { 0.5f, 0.5f,-0.5f},
280
              {    C,-0.5f,    C},
281
              { 0.5f,-0.5f,-0.5f},
282
              {-0.5f, 0.5f, 0.5f},
283
              {-0.5f, 0.5f,-0.5f},
284
              {-0.5f,-0.5f, 0.5f},
285
              {-0.5f,-0.5f,-0.5f},
286

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

    
291
              {-0.5f+A, 0.25f,-0.5f+A},
292
              {-0.5f+B, 0.00f,-0.5f+B},
293
              {-0.5f+A,-0.25f,-0.5f+A},
294

    
295
              { 0.5f  , 0.25f,-0.5f+A},
296
              { 0.5f  , 0.00f,-0.5f+B},
297
              { 0.5f  ,-0.25f,-0.5f+A},
298
          };
299

    
300
      int[][] indices =
301
          {
302
              {6,2,0,4,8,9,10},
303
              {1,0,2,3,16,15,14},
304
              {4,0,1,5},
305
              {2,6,7,3},
306

    
307
              {11,8,4,5},
308
              {12,9,8,11},
309
              {13,10,9,12},
310
              {7,6,10,13},
311
              {13,16,3,7},
312
              {12,15,16,13},
313
              {11,14,15,12},
314
              {5,1,14,11}
315
          };
316

    
317
      return new ObjectShape(vertices, indices);
318
      }
319
    }
320

    
321
///////////////////////////////////////////////////////////////////////////////////////////////////
322

    
323
  public ObjectFaceShape getObjectFaceShape(int variant)
324
    {
325
    if( variant==0 )
326
      {
327
      float h1 = isInIconMode() ? 0.001f : 0.015f;
328
      float h2 = isInIconMode() ? 0.001f : 0.010f;
329
      float h3 = isInIconMode() ? 0.001f : 0.030f;
330
      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} };
331
      int[] bandIndices = { 0,0,0,1,1,1,1,1,1,2 };
332
      float[][] corners = { {0.02f,0.09f} };
333
      int[] indices     = { -1,0,0,0,0,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1 };
334
      float[][] centers = { { -0.5f, -0.5f, -0.5f } };
335
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
336
      }
337
    else
338
      {
339
      float h1 = isInIconMode() ? 0.001f : 0.01f;
340
      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} };
341
      int[] bandIndices = { 0,0,1,1,2,2,2,2,2,2,2,2 };
342
      float[][] corners = { {0.02f,0.09f} };
343
      int[] indices     = { 0,-1,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 };
344
      float[][] centers = { { 0.0f, 0.0f, 0.0f } };
345
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
346
      }
347
    }
348

    
349
///////////////////////////////////////////////////////////////////////////////////////////////////
350

    
351
  public int getNumCubitVariants(int[] numLayers)
352
    {
353
    return 2;
354
    }
355

    
356
///////////////////////////////////////////////////////////////////////////////////////////////////
357

    
358
  public int getCubitVariant(int cubit, int[] numLayers)
359
    {
360
    return cubit<8 ? 0:1;
361
    }
362

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

    
365
  public float getStickerRadius()
366
    {
367
    return 0.05f;
368
    }
369

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

    
372
  public float getStickerStroke()
373
    {
374
    return isInIconMode() ? 0.22f : 0.12f;
375
    }
376

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

    
379
  public float[][] getStickerAngles()
380
    {
381
    float D = (float)(Math.PI/6);
382
    return new float[][] { { 0,D,0 },{ 0,0,0,-D } };
383
    }
384

    
385
///////////////////////////////////////////////////////////////////////////////////////////////////
386
// PUBLIC API
387

    
388
  public Static3D[] getRotationAxis()
389
    {
390
    return ROT_AXIS;
391
    }
392

    
393
///////////////////////////////////////////////////////////////////////////////////////////////////
394

    
395
  public int[][] getBasicAngles()
396
    {
397
    if( mBasicAngle ==null )
398
      {
399
      int num = getNumLayers()[0];
400
      int[] tmp = new int[num];
401
      for(int i=0; i<num; i++) tmp[i] = 4;
402
      mBasicAngle = new int[][] { tmp,tmp,tmp };
403
      }
404

    
405
    return mBasicAngle;
406
    }
407

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

    
410
  public String getShortName()
411
    {
412
    return ObjectType.VOID_3.name();
413
    }
414

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

    
417
  public ObjectSignature getSignature()
418
    {
419
    return new ObjectSignature(ObjectType.VOID_3);
420
    }
421

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

    
424
  public String getObjectName()
425
    {
426
    return "Void Cube";
427
    }
428

    
429
///////////////////////////////////////////////////////////////////////////////////////////////////
430

    
431
  public String getInventor()
432
    {
433
    return "Katsuhiko Okamoto";
434
    }
435

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

    
438
  public int getYearOfInvention()
439
    {
440
    return 2012;
441
    }
442

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

    
445
  public int getComplexity()
446
    {
447
    return 2;
448
    }
449

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

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