Project

General

Profile

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

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

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.FactoryCubit;
21
import org.distorted.objectlib.helpers.ObjectFaceShape;
22
import org.distorted.objectlib.helpers.ObjectSignature;
23
import org.distorted.objectlib.helpers.ObjectVertexEffects;
24
import org.distorted.objectlib.main.InitData;
25
import org.distorted.objectlib.main.ObjectSignatures;
26
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
27
import org.distorted.objectlib.main.ObjectType;
28
import org.distorted.objectlib.helpers.ObjectShape;
29
import org.distorted.objectlib.shape.ShapeHexahedron;
30

    
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32

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

    
43
  private int[][] mEdges;
44
  private int[][] mBasicAngle;
45
  private float[][] mCuts;
46
  private float[][] mPosition;
47

    
48
///////////////////////////////////////////////////////////////////////////////////////////////////
49

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

    
55
///////////////////////////////////////////////////////////////////////////////////////////////////
56

    
57
  public int[][] getScrambleEdges()
58
    {
59
    if( mEdges==null )
60
      {
61
      mEdges = new int[][]
62
        {
63
          { 0,8,1,8, 4,1,5,1, 6,7,7,7, 10,2,11,2, 12,6,13,6, 16,3,17,3, 18,5,19,5, 22,4,23,4 },  // 0
64
          {                            10,2,11,2,            16,3,17,3, 18,5,19,5            },  // 1
65
          {          4,1,5,1,                     12,6,13,6,                       22,4,23,4 },  // 2
66
          {          4,1,5,1, 6,7,7,7,                                             22,4,23,4 },  // 3
67
          { 0,8,1,8,                   10,2,11,2,            16,3,17,3                       },  // 4
68
          {          4,1,5,1, 6,7,7,7,            12,6,13,6                                  },  // 5
69
          { 0,8,1,8,                   10,2,11,2,                       18,5,19,5            },  // 6
70
          { 0,8,1,8,                                         16,3,17,3, 18,5,19,5            },  // 7
71
          {                   6,7,7,7,            12,6,13,6,                       22,4,23,4 },  // 8
72
        };
73
      }
74

    
75
    return mEdges;
76
    }
77

    
78
///////////////////////////////////////////////////////////////////////////////////////////////////
79

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

    
89
    return mCuts;
90
    }
91

    
92
///////////////////////////////////////////////////////////////////////////////////////////////////
93

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

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

    
102
  public int getTouchControlType()
103
    {
104
    return TC_HEXAHEDRON;
105
    }
106

    
107
///////////////////////////////////////////////////////////////////////////////////////////////////
108

    
109
  public int getTouchControlSplit()
110
    {
111
    return TYPE_SPLIT_CORNER;
112
    }
113

    
114
///////////////////////////////////////////////////////////////////////////////////////////////////
115

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

    
129
///////////////////////////////////////////////////////////////////////////////////////////////////
130

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

    
136
///////////////////////////////////////////////////////////////////////////////////////////////////
137

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

    
143
///////////////////////////////////////////////////////////////////////////////////////////////////
144

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

    
152
      mPosition = new float[][]
153
         {
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
             {-DIST_CORNER,-DIST_CORNER, DIST_CORNER },
161
             {-DIST_CORNER,-DIST_CORNER,-DIST_CORNER },
162

    
163
             {      0.0f, DIST_EDGE, DIST_EDGE },
164
             { DIST_EDGE,      0.0f, DIST_EDGE },
165
             {      0.0f,-DIST_EDGE, DIST_EDGE },
166
             {-DIST_EDGE,      0.0f, DIST_EDGE },
167
             { DIST_EDGE, DIST_EDGE,      0.0f },
168
             { DIST_EDGE,-DIST_EDGE,      0.0f },
169
             {-DIST_EDGE,-DIST_EDGE,      0.0f },
170
             {-DIST_EDGE, DIST_EDGE,      0.0f },
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
         };
176
      }
177

    
178
    return mPosition;
179
    }
180

    
181
///////////////////////////////////////////////////////////////////////////////////////////////////
182

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

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

    
210
    return null;
211
    }
212

    
213
///////////////////////////////////////////////////////////////////////////////////////////////////
214

    
215
  private float[][] getVertices(int variant)
216
    {
217
    if( variant==0 )
218
      {
219
      return new float[][]
220
          {
221
             { 0.0f, 0.0f, 0.0f },
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
             { 0.5f,-0.5f,-0.5f },
228
             {-0.5f, 0.5f,-0.5f },
229
          };
230
      }
231
    else
232
      {
233
      return new float[][]
234
          {
235
             {-0.5f, 0.0f, 0.0f},
236
             { 0.5f, 0.0f, 0.0f},
237
             {-0.5f,-1.0f, 0.0f},
238
             { 0.5f,-1.0f, 0.0f},
239
             { 0.0f,-1.5f, 0.0f},
240
             {-0.5f, 0.0f,-1.0f},
241
             { 0.5f, 0.0f,-1.0f},
242
             { 0.0f, 0.0f,-1.5f},
243
          };
244
      }
245
    }
246

    
247
///////////////////////////////////////////////////////////////////////////////////////////////////
248

    
249
  public ObjectShape getObjectShape(int variant)
250
    {
251
    if( variant==0 )
252
      {
253
      int[][] indices =
254
          {
255
             { 2,4,3,1 },
256
             { 1,3,5,7 },
257
             { 4,6,5,3 },
258

    
259
             { 0,4,2 },
260
             { 0,7,5 },
261
             { 0,6,4 },
262
             { 0,1,7 },
263
             { 0,2,1 },
264
             { 0,5,6 }
265
          };
266

    
267
      return new ObjectShape(getVertices(variant), indices);
268
      }
269
    else
270
      {
271
      int[][] indices =
272
          {
273
             { 0,2,4,3,1 },
274
             { 0,1,6,7,5 },
275
             { 1,3,6 },
276
             { 5,2,0 },
277
             { 4,7,6,3 },
278
             { 2,5,7,4 }
279
          };
280

    
281
      return new ObjectShape(getVertices(variant), indices);
282
      }
283
    }
284

    
285
///////////////////////////////////////////////////////////////////////////////////////////////////
286

    
287
  public ObjectFaceShape getObjectFaceShape(int variant)
288
    {
289
    if( variant==0 )
290
      {
291
      float h1 = isInIconMode() ? 0.001f : 0.06f;
292
      float h2 = isInIconMode() ? 0.001f : 0.01f;
293
      float[][] bands = { {h1,35,0.5f,0.7f,5,2,2}, {h2,35,0.2f,0.4f,5,2,2} };
294
      int[] indices   = { 0,0,0,1,1,1,1,1,1 };
295
      return new ObjectFaceShape(bands,indices,null);
296
      }
297
    else
298
      {
299
      float h1 = isInIconMode() ? 0.001f : 0.038f;
300
      float h2 = isInIconMode() ? 0.001f : 0.020f;
301
      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} };
302
      int[] indices   = { 0,0,1,1,2,2 };
303
      return new ObjectFaceShape(bands,indices,null);
304
      }
305
    }
306

    
307
///////////////////////////////////////////////////////////////////////////////////////////////////
308

    
309
  public ObjectVertexEffects getVertexEffects(int variant)
310
    {
311
    if( variant==0 )
312
      {
313
      float[][] corners = { {0.06f,0.12f} };
314
      int[] indices     = { -1,0,-1,0,0,0,-1,-1 };
315
      float[][] centers = { { 0.0f, 0.0f, 0.0f} };
316
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
317
      }
318
    else
319
      {
320
      float[][] corners = { {0.06f,0.20f} };
321
      int[] indices     = { 0,0,-1,-1,-1,-1,-1,-1 };
322
      float[][] centers = { { 0.0f,-0.75f,-0.75f} };
323
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
324
      }
325
    }
326

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

    
329
  public int getNumCubitVariants(int[] numLayers)
330
    {
331
    return 2;
332
    }
333

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

    
336
  public int getCubitVariant(int cubit, int[] numLayers)
337
    {
338
    return cubit<8 ? 0:1;
339
    }
340

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

    
343
  public float getStickerRadius()
344
    {
345
    return 0.09f;
346
    }
347

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

    
350
  public float getStickerStroke()
351
    {
352
    return isInIconMode() ? 0.20f : 0.09f;
353
    }
354

    
355
///////////////////////////////////////////////////////////////////////////////////////////////////
356

    
357
  public float[][] getStickerAngles()
358
    {
359
    return null;
360
    }
361

    
362
///////////////////////////////////////////////////////////////////////////////////////////////////
363
// PUBLIC API
364

    
365
  public Static3D[] getRotationAxis()
366
    {
367
    return ROT_AXIS;
368
    }
369

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

    
372
  public int[][] getBasicAngles()
373
    {
374
    if( mBasicAngle ==null )
375
      {
376
      int num = getNumLayers()[0];
377
      int[] tmp = new int[num];
378
      for(int i=0; i<num; i++) tmp[i] = 3;
379
      mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
380
      }
381

    
382
    return mBasicAngle;
383
    }
384

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

    
387
  public String getShortName()
388
    {
389
    return ObjectType.REDI_3.name();
390
    }
391

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

    
394
  public ObjectSignature getSignature()
395
    {
396
    return new ObjectSignature(ObjectSignatures.REDI_3);
397
    }
398

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

    
401
  public String getObjectName()
402
    {
403
    return "Redi Cube";
404
    }
405

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

    
408
  public String getInventor()
409
    {
410
    return "Oskar van Deventer";
411
    }
412

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

    
415
  public int getYearOfInvention()
416
    {
417
    return 2009;
418
    }
419

    
420
///////////////////////////////////////////////////////////////////////////////////////////////////
421

    
422
  public int getComplexity()
423
    {
424
    return 1;
425
    }
426

    
427
///////////////////////////////////////////////////////////////////////////////////////////////////
428

    
429
  public String[][] getTutorials()
430
    {
431
    return new String[][] {
432
                          {"gb","Qn7TJED6O-4","How to Solve the MoYu Redi Cube","Z3"},
433
                          {"es","g0M38Aotgac","Resolver Redi Cube","Cuby"},
434
                          {"ru","dlNRbE-hyzU","Как собрать Реди Куб","Алексей Ярыгин"},
435
                          {"fr","zw7UZcqqsgA","Comment résoudre le Redi Cube","ValentinoCube"},
436
                          {"de","YU8riouyC2w","Redi Cube Solve","CubaroCubing"},
437
                          {"pl","vxo3lXMsWQI","Jak ułożyć Redi Cube?","DJ rubiks"},
438
                          {"br","muQ8U_G4LmM","Como resolver o Redi Cube","Rafael Cinoto"},
439
                          {"kr","a5CzDMbRzbY","레디큐브를 배우기","vincentcube"},
440
                          {"vn","2JZxtmrKUn4","Tutorial N.6 - Redi","Duy Thích Rubik"},
441
                         };
442
    }
443
}
(31-31/41)