Project

General

Profile

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

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

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