Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyRex.java @ 846b69f3

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

    
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39

    
40
public class TwistyRex extends ShapeHexahedron
41
{
42
  static final Static3D[] ROT_AXIS = new Static3D[]
43
         {
44
           new Static3D(+SQ3/3,+SQ3/3,+SQ3/3),
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
         };
49

    
50
  public static final float REX_D = 0.2f;
51

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

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

    
58
  public TwistyRex(int[] numL, int meshState, Static4D quat, Static3D move, float scale, InputStream stream)
59
    {
60
    super(numL, meshState, numL[0], quat, move, scale, stream);
61
    }
62

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

    
65
  @Override
66
  public void adjustStickerCoords()
67
    {
68
    mStickerCoords = new float[][]
69
          {
70
             { -0.5f, 0.1428f, -0.1428f, 0.5f, 0.35f, -0.35f },
71
             { -0.5f, 0.0f, 0.0f, -0.5f, 0.5f, 0.0f, 0.0f, 0.5f },
72
             { -0.525f, 0.105f, 0.525f, 0.105f, 0.000f, -0.200f  }
73
          };
74
    }
75

    
76
///////////////////////////////////////////////////////////////////////////////////////////////////
77

    
78
  public ScrambleState[] getScrambleStates()
79
    {
80
    if( mStates==null )
81
      {
82
      int[] tmp = {0,-1,0, 0,1,0, 2,-1,0, 2,1,0 };
83

    
84
      mStates = new ScrambleState[]
85
        {
86
        new ScrambleState( new int[][] {tmp,tmp,tmp,tmp} )
87
        };
88
      }
89

    
90
    return mStates;
91
    }
92

    
93
///////////////////////////////////////////////////////////////////////////////////////////////////
94

    
95
  public float[][] getCuts(int[] numLayers)
96
    {
97
    if( mCuts==null )
98
      {
99
      float C = SQ3*0.45f; // bit less than 1/2 of the length of the main diagonal
100
      float[] cut = new float[] {-C,+C};
101
      mCuts = new float[][] { cut,cut,cut,cut };
102
      }
103

    
104
    return mCuts;
105
    }
106

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

    
109
  public boolean[][] getLayerRotatable(int[] numLayers)
110
    {
111
    boolean[] tmp = new boolean[] {true,false,true};
112
    return new boolean[][] { tmp,tmp,tmp,tmp };
113
    }
114

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

    
117
  public int getTouchControlType()
118
    {
119
    return TC_HEXAHEDRON;
120
    }
121

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

    
124
  public int getTouchControlSplit()
125
    {
126
    return TYPE_SPLIT_CORNER;
127
    }
128

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

    
131
  public int[][][] getEnabled()
132
    {
133
    return new int[][][]
134
      {
135
          {{0,1},{3,1},{2,3},{0,2}},
136
          {{2,3},{3,1},{0,1},{0,2}},
137
          {{1,2},{0,1},{0,3},{2,3}},
138
          {{1,2},{2,3},{0,3},{0,1}},
139
          {{0,3},{0,2},{1,2},{1,3}},
140
          {{1,2},{0,2},{0,3},{1,3}},
141
      };
142
    }
143

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

    
146
  public float[] getDist3D(int[] numLayers)
147
    {
148
    return TouchControlHexahedron.D3D;
149
    }
150

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

    
153
  public Static3D[] getFaceAxis()
154
    {
155
    return TouchControlHexahedron.FACE_AXIS;
156
    }
157

    
158
///////////////////////////////////////////////////////////////////////////////////////////////////
159

    
160
  public float[][] getCubitPositions(int[] numLayers)
161
    {
162
    final float DIST1= 1.50f;
163
    final float DIST2= (1+2*REX_D)/2;
164
    final float DIST3= 1.53f;
165

    
166
    return new float[][]
167
      {
168
        { +DIST3, +DIST2, +DIST2 },
169
        { +DIST3, +DIST2, -DIST2 },
170
        { +DIST3, -DIST2, -DIST2 },
171
        { +DIST3, -DIST2, +DIST2 },
172
        { -DIST3, +DIST2, +DIST2 },
173
        { -DIST3, +DIST2, -DIST2 },
174
        { -DIST3, -DIST2, -DIST2 },
175
        { -DIST3, -DIST2, +DIST2 },
176
        { +DIST2, +DIST3, +DIST2 },
177
        { +DIST2, +DIST3, -DIST2 },
178
        { -DIST2, +DIST3, -DIST2 },
179
        { -DIST2, +DIST3, +DIST2 },
180
        { +DIST2, -DIST3, +DIST2 },
181
        { +DIST2, -DIST3, -DIST2 },
182
        { -DIST2, -DIST3, -DIST2 },
183
        { -DIST2, -DIST3, +DIST2 },
184
        { +DIST2, +DIST2, +DIST3 },
185
        { +DIST2, -DIST2, +DIST3 },
186
        { -DIST2, -DIST2, +DIST3 },
187
        { -DIST2, +DIST2, +DIST3 },
188
        { +DIST2, +DIST2, -DIST3 },
189
        { +DIST2, -DIST2, -DIST3 },
190
        { -DIST2, -DIST2, -DIST3 },
191
        { -DIST2, +DIST2, -DIST3 },
192

    
193
        { +DIST3, +0.00f, +0.00f },
194
        { -DIST3, +0.00f, +0.00f },
195
        { +0.00f, +DIST3, +0.00f },
196
        { +0.00f, -DIST3, +0.00f },
197
        { +0.00f, +0.00f, +DIST3 },
198
        { +0.00f, +0.00f, -DIST3 },
199

    
200
        { +0.00f, +DIST1, +DIST1 },
201
        { +DIST1, +0.00f, +DIST1 },
202
        { +0.00f, -DIST1, +DIST1 },
203
        { -DIST1, +0.00f, +DIST1 },
204
        { +DIST1, +DIST1, +0.00f },
205
        { +DIST1, -DIST1, +0.00f },
206
        { -DIST1, -DIST1, +0.00f },
207
        { -DIST1, +DIST1, +0.00f },
208
        { +0.00f, +DIST1, -DIST1 },
209
        { +DIST1, +0.00f, -DIST1 },
210
        { +0.00f, -DIST1, -DIST1 },
211
        { -DIST1, +0.00f, -DIST1 },
212
      };
213
    }
214

    
215
///////////////////////////////////////////////////////////////////////////////////////////////////
216

    
217
  public Static4D getCubitQuats(int cubit, int[] numLayers)
218
    {
219
    switch(cubit)
220
      {
221
      case  0: return new Static4D(+SQ2/2,     0,+SQ2/2,     0);
222
      case  1: return mObjectQuats[2];
223
      case  2: return new Static4D(     0,-SQ2/2,     0, SQ2/2);
224
      case  3: return mObjectQuats[5];
225
      case  4: return mObjectQuats[3];
226
      case  5: return new Static4D(-SQ2/2,     0,+SQ2/2,     0);
227
      case  6: return mObjectQuats[8];
228
      case  7: return new Static4D(     0,+SQ2/2,     0, SQ2/2);
229
      case  8: return new Static4D(+SQ2/2,     0,     0, SQ2/2);
230
      case  9: return mObjectQuats[7];
231
      case 10: return new Static4D(     0,+SQ2/2,+SQ2/2,     0);
232
      case 11: return mObjectQuats[1];
233
      case 12: return mObjectQuats[6];
234
      case 13: return new Static4D(-SQ2/2,     0,     0, SQ2/2);
235
      case 14: return mObjectQuats[4];
236
      case 15: return new Static4D(     0,-SQ2/2,+SQ2/2,     0);
237
      case 16: return new Static4D(     0,     0,-SQ2/2, SQ2/2);
238
      case 17: return mObjectQuats[0];
239
      case 18: return new Static4D(     0,     0,+SQ2/2, SQ2/2);
240
      case 19: return mObjectQuats[10];
241
      case 20: return mObjectQuats[9];
242
      case 21: return new Static4D(+SQ2/2,-SQ2/2,     0,     0);
243
      case 22: return mObjectQuats[11];
244
      case 23: return new Static4D(+SQ2/2,+SQ2/2,     0,     0);
245

    
246
      case 24: return new Static4D(     0,-SQ2/2,     0, SQ2/2);
247
      case 25: return new Static4D(     0,+SQ2/2,     0, SQ2/2);
248
      case 26: return new Static4D(+SQ2/2,     0,     0, SQ2/2);
249
      case 27: return new Static4D(-SQ2/2,     0,     0, SQ2/2);
250
      case 28: return mObjectQuats[0];
251
      case 29: return mObjectQuats[9];
252

    
253
      case 30: return mObjectQuats[0];
254
      case 31: return new Static4D(     0,     0,+SQ2/2, SQ2/2);
255
      case 32: return mObjectQuats[10];
256
      case 33: return new Static4D(     0,     0,-SQ2/2, SQ2/2);
257
      case 34: return new Static4D(     0,-SQ2/2,     0, SQ2/2);
258
      case 35: return mObjectQuats[4];
259
      case 36: return mObjectQuats[6];
260
      case 37: return new Static4D(     0,+SQ2/2,     0, SQ2/2);
261
      case 38: return new Static4D(+SQ2/2,     0,     0, SQ2/2);
262
      case 39: return mObjectQuats[5];
263
      case 40: return mObjectQuats[9];
264
      case 41: return mObjectQuats[3];
265
      }
266

    
267
    return mObjectQuats[0];
268
    }
269

    
270
///////////////////////////////////////////////////////////////////////////////////////////////////
271

    
272
  public ObjectShape getObjectShape(int variant)
273
    {
274
    if( variant==0 )
275
      {
276
      float[][] vertices= { {-0.10f,0.70f,0},{-0.70f,0.10f,0},{+0.65f,-0.71f,0},{+0.71f,-0.65f,0},{0,0.05f,-0.2f} };
277
      int[][] indices   = { {0,1,2,3},{0,3,4},{3,2,4},{2,1,4},{1,0,4} };
278
      return new ObjectShape(vertices, indices);
279
      }
280
    else if( variant==1 )
281
      {
282
      float G = 3*REX_D;
283
      float[][] vertices= { { -G, 0, 0 },{ 0,-G, 0 },{ +G, 0, 0 },{ 0,+G,0 },{ 0, 0,-G} };
284
      int[][] indices   = { {0,1,2,3},{0,3,4},{3,2,4},{2,1,4},{1,0,4} };
285
      return new ObjectShape(vertices, indices);
286
      }
287
    else
288
      {
289
      float E = 1.5f - 3*REX_D;
290
      float F = 1.5f;
291
      float[][] vertices= { { -F, 0, 0 },{  0,-E, 0 },{ +F, 0, 0 },{  0, 0,-E } };
292
      int[][] indices   = { {0,1,2}, {0,2,3}, {0,3,1}, {1,3,2} };
293
      return new ObjectShape(vertices, indices);
294
      }
295
    }
296

    
297
///////////////////////////////////////////////////////////////////////////////////////////////////
298

    
299
  public ObjectFaceShape getObjectFaceShape(int variant)
300
    {
301
    if( variant==0 )
302
      {
303
      float G = (1-REX_D)*SQ2/2;
304
      float[][] centers= { {0.0f,0.0f,-G} };
305
      float[][] corners= { {0.03f,0.30f} };
306
      int[] indices    = {-1,-1,0,0,-1};
307
      int[] bandIndices= { 0,1,1,1,1 };
308
      float[][] bands  = { {+0.02f,10,G/3,0.5f,5,1,1},{ +0.0f,45,0.1f,0.1f,2,0,0} };
309
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
310
      }
311
    else if( variant==1 )
312
      {
313
      float G = 3*REX_D;
314
      int[] indices    = {-1,-1,-1,-1,-1};
315
      int[] bandIndices= { 0,1,1,1,1 };
316
      float[][] bands  = { {0.025f,10,G/2,0.5f,5,0,0},{0.000f,45,G/2,0.0f,2,0,0} };
317
      return new ObjectFaceShape(bands,bandIndices,null,indices,null,indices,null);
318
      }
319
    else
320
      {
321
      float E = 1.5f - 3*REX_D;
322
      float F = 1.5f;
323
      float G = (float)Math.sqrt(E*E+F*F);
324
      float[][] centers= { {0.0f,-1.5f,-1.5f} };
325
      float[][] corners= { {0.06f,0.20f} };
326
      int[] indices    = { 0,-1,0,-1 };
327
      int[] bandIndices= { 0,0,1,1 };
328
      float[][] bands  = { {0.03f,12,F/3,0.8f,5,2,3},{0.01f,45,G/3,0.2f,3,1,2} };
329
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
330
      }
331
    }
332

    
333
///////////////////////////////////////////////////////////////////////////////////////////////////
334

    
335
  public int getNumCubitVariants(int[] numLayers)
336
    {
337
    return 3;
338
    }
339

    
340
///////////////////////////////////////////////////////////////////////////////////////////////////
341

    
342
  public int getCubitVariant(int cubit, int[] numLayers)
343
    {
344
    return cubit<24 ? 0 : (cubit<30?1:2);
345
    }
346

    
347
///////////////////////////////////////////////////////////////////////////////////////////////////
348

    
349
  public float getStickerRadius()
350
    {
351
    return 0.09f;
352
    }
353

    
354
///////////////////////////////////////////////////////////////////////////////////////////////////
355

    
356
  public float getStickerStroke()
357
    {
358
    return ObjectControl.isInIconMode() ? 0.25f : 0.12f;
359
    }
360

    
361
///////////////////////////////////////////////////////////////////////////////////////////////////
362

    
363
  public float[][] getStickerAngles()
364
    {
365
    final float F = (float)(Math.PI/20);
366
    return new float[][] { { -F/2,F,F },null,{ F/10,-F,-F } };
367
    }
368

    
369
///////////////////////////////////////////////////////////////////////////////////////////////////
370
// PUBLIC API
371

    
372
  public Static3D[] getRotationAxis()
373
    {
374
    return ROT_AXIS;
375
    }
376

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

    
379
  public int[] getBasicAngles()
380
    {
381
    if( mBasicAngle ==null ) mBasicAngle = new int[] { 3,3,3,3 };
382
    return mBasicAngle;
383
    }
384

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

    
387
  public ObjectType intGetObjectType(int[] numLayers)
388
    {
389
    return ObjectType.REX_3;
390
    }
391

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

    
394
  public String getObjectName()
395
    {
396
    return "Rex Cube";
397
    }
398

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

    
401
  public String getInventor()
402
    {
403
    return "Andrew Cormier";
404
    }
405

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

    
408
  public int getYearOfInvention()
409
    {
410
    return 2009;
411
    }
412

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

    
415
  public int getComplexity()
416
    {
417
    return 3;
418
    }
419

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

    
422
  public String[][] getTutorials()
423
    {
424
    return new String[][]{
425
                          {"gb","noAQfWqlMbk","Rex Cube Tutorial","CrazyBadCuber"},
426
                          {"es","Q90x9rjLJzw","Resolver Cubo Rex","Cuby"},
427
                          {"ru","Dr9CLM6A3fU","Как собрать Рекс Куб","Алексей Ярыгин"},
428
                          {"fr","SvK1kf6c43c","Résolution du Rex Cube","Asthalis"},
429
                          {"de","AI4vtwpRkEQ","Rex Cube - Tutorial","GerCubing"},
430
                          {"pl","ffbFRnHglWY","Rex Cube TUTORIAL PL","MrUk"},
431
                          {"kr","B3ftZzHRQyU","렉스 큐브 해법","듀나메스 큐브 해법연구소"},
432
                         };
433
    }
434
}
(23-23/30)