Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistySquare1.java @ f2259427

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 82eb152a Leszek Koltunski
import java.io.InputStream;
13 29b82486 Leszek Koltunski
14 ecf3d6e3 Leszek Koltunski
import org.distorted.library.type.Static3D;
15 29b82486 Leszek Koltunski
import org.distorted.library.type.Static4D;
16
17 3ee1d662 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectFaceShape;
18 1d581993 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectSignature;
19 a8295031 Leszek Koltunski
import org.distorted.objectlib.main.InitData;
20 8005e762 Leszek Koltunski
import org.distorted.objectlib.main.ObjectType;
21 198c5bf0 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectShape;
22 10b7e306 Leszek Koltunski
import org.distorted.objectlib.scrambling.ScrambleState;
23 29b82486 Leszek Koltunski
24
///////////////////////////////////////////////////////////////////////////////////////////////////
25
26
public class TwistySquare1 extends TwistySquare
27
{
28 82e62580 Leszek Koltunski
  private int[] mQuatIndex;
29 29b82486 Leszek Koltunski
  private float[][] mCenters;
30
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32
33 a8295031 Leszek Koltunski
  public TwistySquare1(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
34 29b82486 Leszek Koltunski
    {
35 a8295031 Leszek Koltunski
    super(data, meshState, iconMode, quat, move, scale, stream);
36 29b82486 Leszek Koltunski
    }
37
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39
40 ed0988c0 Leszek Koltunski
  @Override
41
  public int getScrambleType()
42 29b82486 Leszek Koltunski
    {
43 ed0988c0 Leszek Koltunski
    return 1;
44 29b82486 Leszek Koltunski
    }
45
46
///////////////////////////////////////////////////////////////////////////////////////////////////
47
48 0e311558 Leszek Koltunski
  @Override
49 ed0988c0 Leszek Koltunski
  public ScrambleState[] getScrambleStates()
50 29b82486 Leszek Koltunski
    {
51 ed0988c0 Leszek Koltunski
    return null;
52 29b82486 Leszek Koltunski
    }
53
54 d0e6cf7f Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
55
56
  public float[][] getCubitPositions(int[] numLayers)
57
    {
58
    if( mCenters==null )
59
      {
60
      mCenters = new float[][]
61
        {
62
         { 1.5f, 0.0f, 0.0f },
63
         {-1.5f, 0.0f, 0.0f },
64
65
         { 0.0f, 1.0f, 1.5f },
66
         { 1.5f, 1.0f, 0.0f },
67
         { 0.0f, 1.0f,-1.5f },
68
         {-1.5f, 1.0f, 0.0f },
69
         { 0.0f,-1.0f, 1.5f },
70
         { 1.5f,-1.0f, 0.0f },
71
         { 0.0f,-1.0f,-1.5f },
72
         {-1.5f,-1.0f, 0.0f },
73
74
         { 1.0f, 1.0f, 2.0f, 2.0f, 1.0f, 1.0f },
75
         { 1.0f, 1.0f,-2.0f, 2.0f, 1.0f,-1.0f },
76
         {-1.0f, 1.0f,-2.0f,-2.0f, 1.0f,-1.0f },
77
         {-1.0f, 1.0f, 2.0f,-2.0f, 1.0f, 1.0f },
78
         { 1.0f,-1.0f, 2.0f, 2.0f,-1.0f, 1.0f },
79
         { 1.0f,-1.0f,-2.0f, 2.0f,-1.0f,-1.0f },
80
         {-1.0f,-1.0f,-2.0f,-2.0f,-1.0f,-1.0f },
81
         {-1.0f,-1.0f, 2.0f,-2.0f,-1.0f, 1.0f }
82
        };
83
      }
84
    return mCenters;
85
    }
86
87
///////////////////////////////////////////////////////////////////////////////////////////////////
88
89
  public Static4D getCubitQuats(int cubit, int[] numLayers)
90
    {
91 82e62580 Leszek Koltunski
    if( mQuatIndex ==null )
92 d0e6cf7f Leszek Koltunski
      {
93 82e62580 Leszek Koltunski
      mQuatIndex = new int[]
94 d0e6cf7f Leszek Koltunski
        {
95
        0, 6,
96 db6d9617 Leszek Koltunski
        0, 9, 6, 3, 17, 14, 23, 20,
97
        0, 9, 6, 3, 14, 23, 20, 17
98 d0e6cf7f Leszek Koltunski
        };
99
      }
100
101 82e62580 Leszek Koltunski
    return mObjectQuats[mQuatIndex[cubit]];
102 d0e6cf7f Leszek Koltunski
    }
103
104 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
105
106 e30c522a Leszek Koltunski
  public ObjectShape getObjectShape(int variant)
107 29b82486 Leszek Koltunski
    {
108
    if( variant==0 )
109
      {
110 4e9f2df5 Leszek Koltunski
      float[][] vertices =
111 29b82486 Leszek Koltunski
        {
112 57ef6378 Leszek Koltunski
         { -1.5f-X, 0.5f, 1.5f },
113
         {    0.0f, 0.5f, 1.5f },
114
         {    0.0f, 0.5f,-1.5f },
115
         { -1.5f+X, 0.5f,-1.5f },
116
         { -1.5f-X,-0.5f, 1.5f },
117
         {    0.0f,-0.5f, 1.5f },
118
         {    0.0f,-0.5f,-1.5f },
119
         { -1.5f+X,-0.5f,-1.5f }
120 29b82486 Leszek Koltunski
        };
121
122 4e9f2df5 Leszek Koltunski
      int[][] indices =
123 29b82486 Leszek Koltunski
        {
124
         {4,5,1,0},
125
         {5,6,2,1},
126
         {6,7,3,2},
127 33c707e8 Leszek Koltunski
         {7,4,0,3},
128
         {0,1,2,3},
129 846b69f3 Leszek Koltunski
         {7,6,5,4}
130 29b82486 Leszek Koltunski
        };
131
132 59a971c1 Leszek Koltunski
      return new ObjectShape(vertices, indices);
133 29b82486 Leszek Koltunski
      }
134
    else if( variant==1 )
135
      {
136 4e9f2df5 Leszek Koltunski
      float[][] vertices =
137 29b82486 Leszek Koltunski
        {
138 57ef6378 Leszek Koltunski
         {  -X, 0.5f, 0.0f },
139
         {  +X, 0.5f, 0.0f },
140
         {0.0f, 0.5f,-1.5f },
141
         {  -X,-0.5f, 0.0f },
142
         {  +X,-0.5f, 0.0f },
143
         {0.0f,-0.5f,-1.5f },
144 29b82486 Leszek Koltunski
        };
145
146 4e9f2df5 Leszek Koltunski
      int[][] indices =
147 29b82486 Leszek Koltunski
        {
148
         {0,1,2},
149
         {3,4,1,0},
150 846b69f3 Leszek Koltunski
         {5,4,3},
151 29b82486 Leszek Koltunski
         {4,5,2,1},
152
         {5,3,0,2}
153
        };
154
155 59a971c1 Leszek Koltunski
      return new ObjectShape(vertices, indices);
156 29b82486 Leszek Koltunski
      }
157
    else
158
      {
159 4e9f2df5 Leszek Koltunski
      float[][] vertices =
160 29b82486 Leszek Koltunski
        {
161 57ef6378 Leszek Koltunski
         { X-1.5f, 0.5f,  0.0f },
162
         {   0.0f, 0.5f,  0.0f },
163
         {   0.0f, 0.5f,X-1.5f },
164
         {  -1.5f, 0.5f, -1.5f },
165
         { X-1.5f,-0.5f,  0.0f },
166
         {   0.0f,-0.5f,  0.0f },
167
         {   0.0f,-0.5f,X-1.5f },
168
         {  -1.5f,-0.5f, -1.5f }
169 29b82486 Leszek Koltunski
        };
170 4e9f2df5 Leszek Koltunski
      int[][] indices =
171 29b82486 Leszek Koltunski
        {
172
         {0,1,2,3},
173
         {4,5,1,0},
174
         {5,6,2,1},
175
         {7,4,0,3},
176 33c707e8 Leszek Koltunski
         {6,7,3,2},
177 846b69f3 Leszek Koltunski
         {7,6,5,4}
178 29b82486 Leszek Koltunski
        };
179
180 59a971c1 Leszek Koltunski
      return new ObjectShape(vertices, indices);
181 3ee1d662 Leszek Koltunski
      }
182
    }
183
184
///////////////////////////////////////////////////////////////////////////////////////////////////
185 29b82486 Leszek Koltunski
186 3ee1d662 Leszek Koltunski
  public ObjectFaceShape getObjectFaceShape(int variant)
187
    {
188
    if( variant==0 )
189
      {
190 3bf19410 Leszek Koltunski
      float h1 = isInIconMode() ? 0.001f : 0.04f;
191
      float h2 = isInIconMode() ? 0.001f : 0.02f;
192
      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} };
193 846b69f3 Leszek Koltunski
      int[] bandIndices   = { 0,0,1,2,2,2 };
194 3ee1d662 Leszek Koltunski
      float[][] corners   = { {0.03f,0.05f} };
195
      int[] cornerIndices = { 0,0,0,0,0,0,0,0 };
196
      float[][] centers   = { { -0.75f, 0.0f, 0.0f} };
197
      int[] centerIndices = { 0,0,0,0,0,0,0,0 };
198
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
199
      }
200
    else if( variant==1 )
201
      {
202 3bf19410 Leszek Koltunski
      float height = isInIconMode() ? 0.001f : 0.038f;
203
      float[][] bands     = { {height,35,0.5f,0.9f, 5,2,1}, {0.001f,35,0.5f,0.9f, 5,2,1} };
204 846b69f3 Leszek Koltunski
      int[] bandIndices   = { 0,0,0,1,1 };
205 3ee1d662 Leszek Koltunski
      float[][] corners   = { {0.04f,0.15f} };
206
      int[] cornerIndices = { 0,0,-1,0,0,-1 };
207
      float[][] centers   = { { 0.0f, 0.0f,-0.5f} };
208
      int[] centerIndices = { 0,0,-1,0,0,-1 };
209
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
210
      }
211
    else
212
      {
213 3bf19410 Leszek Koltunski
      float height = isInIconMode() ? 0.001f : 0.038f;
214
      float[][] bands     = { {height,35,0.9f,1.0f, 5,2,1}, {0.001f,35,0.9f,1.0f, 5,2,1} };
215 846b69f3 Leszek Koltunski
      int[] bandIndices   = { 0,0,0,1,1,1 };
216 3ee1d662 Leszek Koltunski
      float[][] corners   = { {0.05f,0.13f} };
217
      int[] cornerIndices = { 0,0,0,-1,0,0,0,-1 };
218
      float[][] centers   = { { -0.5f, 0.0f,-0.5f} };
219
      int[] centerIndices = { -1,0,-1,-1,-1,0,-1,-1 };
220
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
221 29b82486 Leszek Koltunski
      }
222
    }
223
224
///////////////////////////////////////////////////////////////////////////////////////////////////
225
226 e30c522a Leszek Koltunski
  public int getNumCubitVariants(int[] numLayers)
227 29b82486 Leszek Koltunski
    {
228
    return 3;
229
    }
230
231
///////////////////////////////////////////////////////////////////////////////////////////////////
232
233 e30c522a Leszek Koltunski
  public int getCubitVariant(int cubit, int[] numLayers)
234 29b82486 Leszek Koltunski
    {
235
    return cubit<2 ? 0 : (cubit<10 ? 1:2);
236
    }
237
238 89704841 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
239
240 d53fb890 Leszek Koltunski
  public float getStickerRadius()
241 89704841 Leszek Koltunski
    {
242
    return 0.12f;
243
    }
244
245
///////////////////////////////////////////////////////////////////////////////////////////////////
246
247 d53fb890 Leszek Koltunski
  public float getStickerStroke()
248 89704841 Leszek Koltunski
    {
249 3bf19410 Leszek Koltunski
    return isInIconMode() ? 0.20f : 0.10f;
250 89704841 Leszek Koltunski
    }
251
252
///////////////////////////////////////////////////////////////////////////////////////////////////
253
254 d53fb890 Leszek Koltunski
  public float[][] getStickerAngles()
255 89704841 Leszek Koltunski
    {
256
    return null;
257
    }
258
259 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
260
// PUBLIC API
261
262 5f54927b Leszek Koltunski
  public String getShortName()
263 61aa85e4 Leszek Koltunski
    {
264 5f54927b Leszek Koltunski
    return ObjectType.SQU1_3.name();
265
    }
266
267
///////////////////////////////////////////////////////////////////////////////////////////////////
268
269 1d581993 Leszek Koltunski
  public ObjectSignature getSignature()
270 5f54927b Leszek Koltunski
    {
271 1d581993 Leszek Koltunski
    return new ObjectSignature(ObjectType.SQU1_3);
272 61aa85e4 Leszek Koltunski
    }
273
274
///////////////////////////////////////////////////////////////////////////////////////////////////
275
276 e26eb4e7 Leszek Koltunski
  public String getObjectName()
277 29b82486 Leszek Koltunski
    {
278 e26eb4e7 Leszek Koltunski
    return "Square-1";
279 29b82486 Leszek Koltunski
    }
280
281
///////////////////////////////////////////////////////////////////////////////////////////////////
282
283 e26eb4e7 Leszek Koltunski
  public String getInventor()
284 29b82486 Leszek Koltunski
    {
285 2a14c33e Leszek Koltunski
    return "V. Kopsky, K. Hrsel";
286 29b82486 Leszek Koltunski
    }
287
288 59c20632 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
289
290 e26eb4e7 Leszek Koltunski
  public int getYearOfInvention()
291 59c20632 Leszek Koltunski
    {
292 577fcf3d Leszek Koltunski
    return 1990;
293 59c20632 Leszek Koltunski
    }
294
295 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
296
297 e26eb4e7 Leszek Koltunski
  public int getComplexity()
298 29b82486 Leszek Koltunski
    {
299 b4223a92 Leszek Koltunski
    return 3;
300 29b82486 Leszek Koltunski
    }
301 052e0362 Leszek Koltunski
302
///////////////////////////////////////////////////////////////////////////////////////////////////
303
304
  public String[][] getTutorials()
305
    {
306
    return new String[][]{
307
                          {"gb","0tX-f6RLgac","How to Solve the Square-1","Z3"},
308
                          {"es","mGtHDWj_i1o","Resolver SQUARE-1","Cuby"},
309
                          {"ru","XguuJTUwJoE","Как собрать Скваер-1","Алексей Ярыгин"},
310
                          {"fr","knRmTSa6aHQ","Comment résoudre le Square-1 (1/3)","Valentino Cube"},
311
                          {"fr","y-0ZrAgzETI","Comment résoudre le Square-1 (2/3)","Valentino Cube"},
312
                          {"fr","tYbE9GfEokw","Comment résoudre le Square-1 (3/3)","Valentino Cube"},
313
                          {"de","p9DMIzNQ3b8","Square-1 Tutorial (1/2)","Pezcraft"},
314
                          {"de","gM6E28JGmoo","Square-1 Tutorial (2/2)","Pezcraft"},
315
                          {"pl","_0rsImrp9jc","Jak ułożyć: Square-1","DżoDżo"},
316
                          {"br","geT7SvX0DEw","Tutorial do Square-1","Pedro Filho"},
317
                          {"kr","NcB50lWdQzE","스퀘어1 맞추는 방법","iamzoone"},
318 a399e91b Leszek Koltunski
                          {"vn","YvCZXkbZnNs","Tutorial N.120 - Square 1","Duy Thích Rubik"},
319 052e0362 Leszek Koltunski
                         };
320
    }
321 29b82486 Leszek Koltunski
}