Project

General

Profile

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

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

1
///////////////////////////////////////////////////////////////////////////////////////////////////
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
import java.io.InputStream;
23

    
24
import org.distorted.library.type.Static3D;
25
import org.distorted.library.type.Static4D;
26

    
27
import org.distorted.objectlib.helpers.ObjectFaceShape;
28
import org.distorted.objectlib.main.ObjectControl;
29
import org.distorted.objectlib.main.ObjectType;
30
import org.distorted.objectlib.helpers.ObjectShape;
31
import org.distorted.objectlib.scrambling.ScrambleState;
32

    
33
///////////////////////////////////////////////////////////////////////////////////////////////////
34

    
35
public class TwistySquare2 extends TwistySquare
36
{
37
  private ScrambleState[] mStates;
38
  private int[] mQuatNumber;
39
  private float[][] mCenters;
40

    
41
///////////////////////////////////////////////////////////////////////////////////////////////////
42

    
43
  public TwistySquare2(int[] numL, int meshState, Static4D quat, Static3D move, float scale, InputStream stream)
44
    {
45
    super(numL, meshState, quat, move, scale, stream);
46
    }
47

    
48
///////////////////////////////////////////////////////////////////////////////////////////////////
49

    
50
  @Override
51
  public int[][] getSolvedQuats()
52
    {
53
    return new int[][]
54
      {
55
        { 2, 0,1 },                                   // 2 middle cubits in the first group
56
        {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]
57
        {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]
58
      };
59
    }
60

    
61
///////////////////////////////////////////////////////////////////////////////////////////////////
62

    
63
  public ScrambleState[] getScrambleStates()
64
    {
65
    if( mStates==null )
66
      {
67
      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};
68
      int[] SL_1 = new int[] { 0,1,1, 1,1,1 };
69
      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 };
70
      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 };
71
      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 };
72

    
73
      mStates = new ScrambleState[]
74
        {
75
        new ScrambleState( new int[][] { LO_2, SL_6, LO_3 } ),  // 0
76
        new ScrambleState( new int[][] { LO_2, null, LO_3 } ),  // SL
77
        new ScrambleState( new int[][] { null, SL_1, LO_4 } ),  // LO
78
        new ScrambleState( new int[][] { LO_4, SL_1, null } ),  // UP
79
        new ScrambleState( new int[][] { null, SL_1, null } ),  // UL
80
        };
81
      }
82

    
83
    return mStates;
84
    }
85

    
86
///////////////////////////////////////////////////////////////////////////////////////////////////
87

    
88
  public float[][] getCubitPositions(int[] numLayers)
89
    {
90
    if( mCenters ==null )
91
      {
92
      float Y = 0.75f + X/2;
93

    
94
      mCenters = new float[][]
95
        {
96
         { 1.5f, 0.0f, 0.0f }, // 0
97
         {-1.5f, 0.0f, 0.0f },
98

    
99
         { 0.0f, 1.0f, 1.5f }, // 2
100
         { 1.5f, 1.0f, 0.0f },
101
         { 0.0f, 1.0f,-1.5f },
102
         {-1.5f, 1.0f, 0.0f },
103
         { 0.0f,-1.0f, 1.5f },
104
         { 1.5f,-1.0f, 0.0f },
105
         { 0.0f,-1.0f,-1.5f },
106
         {-1.5f,-1.0f, 0.0f },
107

    
108
         {    Y, 1.0f, 1.5f }, // 10
109
         { 1.5f, 1.0f,   -Y },
110
         {   -Y, 1.0f,-1.5f },
111
         {-1.5f, 1.0f,    Y },
112
         {    Y,-1.0f, 1.5f },
113
         { 1.5f,-1.0f,   -Y },
114
         {   -Y,-1.0f,-1.5f },
115
         {-1.5f,-1.0f,    Y },
116

    
117
         { 1.5f, 1.0f,    Y }, // 18
118
         {    Y, 1.0f,-1.5f },
119
         {-1.5f, 1.0f,   -Y },
120
         {   -Y, 1.0f, 1.5f },
121
         { 1.5f,-1.0f,    Y },
122
         {    Y,-1.0f,-1.5f },
123
         {-1.5f,-1.0f,   -Y },
124
         {   -Y,-1.0f, 1.5f },
125
        };
126
      }
127

    
128
    return mCenters;
129
    }
130

    
131
///////////////////////////////////////////////////////////////////////////////////////////////////
132

    
133
  public Static4D getCubitQuats(int cubit, int[] numLayers)
134
    {
135
    if( mQuatNumber ==null )
136
      {
137
      mQuatNumber = new int[]
138
        {
139
        0, 6,
140
        0, 9, 6, 3, 17, 14, 23, 20,
141
        0, 9, 6, 3, 0, 9, 6, 3,
142
        14, 23, 20, 17, 14, 23, 20, 17
143
        };
144
      }
145

    
146
    return mObjectQuats[mQuatNumber[cubit]];
147
    }
148

    
149
///////////////////////////////////////////////////////////////////////////////////////////////////
150

    
151
  public ObjectShape getObjectShape(int variant)
152
    {
153
    if( variant==0 )
154
      {
155
      float[][] vertices =
156
        {
157
         { -1.5f-X, 0.5f, 1.5f },
158
         {    0.0f, 0.5f, 1.5f },
159
         {    0.0f, 0.5f,-1.5f },
160
         { -1.5f+X, 0.5f,-1.5f },
161
         { -1.5f-X,-0.5f, 1.5f },
162
         {    0.0f,-0.5f, 1.5f },
163
         {    0.0f,-0.5f,-1.5f },
164
         { -1.5f+X,-0.5f,-1.5f }
165
        };
166

    
167
      int[][] indices =
168
        {
169
         {4,5,1,0},
170
         {5,6,2,1},
171
         {6,7,3,2},
172
         {7,4,0,3},
173
         {0,1,2,3},
174
         {7,6,5,4}
175
        };
176

    
177
      return new ObjectShape(vertices, indices);
178
      }
179
    else if( variant==1 )
180
      {
181
      float[][] vertices =
182
        {
183
         {  -X, 0.5f, 0.0f },
184
         {  +X, 0.5f, 0.0f },
185
         {0.0f, 0.5f,-1.5f },
186
         {  -X,-0.5f, 0.0f },
187
         {  +X,-0.5f, 0.0f },
188
         {0.0f,-0.5f,-1.5f },
189
        };
190

    
191
      int[][] indices =
192
        {
193
         {0,1,2},
194
         {3,4,1,0},
195
         {5,4,3},
196
         {4,5,2,1},
197
         {5,3,0,2}
198
        };
199

    
200
      return new ObjectShape(vertices, indices);
201
      }
202
    else
203
      {
204
      float[][] vertices =
205
        {
206
         {-0.75f+X/2, 0.5f,  0.0f },
207
         { 0.75f-X/2, 0.5f,  0.0f },
208
         {-0.75f-X/2, 0.5f, -1.5f },
209
         {-0.75f+X/2,-0.5f,  0.0f },
210
         { 0.75f-X/2,-0.5f,  0.0f },
211
         {-0.75f-X/2,-0.5f, -1.5f }
212
        };
213
      int[][] indices =
214
        {
215
         {0,1,2},
216
         {3,4,1,0},
217
         {5,4,3},
218
         {4,5,2,1},
219
         {5,3,0,2}
220
        };
221

    
222
      return new ObjectShape(vertices, indices);
223
      }
224
    }
225

    
226
///////////////////////////////////////////////////////////////////////////////////////////////////
227

    
228
  public ObjectFaceShape getObjectFaceShape(int variant)
229
    {
230
    if( variant==0 )
231
      {
232
      float[][] bands     = { {0.040f,35,0.2f,0.8f,5,2,1}, {0.020f,35,0.5f,1.0f,5,2,1}, {0.001f,35,0.3f,0.8f,5,2,1} };
233
      int[] bandIndices   = { 0,0,1,2,2,2 };
234
      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
      float[][] bands     = { {0.038f,35,0.5f,0.9f, 5,2,1}, {0.001f,35,0.5f,0.9f, 5,2,1} };
243
      int[] bandIndices   = { 0,0,0,1,1 };
244
      float[][] corners   = { {0.04f,0.15f} };
245
      int[] cornerIndices = { 0,0,-1,0,0,-1 };
246
      float[][] centers   = { { 0.0f, 0.0f,-0.5f} };
247
      int[] centerIndices = { 0,0,-1,0,0,-1 };
248
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
249
      }
250
    else
251
      {
252
      float[][] bands     = { {0.030f,35,0.9f,1.0f, 5,2,1}, {0.001f,35,0.9f,1.0f, 5,2,1} };
253
      int[] bandIndices   = { 0,0,0,1,1 };
254
      float[][] corners   = { {0.05f,0.13f} };
255
      int[] cornerIndices = { 0,0,-1,0,0,-1 };
256
      float[][] centers   = { { 0.0f, 0.0f,-0.5f} };
257
      int[] centerIndices = { 0,0,-1,0,0,-1 };
258
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
259
      }
260
    }
261

    
262
///////////////////////////////////////////////////////////////////////////////////////////////////
263

    
264
  public int getNumCubitVariants(int[] numLayers)
265
    {
266
    return 3;
267
    }
268

    
269
///////////////////////////////////////////////////////////////////////////////////////////////////
270

    
271
  public int getCubitVariant(int cubit, int[] numLayers)
272
    {
273
    return cubit<2 ? 0 : (cubit<10 ? 1:2);
274
    }
275

    
276
///////////////////////////////////////////////////////////////////////////////////////////////////
277

    
278
  public float getStickerRadius()
279
    {
280
    return 0.12f;
281
    }
282

    
283
///////////////////////////////////////////////////////////////////////////////////////////////////
284

    
285
  public float getStickerStroke()
286
    {
287
    return ObjectControl.isInIconMode() ? 0.20f : 0.10f;
288
    }
289

    
290
///////////////////////////////////////////////////////////////////////////////////////////////////
291

    
292
  public float[][] getStickerAngles()
293
    {
294
    return null;
295
    }
296

    
297
///////////////////////////////////////////////////////////////////////////////////////////////////
298
// PUBLIC API
299

    
300
  public String getShortName()
301
    {
302
    return ObjectType.SQU2_3.name();
303
    }
304

    
305
///////////////////////////////////////////////////////////////////////////////////////////////////
306

    
307
  public long getSignature()
308
    {
309
    return ObjectType.SQU2_3.ordinal();
310
    }
311

    
312
///////////////////////////////////////////////////////////////////////////////////////////////////
313

    
314
  public String getObjectName()
315
    {
316
    return "Square-2";
317
    }
318

    
319
///////////////////////////////////////////////////////////////////////////////////////////////////
320

    
321
  public String getInventor()
322
    {
323
    return "David Litwin";
324
    }
325

    
326
///////////////////////////////////////////////////////////////////////////////////////////////////
327

    
328
  public int getYearOfInvention()
329
    {
330
    return 1995;
331
    }
332

    
333
///////////////////////////////////////////////////////////////////////////////////////////////////
334

    
335
  public int getComplexity()
336
    {
337
    return 3;
338
    }
339

    
340
///////////////////////////////////////////////////////////////////////////////////////////////////
341

    
342
  public String[][] getTutorials()
343
    {
344
    return new String[][] {
345
                          {"gb","PPXojiFthEs","Square-2 Tutorial","SuperAntoniovivaldi"},
346
                          {"es","IiMwc51xKBQ","Cómo resolver Square-2","skieur cubb"},
347
                          {"ru","XZ6m8uF5oUk","Как собрать Square-2.","Илья Топор-Гилка"},
348
                          {"fr","R-m9IgYAFPA","Tutoriel: résolution du Square-2","skieur cubb"},
349
                          {"pl","SukHyoMzcgM","Square-2 TUTORIAL PL","MrUk"},
350
                          {"br","T3ts5gHLJV8","Tutorial do Square-2 1/2","Rafael Cinoto"},
351
                          {"br","4wwWE5Ni0Fw","Tutorial do Square-2 2/2","Rafael Cinoto"},
352
                          {"kr","psG9Ar4pBrc","초보자를 위한 스퀘어2 해법","SlowCuberToumai"},
353
                         };
354
    }
355
}
(29-29/33)