Project

General

Profile

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

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

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_EDGE;
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.scrambling.ScrambleState;
36
import org.distorted.objectlib.main.ShapeHexahedron;
37

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

    
40
public class TwistyHelicopter extends ShapeHexahedron
41
{
42
  static final Static3D[] ROT_AXIS = new Static3D[]
43
         {
44
           new Static3D(     0, +SQ2/2, -SQ2/2),
45
           new Static3D(     0, -SQ2/2, -SQ2/2),
46
           new Static3D(+SQ2/2,      0, -SQ2/2),
47
           new Static3D(-SQ2/2,      0, -SQ2/2),
48
           new Static3D(+SQ2/2, -SQ2/2,      0),
49
           new Static3D(-SQ2/2, -SQ2/2,      0)
50
         };
51

    
52
  private ScrambleState[] mStates;
53
  private int[] mBasicAngle;
54
  private float[][] mCuts;
55
  private float[][] mCenters;
56
  private int[] mQuatIndices;
57

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

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

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

    
67
  public ScrambleState[] getScrambleStates()
68
    {
69
    if( mStates==null )
70
      {
71
      mStates = new ScrambleState[]
72
        {
73
        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} } ),
74
        new ScrambleState( new int[][] { {           },{           },{0,1,5      },{0,1,7      },{      2,1,10},{       2,1,12} } ),
75
        new ScrambleState( new int[][] { {           },{           },{      2,1,6},{      2,1,8},{0,1,9       },{0,1,11       } } ),
76
        new ScrambleState( new int[][] { {           },{           },{0,1,5      },{0,1,7      },{0,1,9       },{0,1,11       } } ),
77
        new ScrambleState( new int[][] { {           },{           },{      2,1,6},{      2,1,8},{      2,1,10},{       2,1,12} } ),
78
        new ScrambleState( new int[][] { {0,1,1      },{0,1,3      },{           },{           },{0,1,9       },{       2,1,12} } ),
79
        new ScrambleState( new int[][] { {      2,1,2},{      2,1,4},{           },{           },{      2,1,10},{0,1,11       } } ),
80
        new ScrambleState( new int[][] { {0,1,1      },{0,1,3      },{           },{           },{      2,1,10},{0,1,11       } } ),
81
        new ScrambleState( new int[][] { {      2,1,2},{      2,1,4},{           },{           },{0,1,9       },{       2,1,12} } ),
82
        new ScrambleState( new int[][] { {      2,1,2},{0,1,3      },{0,1,5      },{      2,1,8},{            },{             } } ),
83
        new ScrambleState( new int[][] { {0,1,1      },{      2,1,4},{      2,1,6},{0,1,7      },{            },{             } } ),
84
        new ScrambleState( new int[][] { {      2,1,2},{0,1,3      },{      2,1,6},{0,1,7      },{            },{             } } ),
85
        new ScrambleState( new int[][] { {0,1,1      },{      2,1,4},{0,1,5      },{      2,1,8},{            },{             } } ),
86
        };
87
      }
88

    
89
    return mStates;
90
    }
91

    
92
///////////////////////////////////////////////////////////////////////////////////////////////////
93

    
94
  public float[][] getCuts(int[] numLayers)
95
    {
96
    if( mCuts==null )
97
      {
98
      float[] cut = new float[] { -3*SQ2/4, +3*SQ2/4 };
99
      mCuts = new float[][] { cut,cut,cut,cut,cut,cut };
100
      }
101

    
102
    return mCuts;
103
    }
104

    
105
///////////////////////////////////////////////////////////////////////////////////////////////////
106

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

    
113
///////////////////////////////////////////////////////////////////////////////////////////////////
114

    
115
  public int getTouchControlType()
116
    {
117
    return TC_HEXAHEDRON;
118
    }
119

    
120
///////////////////////////////////////////////////////////////////////////////////////////////////
121

    
122
  public int getTouchControlSplit()
123
    {
124
    return TYPE_SPLIT_EDGE;
125
    }
126

    
127
///////////////////////////////////////////////////////////////////////////////////////////////////
128

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

    
142
///////////////////////////////////////////////////////////////////////////////////////////////////
143

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

    
149
///////////////////////////////////////////////////////////////////////////////////////////////////
150

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

    
156
///////////////////////////////////////////////////////////////////////////////////////////////////
157

    
158
  public float[][] getCubitPositions(int[] numLayers)
159
    {
160
    if( mCenters==null )
161
      {
162
      float DIST_CORNER = 1.50f;
163
      float DIST_CENTER = 1.50f;
164
      float XY_CENTER = DIST_CORNER/3;
165

    
166
      mCenters = new float[][]
167
         {
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
             {  -DIST_CORNER,   DIST_CORNER,  -DIST_CORNER },
174
             {  -DIST_CORNER,  -DIST_CORNER,   DIST_CORNER },
175
             {  -DIST_CORNER,  -DIST_CORNER,  -DIST_CORNER },
176

    
177
             {   DIST_CENTER,     XY_CENTER,     XY_CENTER },
178
             {   DIST_CENTER,     XY_CENTER,    -XY_CENTER },
179
             {   DIST_CENTER,    -XY_CENTER,     XY_CENTER },
180
             {   DIST_CENTER,    -XY_CENTER,    -XY_CENTER },
181

    
182
             {  -DIST_CENTER,     XY_CENTER,     XY_CENTER },
183
             {  -DIST_CENTER,     XY_CENTER,    -XY_CENTER },
184
             {  -DIST_CENTER,    -XY_CENTER,     XY_CENTER },
185
             {  -DIST_CENTER,    -XY_CENTER,    -XY_CENTER },
186

    
187
             {   XY_CENTER  ,   DIST_CENTER,     XY_CENTER },
188
             {   XY_CENTER  ,   DIST_CENTER,    -XY_CENTER },
189
             {  -XY_CENTER  ,   DIST_CENTER,     XY_CENTER },
190
             {  -XY_CENTER  ,   DIST_CENTER,    -XY_CENTER },
191

    
192
             {   XY_CENTER  ,  -DIST_CENTER,     XY_CENTER },
193
             {   XY_CENTER  ,  -DIST_CENTER,    -XY_CENTER },
194
             {  -XY_CENTER  ,  -DIST_CENTER,     XY_CENTER },
195
             {  -XY_CENTER  ,  -DIST_CENTER,    -XY_CENTER },
196

    
197
             {   XY_CENTER  ,     XY_CENTER,   DIST_CENTER },
198
             {   XY_CENTER  ,    -XY_CENTER,   DIST_CENTER },
199
             {  -XY_CENTER  ,     XY_CENTER,   DIST_CENTER },
200
             {  -XY_CENTER  ,    -XY_CENTER,   DIST_CENTER },
201

    
202
             {   XY_CENTER  ,     XY_CENTER,  -DIST_CENTER },
203
             {   XY_CENTER  ,    -XY_CENTER,  -DIST_CENTER },
204
             {  -XY_CENTER  ,     XY_CENTER,  -DIST_CENTER },
205
             {  -XY_CENTER  ,    -XY_CENTER,  -DIST_CENTER },
206
         };
207
      }
208

    
209
    return mCenters;
210
    }
211

    
212
///////////////////////////////////////////////////////////////////////////////////////////////////
213

    
214
  public Static4D getCubitQuats(int cubit, int[] numLayers)
215
    {
216
    if( mQuatIndices==null ) mQuatIndices = new int[] { 0,19,21,7,18,16,17,3,12,4,19,8,3,9,13,18,11,2,22,10,1,15,14,23,17,20,21,0,5,16,7,6 };
217
    return mObjectQuats[mQuatIndices[cubit]];
218
    }
219

    
220
///////////////////////////////////////////////////////////////////////////////////////////////////
221

    
222
  public ObjectShape getObjectShape(int variant)
223
    {
224
    if( variant==0 )
225
      {
226
      float[][] vertices =
227
        { {-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} };
228
      int[][] indices = { {0,1,4},{2,0,4},{1,2,4},{3,1,0},{3,2,1},{3,0,2} };
229
      return new ObjectShape(vertices, indices);
230
      }
231
    else
232
      {
233
      float[][] vertices =
234
        { { 0.50f, 0.50f, 0.00f }, {-1.00f, 0.50f, 0.00f }, { 0.50f,-1.00f, 0.00f }, {-0.25f,-0.25f,-0.75f } };
235
      int[][] indices = { { 0,1,2 },{ 2,1,3 },{ 3,1,0 },{ 3,0,2 } };
236
      return new ObjectShape(vertices, indices);
237
      }
238
    }
239

    
240
///////////////////////////////////////////////////////////////////////////////////////////////////
241

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

    
266
///////////////////////////////////////////////////////////////////////////////////////////////////
267

    
268
  public int getNumCubitVariants(int[] numLayers)
269
    {
270
    return 2;
271
    }
272

    
273
///////////////////////////////////////////////////////////////////////////////////////////////////
274

    
275
  public int getCubitVariant(int cubit, int[] numLayers)
276
    {
277
    return cubit<8 ? 0:1;
278
    }
279

    
280
///////////////////////////////////////////////////////////////////////////////////////////////////
281

    
282
  public float getStickerRadius()
283
    {
284
    return 0.08f;
285
    }
286

    
287
///////////////////////////////////////////////////////////////////////////////////////////////////
288

    
289
  public float getStickerStroke()
290
    {
291
    return ObjectControl.isInIconMode() ? 0.20f : 0.10f;
292
    }
293

    
294
///////////////////////////////////////////////////////////////////////////////////////////////////
295

    
296
  public float[][] getStickerAngles()
297
    {
298
    return null;
299
    }
300

    
301
///////////////////////////////////////////////////////////////////////////////////////////////////
302
// PUBLIC API
303

    
304
  public Static3D[] getRotationAxis()
305
    {
306
    return ROT_AXIS;
307
    }
308

    
309
///////////////////////////////////////////////////////////////////////////////////////////////////
310

    
311
  public int[] getBasicAngles()
312
    {
313
    if( mBasicAngle ==null ) mBasicAngle = new int[] { 2,2,2,2,2,2 };
314
    return mBasicAngle;
315
    }
316

    
317
///////////////////////////////////////////////////////////////////////////////////////////////////
318

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

    
324
///////////////////////////////////////////////////////////////////////////////////////////////////
325

    
326
  public long getSignature()
327
    {
328
    return ObjectType.HELI_3.ordinal();
329
    }
330

    
331
///////////////////////////////////////////////////////////////////////////////////////////////////
332

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

    
338
///////////////////////////////////////////////////////////////////////////////////////////////////
339

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

    
345
///////////////////////////////////////////////////////////////////////////////////////////////////
346

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

    
352
///////////////////////////////////////////////////////////////////////////////////////////////////
353

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

    
359
///////////////////////////////////////////////////////////////////////////////////////////////////
360

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