Project

General

Profile

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

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

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.ObjectControl;
29
import org.distorted.objectlib.main.ObjectType;
30
import org.distorted.objectlib.helpers.ObjectShape;
31
import org.distorted.objectlib.scrambling.ScrambleState;
32

    
33
///////////////////////////////////////////////////////////////////////////////////////////////////
34

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

    
40
///////////////////////////////////////////////////////////////////////////////////////////////////
41

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

    
47
///////////////////////////////////////////////////////////////////////////////////////////////////
48

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

    
55
///////////////////////////////////////////////////////////////////////////////////////////////////
56

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

    
62
///////////////////////////////////////////////////////////////////////////////////////////////////
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
    if( mQuatNumber ==null )
100
      {
101
      mQuatNumber = new int[]
102
        {
103
        0, 6,
104
        0, 9, 6, 3, 17, 14, 23, 20,
105
        0, 9, 6, 3, 14, 23, 20, 17
106
        };
107
      }
108

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

    
112
///////////////////////////////////////////////////////////////////////////////////////////////////
113

    
114
  public ObjectShape getObjectShape(int variant)
115
    {
116
    if( variant==0 )
117
      {
118
      float[][] vertices =
119
        {
120
         { -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
        };
129

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

    
140
      return new ObjectShape(vertices, indices);
141
      }
142
    else if( variant==1 )
143
      {
144
      float[][] vertices =
145
        {
146
         {  -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
        };
153

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

    
163
      return new ObjectShape(vertices, indices);
164
      }
165
    else
166
      {
167
      float[][] vertices =
168
        {
169
         { 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
        };
178
      int[][] indices =
179
        {
180
         {0,1,2,3},
181
         {4,5,1,0},
182
         {5,6,2,1},
183
         {7,4,0,3},
184
         {6,7,3,2},
185
         {7,6,5,4}
186
        };
187

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

    
192
///////////////////////////////////////////////////////////////////////////////////////////////////
193

    
194
  public ObjectFaceShape getObjectFaceShape(int variant)
195
    {
196
    if( variant==0 )
197
      {
198
      float[][] bands     = { {0.040f,35,0.2f,0.8f,5,2,1}, {0.020f,35,0.5f,1.0f,5,2,1}, {0.001f,35,0.3f,0.8f,5,2,1} };
199
      int[] bandIndices   = { 0,0,1,2,2,2 };
200
      float[][] corners   = { {0.03f,0.05f} };
201
      int[] cornerIndices = { 0,0,0,0,0,0,0,0 };
202
      float[][] centers   = { { -0.75f, 0.0f, 0.0f} };
203
      int[] centerIndices = { 0,0,0,0,0,0,0,0 };
204
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
205
      }
206
    else if( variant==1 )
207
      {
208
      float[][] bands     = { {0.038f,35,0.5f,0.9f, 5,2,1}, {0.001f,35,0.5f,0.9f, 5,2,1} };
209
      int[] bandIndices   = { 0,0,0,1,1 };
210
      float[][] corners   = { {0.04f,0.15f} };
211
      int[] cornerIndices = { 0,0,-1,0,0,-1 };
212
      float[][] centers   = { { 0.0f, 0.0f,-0.5f} };
213
      int[] centerIndices = { 0,0,-1,0,0,-1 };
214
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
215
      }
216
    else
217
      {
218
      float[][] bands     = { {0.038f,35,0.9f,1.0f, 5,2,1}, {0.001f,35,0.9f,1.0f, 5,2,1} };
219
      int[] bandIndices   = { 0,0,0,1,1,1 };
220
      float[][] corners   = { {0.05f,0.13f} };
221
      int[] cornerIndices = { 0,0,0,-1,0,0,0,-1 };
222
      float[][] centers   = { { -0.5f, 0.0f,-0.5f} };
223
      int[] centerIndices = { -1,0,-1,-1,-1,0,-1,-1 };
224
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
225
      }
226
    }
227

    
228
///////////////////////////////////////////////////////////////////////////////////////////////////
229

    
230
  public int getNumCubitVariants(int[] numLayers)
231
    {
232
    return 3;
233
    }
234

    
235
///////////////////////////////////////////////////////////////////////////////////////////////////
236

    
237
  public int getCubitVariant(int cubit, int[] numLayers)
238
    {
239
    return cubit<2 ? 0 : (cubit<10 ? 1:2);
240
    }
241

    
242
///////////////////////////////////////////////////////////////////////////////////////////////////
243

    
244
  public float getStickerRadius()
245
    {
246
    return 0.12f;
247
    }
248

    
249
///////////////////////////////////////////////////////////////////////////////////////////////////
250

    
251
  public float getStickerStroke()
252
    {
253
    return ObjectControl.isInIconMode() ? 0.20f : 0.10f;
254
    }
255

    
256
///////////////////////////////////////////////////////////////////////////////////////////////////
257

    
258
  public float[][] getStickerAngles()
259
    {
260
    return null;
261
    }
262

    
263
///////////////////////////////////////////////////////////////////////////////////////////////////
264
// PUBLIC API
265

    
266
  public String getShortName()
267
    {
268
    return ObjectType.SQU1_3.name();
269
    }
270

    
271
///////////////////////////////////////////////////////////////////////////////////////////////////
272

    
273
  public long getSignature()
274
    {
275
    return ObjectType.SQU1_3.ordinal();
276
    }
277

    
278
///////////////////////////////////////////////////////////////////////////////////////////////////
279

    
280
  public String getObjectName()
281
    {
282
    return "Square-1";
283
    }
284

    
285
///////////////////////////////////////////////////////////////////////////////////////////////////
286

    
287
  public String getInventor()
288
    {
289
    return "V. Kopsky, K. Hrsel";
290
    }
291

    
292
///////////////////////////////////////////////////////////////////////////////////////////////////
293

    
294
  public int getYearOfInvention()
295
    {
296
    return 1990;
297
    }
298

    
299
///////////////////////////////////////////////////////////////////////////////////////////////////
300

    
301
  public int getComplexity()
302
    {
303
    return 3;
304
    }
305

    
306
///////////////////////////////////////////////////////////////////////////////////////////////////
307

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