Project

General

Profile

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

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

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