Project

General

Profile

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

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

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