Project

General

Profile

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

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

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.helpers.ObjectSignature;
32
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
33
import org.distorted.objectlib.main.ObjectType;
34
import org.distorted.objectlib.helpers.ObjectShape;
35
import org.distorted.objectlib.scrambling.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
  private float[][] mPosition;
56
  private int[] mQuatIndex;
57

    
58
///////////////////////////////////////////////////////////////////////////////////////////////////
59

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

    
65
///////////////////////////////////////////////////////////////////////////////////////////////////
66

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

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

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

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

    
92
    return mStates;
93
    }
94

    
95
///////////////////////////////////////////////////////////////////////////////////////////////////
96

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

    
106
    return mCuts;
107
    }
108

    
109
///////////////////////////////////////////////////////////////////////////////////////////////////
110

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

    
117
///////////////////////////////////////////////////////////////////////////////////////////////////
118

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

    
124
///////////////////////////////////////////////////////////////////////////////////////////////////
125

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

    
131
///////////////////////////////////////////////////////////////////////////////////////////////////
132

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

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

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

    
153
///////////////////////////////////////////////////////////////////////////////////////////////////
154

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

    
160
///////////////////////////////////////////////////////////////////////////////////////////////////
161

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

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

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

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

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

    
220
    return mPosition;
221
    }
222

    
223
///////////////////////////////////////////////////////////////////////////////////////////////////
224

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

    
239
///////////////////////////////////////////////////////////////////////////////////////////////////
240

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

    
272
///////////////////////////////////////////////////////////////////////////////////////////////////
273

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

    
312
///////////////////////////////////////////////////////////////////////////////////////////////////
313

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

    
319
///////////////////////////////////////////////////////////////////////////////////////////////////
320

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

    
326
///////////////////////////////////////////////////////////////////////////////////////////////////
327

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

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

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

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

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

    
348
///////////////////////////////////////////////////////////////////////////////////////////////////
349
// PUBLIC API
350

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

    
356
///////////////////////////////////////////////////////////////////////////////////////////////////
357

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

    
368
    return mBasicAngle;
369
    }
370

    
371
///////////////////////////////////////////////////////////////////////////////////////////////////
372

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

    
378
///////////////////////////////////////////////////////////////////////////////////////////////////
379

    
380
  public ObjectSignature getSignature()
381
    {
382
    return new ObjectSignature(ObjectType.REX_3);
383
    }
384

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

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

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

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

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

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

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

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

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

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