Project

General

Profile

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

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

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