Project

General

Profile

« Previous | Next » 

Revision d5411af4

Added by Leszek Koltunski over 2 years ago

one more crash fix and a bump to 1.10.3

View differences:

src/main/java/org/distorted/objectlib/main/ObjectControl.java
237 237
      TwistyObject object = mPreRender.getObject();
238 238
      int[][] angles = object.getBasicAngles();
239 239

  
240
      if( mCurrentAxis<angles.length )
240
      if( mCurrentAxis<angles.length && mCurrentRow<angles[mCurrentAxis].length )
241 241
        {
242 242
        computeCurrentSpeedInInchesPerSecond();
243 243
        int basic = angles[mCurrentAxis][mCurrentRow];
src/main/java/org/distorted/objectlib/main/ObjectSignatures.java
72 72
  public static final int CRYS_3 = ObjectType.CRYS_3.ordinal();
73 73
  public static final int STAR_3 = ObjectType.STAR_3.ordinal();
74 74
  public static final int PENT_2 = ObjectType.PENT_2.ordinal();
75
  public static final int MIXU_3 = ObjectType.MIXU_3.ordinal();
75 76
  }
src/main/java/org/distorted/objectlib/main/ObjectType.java
79 79
  SKEW_3 ( TwistySkewb.class         , new int[] {3,3,3,3}    , 21, R.drawable.skew_3, true),
80 80
  CONT_2 ( TwistyContainer.class     , new int[] {2,2,2,2}    , 12, R.drawable.cont_2, true),
81 81

  
82
  MIXU_3 ( TwistyMixup.class         , new int[] {3,3,3}      , 22, R.drawable.cont_2, false),
83

  
82 84
  VOID_3 ( TwistyVoid.class          , new int[] {3,3,3}      , 17, R.drawable.void_3, false),  // wasDownloadableButNowIsBuiltIn()
83 85
  CRYS_3 ( TwistyCrystal.class       , new int[] {3,3,3,3,3,3}, 27, R.drawable.crys_3, false),  // function!
84 86
  STAR_3 ( TwistyStarminx.class      , new int[] {3,3,3,3,3,3}, 27, R.drawable.star_3, false),
src/main/java/org/distorted/objectlib/objects/TwistyMixup.java
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 org.distorted.library.type.Static3D;
23
import org.distorted.library.type.Static4D;
24
import org.distorted.objectlib.helpers.ObjectFaceShape;
25
import org.distorted.objectlib.helpers.ObjectShape;
26
import org.distorted.objectlib.helpers.ObjectSignature;
27
import org.distorted.objectlib.main.ObjectType;
28
import org.distorted.objectlib.main.ShapeHexahedron;
29
import org.distorted.objectlib.scrambling.ScrambleState;
30
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
31

  
32
import java.io.InputStream;
33

  
34
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_HEXAHEDRON;
35
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
36

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

  
39
public class TwistyMixup extends ShapeHexahedron
40
{
41
  static final Static3D[] ROT_AXIS = new Static3D[]
42
         {
43
           new Static3D(1,0,0),
44
           new Static3D(0,1,0),
45
           new Static3D(0,0,1)
46
         };
47

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

  
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54

  
55
  public TwistyMixup(int[] numL, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
56
    {
57
    super(numL, meshState, iconMode, numL[0], quat, move, scale, stream);
58
    }
59

  
60
///////////////////////////////////////////////////////////////////////////////////////////////////
61

  
62
  public ScrambleState[] getScrambleStates()
63
    {
64
    if( mStates==null )
65
      {
66
      int[][] m = new int[16][];
67

  
68
      for(int i=0; i<16; i++) m[i] = new int[] { 0,-2,i,0, 2,i,0, 4,i,
69
                                                 1,-3,i,1,-2,i,1,-1,i,1,1,i,1,2,i,1,3,i,1,4,i,
70
                                                 2,-2,i,2, 2,i,2, 4,i };
71

  
72
      mStates = new ScrambleState[]
73
          {
74
          new ScrambleState( new int[][] { m[ 1], m[ 2], m[ 3] } ),  //  0 0
75
          new ScrambleState( new int[][] {  null, m[ 4], m[ 5] } ),  //  1 x
76
          new ScrambleState( new int[][] { m[ 6],  null, m[ 7] } ),  //  2 y
77
          new ScrambleState( new int[][] { m[ 8], m[ 9],  null } ),  //  3 z
78
          new ScrambleState( new int[][] { m[10],  null, m[ 7] } ),  //  4 xy
79
          new ScrambleState( new int[][] { m[11], m[ 9],  null } ),  //  5 xz
80
          new ScrambleState( new int[][] {  null, m[12], m[ 5] } ),  //  6 yx
81
          new ScrambleState( new int[][] { m[ 8], m[13],  null } ),  //  7 yz
82
          new ScrambleState( new int[][] {  null, m[ 4], m[14] } ),  //  8 zx
83
          new ScrambleState( new int[][] { m[ 6],  null, m[15] } ),  //  9 zy
84
          new ScrambleState( new int[][] {  null,  null, m[ 5] } ),  // 10 xyx
85
          new ScrambleState( new int[][] {  null, m[ 4],  null } ),  // 11 xzx
86
          new ScrambleState( new int[][] {  null,  null, m[ 7] } ),  // 12 yxy
87
          new ScrambleState( new int[][] { m[ 6],  null,  null } ),  // 13 yzy
88
          new ScrambleState( new int[][] {  null, m[ 9],  null } ),  // 14 zxz
89
          new ScrambleState( new int[][] { m[ 8],  null,  null } ),  // 15 zyz
90
          };
91
      }
92

  
93
    return mStates;
94
    }
95

  
96
///////////////////////////////////////////////////////////////////////////////////////////////////
97

  
98
  public float[][] getCuts(int[] numLayers)
99
    {
100
    if( mCuts==null )
101
      {
102
      float C = 1.5f*(SQ2-1);
103
      float[] cut = new float[] {-C,+C};
104
      mCuts = new float[][] { cut,cut,cut };
105
      }
106

  
107
    return mCuts;
108
    }
109

  
110
///////////////////////////////////////////////////////////////////////////////////////////////////
111

  
112
  public boolean[][] getLayerRotatable(int[] numLayers)
113
    {
114
    boolean[] tmp = new boolean[] {true,true,true};
115
    return new boolean[][] { tmp,tmp,tmp };
116
    }
117

  
118
///////////////////////////////////////////////////////////////////////////////////////////////////
119

  
120
  public int getTouchControlType()
121
    {
122
    return TC_HEXAHEDRON;
123
    }
124

  
125
///////////////////////////////////////////////////////////////////////////////////////////////////
126

  
127
  public int getTouchControlSplit()
128
    {
129
    return TYPE_NOT_SPLIT;
130
    }
131

  
132
///////////////////////////////////////////////////////////////////////////////////////////////////
133

  
134
  public int[][][] getEnabled()
135
    {
136
    return new int[][][] { {{1,2}},{{1,2}},{{0,2}},{{0,2}},{{0,1}},{{0,1}} };
137
    }
138

  
139
///////////////////////////////////////////////////////////////////////////////////////////////////
140

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

  
146
///////////////////////////////////////////////////////////////////////////////////////////////////
147

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

  
153
///////////////////////////////////////////////////////////////////////////////////////////////////
154
// TODO
155

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

  
163
      mPosition = new float[][]
164
         {
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
             {-DIST_CORNER, DIST_CORNER,-DIST_CORNER },
171
             {-DIST_CORNER,-DIST_CORNER, DIST_CORNER },
172
             {-DIST_CORNER,-DIST_CORNER,-DIST_CORNER },
173

  
174
             {      0.0f, DIST_EDGE, DIST_EDGE },
175
             { DIST_EDGE,      0.0f, DIST_EDGE },
176
             {      0.0f,-DIST_EDGE, DIST_EDGE },
177
             {-DIST_EDGE,      0.0f, DIST_EDGE },
178
             { DIST_EDGE, DIST_EDGE,      0.0f },
179
             { DIST_EDGE,-DIST_EDGE,      0.0f },
180
             {-DIST_EDGE,-DIST_EDGE,      0.0f },
181
             {-DIST_EDGE, DIST_EDGE,      0.0f },
182
             {      0.0f, DIST_EDGE,-DIST_EDGE },
183
             { DIST_EDGE,      0.0f,-DIST_EDGE },
184
             {      0.0f,-DIST_EDGE,-DIST_EDGE },
185
             {-DIST_EDGE,      0.0f,-DIST_EDGE }
186
         };
187
      }
188

  
189
    return mPosition;
190
    }
191

  
192
///////////////////////////////////////////////////////////////////////////////////////////////////
193
// TODO
194

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

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

  
222
    return null;
223
    }
224

  
225
///////////////////////////////////////////////////////////////////////////////////////////////////
226
// TODO
227

  
228
  public ObjectShape getObjectShape(int variant)
229
    {
230
    if( variant==0 )
231
      {
232
      float[][] vertices =
233
          {
234
             { 0.0f, 0.0f, 0.0f },
235
             {-0.5f, 0.5f, 0.5f },
236
             {-0.5f,-0.5f, 0.5f },
237
             { 0.5f, 0.5f, 0.5f },
238
             { 0.5f,-0.5f, 0.5f },
239
             { 0.5f, 0.5f,-0.5f },
240
             { 0.5f,-0.5f,-0.5f },
241
             {-0.5f, 0.5f,-0.5f },
242
          };
243

  
244
      int[][] indices =
245
          {
246
             { 2,4,3,1 },
247
             { 1,3,5,7 },
248
             { 4,6,5,3 },
249

  
250
             { 0,4,2 },
251
             { 0,7,5 },
252
             { 0,6,4 },
253
             { 0,1,7 },
254
             { 0,2,1 },
255
             { 0,5,6 }
256
          };
257

  
258
      return new ObjectShape(vertices, indices);
259
      }
260
    else
261
      {
262
      float[][] vertices =
263
          {
264
             {-0.5f, 0.0f, 0.0f},
265
             { 0.5f, 0.0f, 0.0f},
266
             {-0.5f,-1.0f, 0.0f},
267
             { 0.5f,-1.0f, 0.0f},
268
             { 0.0f,-1.5f, 0.0f},
269
             {-0.5f, 0.0f,-1.0f},
270
             { 0.5f, 0.0f,-1.0f},
271
             { 0.0f, 0.0f,-1.5f},
272
          };
273

  
274
      int[][] indices =
275
          {
276
             { 0,2,4,3,1 },
277
             { 0,1,6,7,5 },
278
             { 1,3,6 },
279
             { 5,2,0 },
280
             { 4,7,6,3 },
281
             { 2,5,7,4 }
282
          };
283

  
284
      return new ObjectShape(vertices, indices);
285
      }
286
    }
287

  
288
///////////////////////////////////////////////////////////////////////////////////////////////////
289
// TODO
290

  
291
  public ObjectFaceShape getObjectFaceShape(int variant)
292
    {
293
    if( variant==0 )
294
      {
295
      float h1 = isInIconMode() ? 0.001f : 0.06f;
296
      float h2 = isInIconMode() ? 0.001f : 0.01f;
297

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

  
311
      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} };
312
      int[] bandIndices   = { 0,0,1,1,2,2 };
313
      float[][] corners   = { {0.06f,0.20f} };
314
      int[] cornerIndices = { 0,0,-1,-1,-1,-1,-1,-1 };
315
      float[][] centers   = { { 0.0f,-0.75f,-0.75f} };
316
      int[] centerIndices = { 0,0,-1,-1,-1,-1,-1,-1 };
317
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
318
      }
319
    }
320

  
321
///////////////////////////////////////////////////////////////////////////////////////////////////
322

  
323
  public int getNumCubitVariants(int[] numLayers)
324
    {
325
    return 3;
326
    }
327

  
328
///////////////////////////////////////////////////////////////////////////////////////////////////
329

  
330
  public int getCubitVariant(int cubit, int[] numLayers)
331
    {
332
    return cubit<8 ? 0 : (cubit<20?1:2);
333
    }
334

  
335
///////////////////////////////////////////////////////////////////////////////////////////////////
336

  
337
  public float getStickerRadius()
338
    {
339
    return 0.09f;
340
    }
341

  
342
///////////////////////////////////////////////////////////////////////////////////////////////////
343

  
344
  public float getStickerStroke()
345
    {
346
    return isInIconMode() ? 0.20f : 0.09f;
347
    }
348

  
349
///////////////////////////////////////////////////////////////////////////////////////////////////
350

  
351
  public float[][] getStickerAngles()
352
    {
353
    return null;
354
    }
355

  
356
///////////////////////////////////////////////////////////////////////////////////////////////////
357
// PUBLIC API
358

  
359
  public Static3D[] getRotationAxis()
360
    {
361
    return ROT_AXIS;
362
    }
363

  
364
///////////////////////////////////////////////////////////////////////////////////////////////////
365

  
366
  public int[][] getBasicAngles()
367
    {
368
    if( mBasicAngle ==null )
369
      {
370
      int[] tmp = new int[] {4,8,4};
371
      mBasicAngle = new int[][] { tmp,tmp,tmp };
372
      }
373

  
374
    return mBasicAngle;
375
    }
376

  
377
///////////////////////////////////////////////////////////////////////////////////////////////////
378

  
379
  public String getShortName()
380
    {
381
    return ObjectType.MIXU_3.name();
382
    }
383

  
384
///////////////////////////////////////////////////////////////////////////////////////////////////
385

  
386
  public ObjectSignature getSignature()
387
    {
388
    return new ObjectSignature(ObjectType.MIXU_3);
389
    }
390

  
391
///////////////////////////////////////////////////////////////////////////////////////////////////
392

  
393
  public String getObjectName()
394
    {
395
    return "Mixup Cube";
396
    }
397

  
398
///////////////////////////////////////////////////////////////////////////////////////////////////
399

  
400
  public String getInventor()
401
    {
402
    return "Sergey Makarov";
403
    }
404

  
405
///////////////////////////////////////////////////////////////////////////////////////////////////
406

  
407
  public int getYearOfInvention()
408
    {
409
    return 1985;
410
    }
411

  
412
///////////////////////////////////////////////////////////////////////////////////////////////////
413

  
414
  public int getComplexity()
415
    {
416
    return 2;
417
    }
418

  
419
///////////////////////////////////////////////////////////////////////////////////////////////////
420

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

Also available in: Unified diff