Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyHelicopter.java @ 3bf19410

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.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 TwistyHelicopter extends ShapeHexahedron
40
{
41
  static final Static3D[] ROT_AXIS = new Static3D[]
42
         {
43
           new Static3D(     0, +SQ2/2, -SQ2/2),
44
           new Static3D(     0, -SQ2/2, -SQ2/2),
45
           new Static3D(+SQ2/2,      0, -SQ2/2),
46
           new Static3D(-SQ2/2,      0, -SQ2/2),
47
           new Static3D(+SQ2/2, -SQ2/2,      0),
48
           new Static3D(-SQ2/2, -SQ2/2,      0)
49
         };
50

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

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

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

    
88
    return mStates;
89
    }
90

    
91
///////////////////////////////////////////////////////////////////////////////////////////////////
92

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

    
101
    return mCuts;
102
    }
103

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

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

    
112
///////////////////////////////////////////////////////////////////////////////////////////////////
113

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

    
119
///////////////////////////////////////////////////////////////////////////////////////////////////
120

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

    
126
///////////////////////////////////////////////////////////////////////////////////////////////////
127

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

    
141
///////////////////////////////////////////////////////////////////////////////////////////////////
142

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

    
148
///////////////////////////////////////////////////////////////////////////////////////////////////
149

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

    
155
///////////////////////////////////////////////////////////////////////////////////////////////////
156

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

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

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

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

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

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

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

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

    
208
    return mCenters;
209
    }
210

    
211
///////////////////////////////////////////////////////////////////////////////////////////////////
212

    
213
  public Static4D getCubitQuats(int cubit, int[] numLayers)
214
    {
215
    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 };
216
    return mObjectQuats[mQuatIndices[cubit]];
217
    }
218

    
219
///////////////////////////////////////////////////////////////////////////////////////////////////
220

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

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

    
241
  public ObjectFaceShape getObjectFaceShape(int variant)
242
    {
243
    float height = isInIconMode() ? 0.001f : 0.028f;
244

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

    
267
///////////////////////////////////////////////////////////////////////////////////////////////////
268

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

    
274
///////////////////////////////////////////////////////////////////////////////////////////////////
275

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

    
281
///////////////////////////////////////////////////////////////////////////////////////////////////
282

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

    
288
///////////////////////////////////////////////////////////////////////////////////////////////////
289

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

    
295
///////////////////////////////////////////////////////////////////////////////////////////////////
296

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

    
302
///////////////////////////////////////////////////////////////////////////////////////////////////
303
// PUBLIC API
304

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

    
310
///////////////////////////////////////////////////////////////////////////////////////////////////
311

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

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

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

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

    
327
  public long getSignature()
328
    {
329
    return ObjectType.HELI_3.ordinal();
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
}
(16-16/34)