Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyHelicopter.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_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.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 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, 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
  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
             {  -XY_CENTER  ,    -XY_CENTER,   DIST_CENTER },
178
             {  -XY_CENTER  ,     XY_CENTER,   DIST_CENTER },
179
             {   XY_CENTER  ,    -XY_CENTER,   DIST_CENTER },
180
             {   XY_CENTER  ,     XY_CENTER,   DIST_CENTER },
181
             {  -XY_CENTER  ,    -XY_CENTER,  -DIST_CENTER },
182
             {  -XY_CENTER  ,     XY_CENTER,  -DIST_CENTER },
183
             {   XY_CENTER  ,    -XY_CENTER,  -DIST_CENTER },
184
             {   XY_CENTER  ,     XY_CENTER,  -DIST_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
             {  -XY_CENTER  ,  -DIST_CENTER,    -XY_CENTER },
191
             {  -XY_CENTER  ,  -DIST_CENTER,     XY_CENTER },
192
             {   XY_CENTER  ,  -DIST_CENTER,    -XY_CENTER },
193
             {   XY_CENTER  ,  -DIST_CENTER,     XY_CENTER },
194

    
195
             {   DIST_CENTER,    -XY_CENTER,    -XY_CENTER },
196
             {   DIST_CENTER,    -XY_CENTER,     XY_CENTER },
197
             {   DIST_CENTER,     XY_CENTER,    -XY_CENTER },
198
             {   DIST_CENTER,     XY_CENTER,     XY_CENTER },
199
             {  -DIST_CENTER,    -XY_CENTER,    -XY_CENTER },
200
             {  -DIST_CENTER,    -XY_CENTER,     XY_CENTER },
201
             {  -DIST_CENTER,     XY_CENTER,    -XY_CENTER },
202
             {  -DIST_CENTER,     XY_CENTER,     XY_CENTER },
203
         };
204
      }
205

    
206
    return mCenters;
207
    }
208

    
209
///////////////////////////////////////////////////////////////////////////////////////////////////
210

    
211
  public Static4D getCubitQuats(int cubit, int[] numLayers)
212
    {
213
    if( mQuatIndices==null ) mQuatIndices = new int[] {  0,19,21, 7,18,16,17, 3,
214

    
215
                                                         0,21,20,17, 6, 7,16, 5,
216
                                                        10,22, 2,11,23,14,15, 1,
217
                                                         8,19, 4,12,18,13, 9, 3
218
                                                        };
219
    return mObjectQuats[mQuatIndices[cubit]];
220
    }
221

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

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

    
242
///////////////////////////////////////////////////////////////////////////////////////////////////
243

    
244
  public ObjectFaceShape getObjectFaceShape(int variant)
245
    {
246
    float height = isInIconMode() ? 0.001f : 0.028f;
247

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

    
270
///////////////////////////////////////////////////////////////////////////////////////////////////
271

    
272
  public int getNumCubitVariants(int[] numLayers)
273
    {
274
    return 2;
275
    }
276

    
277
///////////////////////////////////////////////////////////////////////////////////////////////////
278

    
279
  public int getCubitVariant(int cubit, int[] numLayers)
280
    {
281
    return cubit<8 ? 0:1;
282
    }
283

    
284
///////////////////////////////////////////////////////////////////////////////////////////////////
285

    
286
  public float getStickerRadius()
287
    {
288
    return 0.08f;
289
    }
290

    
291
///////////////////////////////////////////////////////////////////////////////////////////////////
292

    
293
  public float getStickerStroke()
294
    {
295
    return isInIconMode() ? 0.20f : 0.10f;
296
    }
297

    
298
///////////////////////////////////////////////////////////////////////////////////////////////////
299

    
300
  public float[][] getStickerAngles()
301
    {
302
    return null;
303
    }
304

    
305
///////////////////////////////////////////////////////////////////////////////////////////////////
306
// PUBLIC API
307

    
308
  public Static3D[] getRotationAxis()
309
    {
310
    return ROT_AXIS;
311
    }
312

    
313
///////////////////////////////////////////////////////////////////////////////////////////////////
314

    
315
  public int[][] getBasicAngles()
316
    {
317
    if( mBasicAngle ==null )
318
      {
319
      int num = getNumLayers()[0];
320
      int[] tmp = new int[num];
321
      for(int i=0; i<num; i++) tmp[i] = 2;
322
      mBasicAngle = new int[][] { tmp,tmp,tmp,tmp,tmp,tmp };
323
      }
324
    return mBasicAngle;
325
    }
326

    
327
///////////////////////////////////////////////////////////////////////////////////////////////////
328

    
329
  public String getShortName()
330
    {
331
    return ObjectType.HELI_3.name();
332
    }
333

    
334
///////////////////////////////////////////////////////////////////////////////////////////////////
335

    
336
  public ObjectSignature getSignature()
337
    {
338
    return new ObjectSignature(ObjectType.HELI_3);
339
    }
340

    
341
///////////////////////////////////////////////////////////////////////////////////////////////////
342

    
343
  public String getObjectName()
344
    {
345
    return "Helicopter Cube";
346
    }
347

    
348
///////////////////////////////////////////////////////////////////////////////////////////////////
349

    
350
  public String getInventor()
351
    {
352
    return "Adam G. Cowan";
353
    }
354

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

    
357
  public int getYearOfInvention()
358
    {
359
    return 2006;
360
    }
361

    
362
///////////////////////////////////////////////////////////////////////////////////////////////////
363

    
364
  public int getComplexity()
365
    {
366
    return 3;
367
    }
368

    
369
///////////////////////////////////////////////////////////////////////////////////////////////////
370

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