Project

General

Profile

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

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

1 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6 6133be67 Leszek Koltunski
// 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 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
9
10
package org.distorted.objectlib.objects;
11
12 c9c71c3f Leszek Koltunski
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_HEXAHEDRON;
13
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_SPLIT_CORNER;
14 29b82486 Leszek Koltunski
15 82eb152a Leszek Koltunski
import java.io.InputStream;
16 29b82486 Leszek Koltunski
17
import org.distorted.library.type.Static3D;
18
import org.distorted.library.type.Static4D;
19
20 3ee1d662 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectFaceShape;
21 1d581993 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectSignature;
22 a8295031 Leszek Koltunski
import org.distorted.objectlib.main.InitData;
23 c9c71c3f Leszek Koltunski
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
24 8005e762 Leszek Koltunski
import org.distorted.objectlib.main.ObjectType;
25 198c5bf0 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectShape;
26 10b7e306 Leszek Koltunski
import org.distorted.objectlib.scrambling.ScrambleState;
27 386af988 Leszek Koltunski
import org.distorted.objectlib.main.ShapeHexahedron;
28 29b82486 Leszek Koltunski
29
///////////////////////////////////////////////////////////////////////////////////////////////////
30
31 386af988 Leszek Koltunski
public class TwistyRedi extends ShapeHexahedron
32 29b82486 Leszek Koltunski
{
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 beee90ab Leszek Koltunski
  private int[][] mBasicAngle;
43 29b82486 Leszek Koltunski
  private float[][] mCuts;
44 52f4db8a Leszek Koltunski
  private float[][] mPosition;
45 29b82486 Leszek Koltunski
46
///////////////////////////////////////////////////////////////////////////////////////////////////
47
48 a8295031 Leszek Koltunski
  public TwistyRedi(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
49 29b82486 Leszek Koltunski
    {
50 a8295031 Leszek Koltunski
    super(data, meshState, iconMode, data.getNumLayers()[0], quat, move, scale, stream);
51 29b82486 Leszek Koltunski
    }
52
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54
55 f9a81f52 Leszek Koltunski
  public ScrambleState[] getScrambleStates()
56 29b82486 Leszek Koltunski
    {
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 7bbfc84f Leszek Koltunski
  public float[][] getCuts(int[] numLayers)
79 29b82486 Leszek Koltunski
    {
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 59c20632 Leszek Koltunski
  public boolean[][] getLayerRotatable(int[] numLayers)
93
    {
94
    boolean[] tmp = new boolean[] {true,false,true};
95 802fe251 Leszek Koltunski
    return new boolean[][] { tmp,tmp,tmp,tmp };
96 59c20632 Leszek Koltunski
    }
97
98
///////////////////////////////////////////////////////////////////////////////////////////////////
99
100 11fa413d Leszek Koltunski
  public int getTouchControlType()
101 59c20632 Leszek Koltunski
    {
102 c9c71c3f Leszek Koltunski
    return TC_HEXAHEDRON;
103 59c20632 Leszek Koltunski
    }
104
105
///////////////////////////////////////////////////////////////////////////////////////////////////
106
107 11fa413d Leszek Koltunski
  public int getTouchControlSplit()
108 29b82486 Leszek Koltunski
    {
109 59c20632 Leszek Koltunski
    return TYPE_SPLIT_CORNER;
110
    }
111
112
///////////////////////////////////////////////////////////////////////////////////////////////////
113
114
  public int[][][] getEnabled()
115
    {
116
    return new int[][][]
117 29b82486 Leszek Koltunski
      {
118 59c20632 Leszek Koltunski
          {{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 4c9ca251 Leszek Koltunski
    return TouchControlHexahedron.D3D;
132
    }
133
134
///////////////////////////////////////////////////////////////////////////////////////////////////
135
136
  public Static3D[] getFaceAxis()
137
    {
138
    return TouchControlHexahedron.FACE_AXIS;
139 29b82486 Leszek Koltunski
    }
140
141
///////////////////////////////////////////////////////////////////////////////////////////////////
142
143 7b832206 Leszek Koltunski
  public float[][] getCubitPositions(int[] numLayers)
144 29b82486 Leszek Koltunski
    {
145 52f4db8a Leszek Koltunski
    if( mPosition==null )
146 29b82486 Leszek Koltunski
      {
147
      final float DIST_CORNER = 1.0f;
148
      final float DIST_EDGE   = 1.5f;
149
150 52f4db8a Leszek Koltunski
      mPosition = new float[][]
151 29b82486 Leszek Koltunski
         {
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 52f4db8a Leszek Koltunski
    return mPosition;
177 29b82486 Leszek Koltunski
    }
178
179 d0e6cf7f Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
180
181
  public Static4D getCubitQuats(int cubit, int[] numLayers)
182
    {
183
    switch(cubit)
184
      {
185 802fe251 Leszek Koltunski
      case  0: return mObjectQuats[0];                   //  unit quat
186 d0e6cf7f Leszek Koltunski
      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 802fe251 Leszek Koltunski
      case  3: return mObjectQuats[9];                   // 180 along X
189 d0e6cf7f Leszek Koltunski
      case  4: return new Static4D(0, SQ2/2,0,SQ2/2);    //  90 along Y
190 802fe251 Leszek Koltunski
      case  5: return mObjectQuats[11];                  // 180 along Y
191
      case  6: return mObjectQuats[10];                  // 180 along Z
192 d0e6cf7f Leszek Koltunski
      case  7: return new Static4D(SQ2/2,0,-SQ2/2,0);    // 180 along (SQ2/2,0,-SQ2/2)
193
194 802fe251 Leszek Koltunski
      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 d0e6cf7f Leszek Koltunski
      }
207
208
    return null;
209
    }
210
211 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
212
213 e30c522a Leszek Koltunski
  public ObjectShape getObjectShape(int variant)
214 29b82486 Leszek Koltunski
    {
215
    if( variant==0 )
216
      {
217 4e9f2df5 Leszek Koltunski
      float[][] vertices =
218 29b82486 Leszek Koltunski
          {
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 4e9f2df5 Leszek Koltunski
      int[][] indices =
230 29b82486 Leszek Koltunski
          {
231
             { 2,4,3,1 },
232
             { 1,3,5,7 },
233
             { 4,6,5,3 },
234
235 846b69f3 Leszek Koltunski
             { 0,4,2 },
236
             { 0,7,5 },
237
             { 0,6,4 },
238
             { 0,1,7 },
239
             { 0,2,1 },
240
             { 0,5,6 }
241 29b82486 Leszek Koltunski
          };
242
243 59a971c1 Leszek Koltunski
      return new ObjectShape(vertices, indices);
244 29b82486 Leszek Koltunski
      }
245
    else
246
      {
247 4e9f2df5 Leszek Koltunski
      float[][] vertices =
248 29b82486 Leszek Koltunski
          {
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 4e9f2df5 Leszek Koltunski
      int[][] indices =
260 29b82486 Leszek Koltunski
          {
261
             { 0,2,4,3,1 },
262
             { 0,1,6,7,5 },
263
             { 1,3,6 },
264 846b69f3 Leszek Koltunski
             { 5,2,0 },
265 29b82486 Leszek Koltunski
             { 4,7,6,3 },
266 846b69f3 Leszek Koltunski
             { 2,5,7,4 }
267 29b82486 Leszek Koltunski
          };
268
269 59a971c1 Leszek Koltunski
      return new ObjectShape(vertices, indices);
270 3ee1d662 Leszek Koltunski
      }
271
    }
272
273
///////////////////////////////////////////////////////////////////////////////////////////////////
274
275
  public ObjectFaceShape getObjectFaceShape(int variant)
276
    {
277
    if( variant==0 )
278
      {
279 3bf19410 Leszek Koltunski
      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 3ee1d662 Leszek Koltunski
      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 3bf19410 Leszek Koltunski
      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 3ee1d662 Leszek Koltunski
      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 29b82486 Leszek Koltunski
      }
303
    }
304
305
///////////////////////////////////////////////////////////////////////////////////////////////////
306
307 e30c522a Leszek Koltunski
  public int getNumCubitVariants(int[] numLayers)
308 29b82486 Leszek Koltunski
    {
309
    return 2;
310
    }
311
312
///////////////////////////////////////////////////////////////////////////////////////////////////
313
314 e30c522a Leszek Koltunski
  public int getCubitVariant(int cubit, int[] numLayers)
315 29b82486 Leszek Koltunski
    {
316
    return cubit<8 ? 0:1;
317
    }
318
319 053ffa02 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
320 8592461c Leszek Koltunski
321 d53fb890 Leszek Koltunski
  public float getStickerRadius()
322 053ffa02 Leszek Koltunski
    {
323
    return 0.09f;
324
    }
325
326
///////////////////////////////////////////////////////////////////////////////////////////////////
327
328 d53fb890 Leszek Koltunski
  public float getStickerStroke()
329 053ffa02 Leszek Koltunski
    {
330 3bf19410 Leszek Koltunski
    return isInIconMode() ? 0.20f : 0.09f;
331 053ffa02 Leszek Koltunski
    }
332
333 00f4980d Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
334
335 d53fb890 Leszek Koltunski
  public float[][] getStickerAngles()
336 00f4980d Leszek Koltunski
    {
337
    return null;
338
    }
339
340 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
341
// PUBLIC API
342
343
  public Static3D[] getRotationAxis()
344
    {
345
    return ROT_AXIS;
346
    }
347
348
///////////////////////////////////////////////////////////////////////////////////////////////////
349
350 beee90ab Leszek Koltunski
  public int[][] getBasicAngles()
351 29b82486 Leszek Koltunski
    {
352 beee90ab Leszek Koltunski
    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 29b82486 Leszek Koltunski
    return mBasicAngle;
361
    }
362
363 61aa85e4 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
364
365 5f54927b Leszek Koltunski
  public String getShortName()
366 61aa85e4 Leszek Koltunski
    {
367 5f54927b Leszek Koltunski
    return ObjectType.REDI_3.name();
368
    }
369
370
///////////////////////////////////////////////////////////////////////////////////////////////////
371
372 1d581993 Leszek Koltunski
  public ObjectSignature getSignature()
373 5f54927b Leszek Koltunski
    {
374 1d581993 Leszek Koltunski
    return new ObjectSignature(ObjectType.REDI_3);
375 61aa85e4 Leszek Koltunski
    }
376
377 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
378
379 e26eb4e7 Leszek Koltunski
  public String getObjectName()
380 29b82486 Leszek Koltunski
    {
381 e26eb4e7 Leszek Koltunski
    return "Redi Cube";
382 29b82486 Leszek Koltunski
    }
383
384
///////////////////////////////////////////////////////////////////////////////////////////////////
385
386 e26eb4e7 Leszek Koltunski
  public String getInventor()
387 29b82486 Leszek Koltunski
    {
388 e26eb4e7 Leszek Koltunski
    return "Oskar van Deventer";
389 29b82486 Leszek Koltunski
    }
390
391 59c20632 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
392
393 e26eb4e7 Leszek Koltunski
  public int getYearOfInvention()
394 59c20632 Leszek Koltunski
    {
395
    return 2009;
396
    }
397
398 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
399
400 e26eb4e7 Leszek Koltunski
  public int getComplexity()
401 29b82486 Leszek Koltunski
    {
402 b4223a92 Leszek Koltunski
    return 1;
403 29b82486 Leszek Koltunski
    }
404 052e0362 Leszek Koltunski
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 a399e91b Leszek Koltunski
                          {"vn","2JZxtmrKUn4","Tutorial N.6 - Redi","Duy Thích Rubik"},
419 052e0362 Leszek Koltunski
                         };
420
    }
421 29b82486 Leszek Koltunski
}