Project

General

Profile

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

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

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 org.distorted.library.type.Static3D;
13
import org.distorted.library.type.Static4D;
14

    
15
import org.distorted.objectlib.helpers.FactoryCubit;
16
import org.distorted.objectlib.helpers.ObjectFaceShape;
17
import org.distorted.objectlib.helpers.ObjectSignature;
18
import org.distorted.objectlib.helpers.ObjectVertexEffects;
19
import org.distorted.objectlib.main.InitAssets;
20
import org.distorted.objectlib.main.InitData;
21
import org.distorted.objectlib.main.ObjectSignatures;
22
import org.distorted.objectlib.main.ObjectType;
23
import org.distorted.objectlib.helpers.ObjectShape;
24

    
25
///////////////////////////////////////////////////////////////////////////////////////////////////
26

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

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

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

    
40
///////////////////////////////////////////////////////////////////////////////////////////////////
41

    
42
  float getFactor()
43
    {
44
    return 0.8f;
45
    }
46

    
47
///////////////////////////////////////////////////////////////////////////////////////////////////
48

    
49
  @Override
50
  public int[][] getSolvedQuats()
51
    {
52
    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
    }
59

    
60
///////////////////////////////////////////////////////////////////////////////////////////////////
61

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

    
81
    return mEdges;
82
    }
83

    
84
///////////////////////////////////////////////////////////////////////////////////////////////////
85

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

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

    
97
         { 0.0f, 1.0f, 1.5f }, // 2
98
         { 1.5f, 1.0f, 0.0f },
99
         { 0.0f, 1.0f,-1.5f },
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

    
106
         {    Y, 1.0f, 1.5f }, // 10
107
         { 1.5f, 1.0f,   -Y },
108
         {   -Y, 1.0f,-1.5f },
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

    
115
         { 1.5f, 1.0f,    Y }, // 18
116
         {    Y, 1.0f,-1.5f },
117
         {-1.5f, 1.0f,   -Y },
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
        };
124
      }
125

    
126
    return mCenters;
127
    }
128

    
129
///////////////////////////////////////////////////////////////////////////////////////////////////
130

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

    
143
    return mObjectQuats[mQuatIndex[cubit]];
144
    }
145

    
146
///////////////////////////////////////////////////////////////////////////////////////////////////
147

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

    
190
///////////////////////////////////////////////////////////////////////////////////////////////////
191

    
192
  public ObjectShape getObjectShape(int variant)
193
    {
194
    if( variant==0 )
195
      {
196
      int[][] indices =
197
        {
198
         {4,5,1,0},
199
         {5,6,2,1},
200
         {6,7,3,2},
201
         {7,4,0,3},
202
         {0,1,2,3},
203
         {7,6,5,4}
204
        };
205

    
206
      return new ObjectShape(getVertices(variant), indices);
207
      }
208
    else if( variant==1 )
209
      {
210
      int[][] indices =
211
        {
212
         {0,1,2},
213
         {3,4,1,0},
214
         {5,4,3},
215
         {4,5,2,1},
216
         {5,3,0,2}
217
        };
218

    
219
      return new ObjectShape(getVertices(variant), indices);
220
      }
221
    else
222
      {
223
      int[][] indices =
224
        {
225
         {0,1,2},
226
         {3,4,1,0},
227
         {5,4,3},
228
         {4,5,2,1},
229
         {5,3,0,2}
230
        };
231

    
232
      return new ObjectShape(getVertices(variant), indices);
233
      }
234
    }
235

    
236
///////////////////////////////////////////////////////////////////////////////////////////////////
237

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

    
264
///////////////////////////////////////////////////////////////////////////////////////////////////
265

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

    
291
///////////////////////////////////////////////////////////////////////////////////////////////////
292

    
293
  public int getNumCubitVariants(int[] numLayers)
294
    {
295
    return 3;
296
    }
297

    
298
///////////////////////////////////////////////////////////////////////////////////////////////////
299

    
300
  public int getCubitVariant(int cubit, int[] numLayers)
301
    {
302
    return cubit<2 ? 0 : (cubit<10 ? 1:2);
303
    }
304

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

    
307
  public float getStickerRadius()
308
    {
309
    return 0.12f;
310
    }
311

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

    
314
  public float getStickerStroke()
315
    {
316
    return isInIconMode() ? 0.20f : 0.10f;
317
    }
318

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

    
321
  public float[][] getStickerAngles()
322
    {
323
    return null;
324
    }
325

    
326
///////////////////////////////////////////////////////////////////////////////////////////////////
327
// PUBLIC API
328

    
329
  public String getShortName()
330
    {
331
    return ObjectType.SQU2_3.name();
332
    }
333

    
334
///////////////////////////////////////////////////////////////////////////////////////////////////
335

    
336
  public ObjectSignature getSignature()
337
    {
338
    return new ObjectSignature(ObjectSignatures.SQU2_3);
339
    }
340

    
341
///////////////////////////////////////////////////////////////////////////////////////////////////
342

    
343
  public String getObjectName()
344
    {
345
    return "Square-2";
346
    }
347

    
348
///////////////////////////////////////////////////////////////////////////////////////////////////
349

    
350
  public String getInventor()
351
    {
352
    return "David Litwin";
353
    }
354

    
355
///////////////////////////////////////////////////////////////////////////////////////////////////
356

    
357
  public int getYearOfInvention()
358
    {
359
    return 1995;
360
    }
361

    
362
///////////////////////////////////////////////////////////////////////////////////////////////////
363

    
364
  public int getComplexity()
365
    {
366
    return 3;
367
    }
368

    
369
///////////////////////////////////////////////////////////////////////////////////////////////////
370

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