Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyHelicopter.java @ 5d09301e

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_EDGE;
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.ObjectFaceShape;
21
import org.distorted.objectlib.helpers.ObjectSignature;
22
import org.distorted.objectlib.main.InitData;
23
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
24
import org.distorted.objectlib.main.ObjectType;
25
import org.distorted.objectlib.helpers.ObjectShape;
26
import org.distorted.objectlib.scrambling.ScrambleState;
27
import org.distorted.objectlib.main.ShapeHexahedron;
28

    
29
///////////////////////////////////////////////////////////////////////////////////////////////////
30

    
31
public class TwistyHelicopter extends ShapeHexahedron
32
{
33
  static final Static3D[] ROT_AXIS = new Static3D[]
34
         {
35
           new Static3D(     0, +SQ2/2, -SQ2/2),
36
           new Static3D(     0, -SQ2/2, -SQ2/2),
37
           new Static3D(+SQ2/2,      0, -SQ2/2),
38
           new Static3D(-SQ2/2,      0, -SQ2/2),
39
           new Static3D(+SQ2/2, -SQ2/2,      0),
40
           new Static3D(-SQ2/2, -SQ2/2,      0)
41
         };
42

    
43
  private ScrambleState[] mStates;
44
  private int[][] mBasicAngle;
45
  private float[][] mCuts;
46
  private float[][] mCenters;
47
  private int[] mQuatIndices;
48

    
49
///////////////////////////////////////////////////////////////////////////////////////////////////
50

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

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

    
58
  public ScrambleState[] getScrambleStates()
59
    {
60
    if( mStates==null )
61
      {
62
      mStates = new ScrambleState[]
63
        {
64
        new ScrambleState( new int[][] { {0,1,1,2,1,2},{0,1,3,2,1,4},{0,1,5,2,1,6},{0,1,7,2,1,8},{0,1,9,2,1,10},{0,1,11,2,1,12} } ),
65
        new ScrambleState( new int[][] { {           },{           },{0,1,5      },{0,1,7      },{      2,1,10},{       2,1,12} } ),
66
        new ScrambleState( new int[][] { {           },{           },{      2,1,6},{      2,1,8},{0,1,9       },{0,1,11       } } ),
67
        new ScrambleState( new int[][] { {           },{           },{0,1,5      },{0,1,7      },{0,1,9       },{0,1,11       } } ),
68
        new ScrambleState( new int[][] { {           },{           },{      2,1,6},{      2,1,8},{      2,1,10},{       2,1,12} } ),
69
        new ScrambleState( new int[][] { {0,1,1      },{0,1,3      },{           },{           },{0,1,9       },{       2,1,12} } ),
70
        new ScrambleState( new int[][] { {      2,1,2},{      2,1,4},{           },{           },{      2,1,10},{0,1,11       } } ),
71
        new ScrambleState( new int[][] { {0,1,1      },{0,1,3      },{           },{           },{      2,1,10},{0,1,11       } } ),
72
        new ScrambleState( new int[][] { {      2,1,2},{      2,1,4},{           },{           },{0,1,9       },{       2,1,12} } ),
73
        new ScrambleState( new int[][] { {      2,1,2},{0,1,3      },{0,1,5      },{      2,1,8},{            },{             } } ),
74
        new ScrambleState( new int[][] { {0,1,1      },{      2,1,4},{      2,1,6},{0,1,7      },{            },{             } } ),
75
        new ScrambleState( new int[][] { {      2,1,2},{0,1,3      },{      2,1,6},{0,1,7      },{            },{             } } ),
76
        new ScrambleState( new int[][] { {0,1,1      },{      2,1,4},{0,1,5      },{      2,1,8},{            },{             } } ),
77
        };
78
      }
79

    
80
    return mStates;
81
    }
82

    
83
///////////////////////////////////////////////////////////////////////////////////////////////////
84

    
85
  public float[][] getCuts(int[] numLayers)
86
    {
87
    if( mCuts==null )
88
      {
89
      float[] cut = new float[] { -3*SQ2/4, +3*SQ2/4 };
90
      mCuts = new float[][] { cut,cut,cut,cut,cut,cut };
91
      }
92

    
93
    return mCuts;
94
    }
95

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

    
98
  public boolean[][] getLayerRotatable(int[] numLayers)
99
    {
100
    boolean[] tmp = new boolean[] {true,false,true};
101
    return new boolean[][] { tmp,tmp,tmp,tmp,tmp,tmp };
102
    }
103

    
104
///////////////////////////////////////////////////////////////////////////////////////////////////
105

    
106
  public int getTouchControlType()
107
    {
108
    return TC_HEXAHEDRON;
109
    }
110

    
111
///////////////////////////////////////////////////////////////////////////////////////////////////
112

    
113
  public int getTouchControlSplit()
114
    {
115
    return TYPE_SPLIT_EDGE;
116
    }
117

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

    
120
  public int[][][] getEnabled()
121
    {
122
    return new int[][][]
123
      {
124
          {{2,5},{2,4},{3,4},{3,5}},
125
          {{2,4},{2,5},{3,5},{3,4}},
126
          {{0,5},{1,5},{1,4},{0,4}},
127
          {{0,4},{1,4},{1,5},{0,5}},
128
          {{1,3},{0,3},{0,2},{1,2}},
129
          {{0,3},{1,3},{1,2},{0,2}},
130
      };
131
    }
132

    
133
///////////////////////////////////////////////////////////////////////////////////////////////////
134

    
135
  public float[] getDist3D(int[] numLayers)
136
    {
137
    return TouchControlHexahedron.D3D;
138
    }
139

    
140
///////////////////////////////////////////////////////////////////////////////////////////////////
141

    
142
  public Static3D[] getFaceAxis()
143
    {
144
    return TouchControlHexahedron.FACE_AXIS;
145
    }
146

    
147
///////////////////////////////////////////////////////////////////////////////////////////////////
148

    
149
  public float[][] getCubitPositions(int[] numLayers)
150
    {
151
    if( mCenters==null )
152
      {
153
      float DIST_CORNER = 1.50f;
154
      float DIST_CENTER = 1.50f;
155
      float XY_CENTER = DIST_CORNER/3;
156

    
157
      mCenters = new float[][]
158
         {
159
             {   DIST_CORNER,   DIST_CORNER,   DIST_CORNER },
160
             {   DIST_CORNER,   DIST_CORNER,  -DIST_CORNER },
161
             {   DIST_CORNER,  -DIST_CORNER,   DIST_CORNER },
162
             {   DIST_CORNER,  -DIST_CORNER,  -DIST_CORNER },
163
             {  -DIST_CORNER,   DIST_CORNER,   DIST_CORNER },
164
             {  -DIST_CORNER,   DIST_CORNER,  -DIST_CORNER },
165
             {  -DIST_CORNER,  -DIST_CORNER,   DIST_CORNER },
166
             {  -DIST_CORNER,  -DIST_CORNER,  -DIST_CORNER },
167

    
168
             {  -XY_CENTER  ,    -XY_CENTER,   DIST_CENTER },
169
             {  -XY_CENTER  ,     XY_CENTER,   DIST_CENTER },
170
             {   XY_CENTER  ,    -XY_CENTER,   DIST_CENTER },
171
             {   XY_CENTER  ,     XY_CENTER,   DIST_CENTER },
172
             {  -XY_CENTER  ,    -XY_CENTER,  -DIST_CENTER },
173
             {  -XY_CENTER  ,     XY_CENTER,  -DIST_CENTER },
174
             {   XY_CENTER  ,    -XY_CENTER,  -DIST_CENTER },
175
             {   XY_CENTER  ,     XY_CENTER,  -DIST_CENTER },
176

    
177
             {  -XY_CENTER  ,   DIST_CENTER,    -XY_CENTER },
178
             {  -XY_CENTER  ,   DIST_CENTER,     XY_CENTER },
179
             {   XY_CENTER  ,   DIST_CENTER,    -XY_CENTER },
180
             {   XY_CENTER  ,   DIST_CENTER,     XY_CENTER },
181
             {  -XY_CENTER  ,  -DIST_CENTER,    -XY_CENTER },
182
             {  -XY_CENTER  ,  -DIST_CENTER,     XY_CENTER },
183
             {   XY_CENTER  ,  -DIST_CENTER,    -XY_CENTER },
184
             {   XY_CENTER  ,  -DIST_CENTER,     XY_CENTER },
185

    
186
             {   DIST_CENTER,    -XY_CENTER,    -XY_CENTER },
187
             {   DIST_CENTER,    -XY_CENTER,     XY_CENTER },
188
             {   DIST_CENTER,     XY_CENTER,    -XY_CENTER },
189
             {   DIST_CENTER,     XY_CENTER,     XY_CENTER },
190
             {  -DIST_CENTER,    -XY_CENTER,    -XY_CENTER },
191
             {  -DIST_CENTER,    -XY_CENTER,     XY_CENTER },
192
             {  -DIST_CENTER,     XY_CENTER,    -XY_CENTER },
193
             {  -DIST_CENTER,     XY_CENTER,     XY_CENTER },
194
         };
195
      }
196

    
197
    return mCenters;
198
    }
199

    
200
///////////////////////////////////////////////////////////////////////////////////////////////////
201

    
202
  public Static4D getCubitQuats(int cubit, int[] numLayers)
203
    {
204
    if( mQuatIndices==null ) mQuatIndices = new int[] {  0,19,21, 7,18,16,17, 3,
205

    
206
                                                         0,21,20,17, 6, 7,16, 5,
207
                                                        10,22, 2,11,23,14,15, 1,
208
                                                         8,19, 4,12,18,13, 9, 3
209
                                                        };
210
    return mObjectQuats[mQuatIndices[cubit]];
211
    }
212

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

    
215
  public ObjectShape getObjectShape(int variant)
216
    {
217
    if( variant==0 )
218
      {
219
      float[][] vertices =
220
        { {-1.50f, 0.00f, 0.00f},{ 0.00f,-1.50f, 0.00f},{ 0.00f, 0.00f,-1.50f},{-0.75f,-0.75f,-0.75f},{ 0.00f, 0.00f, 0.00f} };
221
      int[][] indices = { {0,1,4},{2,0,4},{1,2,4},{3,1,0},{3,2,1},{3,0,2} };
222
      return new ObjectShape(vertices, indices);
223
      }
224
    else
225
      {
226
      float[][] vertices =
227
        { { 0.50f, 0.50f, 0.00f }, {-1.00f, 0.50f, 0.00f }, { 0.50f,-1.00f, 0.00f }, {-0.25f,-0.25f,-0.75f } };
228
      int[][] indices = { { 0,1,2 },{ 2,1,3 },{ 3,1,0 },{ 3,0,2 } };
229
      return new ObjectShape(vertices, indices);
230
      }
231
    }
232

    
233
///////////////////////////////////////////////////////////////////////////////////////////////////
234

    
235
  public ObjectFaceShape getObjectFaceShape(int variant)
236
    {
237
    float height = isInIconMode() ? 0.001f : 0.028f;
238

    
239
    if( variant==0 )
240
      {
241
      float[][] bands     = { {height,35,0.16f,0.7f,7,3,3}, {0.001f, 0,1.00f,0.0f,3,1,5} };
242
      int[] bandIndices   = { 0,0,0,1,1,1 };
243
      float[][] corners   = { {0.08f,0.20f} };
244
      int[] cornerIndices = { 0,0,0,0,0 };
245
      float[][] centers   = { {-0.75f, -0.75f, -0.75f} };
246
      int[] centerIndices = { 0,0,0,-1,0 };
247
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
248
      }
249
    else
250
      {
251
      float[][] bands     = { {height,35,0.16f,0.7f,7,3,3}, {0.001f, 0,1.00f,0.0f,3,1,3} };
252
      int[] bandIndices   = { 0,1,1,1 };
253
      float[][] corners   = { {0.06f,0.20f} };
254
      int[] cornerIndices = { 0,0,0,-1 };
255
      float[][] centers   = { {-0.25f, -0.25f, -0.75f} };
256
      int[] centerIndices = { 0,0,0,-1 };
257
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
258
      }
259
    }
260

    
261
///////////////////////////////////////////////////////////////////////////////////////////////////
262

    
263
  public int getNumCubitVariants(int[] numLayers)
264
    {
265
    return 2;
266
    }
267

    
268
///////////////////////////////////////////////////////////////////////////////////////////////////
269

    
270
  public int getCubitVariant(int cubit, int[] numLayers)
271
    {
272
    return cubit<8 ? 0:1;
273
    }
274

    
275
///////////////////////////////////////////////////////////////////////////////////////////////////
276

    
277
  public float getStickerRadius()
278
    {
279
    return 0.08f;
280
    }
281

    
282
///////////////////////////////////////////////////////////////////////////////////////////////////
283

    
284
  public float getStickerStroke()
285
    {
286
    return isInIconMode() ? 0.20f : 0.10f;
287
    }
288

    
289
///////////////////////////////////////////////////////////////////////////////////////////////////
290

    
291
  public float[][] getStickerAngles()
292
    {
293
    return null;
294
    }
295

    
296
///////////////////////////////////////////////////////////////////////////////////////////////////
297
// PUBLIC API
298

    
299
  public Static3D[] getRotationAxis()
300
    {
301
    return ROT_AXIS;
302
    }
303

    
304
///////////////////////////////////////////////////////////////////////////////////////////////////
305

    
306
  public int[][] getBasicAngles()
307
    {
308
    if( mBasicAngle ==null )
309
      {
310
      int num = getNumLayers()[0];
311
      int[] tmp = new int[num];
312
      for(int i=0; i<num; i++) tmp[i] = 2;
313
      mBasicAngle = new int[][] { tmp,tmp,tmp,tmp,tmp,tmp };
314
      }
315
    return mBasicAngle;
316
    }
317

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

    
320
  public String getShortName()
321
    {
322
    return ObjectType.HELI_3.name();
323
    }
324

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

    
327
  public ObjectSignature getSignature()
328
    {
329
    return new ObjectSignature(ObjectType.HELI_3);
330
    }
331

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

    
334
  public String getObjectName()
335
    {
336
    return "Helicopter Cube";
337
    }
338

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

    
341
  public String getInventor()
342
    {
343
    return "Adam G. Cowan";
344
    }
345

    
346
///////////////////////////////////////////////////////////////////////////////////////////////////
347

    
348
  public int getYearOfInvention()
349
    {
350
    return 2006;
351
    }
352

    
353
///////////////////////////////////////////////////////////////////////////////////////////////////
354

    
355
  public int getComplexity()
356
    {
357
    return 3;
358
    }
359

    
360
///////////////////////////////////////////////////////////////////////////////////////////////////
361

    
362
  public String[][] getTutorials()
363
    {
364
    return new String[][]{
365
                          {"gb","-suwJpd_PO8","Helicopter Cube Tutorial","Bearded Cubing"},
366
                          {"es","DWG9n_YyGPA","Resolver Helicopter Cube","Cuby"},
367
                          {"ru","V4lJ3pg7Hio","Как собрать Куб Вертолет","Алексей Ярыгин"},
368
                          {"fr","Zk8zWBWD2Ow","Comment résoudre le Helicopter Cube","Julien"},
369
                          {"de","6VUH_FkBTlw","Helicopter Cube Tutorial","GerCubing"},
370
                          {"pl","zoBZame4gFo","Helicopter Cube TUTORIAL PL","MrUk"},
371
                          {"br","k8PVOARh6Kk","Como resolver o Helicopter Cube 1/3","Rafael Cinoto"},
372
                          {"br","6d4JLfuIwOQ","Como resolver o Helicopter Cube 2/3","Rafael Cinoto"},
373
                          {"br","moiV-2oWgrA","Como resolver o Helicopter Cube 3/3","Rafael Cinoto"},
374
                          {"kr","xsXQSrEbgag","헬리콥터 큐브를 맞추는 법","연서큐브박"},
375
                          {"vn","Ff6-IHhQHGY","Tutorial N.89 - Helicopter","Duy Thích Rubik"},
376
                         };
377
    }
378
}
(13-13/36)