Project

General

Profile

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

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

1 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
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 c9c71c3f Leszek Koltunski
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_HEXAHEDRON;
23
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_SPLIT_CORNER;
24 29b82486 Leszek Koltunski
25 82eb152a Leszek Koltunski
import java.io.InputStream;
26 29b82486 Leszek Koltunski
27
import org.distorted.library.type.Static3D;
28
import org.distorted.library.type.Static4D;
29
30 3ee1d662 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectFaceShape;
31 1d581993 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectSignature;
32 a8295031 Leszek Koltunski
import org.distorted.objectlib.main.InitData;
33 c9c71c3f Leszek Koltunski
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
34 8005e762 Leszek Koltunski
import org.distorted.objectlib.main.ObjectType;
35 198c5bf0 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectShape;
36 10b7e306 Leszek Koltunski
import org.distorted.objectlib.scrambling.ScrambleState;
37 386af988 Leszek Koltunski
import org.distorted.objectlib.main.ShapeHexahedron;
38 29b82486 Leszek Koltunski
39
///////////////////////////////////////////////////////////////////////////////////////////////////
40
41 386af988 Leszek Koltunski
public class TwistyRedi extends ShapeHexahedron
42 29b82486 Leszek Koltunski
{
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 beee90ab Leszek Koltunski
  private int[][] mBasicAngle;
53 29b82486 Leszek Koltunski
  private float[][] mCuts;
54 52f4db8a Leszek Koltunski
  private float[][] mPosition;
55 29b82486 Leszek Koltunski
56
///////////////////////////////////////////////////////////////////////////////////////////////////
57
58 a8295031 Leszek Koltunski
  public TwistyRedi(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
59 29b82486 Leszek Koltunski
    {
60 a8295031 Leszek Koltunski
    super(data, meshState, iconMode, data.getNumLayers()[0], quat, move, scale, stream);
61 29b82486 Leszek Koltunski
    }
62
63
///////////////////////////////////////////////////////////////////////////////////////////////////
64
65 f9a81f52 Leszek Koltunski
  public ScrambleState[] getScrambleStates()
66 29b82486 Leszek Koltunski
    {
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 7bbfc84f Leszek Koltunski
  public float[][] getCuts(int[] numLayers)
89 29b82486 Leszek Koltunski
    {
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 59c20632 Leszek Koltunski
  public boolean[][] getLayerRotatable(int[] numLayers)
103
    {
104
    boolean[] tmp = new boolean[] {true,false,true};
105 802fe251 Leszek Koltunski
    return new boolean[][] { tmp,tmp,tmp,tmp };
106 59c20632 Leszek Koltunski
    }
107
108
///////////////////////////////////////////////////////////////////////////////////////////////////
109
110 11fa413d Leszek Koltunski
  public int getTouchControlType()
111 59c20632 Leszek Koltunski
    {
112 c9c71c3f Leszek Koltunski
    return TC_HEXAHEDRON;
113 59c20632 Leszek Koltunski
    }
114
115
///////////////////////////////////////////////////////////////////////////////////////////////////
116
117 11fa413d Leszek Koltunski
  public int getTouchControlSplit()
118 29b82486 Leszek Koltunski
    {
119 59c20632 Leszek Koltunski
    return TYPE_SPLIT_CORNER;
120
    }
121
122
///////////////////////////////////////////////////////////////////////////////////////////////////
123
124
  public int[][][] getEnabled()
125
    {
126
    return new int[][][]
127 29b82486 Leszek Koltunski
      {
128 59c20632 Leszek Koltunski
          {{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 4c9ca251 Leszek Koltunski
    return TouchControlHexahedron.D3D;
142
    }
143
144
///////////////////////////////////////////////////////////////////////////////////////////////////
145
146
  public Static3D[] getFaceAxis()
147
    {
148
    return TouchControlHexahedron.FACE_AXIS;
149 29b82486 Leszek Koltunski
    }
150
151
///////////////////////////////////////////////////////////////////////////////////////////////////
152
153 7b832206 Leszek Koltunski
  public float[][] getCubitPositions(int[] numLayers)
154 29b82486 Leszek Koltunski
    {
155 52f4db8a Leszek Koltunski
    if( mPosition==null )
156 29b82486 Leszek Koltunski
      {
157
      final float DIST_CORNER = 1.0f;
158
      final float DIST_EDGE   = 1.5f;
159
160 52f4db8a Leszek Koltunski
      mPosition = new float[][]
161 29b82486 Leszek Koltunski
         {
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 52f4db8a Leszek Koltunski
    return mPosition;
187 29b82486 Leszek Koltunski
    }
188
189 d0e6cf7f Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
190
191
  public Static4D getCubitQuats(int cubit, int[] numLayers)
192
    {
193
    switch(cubit)
194
      {
195 802fe251 Leszek Koltunski
      case  0: return mObjectQuats[0];                   //  unit quat
196 d0e6cf7f Leszek Koltunski
      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 802fe251 Leszek Koltunski
      case  3: return mObjectQuats[9];                   // 180 along X
199 d0e6cf7f Leszek Koltunski
      case  4: return new Static4D(0, SQ2/2,0,SQ2/2);    //  90 along Y
200 802fe251 Leszek Koltunski
      case  5: return mObjectQuats[11];                  // 180 along Y
201
      case  6: return mObjectQuats[10];                  // 180 along Z
202 d0e6cf7f Leszek Koltunski
      case  7: return new Static4D(SQ2/2,0,-SQ2/2,0);    // 180 along (SQ2/2,0,-SQ2/2)
203
204 802fe251 Leszek Koltunski
      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 d0e6cf7f Leszek Koltunski
      }
217
218
    return null;
219
    }
220
221 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
222
223 e30c522a Leszek Koltunski
  public ObjectShape getObjectShape(int variant)
224 29b82486 Leszek Koltunski
    {
225
    if( variant==0 )
226
      {
227 4e9f2df5 Leszek Koltunski
      float[][] vertices =
228 29b82486 Leszek Koltunski
          {
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 4e9f2df5 Leszek Koltunski
      int[][] indices =
240 29b82486 Leszek Koltunski
          {
241
             { 2,4,3,1 },
242
             { 1,3,5,7 },
243
             { 4,6,5,3 },
244
245 846b69f3 Leszek Koltunski
             { 0,4,2 },
246
             { 0,7,5 },
247
             { 0,6,4 },
248
             { 0,1,7 },
249
             { 0,2,1 },
250
             { 0,5,6 }
251 29b82486 Leszek Koltunski
          };
252
253 59a971c1 Leszek Koltunski
      return new ObjectShape(vertices, indices);
254 29b82486 Leszek Koltunski
      }
255
    else
256
      {
257 4e9f2df5 Leszek Koltunski
      float[][] vertices =
258 29b82486 Leszek Koltunski
          {
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 4e9f2df5 Leszek Koltunski
      int[][] indices =
270 29b82486 Leszek Koltunski
          {
271
             { 0,2,4,3,1 },
272
             { 0,1,6,7,5 },
273
             { 1,3,6 },
274 846b69f3 Leszek Koltunski
             { 5,2,0 },
275 29b82486 Leszek Koltunski
             { 4,7,6,3 },
276 846b69f3 Leszek Koltunski
             { 2,5,7,4 }
277 29b82486 Leszek Koltunski
          };
278
279 59a971c1 Leszek Koltunski
      return new ObjectShape(vertices, indices);
280 3ee1d662 Leszek Koltunski
      }
281
    }
282
283
///////////////////////////////////////////////////////////////////////////////////////////////////
284
285
  public ObjectFaceShape getObjectFaceShape(int variant)
286
    {
287
    if( variant==0 )
288
      {
289 3bf19410 Leszek Koltunski
      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 3ee1d662 Leszek Koltunski
      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 3bf19410 Leszek Koltunski
      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 3ee1d662 Leszek Koltunski
      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 29b82486 Leszek Koltunski
      }
313
    }
314
315
///////////////////////////////////////////////////////////////////////////////////////////////////
316
317 e30c522a Leszek Koltunski
  public int getNumCubitVariants(int[] numLayers)
318 29b82486 Leszek Koltunski
    {
319
    return 2;
320
    }
321
322
///////////////////////////////////////////////////////////////////////////////////////////////////
323
324 e30c522a Leszek Koltunski
  public int getCubitVariant(int cubit, int[] numLayers)
325 29b82486 Leszek Koltunski
    {
326
    return cubit<8 ? 0:1;
327
    }
328
329 053ffa02 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
330 8592461c Leszek Koltunski
331 d53fb890 Leszek Koltunski
  public float getStickerRadius()
332 053ffa02 Leszek Koltunski
    {
333
    return 0.09f;
334
    }
335
336
///////////////////////////////////////////////////////////////////////////////////////////////////
337
338 d53fb890 Leszek Koltunski
  public float getStickerStroke()
339 053ffa02 Leszek Koltunski
    {
340 3bf19410 Leszek Koltunski
    return isInIconMode() ? 0.20f : 0.09f;
341 053ffa02 Leszek Koltunski
    }
342
343 00f4980d Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
344
345 d53fb890 Leszek Koltunski
  public float[][] getStickerAngles()
346 00f4980d Leszek Koltunski
    {
347
    return null;
348
    }
349
350 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
351
// PUBLIC API
352
353
  public Static3D[] getRotationAxis()
354
    {
355
    return ROT_AXIS;
356
    }
357
358
///////////////////////////////////////////////////////////////////////////////////////////////////
359
360 beee90ab Leszek Koltunski
  public int[][] getBasicAngles()
361 29b82486 Leszek Koltunski
    {
362 beee90ab Leszek Koltunski
    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 29b82486 Leszek Koltunski
    return mBasicAngle;
371
    }
372
373 61aa85e4 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
374
375 5f54927b Leszek Koltunski
  public String getShortName()
376 61aa85e4 Leszek Koltunski
    {
377 5f54927b Leszek Koltunski
    return ObjectType.REDI_3.name();
378
    }
379
380
///////////////////////////////////////////////////////////////////////////////////////////////////
381
382 1d581993 Leszek Koltunski
  public ObjectSignature getSignature()
383 5f54927b Leszek Koltunski
    {
384 1d581993 Leszek Koltunski
    return new ObjectSignature(ObjectType.REDI_3);
385 61aa85e4 Leszek Koltunski
    }
386
387 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
388
389 e26eb4e7 Leszek Koltunski
  public String getObjectName()
390 29b82486 Leszek Koltunski
    {
391 e26eb4e7 Leszek Koltunski
    return "Redi Cube";
392 29b82486 Leszek Koltunski
    }
393
394
///////////////////////////////////////////////////////////////////////////////////////////////////
395
396 e26eb4e7 Leszek Koltunski
  public String getInventor()
397 29b82486 Leszek Koltunski
    {
398 e26eb4e7 Leszek Koltunski
    return "Oskar van Deventer";
399 29b82486 Leszek Koltunski
    }
400
401 59c20632 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
402
403 e26eb4e7 Leszek Koltunski
  public int getYearOfInvention()
404 59c20632 Leszek Koltunski
    {
405
    return 2009;
406
    }
407
408 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
409
410 e26eb4e7 Leszek Koltunski
  public int getComplexity()
411 29b82486 Leszek Koltunski
    {
412 b4223a92 Leszek Koltunski
    return 1;
413 29b82486 Leszek Koltunski
    }
414 052e0362 Leszek Koltunski
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 a399e91b Leszek Koltunski
                          {"vn","2JZxtmrKUn4","Tutorial N.6 - Redi","Duy Thích Rubik"},
429 052e0362 Leszek Koltunski
                         };
430
    }
431 29b82486 Leszek Koltunski
}