Project

General

Profile

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

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

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 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 static org.distorted.objectlib.touchcontrol.TouchControl.TC_HEXAHEDRON;
13
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_SPLIT_CORNER;
14

    
15
import java.io.InputStream;
16

    
17
import org.distorted.library.type.Static3D;
18
import org.distorted.library.type.Static4D;
19

    
20
import org.distorted.objectlib.helpers.ObjectFaceShape;
21
import org.distorted.objectlib.helpers.ObjectSignature;
22
import org.distorted.objectlib.main.InitData;
23
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
24
import org.distorted.objectlib.main.ObjectType;
25
import org.distorted.objectlib.helpers.ObjectShape;
26
import org.distorted.objectlib.scrambling.ScrambleState;
27
import org.distorted.objectlib.main.ShapeHexahedron;
28

    
29
///////////////////////////////////////////////////////////////////////////////////////////////////
30

    
31
public class TwistyRedi extends ShapeHexahedron
32
{
33
  static final Static3D[] ROT_AXIS = new Static3D[]
34
         {
35
           new Static3D(+SQ3/3,+SQ3/3,+SQ3/3),
36
           new Static3D(+SQ3/3,+SQ3/3,-SQ3/3),
37
           new Static3D(+SQ3/3,-SQ3/3,+SQ3/3),
38
           new Static3D(+SQ3/3,-SQ3/3,-SQ3/3)
39
         };
40

    
41
  private ScrambleState[] mStates;
42
  private int[][] mBasicAngle;
43
  private float[][] mCuts;
44
  private float[][] mPosition;
45

    
46
///////////////////////////////////////////////////////////////////////////////////////////////////
47

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

    
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54

    
55
  public ScrambleState[] getScrambleStates()
56
    {
57
    if( mStates==null )
58
      {
59
      mStates = new ScrambleState[]
60
        {
61
        new ScrambleState( new int[][] { {0,1,1,0,-1,1, 2,1,2,2,-1,2},{0,1,3,0,-1,3, 2,1,4,2,-1,4},{0,1,5,0,-1,5, 2,1,6,2,-1,6},{0,1,7,0,-1,7, 2,1,8,2,-1,8} } ),
62
        new ScrambleState( new int[][] { {                          },{0,1,3,0,-1,3              },{0,1,5,0,-1,5,             },{              2,1,8,2,-1,8} } ),
63
        new ScrambleState( new int[][] { {                          },{              2,1,4,2,-1,4},{              2,1,6,2,-1,6},{0,1,7,0,-1,7              } } ),
64
        new ScrambleState( new int[][] { {0,1,1,0,-1,1              },{                          },{              2,1,6,2,-1,6},{0,1,7,0,-1,7              } } ),
65
        new ScrambleState( new int[][] { {              2,1,2,2,-1,2},{                          },{0,1,5,0,-1,5,             },{              2,1,8,2,-1,8} } ),
66
        new ScrambleState( new int[][] { {0,1,1,0,-1,1              },{              2,1,4,2,-1,4},{                          },{0,1,7,0,-1,7              } } ),
67
        new ScrambleState( new int[][] { {              2,1,2,2,-1,2},{0,1,3,0,-1,3              },{                          },{              2,1,8,2,-1,8} } ),
68
        new ScrambleState( new int[][] { {              2,1,2,2,-1,2},{0,1,3,0,-1,3              },{0,1,5,0,-1,5,             },{                          } } ),
69
        new ScrambleState( new int[][] { {0,1,1,0,-1,1              },{              2,1,4,2,-1,4},{              2,1,6,2,-1,6},{                          } } ),
70
        };
71
      }
72

    
73
    return mStates;
74
    }
75

    
76
///////////////////////////////////////////////////////////////////////////////////////////////////
77

    
78
  public float[][] getCuts(int[] numLayers)
79
    {
80
    if( mCuts==null )
81
      {
82
      float C = +SQ3/3 +0.05f;
83
      float[] cut = new float[] {-C,+C};
84
      mCuts = new float[][] { cut,cut,cut,cut };
85
      }
86

    
87
    return mCuts;
88
    }
89

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

    
92
  public boolean[][] getLayerRotatable(int[] numLayers)
93
    {
94
    boolean[] tmp = new boolean[] {true,false,true};
95
    return new boolean[][] { tmp,tmp,tmp,tmp };
96
    }
97

    
98
///////////////////////////////////////////////////////////////////////////////////////////////////
99

    
100
  public int getTouchControlType()
101
    {
102
    return TC_HEXAHEDRON;
103
    }
104

    
105
///////////////////////////////////////////////////////////////////////////////////////////////////
106

    
107
  public int getTouchControlSplit()
108
    {
109
    return TYPE_SPLIT_CORNER;
110
    }
111

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

    
114
  public int[][][] getEnabled()
115
    {
116
    return new int[][][]
117
      {
118
          {{0,1},{3,1},{2,3},{0,2}},
119
          {{2,3},{3,1},{0,1},{0,2}},
120
          {{1,2},{0,1},{0,3},{2,3}},
121
          {{1,2},{2,3},{0,3},{0,1}},
122
          {{0,3},{0,2},{1,2},{1,3}},
123
          {{1,2},{0,2},{0,3},{1,3}},
124
      };
125
    }
126

    
127
///////////////////////////////////////////////////////////////////////////////////////////////////
128

    
129
  public float[] getDist3D(int[] numLayers)
130
    {
131
    return TouchControlHexahedron.D3D;
132
    }
133

    
134
///////////////////////////////////////////////////////////////////////////////////////////////////
135

    
136
  public Static3D[] getFaceAxis()
137
    {
138
    return TouchControlHexahedron.FACE_AXIS;
139
    }
140

    
141
///////////////////////////////////////////////////////////////////////////////////////////////////
142

    
143
  public float[][] getCubitPositions(int[] numLayers)
144
    {
145
    if( mPosition==null )
146
      {
147
      final float DIST_CORNER = 1.0f;
148
      final float DIST_EDGE   = 1.5f;
149

    
150
      mPosition = new float[][]
151
         {
152
             { DIST_CORNER, DIST_CORNER, DIST_CORNER },
153
             { DIST_CORNER, DIST_CORNER,-DIST_CORNER },
154
             { DIST_CORNER,-DIST_CORNER, DIST_CORNER },
155
             { DIST_CORNER,-DIST_CORNER,-DIST_CORNER },
156
             {-DIST_CORNER, DIST_CORNER, DIST_CORNER },
157
             {-DIST_CORNER, DIST_CORNER,-DIST_CORNER },
158
             {-DIST_CORNER,-DIST_CORNER, DIST_CORNER },
159
             {-DIST_CORNER,-DIST_CORNER,-DIST_CORNER },
160

    
161
             {      0.0f, DIST_EDGE, DIST_EDGE },
162
             { DIST_EDGE,      0.0f, DIST_EDGE },
163
             {      0.0f,-DIST_EDGE, DIST_EDGE },
164
             {-DIST_EDGE,      0.0f, DIST_EDGE },
165
             { DIST_EDGE, DIST_EDGE,      0.0f },
166
             { DIST_EDGE,-DIST_EDGE,      0.0f },
167
             {-DIST_EDGE,-DIST_EDGE,      0.0f },
168
             {-DIST_EDGE, DIST_EDGE,      0.0f },
169
             {      0.0f, DIST_EDGE,-DIST_EDGE },
170
             { DIST_EDGE,      0.0f,-DIST_EDGE },
171
             {      0.0f,-DIST_EDGE,-DIST_EDGE },
172
             {-DIST_EDGE,      0.0f,-DIST_EDGE }
173
         };
174
      }
175

    
176
    return mPosition;
177
    }
178

    
179
///////////////////////////////////////////////////////////////////////////////////////////////////
180

    
181
  public Static4D getCubitQuats(int cubit, int[] numLayers)
182
    {
183
    switch(cubit)
184
      {
185
      case  0: return mObjectQuats[0];                   //  unit quat
186
      case  1: return new Static4D( SQ2/2,0,0,SQ2/2);    //  90 along X
187
      case  2: return new Static4D(-SQ2/2,0,0,SQ2/2);    // -90 along X
188
      case  3: return mObjectQuats[9];                   // 180 along X
189
      case  4: return new Static4D(0, SQ2/2,0,SQ2/2);    //  90 along Y
190
      case  5: return mObjectQuats[11];                  // 180 along Y
191
      case  6: return mObjectQuats[10];                  // 180 along Z
192
      case  7: return new Static4D(SQ2/2,0,-SQ2/2,0);    // 180 along (SQ2/2,0,-SQ2/2)
193

    
194
      case  8: return mObjectQuats[0];
195
      case  9: return mObjectQuats[2];
196
      case 10: return mObjectQuats[10];
197
      case 11: return mObjectQuats[8];
198
      case 12: return mObjectQuats[1];
199
      case 13: return mObjectQuats[4];
200
      case 14: return mObjectQuats[6];
201
      case 15: return mObjectQuats[7];
202
      case 16: return mObjectQuats[11];
203
      case 17: return mObjectQuats[5];
204
      case 18: return mObjectQuats[9];
205
      case 19: return mObjectQuats[3];
206
      }
207

    
208
    return null;
209
    }
210

    
211
///////////////////////////////////////////////////////////////////////////////////////////////////
212

    
213
  public ObjectShape getObjectShape(int variant)
214
    {
215
    if( variant==0 )
216
      {
217
      float[][] vertices =
218
          {
219
             { 0.0f, 0.0f, 0.0f },
220
             {-0.5f, 0.5f, 0.5f },
221
             {-0.5f,-0.5f, 0.5f },
222
             { 0.5f, 0.5f, 0.5f },
223
             { 0.5f,-0.5f, 0.5f },
224
             { 0.5f, 0.5f,-0.5f },
225
             { 0.5f,-0.5f,-0.5f },
226
             {-0.5f, 0.5f,-0.5f },
227
          };
228

    
229
      int[][] indices =
230
          {
231
             { 2,4,3,1 },
232
             { 1,3,5,7 },
233
             { 4,6,5,3 },
234

    
235
             { 0,4,2 },
236
             { 0,7,5 },
237
             { 0,6,4 },
238
             { 0,1,7 },
239
             { 0,2,1 },
240
             { 0,5,6 }
241
          };
242

    
243
      return new ObjectShape(vertices, indices);
244
      }
245
    else
246
      {
247
      float[][] vertices =
248
          {
249
             {-0.5f, 0.0f, 0.0f},
250
             { 0.5f, 0.0f, 0.0f},
251
             {-0.5f,-1.0f, 0.0f},
252
             { 0.5f,-1.0f, 0.0f},
253
             { 0.0f,-1.5f, 0.0f},
254
             {-0.5f, 0.0f,-1.0f},
255
             { 0.5f, 0.0f,-1.0f},
256
             { 0.0f, 0.0f,-1.5f},
257
          };
258

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

    
269
      return new ObjectShape(vertices, indices);
270
      }
271
    }
272

    
273
///////////////////////////////////////////////////////////////////////////////////////////////////
274

    
275
  public ObjectFaceShape getObjectFaceShape(int variant)
276
    {
277
    if( variant==0 )
278
      {
279
      float h1 = isInIconMode() ? 0.001f : 0.06f;
280
      float h2 = isInIconMode() ? 0.001f : 0.01f;
281

    
282
      float[][] bands     = { {h1,35,0.5f,0.7f,5,2,2}, {h2,35,0.2f,0.4f,5,2,2} };
283
      int[] bandIndices   = { 0,0,0,1,1,1,1,1,1 };
284
      float[][] corners   = { {0.06f,0.12f} };
285
      int[] cornerIndices = { -1,0,-1,0,0,0,-1,-1 };
286
      float[][] centers   = { { 0.0f, 0.0f, 0.0f} };
287
      int[] centerIndices = { -1,0,-1,0,0,0,-1,-1 };
288
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
289
      }
290
    else
291
      {
292
      float h1 = isInIconMode() ? 0.001f : 0.038f;
293
      float h2 = isInIconMode() ? 0.001f : 0.020f;
294

    
295
      float[][] bands     = { {h1,35,0.250f,0.7f,7,2,2}, {h2,35,0.125f,0.2f,3,1,2}, {h2,35,0.125f,0.2f,3,1,1} };
296
      int[] bandIndices   = { 0,0,1,1,2,2 };
297
      float[][] corners   = { {0.06f,0.20f} };
298
      int[] cornerIndices = { 0,0,-1,-1,-1,-1,-1,-1 };
299
      float[][] centers   = { { 0.0f,-0.75f,-0.75f} };
300
      int[] centerIndices = { 0,0,-1,-1,-1,-1,-1,-1 };
301
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
302
      }
303
    }
304

    
305
///////////////////////////////////////////////////////////////////////////////////////////////////
306

    
307
  public int getNumCubitVariants(int[] numLayers)
308
    {
309
    return 2;
310
    }
311

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

    
314
  public int getCubitVariant(int cubit, int[] numLayers)
315
    {
316
    return cubit<8 ? 0:1;
317
    }
318

    
319
///////////////////////////////////////////////////////////////////////////////////////////////////
320

    
321
  public float getStickerRadius()
322
    {
323
    return 0.09f;
324
    }
325

    
326
///////////////////////////////////////////////////////////////////////////////////////////////////
327

    
328
  public float getStickerStroke()
329
    {
330
    return isInIconMode() ? 0.20f : 0.09f;
331
    }
332

    
333
///////////////////////////////////////////////////////////////////////////////////////////////////
334

    
335
  public float[][] getStickerAngles()
336
    {
337
    return null;
338
    }
339

    
340
///////////////////////////////////////////////////////////////////////////////////////////////////
341
// PUBLIC API
342

    
343
  public Static3D[] getRotationAxis()
344
    {
345
    return ROT_AXIS;
346
    }
347

    
348
///////////////////////////////////////////////////////////////////////////////////////////////////
349

    
350
  public int[][] getBasicAngles()
351
    {
352
    if( mBasicAngle ==null )
353
      {
354
      int num = getNumLayers()[0];
355
      int[] tmp = new int[num];
356
      for(int i=0; i<num; i++) tmp[i] = 3;
357
      mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
358
      }
359

    
360
    return mBasicAngle;
361
    }
362

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

    
365
  public String getShortName()
366
    {
367
    return ObjectType.REDI_3.name();
368
    }
369

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

    
372
  public ObjectSignature getSignature()
373
    {
374
    return new ObjectSignature(ObjectType.REDI_3);
375
    }
376

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

    
379
  public String getObjectName()
380
    {
381
    return "Redi Cube";
382
    }
383

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

    
386
  public String getInventor()
387
    {
388
    return "Oskar van Deventer";
389
    }
390

    
391
///////////////////////////////////////////////////////////////////////////////////////////////////
392

    
393
  public int getYearOfInvention()
394
    {
395
    return 2009;
396
    }
397

    
398
///////////////////////////////////////////////////////////////////////////////////////////////////
399

    
400
  public int getComplexity()
401
    {
402
    return 1;
403
    }
404

    
405
///////////////////////////////////////////////////////////////////////////////////////////////////
406

    
407
  public String[][] getTutorials()
408
    {
409
    return new String[][] {
410
                          {"gb","Qn7TJED6O-4","How to Solve the MoYu Redi Cube","Z3"},
411
                          {"es","g0M38Aotgac","Resolver Redi Cube","Cuby"},
412
                          {"ru","dlNRbE-hyzU","Как собрать Реди Куб","Алексей Ярыгин"},
413
                          {"fr","zw7UZcqqsgA","Comment résoudre le Redi Cube","ValentinoCube"},
414
                          {"de","YU8riouyC2w","Redi Cube Solve","CubaroCubing"},
415
                          {"pl","vxo3lXMsWQI","Jak ułożyć Redi Cube?","DJ rubiks"},
416
                          {"br","muQ8U_G4LmM","Como resolver o Redi Cube","Rafael Cinoto"},
417
                          {"kr","a5CzDMbRzbY","레디큐브를 배우기","vincentcube"},
418
                          {"vn","2JZxtmrKUn4","Tutorial N.6 - Redi","Duy Thích Rubik"},
419
                         };
420
    }
421
}
(26-26/36)