Project

General

Profile

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

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

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