Project

General

Profile

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

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

1 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
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 c9c71c3f Leszek Koltunski
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_HEXAHEDRON;
23
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_SPLIT_EDGE;
24 29b82486 Leszek Koltunski
25 82eb152a Leszek Koltunski
import java.io.InputStream;
26 29b82486 Leszek Koltunski
27
import org.distorted.library.type.Static3D;
28
import org.distorted.library.type.Static4D;
29
30 3ee1d662 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectFaceShape;
31 c9c71c3f Leszek Koltunski
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
32 8005e762 Leszek Koltunski
import org.distorted.objectlib.main.ObjectType;
33 198c5bf0 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectShape;
34 10b7e306 Leszek Koltunski
import org.distorted.objectlib.scrambling.ScrambleState;
35 386af988 Leszek Koltunski
import org.distorted.objectlib.main.ShapeHexahedron;
36 29b82486 Leszek Koltunski
37
///////////////////////////////////////////////////////////////////////////////////////////////////
38
39 386af988 Leszek Koltunski
public class TwistyHelicopter extends ShapeHexahedron
40 29b82486 Leszek Koltunski
{
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 beee90ab Leszek Koltunski
  private int[][] mBasicAngle;
53 29b82486 Leszek Koltunski
  private float[][] mCuts;
54
  private float[][] mCenters;
55
  private int[] mQuatIndices;
56
57
///////////////////////////////////////////////////////////////////////////////////////////////////
58
59 3bf19410 Leszek Koltunski
  public TwistyHelicopter(int[] numL, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
60 29b82486 Leszek Koltunski
    {
61 3bf19410 Leszek Koltunski
    super(numL, meshState, iconMode, numL[0], quat, move, scale, stream);
62 29b82486 Leszek Koltunski
    }
63
64
///////////////////////////////////////////////////////////////////////////////////////////////////
65
66 f9a81f52 Leszek Koltunski
  public ScrambleState[] getScrambleStates()
67 29b82486 Leszek Koltunski
    {
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 7bbfc84f Leszek Koltunski
  public float[][] getCuts(int[] numLayers)
94 29b82486 Leszek Koltunski
    {
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 59c20632 Leszek Koltunski
  public boolean[][] getLayerRotatable(int[] numLayers)
107
    {
108
    boolean[] tmp = new boolean[] {true,false,true};
109 974a0e69 Leszek Koltunski
    return new boolean[][] { tmp,tmp,tmp,tmp,tmp,tmp };
110 59c20632 Leszek Koltunski
    }
111
112
///////////////////////////////////////////////////////////////////////////////////////////////////
113
114 11fa413d Leszek Koltunski
  public int getTouchControlType()
115 59c20632 Leszek Koltunski
    {
116 c9c71c3f Leszek Koltunski
    return TC_HEXAHEDRON;
117 59c20632 Leszek Koltunski
    }
118
119
///////////////////////////////////////////////////////////////////////////////////////////////////
120
121 11fa413d Leszek Koltunski
  public int getTouchControlSplit()
122 59c20632 Leszek Koltunski
    {
123
    return TYPE_SPLIT_EDGE;
124
    }
125
126
///////////////////////////////////////////////////////////////////////////////////////////////////
127
128
  public int[][][] getEnabled()
129 29b82486 Leszek Koltunski
    {
130 59c20632 Leszek Koltunski
    return new int[][][]
131 29b82486 Leszek Koltunski
      {
132 59c20632 Leszek Koltunski
          {{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 4c9ca251 Leszek Koltunski
    return TouchControlHexahedron.D3D;
146
    }
147
148
///////////////////////////////////////////////////////////////////////////////////////////////////
149
150
  public Static3D[] getFaceAxis()
151
    {
152
    return TouchControlHexahedron.FACE_AXIS;
153 29b82486 Leszek Koltunski
    }
154
155
///////////////////////////////////////////////////////////////////////////////////////////////////
156
157 7b832206 Leszek Koltunski
  public float[][] getCubitPositions(int[] numLayers)
158 29b82486 Leszek Koltunski
    {
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 eaf53357 Leszek Koltunski
             {  -XY_CENTER  ,    -XY_CENTER,   DIST_CENTER },
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 29b82486 Leszek Koltunski
185
             {  -XY_CENTER  ,   DIST_CENTER,    -XY_CENTER },
186 eaf53357 Leszek Koltunski
             {  -XY_CENTER  ,   DIST_CENTER,     XY_CENTER },
187
             {   XY_CENTER  ,   DIST_CENTER,    -XY_CENTER },
188
             {   XY_CENTER  ,   DIST_CENTER,     XY_CENTER },
189 29b82486 Leszek Koltunski
             {  -XY_CENTER  ,  -DIST_CENTER,    -XY_CENTER },
190 eaf53357 Leszek Koltunski
             {  -XY_CENTER  ,  -DIST_CENTER,     XY_CENTER },
191
             {   XY_CENTER  ,  -DIST_CENTER,    -XY_CENTER },
192
             {   XY_CENTER  ,  -DIST_CENTER,     XY_CENTER },
193 29b82486 Leszek Koltunski
194 eaf53357 Leszek Koltunski
             {   DIST_CENTER,    -XY_CENTER,    -XY_CENTER },
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 29b82486 Leszek Koltunski
         };
203
      }
204
205
    return mCenters;
206
    }
207
208 d0e6cf7f Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
209
210
  public Static4D getCubitQuats(int cubit, int[] numLayers)
211
    {
212 82e62580 Leszek Koltunski
    if( mQuatIndices==null ) mQuatIndices = new int[] {  0,19,21, 7,18,16,17, 3,
213 eaf53357 Leszek Koltunski
214
                                                         0,21,20,17, 6, 7,16, 5,
215
                                                        10,22, 2,11,23,14,15, 1,
216
                                                         8,19, 4,12,18,13, 9, 3
217
                                                        };
218 974a0e69 Leszek Koltunski
    return mObjectQuats[mQuatIndices[cubit]];
219 d0e6cf7f Leszek Koltunski
    }
220
221 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
222
223 e30c522a Leszek Koltunski
  public ObjectShape getObjectShape(int variant)
224 29b82486 Leszek Koltunski
    {
225
    if( variant==0 )
226
      {
227 4e9f2df5 Leszek Koltunski
      float[][] vertices =
228 3ee1d662 Leszek Koltunski
        { {-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} };
229 4e9f2df5 Leszek Koltunski
      int[][] indices = { {0,1,4},{2,0,4},{1,2,4},{3,1,0},{3,2,1},{3,0,2} };
230 59a971c1 Leszek Koltunski
      return new ObjectShape(vertices, indices);
231 3ee1d662 Leszek Koltunski
      }
232
    else
233
      {
234 4e9f2df5 Leszek Koltunski
      float[][] vertices =
235 3ee1d662 Leszek Koltunski
        { { 0.50f, 0.50f, 0.00f }, {-1.00f, 0.50f, 0.00f }, { 0.50f,-1.00f, 0.00f }, {-0.25f,-0.25f,-0.75f } };
236 846b69f3 Leszek Koltunski
      int[][] indices = { { 0,1,2 },{ 2,1,3 },{ 3,1,0 },{ 3,0,2 } };
237 59a971c1 Leszek Koltunski
      return new ObjectShape(vertices, indices);
238 3ee1d662 Leszek Koltunski
      }
239
    }
240
241
///////////////////////////////////////////////////////////////////////////////////////////////////
242
243
  public ObjectFaceShape getObjectFaceShape(int variant)
244
    {
245 3bf19410 Leszek Koltunski
    float height = isInIconMode() ? 0.001f : 0.028f;
246
247 3ee1d662 Leszek Koltunski
    if( variant==0 )
248
      {
249 3bf19410 Leszek Koltunski
      float[][] bands     = { {height,35,0.16f,0.7f,7,3,3}, {0.001f, 0,1.00f,0.0f,3,1,5} };
250 4e9f2df5 Leszek Koltunski
      int[] bandIndices   = { 0,0,0,1,1,1 };
251
      float[][] corners   = { {0.08f,0.20f} };
252
      int[] cornerIndices = { 0,0,0,0,0 };
253
      float[][] centers   = { {-0.75f, -0.75f, -0.75f} };
254
      int[] centerIndices = { 0,0,0,-1,0 };
255 3ee1d662 Leszek Koltunski
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
256 29b82486 Leszek Koltunski
      }
257
    else
258
      {
259 3bf19410 Leszek Koltunski
      float[][] bands     = { {height,35,0.16f,0.7f,7,3,3}, {0.001f, 0,1.00f,0.0f,3,1,3} };
260 4e9f2df5 Leszek Koltunski
      int[] bandIndices   = { 0,1,1,1 };
261
      float[][] corners   = { {0.06f,0.20f} };
262
      int[] cornerIndices = { 0,0,0,-1 };
263
      float[][] centers   = { {-0.25f, -0.25f, -0.75f} };
264
      int[] centerIndices = { 0,0,0,-1 };
265 3ee1d662 Leszek Koltunski
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
266 29b82486 Leszek Koltunski
      }
267
    }
268
269
///////////////////////////////////////////////////////////////////////////////////////////////////
270
271 e30c522a Leszek Koltunski
  public int getNumCubitVariants(int[] numLayers)
272 29b82486 Leszek Koltunski
    {
273
    return 2;
274
    }
275
276
///////////////////////////////////////////////////////////////////////////////////////////////////
277
278 e30c522a Leszek Koltunski
  public int getCubitVariant(int cubit, int[] numLayers)
279 29b82486 Leszek Koltunski
    {
280
    return cubit<8 ? 0:1;
281
    }
282
283 3d766df3 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
284
285 d53fb890 Leszek Koltunski
  public float getStickerRadius()
286 3d766df3 Leszek Koltunski
    {
287 00f4980d Leszek Koltunski
    return 0.08f;
288 3d766df3 Leszek Koltunski
    }
289
290
///////////////////////////////////////////////////////////////////////////////////////////////////
291
292 d53fb890 Leszek Koltunski
  public float getStickerStroke()
293 3d766df3 Leszek Koltunski
    {
294 3bf19410 Leszek Koltunski
    return isInIconMode() ? 0.20f : 0.10f;
295 3d766df3 Leszek Koltunski
    }
296
297 00f4980d Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
298
299 d53fb890 Leszek Koltunski
  public float[][] getStickerAngles()
300 00f4980d Leszek Koltunski
    {
301
    return null;
302
    }
303
304 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
305
// PUBLIC API
306
307
  public Static3D[] getRotationAxis()
308
    {
309
    return ROT_AXIS;
310
    }
311
312
///////////////////////////////////////////////////////////////////////////////////////////////////
313
314 beee90ab Leszek Koltunski
  public int[][] getBasicAngles()
315 29b82486 Leszek Koltunski
    {
316 beee90ab Leszek Koltunski
    if( mBasicAngle ==null )
317
      {
318
      int num = getNumLayers()[0];
319
      int[] tmp = new int[num];
320
      for(int i=0; i<num; i++) tmp[i] = 2;
321
      mBasicAngle = new int[][] { tmp,tmp,tmp,tmp,tmp,tmp };
322
      }
323 29b82486 Leszek Koltunski
    return mBasicAngle;
324
    }
325
326 61aa85e4 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
327
328 5f54927b Leszek Koltunski
  public String getShortName()
329 61aa85e4 Leszek Koltunski
    {
330 5f54927b Leszek Koltunski
    return ObjectType.HELI_3.name();
331
    }
332
333
///////////////////////////////////////////////////////////////////////////////////////////////////
334
335
  public long getSignature()
336
    {
337
    return ObjectType.HELI_3.ordinal();
338 61aa85e4 Leszek Koltunski
    }
339
340 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
341
342 e26eb4e7 Leszek Koltunski
  public String getObjectName()
343 29b82486 Leszek Koltunski
    {
344 e26eb4e7 Leszek Koltunski
    return "Helicopter Cube";
345 29b82486 Leszek Koltunski
    }
346
347
///////////////////////////////////////////////////////////////////////////////////////////////////
348
349 e26eb4e7 Leszek Koltunski
  public String getInventor()
350 29b82486 Leszek Koltunski
    {
351 e26eb4e7 Leszek Koltunski
    return "Adam G. Cowan";
352 29b82486 Leszek Koltunski
    }
353
354 59c20632 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
355
356 e26eb4e7 Leszek Koltunski
  public int getYearOfInvention()
357 59c20632 Leszek Koltunski
    {
358
    return 2006;
359
    }
360
361 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
362
363 e26eb4e7 Leszek Koltunski
  public int getComplexity()
364 29b82486 Leszek Koltunski
    {
365 b4223a92 Leszek Koltunski
    return 3;
366 29b82486 Leszek Koltunski
    }
367 052e0362 Leszek Koltunski
368
///////////////////////////////////////////////////////////////////////////////////////////////////
369
370
  public String[][] getTutorials()
371
    {
372
    return new String[][]{
373
                          {"gb","-suwJpd_PO8","Helicopter Cube Tutorial","Bearded Cubing"},
374
                          {"es","DWG9n_YyGPA","Resolver Helicopter Cube","Cuby"},
375
                          {"ru","V4lJ3pg7Hio","Как собрать Куб Вертолет","Алексей Ярыгин"},
376
                          {"fr","Zk8zWBWD2Ow","Comment résoudre le Helicopter Cube","Julien"},
377
                          {"de","6VUH_FkBTlw","Helicopter Cube Tutorial","GerCubing"},
378
                          {"pl","zoBZame4gFo","Helicopter Cube TUTORIAL PL","MrUk"},
379
                          {"br","k8PVOARh6Kk","Como resolver o Helicopter Cube 1/3","Rafael Cinoto"},
380
                          {"br","6d4JLfuIwOQ","Como resolver o Helicopter Cube 2/3","Rafael Cinoto"},
381
                          {"br","moiV-2oWgrA","Como resolver o Helicopter Cube 3/3","Rafael Cinoto"},
382
                          {"kr","xsXQSrEbgag","헬리콥터 큐브를 맞추는 법","연서큐브박"},
383 a399e91b Leszek Koltunski
                          {"vn","Ff6-IHhQHGY","Tutorial N.89 - Helicopter","Duy Thích Rubik"},
384 052e0362 Leszek Koltunski
                         };
385
    }
386 29b82486 Leszek Koltunski
}