Project

General

Profile

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

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

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

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

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

    
49
  public static final float REX_D = 0.2f;
50

    
51
  private ScrambleState[] mStates;
52
  private int[][] mBasicAngle;
53
  private float[][] mCuts;
54
  private float[][] mPosition;
55
  private int[] mQuatIndex;
56

    
57
///////////////////////////////////////////////////////////////////////////////////////////////////
58

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

    
64
///////////////////////////////////////////////////////////////////////////////////////////////////
65

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

    
77
///////////////////////////////////////////////////////////////////////////////////////////////////
78

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

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

    
91
    return mStates;
92
    }
93

    
94
///////////////////////////////////////////////////////////////////////////////////////////////////
95

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

    
105
    return mCuts;
106
    }
107

    
108
///////////////////////////////////////////////////////////////////////////////////////////////////
109

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

    
116
///////////////////////////////////////////////////////////////////////////////////////////////////
117

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

    
123
///////////////////////////////////////////////////////////////////////////////////////////////////
124

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

    
130
///////////////////////////////////////////////////////////////////////////////////////////////////
131

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

    
145
///////////////////////////////////////////////////////////////////////////////////////////////////
146

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

    
152
///////////////////////////////////////////////////////////////////////////////////////////////////
153

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

    
159
///////////////////////////////////////////////////////////////////////////////////////////////////
160

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

    
169
      mPosition = new float[][]
170
        {
171
          { +DIST2, -DIST2, +DIST3 },
172
          { -DIST2, +DIST2, +DIST3 },
173
          { +DIST2, +DIST2, -DIST3 },
174
          { -DIST2, -DIST2, -DIST3 },
175
          { +DIST2, +DIST3, -DIST2 },
176
          { -DIST2, +DIST3, +DIST2 },
177
          { +DIST2, -DIST3, +DIST2 },
178
          { -DIST2, -DIST3, -DIST2 },
179
          { +DIST3, +DIST2, -DIST2 },
180
          { +DIST3, -DIST2, +DIST2 },
181
          { -DIST3, +DIST2, +DIST2 },
182
          { -DIST3, -DIST2, -DIST2 },
183

    
184
          { +DIST2, +DIST2, +DIST3 },
185
          { -DIST2, -DIST2, +DIST3 },
186
          { +DIST2, -DIST2, -DIST3 },
187
          { -DIST2, +DIST2, -DIST3 },
188
          { -DIST2, +DIST3, -DIST2 },
189
          { +DIST2, +DIST3, +DIST2 },
190
          { -DIST2, -DIST3, +DIST2 },
191
          { +DIST2, -DIST3, -DIST2 },
192
          { +DIST3, +DIST2, +DIST2 },
193
          { +DIST3, -DIST2, -DIST2 },
194
          { -DIST3, +DIST2, -DIST2 },
195
          { -DIST3, -DIST2, +DIST2 },
196

    
197
          { +0.00f, +0.00f, +DIST3 },
198
          { +0.00f, +0.00f, -DIST3 },
199
          { +0.00f, +DIST3, +0.00f },
200
          { +0.00f, -DIST3, +0.00f },
201
          { +DIST3, +0.00f, +0.00f },
202
          { -DIST3, +0.00f, +0.00f },
203

    
204
          { +0.00f, +DIST1, +DIST1 },
205
          { +DIST1, +0.00f, +DIST1 },
206
          { +0.00f, -DIST1, +DIST1 },
207
          { -DIST1, +0.00f, +DIST1 },
208
          { +DIST1, +DIST1, +0.00f },
209
          { +DIST1, -DIST1, +0.00f },
210
          { -DIST1, -DIST1, +0.00f },
211
          { -DIST1, +DIST1, +0.00f },
212
          { +0.00f, +DIST1, -DIST1 },
213
          { +DIST1, +0.00f, -DIST1 },
214
          { +0.00f, -DIST1, -DIST1 },
215
          { -DIST1, +0.00f, -DIST1 },
216
        };
217
      }
218

    
219
    return mPosition;
220
    }
221

    
222
///////////////////////////////////////////////////////////////////////////////////////////////////
223

    
224
  public Static4D getCubitQuats(int cubit, int[] numLayers)
225
    {
226
    if( mQuatIndex==null )
227
      {
228
      mQuatIndex = new int[] {
229
                              0,10, 9,11, 7, 1, 6, 4, 2, 5, 3, 8,
230
                              0,10, 9,11, 7, 1, 6, 4, 2, 5, 3, 8,
231
                              0, 9, 1, 4, 2, 3,
232
                              0, 2,10, 8, 1, 4, 6, 7,11, 5, 9, 3
233
                             };
234
      }
235
    return mObjectQuats[mQuatIndex[cubit]];
236
    }
237

    
238
///////////////////////////////////////////////////////////////////////////////////////////////////
239

    
240
  public ObjectShape getObjectShape(int variant)
241
    {
242
    if( variant==0 )
243
      {
244
      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} };
245
      int[][] indices   = { {0,1,2,3},{0,3,4},{3,2,4},{2,1,4},{1,0,4} };
246
      return new ObjectShape(vertices, indices);
247
      }
248
    else if( variant==1 )
249
      {
250
      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} };
251
      int[][] indices   = { {3,2,1,0},{4,3,0},{4,2,3},{4,1,2},{4,0,1} };
252
      return new ObjectShape(vertices, indices);
253
      }
254
    else if( variant==2 )
255
      {
256
      float G = 3*REX_D;
257
      float[][] vertices= { { -G, 0, 0 },{ 0,-G, 0 },{ +G, 0, 0 },{ 0,+G,0 },{ 0, 0,-G} };
258
      int[][] indices   = { {0,1,2,3},{0,3,4},{3,2,4},{2,1,4},{1,0,4} };
259
      return new ObjectShape(vertices, indices);
260
      }
261
    else
262
      {
263
      float E = 1.5f - 3*REX_D;
264
      float F = 1.5f;
265
      float[][] vertices= { { -F, 0, 0 },{  0,-E, 0 },{ +F, 0, 0 },{  0, 0,-E } };
266
      int[][] indices   = { {0,1,2}, {0,2,3}, {0,3,1}, {1,3,2} };
267
      return new ObjectShape(vertices, indices);
268
      }
269
    }
270

    
271
///////////////////////////////////////////////////////////////////////////////////////////////////
272

    
273
  public ObjectFaceShape getObjectFaceShape(int variant)
274
    {
275
    if( variant==0 || variant==1 )
276
      {
277
      float height = isInIconMode() ? 0.001f : 0.02f;
278
      float G = (1-REX_D)*SQ2/2;
279
      float[][] centers= { {0.0f,0.0f,-G} };
280
      float[][] corners= { {0.03f,0.30f} };
281
      int[] indices    = {-1,-1,0,0,-1};
282
      int[] bandIndices= { 0,1,1,1,1 };
283
      float[][] bands  = { { height,10,G/3,0.5f,5,1,1},{ 0.001f,45,0.1f,0.1f,2,0,0} };
284
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
285
      }
286
    else if( variant==2 )
287
      {
288
      float height = isInIconMode() ? 0.001f : 0.025f;
289
      float G = 3*REX_D;
290
      int[] indices    = {-1,-1,-1,-1,-1};
291
      int[] bandIndices= { 0,1,1,1,1 };
292
      float[][] bands  = { {height,10,G/2,0.5f,5,0,0},{0.001f,45,G/2,0.0f,2,0,0} };
293
      return new ObjectFaceShape(bands,bandIndices,null,indices,null,indices,null);
294
      }
295
    else
296
      {
297
      float h1 = isInIconMode() ? 0.001f : 0.03f;
298
      float h2 = isInIconMode() ? 0.001f : 0.01f;
299
      float E = 1.5f - 3*REX_D;
300
      float F = 1.5f;
301
      float G = (float)Math.sqrt(E*E+F*F);
302
      float[][] centers= { {0.0f,-1.5f,-1.5f} };
303
      float[][] corners= { {0.06f,0.20f} };
304
      int[] indices    = { 0,-1,0,-1 };
305
      int[] bandIndices= { 0,0,1,1 };
306
      float[][] bands  = { {h1,12,F/3,0.8f,5,2,3},{h2,45,G/3,0.2f,5,2,3} };
307
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
308
      }
309
    }
310

    
311
///////////////////////////////////////////////////////////////////////////////////////////////////
312

    
313
  public int getNumCubitVariants(int[] numLayers)
314
    {
315
    return 4;
316
    }
317

    
318
///////////////////////////////////////////////////////////////////////////////////////////////////
319

    
320
  public int getCubitVariant(int cubit, int[] numLayers)
321
    {
322
    return cubit<12 ? 0 : (cubit<24 ? 1 : (cubit<30?2:3));
323
    }
324

    
325
///////////////////////////////////////////////////////////////////////////////////////////////////
326

    
327
  public float getStickerRadius()
328
    {
329
    return 0.09f;
330
    }
331

    
332
///////////////////////////////////////////////////////////////////////////////////////////////////
333

    
334
  public float getStickerStroke()
335
    {
336
    return isInIconMode() ? 0.25f : 0.12f;
337
    }
338

    
339
///////////////////////////////////////////////////////////////////////////////////////////////////
340

    
341
  public float[][] getStickerAngles()
342
    {
343
    final float F = (float)(Math.PI/20);
344
    return new float[][] { { F,-F/2,F },{0,0,0,0},{ -F,0,-F } };
345
    }
346

    
347
///////////////////////////////////////////////////////////////////////////////////////////////////
348
// PUBLIC API
349

    
350
  public Static3D[] getRotationAxis()
351
    {
352
    return ROT_AXIS;
353
    }
354

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

    
357
  public int[][] getBasicAngles()
358
    {
359
    if( mBasicAngle==null )
360
      {
361
      int num = getNumLayers()[0];
362
      int[] tmp = new int[num];
363
      for(int i=0; i<num; i++) tmp[i] = 3;
364
      mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
365
      }
366

    
367
    return mBasicAngle;
368
    }
369

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

    
372
  public String getShortName()
373
    {
374
    return ObjectType.REX_3.name();
375
    }
376

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

    
379
  public long getSignature()
380
    {
381
    return ObjectType.REX_3.ordinal();
382
    }
383

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

    
386
  public String getObjectName()
387
    {
388
    return "Rex Cube";
389
    }
390

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

    
393
  public String getInventor()
394
    {
395
    return "Andrew Cormier";
396
    }
397

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

    
400
  public int getYearOfInvention()
401
    {
402
    return 2009;
403
    }
404

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

    
407
  public int getComplexity()
408
    {
409
    return 3;
410
    }
411

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

    
414
  public String[][] getTutorials()
415
    {
416
    return new String[][]{
417
                          {"gb","noAQfWqlMbk","Rex Cube Tutorial","CrazyBadCuber"},
418
                          {"es","Q90x9rjLJzw","Resolver Cubo Rex","Cuby"},
419
                          {"ru","Dr9CLM6A3fU","Как собрать Рекс Куб","Алексей Ярыгин"},
420
                          {"fr","SvK1kf6c43c","Résolution du Rex Cube","Asthalis"},
421
                          {"de","AI4vtwpRkEQ","Rex Cube - Tutorial","GerCubing"},
422
                          {"pl","ffbFRnHglWY","Rex Cube TUTORIAL PL","MrUk"},
423
                          {"kr","B3ftZzHRQyU","렉스 큐브 해법","듀나메스 큐브 해법연구소"},
424
                          {"vn","5nE9Q7QmOP4","Tutorial N.87 - Rex Cube","Duy Thích Rubik"},
425
                         };
426
    }
427
}
(27-27/36)