Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistySquare2.java @ a4af26c1

1 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2021 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 82eb152a Leszek Koltunski
import java.io.InputStream;
23 29b82486 Leszek Koltunski
24 ecf3d6e3 Leszek Koltunski
import org.distorted.library.type.Static3D;
25 29b82486 Leszek Koltunski
import org.distorted.library.type.Static4D;
26
27 3ee1d662 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectFaceShape;
28 8005e762 Leszek Koltunski
import org.distorted.objectlib.main.ObjectType;
29 198c5bf0 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectShape;
30 10b7e306 Leszek Koltunski
import org.distorted.objectlib.scrambling.ScrambleState;
31 29b82486 Leszek Koltunski
32
///////////////////////////////////////////////////////////////////////////////////////////////////
33
34
public class TwistySquare2 extends TwistySquare
35
{
36
  private ScrambleState[] mStates;
37 82e62580 Leszek Koltunski
  private int[] mQuatIndex;
38 29b82486 Leszek Koltunski
  private float[][] mCenters;
39
40
///////////////////////////////////////////////////////////////////////////////////////////////////
41
42 3bf19410 Leszek Koltunski
  public TwistySquare2(int[] numL, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
43 29b82486 Leszek Koltunski
    {
44 3bf19410 Leszek Koltunski
    super(numL, meshState, iconMode, quat, move, scale, stream);
45 29b82486 Leszek Koltunski
    }
46
47 1b7ece90 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
48
49 ed0988c0 Leszek Koltunski
  @Override
50 19595510 Leszek Koltunski
  public int[][] getSolvedQuats()
51 1b7ece90 Leszek Koltunski
    {
52 ed0988c0 Leszek Koltunski
    return new int[][]
53
      {
54
        { 2, 0,1 },                                   // 2 middle cubits in the first group
55
        {12, 2,4,6,8,10,12,14,16,19,21,23,25,  17 },  // 12 front and back edges and corners in the second group with quat[17]
56
        {12, 3,5,7,9,11,13,15,17,18,20,22,24,  23 }   // 12 left and right edges and corners in the third group with quat[23]
57
      };
58 1b7ece90 Leszek Koltunski
    }
59
60 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
61
62 f9a81f52 Leszek Koltunski
  public ScrambleState[] getScrambleStates()
63 29b82486 Leszek Koltunski
    {
64
    if( mStates==null )
65
      {
66
      int[] SL_6 = new int[] { 0,1,1, 1,1,1, 0,1,1, 1,1,1, 0,1,1, 1,1,1, 0,1,1, 1,1,1, 0,1,1, 1,1,1, 0,1,1, 1,1,1};
67
      int[] SL_1 = new int[] { 0,1,1, 1,1,1 };
68
      int[] LO_2 = new int[] { 0,-5,2, 0,-4,2, 0,-3,2, 0,-2,2, 0,-1,2, 0,1,2, 0,2,2, 0,3,2, 0,4,2, 0,5,2, 0,5,2 };
69
      int[] LO_3 = new int[] { 0,-5,3, 0,-4,3, 0,-3,3, 0,-2,3, 0,-1,3, 0,1,3, 0,2,3, 0,3,3, 0,4,3, 0,5,3, 0,5,3 };
70
      int[] LO_4 = new int[] { 0,-5,4, 0,-4,4, 0,-3,4, 0,-2,4, 0,-1,4, 0,1,4, 0,2,4, 0,3,4, 0,4,4, 0,5,4, 0,5,4 };
71
72
      mStates = new ScrambleState[]
73
        {
74
        new ScrambleState( new int[][] { LO_2, SL_6, LO_3 } ),  // 0
75
        new ScrambleState( new int[][] { LO_2, null, LO_3 } ),  // SL
76
        new ScrambleState( new int[][] { null, SL_1, LO_4 } ),  // LO
77
        new ScrambleState( new int[][] { LO_4, SL_1, null } ),  // UP
78
        new ScrambleState( new int[][] { null, SL_1, null } ),  // UL
79
        };
80
      }
81
82
    return mStates;
83
    }
84
85 d0e6cf7f Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
86
87
  public float[][] getCubitPositions(int[] numLayers)
88
    {
89
    if( mCenters ==null )
90
      {
91
      float Y = 0.75f + X/2;
92
93
      mCenters = new float[][]
94
        {
95 ed0988c0 Leszek Koltunski
         { 1.5f, 0.0f, 0.0f }, // 0
96 d0e6cf7f Leszek Koltunski
         {-1.5f, 0.0f, 0.0f },
97
98 ed0988c0 Leszek Koltunski
         { 0.0f, 1.0f, 1.5f }, // 2
99 d0e6cf7f Leszek Koltunski
         { 1.5f, 1.0f, 0.0f },
100
         { 0.0f, 1.0f,-1.5f },
101
         {-1.5f, 1.0f, 0.0f },
102
         { 0.0f,-1.0f, 1.5f },
103
         { 1.5f,-1.0f, 0.0f },
104
         { 0.0f,-1.0f,-1.5f },
105
         {-1.5f,-1.0f, 0.0f },
106
107 ed0988c0 Leszek Koltunski
         {    Y, 1.0f, 1.5f }, // 10
108 d0e6cf7f Leszek Koltunski
         { 1.5f, 1.0f,   -Y },
109
         {   -Y, 1.0f,-1.5f },
110
         {-1.5f, 1.0f,    Y },
111
         {    Y,-1.0f, 1.5f },
112
         { 1.5f,-1.0f,   -Y },
113
         {   -Y,-1.0f,-1.5f },
114
         {-1.5f,-1.0f,    Y },
115
116 ed0988c0 Leszek Koltunski
         { 1.5f, 1.0f,    Y }, // 18
117 d0e6cf7f Leszek Koltunski
         {    Y, 1.0f,-1.5f },
118
         {-1.5f, 1.0f,   -Y },
119
         {   -Y, 1.0f, 1.5f },
120
         { 1.5f,-1.0f,    Y },
121
         {    Y,-1.0f,-1.5f },
122
         {-1.5f,-1.0f,   -Y },
123
         {   -Y,-1.0f, 1.5f },
124
        };
125
      }
126
127
    return mCenters;
128
    }
129
130
///////////////////////////////////////////////////////////////////////////////////////////////////
131
132
  public Static4D getCubitQuats(int cubit, int[] numLayers)
133
    {
134 82e62580 Leszek Koltunski
    if( mQuatIndex==null )
135 d0e6cf7f Leszek Koltunski
      {
136 82e62580 Leszek Koltunski
      mQuatIndex = new int[]
137 d0e6cf7f Leszek Koltunski
        {
138
        0, 6,
139 82e62580 Leszek Koltunski
        0, 9, 6, 3,17,14,23,20,
140
        0, 9, 6, 3, 0, 9, 6, 3,14, 23, 20, 17, 14, 23, 20, 17
141 d0e6cf7f Leszek Koltunski
        };
142
      }
143
144 82e62580 Leszek Koltunski
    return mObjectQuats[mQuatIndex[cubit]];
145 d0e6cf7f Leszek Koltunski
    }
146
147 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
148
149 e30c522a Leszek Koltunski
  public ObjectShape getObjectShape(int variant)
150 29b82486 Leszek Koltunski
    {
151
    if( variant==0 )
152
      {
153 4e9f2df5 Leszek Koltunski
      float[][] vertices =
154 29b82486 Leszek Koltunski
        {
155 57ef6378 Leszek Koltunski
         { -1.5f-X, 0.5f, 1.5f },
156
         {    0.0f, 0.5f, 1.5f },
157
         {    0.0f, 0.5f,-1.5f },
158
         { -1.5f+X, 0.5f,-1.5f },
159
         { -1.5f-X,-0.5f, 1.5f },
160
         {    0.0f,-0.5f, 1.5f },
161
         {    0.0f,-0.5f,-1.5f },
162
         { -1.5f+X,-0.5f,-1.5f }
163 29b82486 Leszek Koltunski
        };
164
165 4e9f2df5 Leszek Koltunski
      int[][] indices =
166 29b82486 Leszek Koltunski
        {
167
         {4,5,1,0},
168
         {5,6,2,1},
169
         {6,7,3,2},
170 33c707e8 Leszek Koltunski
         {7,4,0,3},
171
         {0,1,2,3},
172 846b69f3 Leszek Koltunski
         {7,6,5,4}
173 29b82486 Leszek Koltunski
        };
174
175 59a971c1 Leszek Koltunski
      return new ObjectShape(vertices, indices);
176 29b82486 Leszek Koltunski
      }
177
    else if( variant==1 )
178
      {
179 4e9f2df5 Leszek Koltunski
      float[][] vertices =
180 29b82486 Leszek Koltunski
        {
181 57ef6378 Leszek Koltunski
         {  -X, 0.5f, 0.0f },
182
         {  +X, 0.5f, 0.0f },
183
         {0.0f, 0.5f,-1.5f },
184
         {  -X,-0.5f, 0.0f },
185
         {  +X,-0.5f, 0.0f },
186
         {0.0f,-0.5f,-1.5f },
187 29b82486 Leszek Koltunski
        };
188
189 4e9f2df5 Leszek Koltunski
      int[][] indices =
190 29b82486 Leszek Koltunski
        {
191
         {0,1,2},
192
         {3,4,1,0},
193 846b69f3 Leszek Koltunski
         {5,4,3},
194 29b82486 Leszek Koltunski
         {4,5,2,1},
195
         {5,3,0,2}
196
        };
197
198 59a971c1 Leszek Koltunski
      return new ObjectShape(vertices, indices);
199 29b82486 Leszek Koltunski
      }
200
    else
201
      {
202 4e9f2df5 Leszek Koltunski
      float[][] vertices =
203 29b82486 Leszek Koltunski
        {
204 57ef6378 Leszek Koltunski
         {-0.75f+X/2, 0.5f,  0.0f },
205
         { 0.75f-X/2, 0.5f,  0.0f },
206
         {-0.75f-X/2, 0.5f, -1.5f },
207
         {-0.75f+X/2,-0.5f,  0.0f },
208
         { 0.75f-X/2,-0.5f,  0.0f },
209
         {-0.75f-X/2,-0.5f, -1.5f }
210 29b82486 Leszek Koltunski
        };
211 4e9f2df5 Leszek Koltunski
      int[][] indices =
212 29b82486 Leszek Koltunski
        {
213
         {0,1,2},
214
         {3,4,1,0},
215 c187cb69 Leszek Koltunski
         {5,4,3},
216 29b82486 Leszek Koltunski
         {4,5,2,1},
217
         {5,3,0,2}
218
        };
219
220 59a971c1 Leszek Koltunski
      return new ObjectShape(vertices, indices);
221 3ee1d662 Leszek Koltunski
      }
222
    }
223
224
///////////////////////////////////////////////////////////////////////////////////////////////////
225
226
  public ObjectFaceShape getObjectFaceShape(int variant)
227
    {
228
    if( variant==0 )
229
      {
230 3bf19410 Leszek Koltunski
      float h1 = isInIconMode() ? 0.001f : 0.04f;
231
      float h2 = isInIconMode() ? 0.001f : 0.02f;
232
      float[][] bands     = { {h1,35,0.2f,0.8f,5,2,1}, {h2,35,0.5f,1.0f,5,2,1}, {0.001f,35,0.3f,0.8f,5,2,1} };
233 846b69f3 Leszek Koltunski
      int[] bandIndices   = { 0,0,1,2,2,2 };
234 3ee1d662 Leszek Koltunski
      float[][] corners   = { {0.03f,0.05f} };
235
      int[] cornerIndices = { 0,0,0,0,0,0,0,0 };
236
      float[][] centers   = { { -0.75f, 0.0f, 0.0f} };
237
      int[] centerIndices = { 0,0,0,0,0,0,0,0 };
238
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
239
      }
240
    else if( variant==1 )
241
      {
242 3bf19410 Leszek Koltunski
      float h1 = isInIconMode() ? 0.001f : 0.038f;
243
      float[][] bands     = { {h1,35,0.5f,0.9f, 5,2,1}, {0.001f,35,0.5f,0.9f, 5,2,1} };
244 846b69f3 Leszek Koltunski
      int[] bandIndices   = { 0,0,0,1,1 };
245 3ee1d662 Leszek Koltunski
      float[][] corners   = { {0.04f,0.15f} };
246
      int[] cornerIndices = { 0,0,-1,0,0,-1 };
247
      float[][] centers   = { { 0.0f, 0.0f,-0.5f} };
248
      int[] centerIndices = { 0,0,-1,0,0,-1 };
249
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
250
      }
251
    else
252
      {
253 3bf19410 Leszek Koltunski
      float h1 = isInIconMode() ? 0.001f : 0.03f;
254
      float[][] bands     = { {h1,35,0.9f,1.0f, 5,2,1}, {0.001f,35,0.9f,1.0f, 5,2,1} };
255 3ee1d662 Leszek Koltunski
      int[] bandIndices   = { 0,0,0,1,1 };
256
      float[][] corners   = { {0.05f,0.13f} };
257
      int[] cornerIndices = { 0,0,-1,0,0,-1 };
258
      float[][] centers   = { { 0.0f, 0.0f,-0.5f} };
259
      int[] centerIndices = { 0,0,-1,0,0,-1 };
260
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
261 29b82486 Leszek Koltunski
      }
262
    }
263
264
///////////////////////////////////////////////////////////////////////////////////////////////////
265
266 e30c522a Leszek Koltunski
  public int getNumCubitVariants(int[] numLayers)
267 29b82486 Leszek Koltunski
    {
268
    return 3;
269
    }
270
271
///////////////////////////////////////////////////////////////////////////////////////////////////
272
273 e30c522a Leszek Koltunski
  public int getCubitVariant(int cubit, int[] numLayers)
274 29b82486 Leszek Koltunski
    {
275
    return cubit<2 ? 0 : (cubit<10 ? 1:2);
276
    }
277
278 89704841 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
279
280 d53fb890 Leszek Koltunski
  public float getStickerRadius()
281 89704841 Leszek Koltunski
    {
282
    return 0.12f;
283
    }
284
285
///////////////////////////////////////////////////////////////////////////////////////////////////
286
287 d53fb890 Leszek Koltunski
  public float getStickerStroke()
288 89704841 Leszek Koltunski
    {
289 3bf19410 Leszek Koltunski
    return isInIconMode() ? 0.20f : 0.10f;
290 89704841 Leszek Koltunski
    }
291
292
///////////////////////////////////////////////////////////////////////////////////////////////////
293
294 d53fb890 Leszek Koltunski
  public float[][] getStickerAngles()
295 89704841 Leszek Koltunski
    {
296
    return null;
297
    }
298
299 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
300
// PUBLIC API
301
302 5f54927b Leszek Koltunski
  public String getShortName()
303 61aa85e4 Leszek Koltunski
    {
304 5f54927b Leszek Koltunski
    return ObjectType.SQU2_3.name();
305
    }
306
307
///////////////////////////////////////////////////////////////////////////////////////////////////
308
309
  public long getSignature()
310
    {
311
    return ObjectType.SQU2_3.ordinal();
312 61aa85e4 Leszek Koltunski
    }
313
314
///////////////////////////////////////////////////////////////////////////////////////////////////
315
316 e26eb4e7 Leszek Koltunski
  public String getObjectName()
317 29b82486 Leszek Koltunski
    {
318 e26eb4e7 Leszek Koltunski
    return "Square-2";
319 29b82486 Leszek Koltunski
    }
320
321
///////////////////////////////////////////////////////////////////////////////////////////////////
322
323 e26eb4e7 Leszek Koltunski
  public String getInventor()
324 29b82486 Leszek Koltunski
    {
325 e26eb4e7 Leszek Koltunski
    return "David Litwin";
326 29b82486 Leszek Koltunski
    }
327
328 59c20632 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
329
330 e26eb4e7 Leszek Koltunski
  public int getYearOfInvention()
331 59c20632 Leszek Koltunski
    {
332
    return 1995;
333
    }
334
335 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
336
337 e26eb4e7 Leszek Koltunski
  public int getComplexity()
338 29b82486 Leszek Koltunski
    {
339 b4223a92 Leszek Koltunski
    return 3;
340 29b82486 Leszek Koltunski
    }
341 052e0362 Leszek Koltunski
342
///////////////////////////////////////////////////////////////////////////////////////////////////
343
344
  public String[][] getTutorials()
345
    {
346
    return new String[][] {
347
                          {"gb","PPXojiFthEs","Square-2 Tutorial","SuperAntoniovivaldi"},
348
                          {"es","IiMwc51xKBQ","Cómo resolver Square-2","skieur cubb"},
349
                          {"ru","XZ6m8uF5oUk","Как собрать Square-2.","Илья Топор-Гилка"},
350
                          {"fr","R-m9IgYAFPA","Tutoriel: résolution du Square-2","skieur cubb"},
351
                          {"pl","SukHyoMzcgM","Square-2 TUTORIAL PL","MrUk"},
352
                          {"br","T3ts5gHLJV8","Tutorial do Square-2 1/2","Rafael Cinoto"},
353
                          {"br","4wwWE5Ni0Fw","Tutorial do Square-2 2/2","Rafael Cinoto"},
354
                          {"kr","psG9Ar4pBrc","초보자를 위한 스퀘어2 해법","SlowCuberToumai"},
355 a399e91b Leszek Koltunski
                          {"vn","_37Pc8Y_-Hs","Square-2 Tutorial","VĂN CÔNG TÙNG"},
356 052e0362 Leszek Koltunski
                         };
357
    }
358 29b82486 Leszek Koltunski
}