Project

General

Profile

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

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

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.FactoryCubit;
18
import org.distorted.objectlib.helpers.ObjectFaceShape;
19
import org.distorted.objectlib.helpers.ObjectSignature;
20
import org.distorted.objectlib.helpers.ObjectVertexEffects;
21
import org.distorted.objectlib.main.InitData;
22
import org.distorted.objectlib.main.ObjectSignatures;
23
import org.distorted.objectlib.main.ObjectType;
24
import org.distorted.objectlib.helpers.ObjectShape;
25

    
26
///////////////////////////////////////////////////////////////////////////////////////////////////
27

    
28
public class TwistySquare2 extends TwistySquare
29
{
30
  private int[][] mEdges;
31
  private int[] mQuatIndex;
32
  private float[][] mCenters;
33

    
34
///////////////////////////////////////////////////////////////////////////////////////////////////
35

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

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

    
43
  @Override
44
  public int[][] getSolvedQuats()
45
    {
46
    return new int[][]
47
      {
48
        { 2, 0,1 },                                   // 2 middle cubits in the first group
49
        {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]
50
        {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]
51
      };
52
    }
53

    
54
///////////////////////////////////////////////////////////////////////////////////////////////////
55

    
56
  public int[][] getScrambleEdges()
57
    {
58
    if( mEdges==null )
59
      {
60
      mEdges = new int[][]
61
        {
62
          { 0,2,1,2,2,2,3,2,4,2,5,2,6,2,7,2,8,2,9,2,10,2,
63
            33,1,34,1,33,1,34,1,33,1,34,1,33,1,34,1,33,1,34,1,33,1,34,1,
64
            35,3,36,3,37,3,38,3,39,3,40,3,41,3,42,3,43,3,44,3,45,3 },     // 0
65
          { 0,2,1,2,2,2,3,2,4,2,5,2,6,2,7,2,8,2,9,2,10,2,
66
            35,3,36,3,37,3,38,3,39,3,40,3,41,3,42,3,43,3,44,3,45,3 },     // 1 SL
67
          { 33,1,34,1,
68
            35,4,36,4,37,4,38,4,39,4,40,4,41,4,42,4,43,4,44,4,45,4 },     // 2 LO
69
          { 0,4,1,4,2,4,3,4,4,4,5,4,6,4,7,4,8,4,9,4,10,4,
70
            33,1,34,1 },                                                  // 3 UP
71
          { 33,1,34,1 }                                                   // 4 UL
72
        };
73
      }
74

    
75
    return mEdges;
76
    }
77

    
78
///////////////////////////////////////////////////////////////////////////////////////////////////
79

    
80
  public float[][] getCubitPositions(int[] numLayers)
81
    {
82
    if( mCenters ==null )
83
      {
84
      float Y = 0.75f + X/2;
85

    
86
      mCenters = new float[][]
87
        {
88
         { 1.5f, 0.0f, 0.0f }, // 0
89
         {-1.5f, 0.0f, 0.0f },
90

    
91
         { 0.0f, 1.0f, 1.5f }, // 2
92
         { 1.5f, 1.0f, 0.0f },
93
         { 0.0f, 1.0f,-1.5f },
94
         {-1.5f, 1.0f, 0.0f },
95
         { 0.0f,-1.0f, 1.5f },
96
         { 1.5f,-1.0f, 0.0f },
97
         { 0.0f,-1.0f,-1.5f },
98
         {-1.5f,-1.0f, 0.0f },
99

    
100
         {    Y, 1.0f, 1.5f }, // 10
101
         { 1.5f, 1.0f,   -Y },
102
         {   -Y, 1.0f,-1.5f },
103
         {-1.5f, 1.0f,    Y },
104
         {    Y,-1.0f, 1.5f },
105
         { 1.5f,-1.0f,   -Y },
106
         {   -Y,-1.0f,-1.5f },
107
         {-1.5f,-1.0f,    Y },
108

    
109
         { 1.5f, 1.0f,    Y }, // 18
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
         {   -Y,-1.0f, 1.5f },
117
        };
118
      }
119

    
120
    return mCenters;
121
    }
122

    
123
///////////////////////////////////////////////////////////////////////////////////////////////////
124

    
125
  public Static4D getCubitQuats(int cubit, int[] numLayers)
126
    {
127
    if( mQuatIndex==null )
128
      {
129
      mQuatIndex = new int[]
130
        {
131
        0, 6,
132
        0, 9, 6, 3,17,14,23,20,
133
        0, 9, 6, 3, 0, 9, 6, 3,14, 23, 20, 17, 14, 23, 20, 17
134
        };
135
      }
136

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

    
140
///////////////////////////////////////////////////////////////////////////////////////////////////
141

    
142
  private float[][] getVertices(int variant)
143
    {
144
    if( variant==0 )
145
      {
146
      return new float[][]
147
        {
148
         { -1.5f-X, 0.5f, 1.5f },
149
         {    0.0f, 0.5f, 1.5f },
150
         {    0.0f, 0.5f,-1.5f },
151
         { -1.5f+X, 0.5f,-1.5f },
152
         { -1.5f-X,-0.5f, 1.5f },
153
         {    0.0f,-0.5f, 1.5f },
154
         {    0.0f,-0.5f,-1.5f },
155
         { -1.5f+X,-0.5f,-1.5f }
156
        };
157
      }
158
    else if( variant==1 )
159
      {
160
      return new float[][]
161
        {
162
         {  -X, 0.5f, 0.0f },
163
         {  +X, 0.5f, 0.0f },
164
         {0.0f, 0.5f,-1.5f },
165
         {  -X,-0.5f, 0.0f },
166
         {  +X,-0.5f, 0.0f },
167
         {0.0f,-0.5f,-1.5f },
168
        };
169
      }
170
    else
171
      {
172
      return new float[][]
173
        {
174
         {-0.75f+X/2, 0.5f,  0.0f },
175
         { 0.75f-X/2, 0.5f,  0.0f },
176
         {-0.75f-X/2, 0.5f, -1.5f },
177
         {-0.75f+X/2,-0.5f,  0.0f },
178
         { 0.75f-X/2,-0.5f,  0.0f },
179
         {-0.75f-X/2,-0.5f, -1.5f }
180
        };
181
      }
182
    }
183

    
184
///////////////////////////////////////////////////////////////////////////////////////////////////
185

    
186
  public ObjectShape getObjectShape(int variant)
187
    {
188
    if( variant==0 )
189
      {
190
      int[][] indices =
191
        {
192
         {4,5,1,0},
193
         {5,6,2,1},
194
         {6,7,3,2},
195
         {7,4,0,3},
196
         {0,1,2,3},
197
         {7,6,5,4}
198
        };
199

    
200
      return new ObjectShape(getVertices(variant), indices);
201
      }
202
    else if( variant==1 )
203
      {
204
      int[][] indices =
205
        {
206
         {0,1,2},
207
         {3,4,1,0},
208
         {5,4,3},
209
         {4,5,2,1},
210
         {5,3,0,2}
211
        };
212

    
213
      return new ObjectShape(getVertices(variant), indices);
214
      }
215
    else
216
      {
217
      int[][] indices =
218
        {
219
         {0,1,2},
220
         {3,4,1,0},
221
         {5,4,3},
222
         {4,5,2,1},
223
         {5,3,0,2}
224
        };
225

    
226
      return new ObjectShape(getVertices(variant), indices);
227
      }
228
    }
229

    
230
///////////////////////////////////////////////////////////////////////////////////////////////////
231

    
232
  public ObjectFaceShape getObjectFaceShape(int variant)
233
    {
234
    if( variant==0 )
235
      {
236
      float h1 = isInIconMode() ? 0.001f : 0.04f;
237
      float h2 = isInIconMode() ? 0.001f : 0.02f;
238
      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} };
239
      int[] indices   = { 0,0,1,2,2,2 };
240
      return new ObjectFaceShape(bands,indices,null);
241
      }
242
    else if( variant==1 )
243
      {
244
      float h1 = isInIconMode() ? 0.001f : 0.038f;
245
      float[][] bands = { {h1,35,0.5f,0.9f, 5,2,1}, {0.001f,35,0.5f,0.9f, 5,2,1} };
246
      int[] indices   = { 0,0,0,1,1 };
247
      return new ObjectFaceShape(bands,indices,null);
248
      }
249
    else
250
      {
251
      float h1 = isInIconMode() ? 0.001f : 0.03f;
252
      float[][] bands = { {h1,35,0.9f,1.0f, 5,2,1}, {0.001f,35,0.9f,1.0f, 5,2,1} };
253
      int[] indices   = { 0,0,0,1,1 };
254
      return new ObjectFaceShape(bands,indices,null);
255
      }
256
    }
257

    
258
///////////////////////////////////////////////////////////////////////////////////////////////////
259

    
260
  public ObjectVertexEffects getVertexEffects(int variant)
261
    {
262
    if( variant==0 )
263
      {
264
      float[][] corners = { {0.03f,0.05f} };
265
      int[] indices     = { 0,0,0,0,0,0,0,0 };
266
      float[][] centers = { { -0.75f, 0.0f, 0.0f} };
267
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
268
      }
269
    else if( variant==1 )
270
      {
271
      float[][] corners = { {0.04f,0.15f} };
272
      int[] indices     = { 0,0,-1,0,0,-1 };
273
      float[][] centers = { { 0.0f, 0.0f,-0.5f} };
274
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
275
      }
276
    else
277
      {
278
      float[][] corners = { {0.05f,0.13f} };
279
      int[] indices     = { 0,0,-1,0,0,-1 };
280
      float[][] centers = { { 0.0f, 0.0f,-0.5f} };
281
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
282
      }
283
    }
284

    
285
///////////////////////////////////////////////////////////////////////////////////////////////////
286

    
287
  public int getNumCubitVariants(int[] numLayers)
288
    {
289
    return 3;
290
    }
291

    
292
///////////////////////////////////////////////////////////////////////////////////////////////////
293

    
294
  public int getCubitVariant(int cubit, int[] numLayers)
295
    {
296
    return cubit<2 ? 0 : (cubit<10 ? 1:2);
297
    }
298

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

    
301
  public float getStickerRadius()
302
    {
303
    return 0.12f;
304
    }
305

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

    
308
  public float getStickerStroke()
309
    {
310
    return isInIconMode() ? 0.20f : 0.10f;
311
    }
312

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

    
315
  public float[][] getStickerAngles()
316
    {
317
    return null;
318
    }
319

    
320
///////////////////////////////////////////////////////////////////////////////////////////////////
321
// PUBLIC API
322

    
323
  public String getShortName()
324
    {
325
    return ObjectType.SQU2_3.name();
326
    }
327

    
328
///////////////////////////////////////////////////////////////////////////////////////////////////
329

    
330
  public ObjectSignature getSignature()
331
    {
332
    return new ObjectSignature(ObjectSignatures.SQU2_3);
333
    }
334

    
335
///////////////////////////////////////////////////////////////////////////////////////////////////
336

    
337
  public String getObjectName()
338
    {
339
    return "Square-2";
340
    }
341

    
342
///////////////////////////////////////////////////////////////////////////////////////////////////
343

    
344
  public String getInventor()
345
    {
346
    return "David Litwin";
347
    }
348

    
349
///////////////////////////////////////////////////////////////////////////////////////////////////
350

    
351
  public int getYearOfInvention()
352
    {
353
    return 1995;
354
    }
355

    
356
///////////////////////////////////////////////////////////////////////////////////////////////////
357

    
358
  public int getComplexity()
359
    {
360
    return 3;
361
    }
362

    
363
///////////////////////////////////////////////////////////////////////////////////////////////////
364

    
365
  public String[][] getTutorials()
366
    {
367
    return new String[][] {
368
                          {"gb","PPXojiFthEs","Square-2 Tutorial","SuperAntoniovivaldi"},
369
                          {"es","IiMwc51xKBQ","Cómo resolver Square-2","skieur cubb"},
370
                          {"ru","XZ6m8uF5oUk","Как собрать Square-2.","Илья Топор-Гилка"},
371
                          {"fr","R-m9IgYAFPA","Tutoriel: résolution du Square-2","skieur cubb"},
372
                          {"pl","SukHyoMzcgM","Square-2 TUTORIAL PL","MrUk"},
373
                          {"br","T3ts5gHLJV8","Tutorial do Square-2 1/2","Rafael Cinoto"},
374
                          {"br","4wwWE5Ni0Fw","Tutorial do Square-2 2/2","Rafael Cinoto"},
375
                          {"kr","psG9Ar4pBrc","초보자를 위한 스퀘어2 해법","SlowCuberToumai"},
376
                          {"vn","_37Pc8Y_-Hs","Square-2 Tutorial","VĂN CÔNG TÙNG"},
377
                         };
378
    }
379
}
(36-36/41)