Project

General

Profile

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

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

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