Project

General

Profile

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

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

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2021 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// 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
///////////////////////////////////////////////////////////////////////////////////////////////////
9

    
10
package org.distorted.objectlib.objects;
11

    
12
import java.io.InputStream;
13

    
14
import org.distorted.library.type.Static3D;
15
import org.distorted.library.type.Static4D;
16

    
17
import org.distorted.objectlib.helpers.ObjectFaceShape;
18
import org.distorted.objectlib.helpers.ObjectSignature;
19
import org.distorted.objectlib.main.InitData;
20
import org.distorted.objectlib.main.ObjectType;
21
import org.distorted.objectlib.helpers.ObjectShape;
22
import org.distorted.objectlib.scrambling.ScrambleState;
23

    
24
///////////////////////////////////////////////////////////////////////////////////////////////////
25

    
26
public class TwistySquare2 extends TwistySquare
27
{
28
  private ScrambleState[] mStates;
29
  private int[] mQuatIndex;
30
  private float[][] mCenters;
31

    
32
///////////////////////////////////////////////////////////////////////////////////////////////////
33

    
34
  public TwistySquare2(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
35
    {
36
    super(data, meshState, iconMode, quat, move, scale, stream);
37
    }
38

    
39
///////////////////////////////////////////////////////////////////////////////////////////////////
40

    
41
  @Override
42
  public int[][] getSolvedQuats()
43
    {
44
    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
    }
51

    
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53

    
54
  public ScrambleState[] getScrambleStates()
55
    {
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
///////////////////////////////////////////////////////////////////////////////////////////////////
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
         { 1.5f, 0.0f, 0.0f }, // 0
88
         {-1.5f, 0.0f, 0.0f },
89

    
90
         { 0.0f, 1.0f, 1.5f }, // 2
91
         { 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
         {    Y, 1.0f, 1.5f }, // 10
100
         { 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
         { 1.5f, 1.0f,    Y }, // 18
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
         {   -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
    if( mQuatIndex==null )
127
      {
128
      mQuatIndex = new int[]
129
        {
130
        0, 6,
131
        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
        };
134
      }
135

    
136
    return mObjectQuats[mQuatIndex[cubit]];
137
    }
138

    
139
///////////////////////////////////////////////////////////////////////////////////////////////////
140

    
141
  public ObjectShape getObjectShape(int variant)
142
    {
143
    if( variant==0 )
144
      {
145
      float[][] vertices =
146
        {
147
         { -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
        };
156

    
157
      int[][] indices =
158
        {
159
         {4,5,1,0},
160
         {5,6,2,1},
161
         {6,7,3,2},
162
         {7,4,0,3},
163
         {0,1,2,3},
164
         {7,6,5,4}
165
        };
166

    
167
      return new ObjectShape(vertices, indices);
168
      }
169
    else if( variant==1 )
170
      {
171
      float[][] vertices =
172
        {
173
         {  -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
        };
180

    
181
      int[][] indices =
182
        {
183
         {0,1,2},
184
         {3,4,1,0},
185
         {5,4,3},
186
         {4,5,2,1},
187
         {5,3,0,2}
188
        };
189

    
190
      return new ObjectShape(vertices, indices);
191
      }
192
    else
193
      {
194
      float[][] vertices =
195
        {
196
         {-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
        };
203
      int[][] indices =
204
        {
205
         {0,1,2},
206
         {3,4,1,0},
207
         {5,4,3},
208
         {4,5,2,1},
209
         {5,3,0,2}
210
        };
211

    
212
      return new ObjectShape(vertices, indices);
213
      }
214
    }
215

    
216
///////////////////////////////////////////////////////////////////////////////////////////////////
217

    
218
  public ObjectFaceShape getObjectFaceShape(int variant)
219
    {
220
    if( variant==0 )
221
      {
222
      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
      int[] bandIndices   = { 0,0,1,2,2,2 };
226
      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
      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
      int[] bandIndices   = { 0,0,0,1,1 };
237
      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
      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
      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
      }
254
    }
255

    
256
///////////////////////////////////////////////////////////////////////////////////////////////////
257

    
258
  public int getNumCubitVariants(int[] numLayers)
259
    {
260
    return 3;
261
    }
262

    
263
///////////////////////////////////////////////////////////////////////////////////////////////////
264

    
265
  public int getCubitVariant(int cubit, int[] numLayers)
266
    {
267
    return cubit<2 ? 0 : (cubit<10 ? 1:2);
268
    }
269

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

    
272
  public float getStickerRadius()
273
    {
274
    return 0.12f;
275
    }
276

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

    
279
  public float getStickerStroke()
280
    {
281
    return isInIconMode() ? 0.20f : 0.10f;
282
    }
283

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

    
286
  public float[][] getStickerAngles()
287
    {
288
    return null;
289
    }
290

    
291
///////////////////////////////////////////////////////////////////////////////////////////////////
292
// PUBLIC API
293

    
294
  public String getShortName()
295
    {
296
    return ObjectType.SQU2_3.name();
297
    }
298

    
299
///////////////////////////////////////////////////////////////////////////////////////////////////
300

    
301
  public ObjectSignature getSignature()
302
    {
303
    return new ObjectSignature(ObjectType.SQU2_3);
304
    }
305

    
306
///////////////////////////////////////////////////////////////////////////////////////////////////
307

    
308
  public String getObjectName()
309
    {
310
    return "Square-2";
311
    }
312

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

    
315
  public String getInventor()
316
    {
317
    return "David Litwin";
318
    }
319

    
320
///////////////////////////////////////////////////////////////////////////////////////////////////
321

    
322
  public int getYearOfInvention()
323
    {
324
    return 1995;
325
    }
326

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

    
329
  public int getComplexity()
330
    {
331
    return 3;
332
    }
333

    
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
                          {"vn","_37Pc8Y_-Hs","Square-2 Tutorial","VĂN CÔNG TÙNG"},
348
                         };
349
    }
350
}
(31-31/36)