Project

General

Profile

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

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

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