Project

General

Profile

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

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

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 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_HEXAHEDRON;
23
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_SPLIT_CORNER;
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.TouchControlHexahedron;
32
import org.distorted.objectlib.main.ObjectType;
33
import org.distorted.objectlib.helpers.ObjectShape;
34
import org.distorted.objectlib.scrambling.ScrambleState;
35
import org.distorted.objectlib.main.ShapeHexahedron;
36

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

    
39
public class TwistyRedi extends ShapeHexahedron
40
{
41
  static final Static3D[] ROT_AXIS = new Static3D[]
42
         {
43
           new Static3D(+SQ3/3,+SQ3/3,+SQ3/3),
44
           new Static3D(+SQ3/3,+SQ3/3,-SQ3/3),
45
           new Static3D(+SQ3/3,-SQ3/3,+SQ3/3),
46
           new Static3D(+SQ3/3,-SQ3/3,-SQ3/3)
47
         };
48

    
49
  private ScrambleState[] mStates;
50
  private int[][] mBasicAngle;
51
  private float[][] mCuts;
52
  private float[][] mPosition;
53

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

    
56
  public TwistyRedi(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
  public ScrambleState[] getScrambleStates()
64
    {
65
    if( mStates==null )
66
      {
67
      mStates = new ScrambleState[]
68
        {
69
        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} } ),
70
        new ScrambleState( new int[][] { {                          },{0,1,3,0,-1,3              },{0,1,5,0,-1,5,             },{              2,1,8,2,-1,8} } ),
71
        new ScrambleState( new int[][] { {                          },{              2,1,4,2,-1,4},{              2,1,6,2,-1,6},{0,1,7,0,-1,7              } } ),
72
        new ScrambleState( new int[][] { {0,1,1,0,-1,1              },{                          },{              2,1,6,2,-1,6},{0,1,7,0,-1,7              } } ),
73
        new ScrambleState( new int[][] { {              2,1,2,2,-1,2},{                          },{0,1,5,0,-1,5,             },{              2,1,8,2,-1,8} } ),
74
        new ScrambleState( new int[][] { {0,1,1,0,-1,1              },{              2,1,4,2,-1,4},{                          },{0,1,7,0,-1,7              } } ),
75
        new ScrambleState( new int[][] { {              2,1,2,2,-1,2},{0,1,3,0,-1,3              },{                          },{              2,1,8,2,-1,8} } ),
76
        new ScrambleState( new int[][] { {              2,1,2,2,-1,2},{0,1,3,0,-1,3              },{0,1,5,0,-1,5,             },{                          } } ),
77
        new ScrambleState( new int[][] { {0,1,1,0,-1,1              },{              2,1,4,2,-1,4},{              2,1,6,2,-1,6},{                          } } ),
78
        };
79
      }
80

    
81
    return mStates;
82
    }
83

    
84
///////////////////////////////////////////////////////////////////////////////////////////////////
85

    
86
  public float[][] getCuts(int[] numLayers)
87
    {
88
    if( mCuts==null )
89
      {
90
      float C = +SQ3/3 +0.05f;
91
      float[] cut = new float[] {-C,+C};
92
      mCuts = new float[][] { cut,cut,cut,cut };
93
      }
94

    
95
    return mCuts;
96
    }
97

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

    
100
  public boolean[][] getLayerRotatable(int[] numLayers)
101
    {
102
    boolean[] tmp = new boolean[] {true,false,true};
103
    return new boolean[][] { tmp,tmp,tmp,tmp };
104
    }
105

    
106
///////////////////////////////////////////////////////////////////////////////////////////////////
107

    
108
  public int getTouchControlType()
109
    {
110
    return TC_HEXAHEDRON;
111
    }
112

    
113
///////////////////////////////////////////////////////////////////////////////////////////////////
114

    
115
  public int getTouchControlSplit()
116
    {
117
    return TYPE_SPLIT_CORNER;
118
    }
119

    
120
///////////////////////////////////////////////////////////////////////////////////////////////////
121

    
122
  public int[][][] getEnabled()
123
    {
124
    return new int[][][]
125
      {
126
          {{0,1},{3,1},{2,3},{0,2}},
127
          {{2,3},{3,1},{0,1},{0,2}},
128
          {{1,2},{0,1},{0,3},{2,3}},
129
          {{1,2},{2,3},{0,3},{0,1}},
130
          {{0,3},{0,2},{1,2},{1,3}},
131
          {{1,2},{0,2},{0,3},{1,3}},
132
      };
133
    }
134

    
135
///////////////////////////////////////////////////////////////////////////////////////////////////
136

    
137
  public float[] getDist3D(int[] numLayers)
138
    {
139
    return TouchControlHexahedron.D3D;
140
    }
141

    
142
///////////////////////////////////////////////////////////////////////////////////////////////////
143

    
144
  public Static3D[] getFaceAxis()
145
    {
146
    return TouchControlHexahedron.FACE_AXIS;
147
    }
148

    
149
///////////////////////////////////////////////////////////////////////////////////////////////////
150

    
151
  public float[][] getCubitPositions(int[] numLayers)
152
    {
153
    if( mPosition==null )
154
      {
155
      final float DIST_CORNER = 1.0f;
156
      final float DIST_EDGE   = 1.5f;
157

    
158
      mPosition = new float[][]
159
         {
160
             { DIST_CORNER, DIST_CORNER, DIST_CORNER },
161
             { DIST_CORNER, DIST_CORNER,-DIST_CORNER },
162
             { DIST_CORNER,-DIST_CORNER, DIST_CORNER },
163
             { DIST_CORNER,-DIST_CORNER,-DIST_CORNER },
164
             {-DIST_CORNER, DIST_CORNER, DIST_CORNER },
165
             {-DIST_CORNER, DIST_CORNER,-DIST_CORNER },
166
             {-DIST_CORNER,-DIST_CORNER, DIST_CORNER },
167
             {-DIST_CORNER,-DIST_CORNER,-DIST_CORNER },
168

    
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
             { DIST_EDGE, DIST_EDGE,      0.0f },
174
             { DIST_EDGE,-DIST_EDGE,      0.0f },
175
             {-DIST_EDGE,-DIST_EDGE,      0.0f },
176
             {-DIST_EDGE, DIST_EDGE,      0.0f },
177
             {      0.0f, DIST_EDGE,-DIST_EDGE },
178
             { DIST_EDGE,      0.0f,-DIST_EDGE },
179
             {      0.0f,-DIST_EDGE,-DIST_EDGE },
180
             {-DIST_EDGE,      0.0f,-DIST_EDGE }
181
         };
182
      }
183

    
184
    return mPosition;
185
    }
186

    
187
///////////////////////////////////////////////////////////////////////////////////////////////////
188

    
189
  public Static4D getCubitQuats(int cubit, int[] numLayers)
190
    {
191
    switch(cubit)
192
      {
193
      case  0: return mObjectQuats[0];                   //  unit quat
194
      case  1: return new Static4D( SQ2/2,0,0,SQ2/2);    //  90 along X
195
      case  2: return new Static4D(-SQ2/2,0,0,SQ2/2);    // -90 along X
196
      case  3: return mObjectQuats[9];                   // 180 along X
197
      case  4: return new Static4D(0, SQ2/2,0,SQ2/2);    //  90 along Y
198
      case  5: return mObjectQuats[11];                  // 180 along Y
199
      case  6: return mObjectQuats[10];                  // 180 along Z
200
      case  7: return new Static4D(SQ2/2,0,-SQ2/2,0);    // 180 along (SQ2/2,0,-SQ2/2)
201

    
202
      case  8: return mObjectQuats[0];
203
      case  9: return mObjectQuats[2];
204
      case 10: return mObjectQuats[10];
205
      case 11: return mObjectQuats[8];
206
      case 12: return mObjectQuats[1];
207
      case 13: return mObjectQuats[4];
208
      case 14: return mObjectQuats[6];
209
      case 15: return mObjectQuats[7];
210
      case 16: return mObjectQuats[11];
211
      case 17: return mObjectQuats[5];
212
      case 18: return mObjectQuats[9];
213
      case 19: return mObjectQuats[3];
214
      }
215

    
216
    return null;
217
    }
218

    
219
///////////////////////////////////////////////////////////////////////////////////////////////////
220

    
221
  public ObjectShape getObjectShape(int variant)
222
    {
223
    if( variant==0 )
224
      {
225
      float[][] vertices =
226
          {
227
             { 0.0f, 0.0f, 0.0f },
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 },
235
          };
236

    
237
      int[][] indices =
238
          {
239
             { 2,4,3,1 },
240
             { 1,3,5,7 },
241
             { 4,6,5,3 },
242

    
243
             { 0,4,2 },
244
             { 0,7,5 },
245
             { 0,6,4 },
246
             { 0,1,7 },
247
             { 0,2,1 },
248
             { 0,5,6 }
249
          };
250

    
251
      return new ObjectShape(vertices, indices);
252
      }
253
    else
254
      {
255
      float[][] vertices =
256
          {
257
             {-0.5f, 0.0f, 0.0f},
258
             { 0.5f, 0.0f, 0.0f},
259
             {-0.5f,-1.0f, 0.0f},
260
             { 0.5f,-1.0f, 0.0f},
261
             { 0.0f,-1.5f, 0.0f},
262
             {-0.5f, 0.0f,-1.0f},
263
             { 0.5f, 0.0f,-1.0f},
264
             { 0.0f, 0.0f,-1.5f},
265
          };
266

    
267
      int[][] indices =
268
          {
269
             { 0,2,4,3,1 },
270
             { 0,1,6,7,5 },
271
             { 1,3,6 },
272
             { 5,2,0 },
273
             { 4,7,6,3 },
274
             { 2,5,7,4 }
275
          };
276

    
277
      return new ObjectShape(vertices, indices);
278
      }
279
    }
280

    
281
///////////////////////////////////////////////////////////////////////////////////////////////////
282

    
283
  public ObjectFaceShape getObjectFaceShape(int variant)
284
    {
285
    if( variant==0 )
286
      {
287
      float h1 = isInIconMode() ? 0.001f : 0.06f;
288
      float h2 = isInIconMode() ? 0.001f : 0.01f;
289

    
290
      float[][] bands     = { {h1,35,0.5f,0.7f,5,2,2}, {h2,35,0.2f,0.4f,5,2,2} };
291
      int[] bandIndices   = { 0,0,0,1,1,1,1,1,1 };
292
      float[][] corners   = { {0.06f,0.12f} };
293
      int[] cornerIndices = { -1,0,-1,0,0,0,-1,-1 };
294
      float[][] centers   = { { 0.0f, 0.0f, 0.0f} };
295
      int[] centerIndices = { -1,0,-1,0,0,0,-1,-1 };
296
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
297
      }
298
    else
299
      {
300
      float h1 = isInIconMode() ? 0.001f : 0.038f;
301
      float h2 = isInIconMode() ? 0.001f : 0.020f;
302

    
303
      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} };
304
      int[] bandIndices   = { 0,0,1,1,2,2 };
305
      float[][] corners   = { {0.06f,0.20f} };
306
      int[] cornerIndices = { 0,0,-1,-1,-1,-1,-1,-1 };
307
      float[][] centers   = { { 0.0f,-0.75f,-0.75f} };
308
      int[] centerIndices = { 0,0,-1,-1,-1,-1,-1,-1 };
309
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
310
      }
311
    }
312

    
313
///////////////////////////////////////////////////////////////////////////////////////////////////
314

    
315
  public int getNumCubitVariants(int[] numLayers)
316
    {
317
    return 2;
318
    }
319

    
320
///////////////////////////////////////////////////////////////////////////////////////////////////
321

    
322
  public int getCubitVariant(int cubit, int[] numLayers)
323
    {
324
    return cubit<8 ? 0:1;
325
    }
326

    
327
///////////////////////////////////////////////////////////////////////////////////////////////////
328

    
329
  public float getStickerRadius()
330
    {
331
    return 0.09f;
332
    }
333

    
334
///////////////////////////////////////////////////////////////////////////////////////////////////
335

    
336
  public float getStickerStroke()
337
    {
338
    return isInIconMode() ? 0.20f : 0.09f;
339
    }
340

    
341
///////////////////////////////////////////////////////////////////////////////////////////////////
342

    
343
  public float[][] getStickerAngles()
344
    {
345
    return null;
346
    }
347

    
348
///////////////////////////////////////////////////////////////////////////////////////////////////
349
// PUBLIC API
350

    
351
  public Static3D[] getRotationAxis()
352
    {
353
    return ROT_AXIS;
354
    }
355

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

    
358
  public int[][] getBasicAngles()
359
    {
360
    if( mBasicAngle ==null )
361
      {
362
      int num = getNumLayers()[0];
363
      int[] tmp = new int[num];
364
      for(int i=0; i<num; i++) tmp[i] = 3;
365
      mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
366
      }
367

    
368
    return mBasicAngle;
369
    }
370

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

    
373
  public String getShortName()
374
    {
375
    return ObjectType.REDI_3.name();
376
    }
377

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

    
380
  public long getSignature()
381
    {
382
    return ObjectType.REDI_3.ordinal();
383
    }
384

    
385
///////////////////////////////////////////////////////////////////////////////////////////////////
386

    
387
  public String getObjectName()
388
    {
389
    return "Redi Cube";
390
    }
391

    
392
///////////////////////////////////////////////////////////////////////////////////////////////////
393

    
394
  public String getInventor()
395
    {
396
    return "Oskar van Deventer";
397
    }
398

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

    
401
  public int getYearOfInvention()
402
    {
403
    return 2009;
404
    }
405

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

    
408
  public int getComplexity()
409
    {
410
    return 1;
411
    }
412

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

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