Project

General

Profile

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

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

1
///////////////////////////////////////////////////////////////////////////////////////////////////
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
import java.io.InputStream;
23

    
24
import org.distorted.library.type.Static3D;
25
import org.distorted.library.type.Static4D;
26

    
27
import org.distorted.objectlib.helpers.ObjectFaceShape;
28
import org.distorted.objectlib.main.ObjectType;
29
import org.distorted.objectlib.helpers.ObjectShape;
30
import org.distorted.objectlib.scrambling.ScrambleState;
31

    
32
///////////////////////////////////////////////////////////////////////////////////////////////////
33

    
34
public class TwistySquare1 extends TwistySquare
35
{
36
  private int[] mQuatNumber;
37
  private float[][] mCenters;
38

    
39
///////////////////////////////////////////////////////////////////////////////////////////////////
40

    
41
  public TwistySquare1(int[] numL, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
42
    {
43
    super(numL, meshState, iconMode, quat, move, scale, stream);
44
    }
45

    
46
///////////////////////////////////////////////////////////////////////////////////////////////////
47

    
48
  @Override
49
  public int getScrambleType()
50
    {
51
    return 1;
52
    }
53

    
54
///////////////////////////////////////////////////////////////////////////////////////////////////
55

    
56
  public ScrambleState[] getScrambleStates()
57
    {
58
    return null;
59
    }
60

    
61
///////////////////////////////////////////////////////////////////////////////////////////////////
62

    
63
  public float[][] getCubitPositions(int[] numLayers)
64
    {
65
    if( mCenters==null )
66
      {
67
      mCenters = new float[][]
68
        {
69
         { 1.5f, 0.0f, 0.0f },
70
         {-1.5f, 0.0f, 0.0f },
71

    
72
         { 0.0f, 1.0f, 1.5f },
73
         { 1.5f, 1.0f, 0.0f },
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

    
81
         { 1.0f, 1.0f, 2.0f, 2.0f, 1.0f, 1.0f },
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
        };
90
      }
91
    return mCenters;
92
    }
93

    
94
///////////////////////////////////////////////////////////////////////////////////////////////////
95

    
96
  public Static4D getCubitQuats(int cubit, int[] numLayers)
97
    {
98
    if( mQuatNumber ==null )
99
      {
100
      mQuatNumber = new int[]
101
        {
102
        0, 6,
103
        0, 9, 6, 3, 17, 14, 23, 20,
104
        0, 9, 6, 3, 14, 23, 20, 17
105
        };
106
      }
107

    
108
    return mObjectQuats[mQuatNumber[cubit]];
109
    }
110

    
111
///////////////////////////////////////////////////////////////////////////////////////////////////
112

    
113
  public ObjectShape getObjectShape(int variant)
114
    {
115
    if( variant==0 )
116
      {
117
      float[][] vertices =
118
        {
119
         { -1.5f-X, 0.5f, 1.5f },
120
         {    0.0f, 0.5f, 1.5f },
121
         {    0.0f, 0.5f,-1.5f },
122
         { -1.5f+X, 0.5f,-1.5f },
123
         { -1.5f-X,-0.5f, 1.5f },
124
         {    0.0f,-0.5f, 1.5f },
125
         {    0.0f,-0.5f,-1.5f },
126
         { -1.5f+X,-0.5f,-1.5f }
127
        };
128

    
129
      int[][] indices =
130
        {
131
         {4,5,1,0},
132
         {5,6,2,1},
133
         {6,7,3,2},
134
         {7,4,0,3},
135
         {0,1,2,3},
136
         {7,6,5,4}
137
        };
138

    
139
      return new ObjectShape(vertices, indices);
140
      }
141
    else if( variant==1 )
142
      {
143
      float[][] vertices =
144
        {
145
         {  -X, 0.5f, 0.0f },
146
         {  +X, 0.5f, 0.0f },
147
         {0.0f, 0.5f,-1.5f },
148
         {  -X,-0.5f, 0.0f },
149
         {  +X,-0.5f, 0.0f },
150
         {0.0f,-0.5f,-1.5f },
151
        };
152

    
153
      int[][] indices =
154
        {
155
         {0,1,2},
156
         {3,4,1,0},
157
         {5,4,3},
158
         {4,5,2,1},
159
         {5,3,0,2}
160
        };
161

    
162
      return new ObjectShape(vertices, indices);
163
      }
164
    else
165
      {
166
      float[][] vertices =
167
        {
168
         { X-1.5f, 0.5f,  0.0f },
169
         {   0.0f, 0.5f,  0.0f },
170
         {   0.0f, 0.5f,X-1.5f },
171
         {  -1.5f, 0.5f, -1.5f },
172
         { X-1.5f,-0.5f,  0.0f },
173
         {   0.0f,-0.5f,  0.0f },
174
         {   0.0f,-0.5f,X-1.5f },
175
         {  -1.5f,-0.5f, -1.5f }
176
        };
177
      int[][] indices =
178
        {
179
         {0,1,2,3},
180
         {4,5,1,0},
181
         {5,6,2,1},
182
         {7,4,0,3},
183
         {6,7,3,2},
184
         {7,6,5,4}
185
        };
186

    
187
      return new ObjectShape(vertices, indices);
188
      }
189
    }
190

    
191
///////////////////////////////////////////////////////////////////////////////////////////////////
192

    
193
  public ObjectFaceShape getObjectFaceShape(int variant)
194
    {
195
    if( variant==0 )
196
      {
197
      float h1 = isInIconMode() ? 0.001f : 0.04f;
198
      float h2 = isInIconMode() ? 0.001f : 0.02f;
199
      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} };
200
      int[] bandIndices   = { 0,0,1,2,2,2 };
201
      float[][] corners   = { {0.03f,0.05f} };
202
      int[] cornerIndices = { 0,0,0,0,0,0,0,0 };
203
      float[][] centers   = { { -0.75f, 0.0f, 0.0f} };
204
      int[] centerIndices = { 0,0,0,0,0,0,0,0 };
205
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
206
      }
207
    else if( variant==1 )
208
      {
209
      float height = isInIconMode() ? 0.001f : 0.038f;
210
      float[][] bands     = { {height,35,0.5f,0.9f, 5,2,1}, {0.001f,35,0.5f,0.9f, 5,2,1} };
211
      int[] bandIndices   = { 0,0,0,1,1 };
212
      float[][] corners   = { {0.04f,0.15f} };
213
      int[] cornerIndices = { 0,0,-1,0,0,-1 };
214
      float[][] centers   = { { 0.0f, 0.0f,-0.5f} };
215
      int[] centerIndices = { 0,0,-1,0,0,-1 };
216
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
217
      }
218
    else
219
      {
220
      float height = isInIconMode() ? 0.001f : 0.038f;
221
      float[][] bands     = { {height,35,0.9f,1.0f, 5,2,1}, {0.001f,35,0.9f,1.0f, 5,2,1} };
222
      int[] bandIndices   = { 0,0,0,1,1,1 };
223
      float[][] corners   = { {0.05f,0.13f} };
224
      int[] cornerIndices = { 0,0,0,-1,0,0,0,-1 };
225
      float[][] centers   = { { -0.5f, 0.0f,-0.5f} };
226
      int[] centerIndices = { -1,0,-1,-1,-1,0,-1,-1 };
227
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
228
      }
229
    }
230

    
231
///////////////////////////////////////////////////////////////////////////////////////////////////
232

    
233
  public int getNumCubitVariants(int[] numLayers)
234
    {
235
    return 3;
236
    }
237

    
238
///////////////////////////////////////////////////////////////////////////////////////////////////
239

    
240
  public int getCubitVariant(int cubit, int[] numLayers)
241
    {
242
    return cubit<2 ? 0 : (cubit<10 ? 1:2);
243
    }
244

    
245
///////////////////////////////////////////////////////////////////////////////////////////////////
246

    
247
  public float getStickerRadius()
248
    {
249
    return 0.12f;
250
    }
251

    
252
///////////////////////////////////////////////////////////////////////////////////////////////////
253

    
254
  public float getStickerStroke()
255
    {
256
    return isInIconMode() ? 0.20f : 0.10f;
257
    }
258

    
259
///////////////////////////////////////////////////////////////////////////////////////////////////
260

    
261
  public float[][] getStickerAngles()
262
    {
263
    return null;
264
    }
265

    
266
///////////////////////////////////////////////////////////////////////////////////////////////////
267
// PUBLIC API
268

    
269
  public String getShortName()
270
    {
271
    return ObjectType.SQU1_3.name();
272
    }
273

    
274
///////////////////////////////////////////////////////////////////////////////////////////////////
275

    
276
  public long getSignature()
277
    {
278
    return ObjectType.SQU1_3.ordinal();
279
    }
280

    
281
///////////////////////////////////////////////////////////////////////////////////////////////////
282

    
283
  public String getObjectName()
284
    {
285
    return "Square-1";
286
    }
287

    
288
///////////////////////////////////////////////////////////////////////////////////////////////////
289

    
290
  public String getInventor()
291
    {
292
    return "V. Kopsky, K. Hrsel";
293
    }
294

    
295
///////////////////////////////////////////////////////////////////////////////////////////////////
296

    
297
  public int getYearOfInvention()
298
    {
299
    return 1990;
300
    }
301

    
302
///////////////////////////////////////////////////////////////////////////////////////////////////
303

    
304
  public int getComplexity()
305
    {
306
    return 3;
307
    }
308

    
309
///////////////////////////////////////////////////////////////////////////////////////////////////
310

    
311
  public String[][] getTutorials()
312
    {
313
    return new String[][]{
314
                          {"gb","0tX-f6RLgac","How to Solve the Square-1","Z3"},
315
                          {"es","mGtHDWj_i1o","Resolver SQUARE-1","Cuby"},
316
                          {"ru","XguuJTUwJoE","Как собрать Скваер-1","Алексей Ярыгин"},
317
                          {"fr","knRmTSa6aHQ","Comment résoudre le Square-1 (1/3)","Valentino Cube"},
318
                          {"fr","y-0ZrAgzETI","Comment résoudre le Square-1 (2/3)","Valentino Cube"},
319
                          {"fr","tYbE9GfEokw","Comment résoudre le Square-1 (3/3)","Valentino Cube"},
320
                          {"de","p9DMIzNQ3b8","Square-1 Tutorial (1/2)","Pezcraft"},
321
                          {"de","gM6E28JGmoo","Square-1 Tutorial (2/2)","Pezcraft"},
322
                          {"pl","_0rsImrp9jc","Jak ułożyć: Square-1","DżoDżo"},
323
                          {"br","geT7SvX0DEw","Tutorial do Square-1","Pedro Filho"},
324
                          {"kr","NcB50lWdQzE","스퀘어1 맞추는 방법","iamzoone"},
325
                          {"vn","YvCZXkbZnNs","Tutorial N.120 - Square 1","Duy Thích Rubik"},
326
                         };
327
    }
328
}
(29-29/34)