Project

General

Profile

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

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

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.helpers.ObjectSignature;
32
import org.distorted.objectlib.main.InitData;
33
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
34
import org.distorted.objectlib.main.ObjectType;
35
import org.distorted.objectlib.helpers.ObjectShape;
36
import org.distorted.objectlib.scrambling.ScrambleState;
37
import org.distorted.objectlib.main.ShapeHexahedron;
38

    
39
///////////////////////////////////////////////////////////////////////////////////////////////////
40

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

    
51
  private ScrambleState[] mStates;
52
  private int[][] mBasicAngle;
53
  private float[][] mCuts;
54
  private float[][] mPosition;
55

    
56
///////////////////////////////////////////////////////////////////////////////////////////////////
57

    
58
  public TwistyRedi(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
59
    {
60
    super(data, meshState, iconMode, data.getNumLayers()[0], quat, move, scale, stream);
61
    }
62

    
63
///////////////////////////////////////////////////////////////////////////////////////////////////
64

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

    
83
    return mStates;
84
    }
85

    
86
///////////////////////////////////////////////////////////////////////////////////////////////////
87

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

    
97
    return mCuts;
98
    }
99

    
100
///////////////////////////////////////////////////////////////////////////////////////////////////
101

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

    
108
///////////////////////////////////////////////////////////////////////////////////////////////////
109

    
110
  public int getTouchControlType()
111
    {
112
    return TC_HEXAHEDRON;
113
    }
114

    
115
///////////////////////////////////////////////////////////////////////////////////////////////////
116

    
117
  public int getTouchControlSplit()
118
    {
119
    return TYPE_SPLIT_CORNER;
120
    }
121

    
122
///////////////////////////////////////////////////////////////////////////////////////////////////
123

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

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

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

    
144
///////////////////////////////////////////////////////////////////////////////////////////////////
145

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

    
151
///////////////////////////////////////////////////////////////////////////////////////////////////
152

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

    
160
      mPosition = new float[][]
161
         {
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
             {-DIST_CORNER,-DIST_CORNER, DIST_CORNER },
169
             {-DIST_CORNER,-DIST_CORNER,-DIST_CORNER },
170

    
171
             {      0.0f, DIST_EDGE, DIST_EDGE },
172
             { DIST_EDGE,      0.0f, DIST_EDGE },
173
             {      0.0f,-DIST_EDGE, DIST_EDGE },
174
             {-DIST_EDGE,      0.0f, DIST_EDGE },
175
             { DIST_EDGE, DIST_EDGE,      0.0f },
176
             { DIST_EDGE,-DIST_EDGE,      0.0f },
177
             {-DIST_EDGE,-DIST_EDGE,      0.0f },
178
             {-DIST_EDGE, DIST_EDGE,      0.0f },
179
             {      0.0f, DIST_EDGE,-DIST_EDGE },
180
             { DIST_EDGE,      0.0f,-DIST_EDGE },
181
             {      0.0f,-DIST_EDGE,-DIST_EDGE },
182
             {-DIST_EDGE,      0.0f,-DIST_EDGE }
183
         };
184
      }
185

    
186
    return mPosition;
187
    }
188

    
189
///////////////////////////////////////////////////////////////////////////////////////////////////
190

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

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

    
218
    return null;
219
    }
220

    
221
///////////////////////////////////////////////////////////////////////////////////////////////////
222

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

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

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

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

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

    
279
      return new ObjectShape(vertices, indices);
280
      }
281
    }
282

    
283
///////////////////////////////////////////////////////////////////////////////////////////////////
284

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

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

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

    
315
///////////////////////////////////////////////////////////////////////////////////////////////////
316

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

    
322
///////////////////////////////////////////////////////////////////////////////////////////////////
323

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

    
329
///////////////////////////////////////////////////////////////////////////////////////////////////
330

    
331
  public float getStickerRadius()
332
    {
333
    return 0.09f;
334
    }
335

    
336
///////////////////////////////////////////////////////////////////////////////////////////////////
337

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

    
343
///////////////////////////////////////////////////////////////////////////////////////////////////
344

    
345
  public float[][] getStickerAngles()
346
    {
347
    return null;
348
    }
349

    
350
///////////////////////////////////////////////////////////////////////////////////////////////////
351
// PUBLIC API
352

    
353
  public Static3D[] getRotationAxis()
354
    {
355
    return ROT_AXIS;
356
    }
357

    
358
///////////////////////////////////////////////////////////////////////////////////////////////////
359

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

    
370
    return mBasicAngle;
371
    }
372

    
373
///////////////////////////////////////////////////////////////////////////////////////////////////
374

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

    
380
///////////////////////////////////////////////////////////////////////////////////////////////////
381

    
382
  public ObjectSignature getSignature()
383
    {
384
    return new ObjectSignature(ObjectType.REDI_3);
385
    }
386

    
387
///////////////////////////////////////////////////////////////////////////////////////////////////
388

    
389
  public String getObjectName()
390
    {
391
    return "Redi Cube";
392
    }
393

    
394
///////////////////////////////////////////////////////////////////////////////////////////////////
395

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

    
401
///////////////////////////////////////////////////////////////////////////////////////////////////
402

    
403
  public int getYearOfInvention()
404
    {
405
    return 2009;
406
    }
407

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

    
410
  public int getComplexity()
411
    {
412
    return 1;
413
    }
414

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

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