Project

General

Profile

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

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

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 ecf3d6e3 Leszek Koltunski
import org.distorted.library.type.Static3D;
13 29b82486 Leszek Koltunski
import org.distorted.library.type.Static4D;
14
15 84a17011 Leszek Koltunski
import org.distorted.objectlib.helpers.FactoryCubit;
16 3ee1d662 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectFaceShape;
17 ae9d9227 leszek
import org.distorted.objectlib.metadata.Metadata;
18 84a17011 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectVertexEffects;
19 cf93ea4e Leszek Koltunski
import org.distorted.objectlib.main.InitAssets;
20 361fd0de leszek
import org.distorted.objectlib.metadata.ListObjects;
21 198c5bf0 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectShape;
22 29b82486 Leszek Koltunski
23
///////////////////////////////////////////////////////////////////////////////////////////////////
24
25
public class TwistySquare2 extends TwistySquare
26
{
27 9ba7f3f6 Leszek Koltunski
  private int[][] mEdges;
28 82e62580 Leszek Koltunski
  private int[] mQuatIndex;
29 29b82486 Leszek Koltunski
  private float[][] mCenters;
30
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32
33 ae9d9227 leszek
  public TwistySquare2(int iconMode, Static4D quat, Static3D move, float scale, Metadata meta, InitAssets asset)
34 29b82486 Leszek Koltunski
    {
35 ae9d9227 leszek
    super(iconMode, quat, move, scale, meta, asset);
36 29b82486 Leszek Koltunski
    }
37
38 a70b1e96 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
39
40
  float getFactor()
41
    {
42
    return 0.8f;
43
    }
44
45 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
46
47 9ba7f3f6 Leszek Koltunski
  public int[][] getScrambleEdges()
48 29b82486 Leszek Koltunski
    {
49 9ba7f3f6 Leszek Koltunski
    if( mEdges==null )
50 29b82486 Leszek Koltunski
      {
51 9ba7f3f6 Leszek Koltunski
      mEdges = new int[][]
52 29b82486 Leszek Koltunski
        {
53 9ba7f3f6 Leszek Koltunski
          { 0,2,1,2,2,2,3,2,4,2,5,2,6,2,7,2,8,2,9,2,10,2,
54
            33,1,34,1,33,1,34,1,33,1,34,1,33,1,34,1,33,1,34,1,33,1,34,1,
55
            35,3,36,3,37,3,38,3,39,3,40,3,41,3,42,3,43,3,44,3,45,3 },     // 0
56
          { 0,2,1,2,2,2,3,2,4,2,5,2,6,2,7,2,8,2,9,2,10,2,
57
            35,3,36,3,37,3,38,3,39,3,40,3,41,3,42,3,43,3,44,3,45,3 },     // 1 SL
58
          { 33,1,34,1,
59
            35,4,36,4,37,4,38,4,39,4,40,4,41,4,42,4,43,4,44,4,45,4 },     // 2 LO
60
          { 0,4,1,4,2,4,3,4,4,4,5,4,6,4,7,4,8,4,9,4,10,4,
61
            33,1,34,1 },                                                  // 3 UP
62
          { 33,1,34,1 }                                                   // 4 UL
63 29b82486 Leszek Koltunski
        };
64
      }
65
66 9ba7f3f6 Leszek Koltunski
    return mEdges;
67 29b82486 Leszek Koltunski
    }
68
69 d0e6cf7f Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
70
71
  public float[][] getCubitPositions(int[] numLayers)
72
    {
73
    if( mCenters ==null )
74
      {
75
      float Y = 0.75f + X/2;
76
77
      mCenters = new float[][]
78
        {
79 ed0988c0 Leszek Koltunski
         { 1.5f, 0.0f, 0.0f }, // 0
80 d0e6cf7f Leszek Koltunski
         {-1.5f, 0.0f, 0.0f },
81
82 ed0988c0 Leszek Koltunski
         { 0.0f, 1.0f, 1.5f }, // 2
83 d0e6cf7f Leszek Koltunski
         { 1.5f, 1.0f, 0.0f },
84
         { 0.0f, 1.0f,-1.5f },
85
         {-1.5f, 1.0f, 0.0f },
86
         { 0.0f,-1.0f, 1.5f },
87
         { 1.5f,-1.0f, 0.0f },
88
         { 0.0f,-1.0f,-1.5f },
89
         {-1.5f,-1.0f, 0.0f },
90
91 ed0988c0 Leszek Koltunski
         {    Y, 1.0f, 1.5f }, // 10
92 d0e6cf7f Leszek Koltunski
         { 1.5f, 1.0f,   -Y },
93
         {   -Y, 1.0f,-1.5f },
94
         {-1.5f, 1.0f,    Y },
95
         {    Y,-1.0f, 1.5f },
96
         { 1.5f,-1.0f,   -Y },
97
         {   -Y,-1.0f,-1.5f },
98
         {-1.5f,-1.0f,    Y },
99
100 ed0988c0 Leszek Koltunski
         { 1.5f, 1.0f,    Y }, // 18
101 d0e6cf7f Leszek Koltunski
         {    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
         {   -Y,-1.0f, 1.5f },
108
        };
109
      }
110
111
    return mCenters;
112
    }
113
114
///////////////////////////////////////////////////////////////////////////////////////////////////
115
116
  public Static4D getCubitQuats(int cubit, int[] numLayers)
117
    {
118 82e62580 Leszek Koltunski
    if( mQuatIndex==null )
119 d0e6cf7f Leszek Koltunski
      {
120 82e62580 Leszek Koltunski
      mQuatIndex = new int[]
121 d0e6cf7f Leszek Koltunski
        {
122
        0, 6,
123 82e62580 Leszek Koltunski
        0, 9, 6, 3,17,14,23,20,
124
        0, 9, 6, 3, 0, 9, 6, 3,14, 23, 20, 17, 14, 23, 20, 17
125 d0e6cf7f Leszek Koltunski
        };
126
      }
127
128 82e62580 Leszek Koltunski
    return mObjectQuats[mQuatIndex[cubit]];
129 d0e6cf7f Leszek Koltunski
    }
130
131 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
132
133 84a17011 Leszek Koltunski
  private float[][] getVertices(int variant)
134 29b82486 Leszek Koltunski
    {
135
    if( variant==0 )
136
      {
137 84a17011 Leszek Koltunski
      return new float[][]
138 29b82486 Leszek Koltunski
        {
139 57ef6378 Leszek Koltunski
         { -1.5f-X, 0.5f, 1.5f },
140
         {    0.0f, 0.5f, 1.5f },
141
         {    0.0f, 0.5f,-1.5f },
142
         { -1.5f+X, 0.5f,-1.5f },
143
         { -1.5f-X,-0.5f, 1.5f },
144
         {    0.0f,-0.5f, 1.5f },
145
         {    0.0f,-0.5f,-1.5f },
146
         { -1.5f+X,-0.5f,-1.5f }
147 29b82486 Leszek Koltunski
        };
148 84a17011 Leszek Koltunski
      }
149
    else if( variant==1 )
150
      {
151
      return new float[][]
152
        {
153
         {  -X, 0.5f, 0.0f },
154
         {  +X, 0.5f, 0.0f },
155
         {0.0f, 0.5f,-1.5f },
156
         {  -X,-0.5f, 0.0f },
157
         {  +X,-0.5f, 0.0f },
158
         {0.0f,-0.5f,-1.5f },
159
        };
160
      }
161
    else
162
      {
163
      return new float[][]
164
        {
165
         {-0.75f+X/2, 0.5f,  0.0f },
166
         { 0.75f-X/2, 0.5f,  0.0f },
167
         {-0.75f-X/2, 0.5f, -1.5f },
168
         {-0.75f+X/2,-0.5f,  0.0f },
169
         { 0.75f-X/2,-0.5f,  0.0f },
170
         {-0.75f-X/2,-0.5f, -1.5f }
171
        };
172
      }
173
    }
174
175
///////////////////////////////////////////////////////////////////////////////////////////////////
176 29b82486 Leszek Koltunski
177 84a17011 Leszek Koltunski
  public ObjectShape getObjectShape(int variant)
178
    {
179
    if( variant==0 )
180
      {
181 4e9f2df5 Leszek Koltunski
      int[][] indices =
182 29b82486 Leszek Koltunski
        {
183
         {4,5,1,0},
184
         {5,6,2,1},
185
         {6,7,3,2},
186 33c707e8 Leszek Koltunski
         {7,4,0,3},
187
         {0,1,2,3},
188 846b69f3 Leszek Koltunski
         {7,6,5,4}
189 29b82486 Leszek Koltunski
        };
190
191 84a17011 Leszek Koltunski
      return new ObjectShape(getVertices(variant), indices);
192 29b82486 Leszek Koltunski
      }
193
    else if( variant==1 )
194
      {
195 4e9f2df5 Leszek Koltunski
      int[][] indices =
196 29b82486 Leszek Koltunski
        {
197
         {0,1,2},
198
         {3,4,1,0},
199 846b69f3 Leszek Koltunski
         {5,4,3},
200 29b82486 Leszek Koltunski
         {4,5,2,1},
201
         {5,3,0,2}
202
        };
203
204 84a17011 Leszek Koltunski
      return new ObjectShape(getVertices(variant), indices);
205 29b82486 Leszek Koltunski
      }
206
    else
207
      {
208 4e9f2df5 Leszek Koltunski
      int[][] indices =
209 29b82486 Leszek Koltunski
        {
210
         {0,1,2},
211
         {3,4,1,0},
212 c187cb69 Leszek Koltunski
         {5,4,3},
213 29b82486 Leszek Koltunski
         {4,5,2,1},
214
         {5,3,0,2}
215
        };
216
217 84a17011 Leszek Koltunski
      return new ObjectShape(getVertices(variant), indices);
218 3ee1d662 Leszek Koltunski
      }
219
    }
220
221
///////////////////////////////////////////////////////////////////////////////////////////////////
222
223
  public ObjectFaceShape getObjectFaceShape(int variant)
224
    {
225 347f6cc1 Leszek Koltunski
    int angle1 = 25;
226
    int angle2 = 35;
227
    float R = 0.2f;
228
    float S = 0.8f;
229
230 3ee1d662 Leszek Koltunski
    if( variant==0 )
231
      {
232 3bf19410 Leszek Koltunski
      float h1 = isInIconMode() ? 0.001f : 0.04f;
233
      float h2 = isInIconMode() ? 0.001f : 0.02f;
234 347f6cc1 Leszek Koltunski
      float[][] bands = { {h1,angle1,R,S,5,2,1}, {h2,angle1,R,S,5,2,1}, {0.001f,angle1,R,S,5,2,1} };
235 84a17011 Leszek Koltunski
      int[] indices   = { 0,0,1,2,2,2 };
236
      return new ObjectFaceShape(bands,indices,null);
237 3ee1d662 Leszek Koltunski
      }
238
    else if( variant==1 )
239
      {
240 3bf19410 Leszek Koltunski
      float h1 = isInIconMode() ? 0.001f : 0.038f;
241 347f6cc1 Leszek Koltunski
      float[][] bands = { {h1,angle2,R,S, 5,2,1}, {0.001f,angle2,R,S, 5,2,1} };
242 84a17011 Leszek Koltunski
      int[] indices   = { 0,0,0,1,1 };
243
      return new ObjectFaceShape(bands,indices,null);
244 3ee1d662 Leszek Koltunski
      }
245
    else
246
      {
247 3bf19410 Leszek Koltunski
      float h1 = isInIconMode() ? 0.001f : 0.03f;
248 347f6cc1 Leszek Koltunski
      float[][] bands = { {h1,angle2,R,S, 5,2,1}, {0.001f,angle2,R,S, 5,2,1} };
249 84a17011 Leszek Koltunski
      int[] indices   = { 0,0,0,1,1 };
250
      return new ObjectFaceShape(bands,indices,null);
251
      }
252
    }
253
254
///////////////////////////////////////////////////////////////////////////////////////////////////
255
256
  public ObjectVertexEffects getVertexEffects(int variant)
257
    {
258
    if( variant==0 )
259
      {
260
      float[][] corners = { {0.03f,0.05f} };
261
      int[] indices     = { 0,0,0,0,0,0,0,0 };
262
      float[][] centers = { { -0.75f, 0.0f, 0.0f} };
263
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
264
      }
265
    else if( variant==1 )
266
      {
267
      float[][] corners = { {0.04f,0.15f} };
268
      int[] indices     = { 0,0,-1,0,0,-1 };
269
      float[][] centers = { { 0.0f, 0.0f,-0.5f} };
270
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
271
      }
272
    else
273
      {
274
      float[][] corners = { {0.05f,0.13f} };
275
      int[] indices     = { 0,0,-1,0,0,-1 };
276
      float[][] centers = { { 0.0f, 0.0f,-0.5f} };
277
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
278 29b82486 Leszek Koltunski
      }
279
    }
280
281
///////////////////////////////////////////////////////////////////////////////////////////////////
282
283 e30c522a Leszek Koltunski
  public int getNumCubitVariants(int[] numLayers)
284 29b82486 Leszek Koltunski
    {
285
    return 3;
286
    }
287
288
///////////////////////////////////////////////////////////////////////////////////////////////////
289
290 e30c522a Leszek Koltunski
  public int getCubitVariant(int cubit, int[] numLayers)
291 29b82486 Leszek Koltunski
    {
292
    return cubit<2 ? 0 : (cubit<10 ? 1:2);
293
    }
294
295 89704841 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
296
297 d53fb890 Leszek Koltunski
  public float getStickerRadius()
298 89704841 Leszek Koltunski
    {
299
    return 0.12f;
300
    }
301
302
///////////////////////////////////////////////////////////////////////////////////////////////////
303
304 d53fb890 Leszek Koltunski
  public float getStickerStroke()
305 89704841 Leszek Koltunski
    {
306 3bf19410 Leszek Koltunski
    return isInIconMode() ? 0.20f : 0.10f;
307 89704841 Leszek Koltunski
    }
308
309 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
310
// PUBLIC API
311
312 5f54927b Leszek Koltunski
  public String getShortName()
313 61aa85e4 Leszek Koltunski
    {
314 361fd0de leszek
    return ListObjects.SQU2_3.name();
315 5f54927b Leszek Koltunski
    }
316
317 052e0362 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
318
319
  public String[][] getTutorials()
320
    {
321
    return new String[][] {
322
                          {"gb","PPXojiFthEs","Square-2 Tutorial","SuperAntoniovivaldi"},
323
                          {"es","IiMwc51xKBQ","Cómo resolver Square-2","skieur cubb"},
324
                          {"ru","XZ6m8uF5oUk","Как собрать Square-2.","Илья Топор-Гилка"},
325
                          {"fr","R-m9IgYAFPA","Tutoriel: résolution du Square-2","skieur cubb"},
326
                          {"pl","SukHyoMzcgM","Square-2 TUTORIAL PL","MrUk"},
327
                          {"br","T3ts5gHLJV8","Tutorial do Square-2 1/2","Rafael Cinoto"},
328
                          {"br","4wwWE5Ni0Fw","Tutorial do Square-2 2/2","Rafael Cinoto"},
329
                          {"kr","psG9Ar4pBrc","초보자를 위한 스퀘어2 해법","SlowCuberToumai"},
330 a399e91b Leszek Koltunski
                          {"vn","_37Pc8Y_-Hs","Square-2 Tutorial","VĂN CÔNG TÙNG"},
331 2318a72a leszek
                          {"tw","hye02xzNAZk","Square-2(SQ-2) 教學","不正常魔術方塊研究中心"},
332 052e0362 Leszek Koltunski
                         };
333
    }
334 29b82486 Leszek Koltunski
}