Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistySquare2.java @ 1b7ece90

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.helpers.ScrambleState;
32

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

    
35
public class TwistySquare2 extends TwistySquare
36
{
37
  private ScrambleState[] mStates;
38
  private int[] mQuatNumber;
39
  private float[][] mCenters;
40

    
41
///////////////////////////////////////////////////////////////////////////////////////////////////
42

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

    
48
///////////////////////////////////////////////////////////////////////////////////////////////////
49

    
50
  public int[] getSolvedQuats(int cubit, int[] numLayers)
51
    {
52
    return null;
53
    }
54

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

    
57
  public int getSolvedFunctionIndex()
58
    {
59
    return 3;
60
    }
61

    
62
///////////////////////////////////////////////////////////////////////////////////////////////////
63

    
64
  public ScrambleState[] getScrambleStates()
65
    {
66
    if( mStates==null )
67
      {
68
      int[] SL_6 = new int[] { 0,1,1, 1,1,1, 0,1,1, 1,1,1, 0,1,1, 1,1,1, 0,1,1, 1,1,1, 0,1,1, 1,1,1, 0,1,1, 1,1,1};
69
      int[] SL_1 = new int[] { 0,1,1, 1,1,1 };
70
      int[] LO_2 = new int[] { 0,-5,2, 0,-4,2, 0,-3,2, 0,-2,2, 0,-1,2, 0,1,2, 0,2,2, 0,3,2, 0,4,2, 0,5,2, 0,5,2 };
71
      int[] LO_3 = new int[] { 0,-5,3, 0,-4,3, 0,-3,3, 0,-2,3, 0,-1,3, 0,1,3, 0,2,3, 0,3,3, 0,4,3, 0,5,3, 0,5,3 };
72
      int[] LO_4 = new int[] { 0,-5,4, 0,-4,4, 0,-3,4, 0,-2,4, 0,-1,4, 0,1,4, 0,2,4, 0,3,4, 0,4,4, 0,5,4, 0,5,4 };
73

    
74
      mStates = new ScrambleState[]
75
        {
76
        new ScrambleState( new int[][] { LO_2, SL_6, LO_3 } ),  // 0
77
        new ScrambleState( new int[][] { LO_2, null, LO_3 } ),  // SL
78
        new ScrambleState( new int[][] { null, SL_1, LO_4 } ),  // LO
79
        new ScrambleState( new int[][] { LO_4, SL_1, null } ),  // UP
80
        new ScrambleState( new int[][] { null, SL_1, null } ),  // UL
81
        };
82
      }
83

    
84
    return mStates;
85
    }
86

    
87
///////////////////////////////////////////////////////////////////////////////////////////////////
88

    
89
  public float[][] getCubitPositions(int[] numLayers)
90
    {
91
    if( mCenters ==null )
92
      {
93
      float Y = 0.75f + X/2;
94

    
95
      mCenters = new float[][]
96
        {
97
         { 1.5f, 0.0f, 0.0f },
98
         {-1.5f, 0.0f, 0.0f },
99

    
100
         { 0.0f, 1.0f, 1.5f },
101
         { 1.5f, 1.0f, 0.0f },
102
         { 0.0f, 1.0f,-1.5f },
103
         {-1.5f, 1.0f, 0.0f },
104
         { 0.0f,-1.0f, 1.5f },
105
         { 1.5f,-1.0f, 0.0f },
106
         { 0.0f,-1.0f,-1.5f },
107
         {-1.5f,-1.0f, 0.0f },
108

    
109
         {    Y, 1.0f, 1.5f },
110
         { 1.5f, 1.0f,   -Y },
111
         {   -Y, 1.0f,-1.5f },
112
         {-1.5f, 1.0f,    Y },
113
         {    Y,-1.0f, 1.5f },
114
         { 1.5f,-1.0f,   -Y },
115
         {   -Y,-1.0f,-1.5f },
116
         {-1.5f,-1.0f,    Y },
117

    
118
         { 1.5f, 1.0f,    Y },
119
         {    Y, 1.0f,-1.5f },
120
         {-1.5f, 1.0f,   -Y },
121
         {   -Y, 1.0f, 1.5f },
122
         { 1.5f,-1.0f,    Y },
123
         {    Y,-1.0f,-1.5f },
124
         {-1.5f,-1.0f,   -Y },
125
         {   -Y,-1.0f, 1.5f },
126
        };
127
      }
128

    
129
    return mCenters;
130
    }
131

    
132
///////////////////////////////////////////////////////////////////////////////////////////////////
133

    
134
  public Static4D getCubitQuats(int cubit, int[] numLayers)
135
    {
136
    if( mQuatNumber ==null )
137
      {
138
      mQuatNumber = new int[]
139
        {
140
        0, 6,
141
        0, 9, 6, 3, 17, 14, 23, 20,
142
        0, 9, 6, 3, 0, 9, 6, 3,
143
        14, 23, 20, 17, 14, 23, 20, 17
144
        };
145
      }
146

    
147
    return mObjectQuats[mQuatNumber[cubit]];
148
    }
149

    
150
///////////////////////////////////////////////////////////////////////////////////////////////////
151

    
152
  public ObjectShape getObjectShape(int variant)
153
    {
154
    if( variant==0 )
155
      {
156
      float[][] vertices =
157
        {
158
         { -1.5f-X, 0.5f, 1.5f },
159
         {    0.0f, 0.5f, 1.5f },
160
         {    0.0f, 0.5f,-1.5f },
161
         { -1.5f+X, 0.5f,-1.5f },
162
         { -1.5f-X,-0.5f, 1.5f },
163
         {    0.0f,-0.5f, 1.5f },
164
         {    0.0f,-0.5f,-1.5f },
165
         { -1.5f+X,-0.5f,-1.5f }
166
        };
167

    
168
      int[][] indices =
169
        {
170
         {4,5,1,0},
171
         {5,6,2,1},
172
         {6,7,3,2},
173
         {7,4,0,3},
174
         {0,1,2,3},
175
         {4,5,6,7}
176
        };
177

    
178
      return new ObjectShape(vertices, indices);
179
      }
180
    else if( variant==1 )
181
      {
182
      float[][] vertices =
183
        {
184
         {  -X, 0.5f, 0.0f },
185
         {  +X, 0.5f, 0.0f },
186
         {0.0f, 0.5f,-1.5f },
187
         {  -X,-0.5f, 0.0f },
188
         {  +X,-0.5f, 0.0f },
189
         {0.0f,-0.5f,-1.5f },
190
        };
191

    
192
      int[][] indices =
193
        {
194
         {0,1,2},
195
         {3,4,1,0},
196
         {3,4,5},
197
         {4,5,2,1},
198
         {5,3,0,2}
199
        };
200

    
201
      return new ObjectShape(vertices, indices);
202
      }
203
    else
204
      {
205
      float[][] vertices =
206
        {
207
         {-0.75f+X/2, 0.5f,  0.0f },
208
         { 0.75f-X/2, 0.5f,  0.0f },
209
         {-0.75f-X/2, 0.5f, -1.5f },
210
         {-0.75f+X/2,-0.5f,  0.0f },
211
         { 0.75f-X/2,-0.5f,  0.0f },
212
         {-0.75f-X/2,-0.5f, -1.5f }
213
        };
214
      int[][] indices =
215
        {
216
         {0,1,2},
217
         {3,4,1,0},
218
         {5,4,3},
219
         {4,5,2,1},
220
         {5,3,0,2}
221
        };
222

    
223
      return new ObjectShape(vertices, indices);
224
      }
225
    }
226

    
227
///////////////////////////////////////////////////////////////////////////////////////////////////
228

    
229
  public ObjectFaceShape getObjectFaceShape(int variant)
230
    {
231
    if( variant==0 )
232
      {
233
      float[][] bands     = { {0.040f,35,0.8f,1.0f,5,2,1}, {0.020f,35,0.8f,1.0f,5,2,1}, {0.001f,35,0.8f,1.0f,5,2,1} };
234
      int[] bandIndices   = { 2,2,1,1,0,2 };
235
      float[][] corners   = { {0.03f,0.05f} };
236
      int[] cornerIndices = { 0,0,0,0,0,0,0,0 };
237
      float[][] centers   = { { -0.75f, 0.0f, 0.0f} };
238
      int[] centerIndices = { 0,0,0,0,0,0,0,0 };
239
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
240
      }
241
    else if( variant==1 )
242
      {
243
      float[][] bands     = { {0.038f,35,0.5f,0.9f, 5,2,1}, {0.001f,35,0.5f,0.9f, 5,2,1} };
244
      int[] bandIndices   = { 0,1,0,1,1 };
245
      float[][] corners   = { {0.04f,0.15f} };
246
      int[] cornerIndices = { 0,0,-1,0,0,-1 };
247
      float[][] centers   = { { 0.0f, 0.0f,-0.5f} };
248
      int[] centerIndices = { 0,0,-1,0,0,-1 };
249
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
250
      }
251
    else
252
      {
253
      float[][] bands     = { {0.030f,35,0.9f,1.0f, 5,2,1}, {0.001f,35,0.9f,1.0f, 5,2,1} };
254
      int[] bandIndices   = { 0,0,0,1,1 };
255
      float[][] corners   = { {0.05f,0.13f} };
256
      int[] cornerIndices = { 0,0,-1,0,0,-1 };
257
      float[][] centers   = { { 0.0f, 0.0f,-0.5f} };
258
      int[] centerIndices = { 0,0,-1,0,0,-1 };
259
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
260
      }
261
    }
262

    
263
///////////////////////////////////////////////////////////////////////////////////////////////////
264

    
265
  public int getNumCubitVariants(int[] numLayers)
266
    {
267
    return 3;
268
    }
269

    
270
///////////////////////////////////////////////////////////////////////////////////////////////////
271

    
272
  public int getCubitVariant(int cubit, int[] numLayers)
273
    {
274
    return cubit<2 ? 0 : (cubit<10 ? 1:2);
275
    }
276

    
277
///////////////////////////////////////////////////////////////////////////////////////////////////
278

    
279
  public float getStickerRadius()
280
    {
281
    return 0.12f;
282
    }
283

    
284
///////////////////////////////////////////////////////////////////////////////////////////////////
285

    
286
  public float getStickerStroke()
287
    {
288
    return ObjectControl.isInIconMode() ? 0.20f : 0.10f;
289
    }
290

    
291
///////////////////////////////////////////////////////////////////////////////////////////////////
292

    
293
  public float[][] getStickerAngles()
294
    {
295
    return null;
296
    }
297

    
298
///////////////////////////////////////////////////////////////////////////////////////////////////
299
// PUBLIC API
300

    
301
  public ObjectType intGetObjectType(int[] numLayers)
302
    {
303
    return ObjectType.SQU2_3;
304
    }
305

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

    
308
  public String getObjectName()
309
    {
310
    return "Square-2";
311
    }
312

    
313
///////////////////////////////////////////////////////////////////////////////////////////////////
314

    
315
  public String getInventor()
316
    {
317
    return "David Litwin";
318
    }
319

    
320
///////////////////////////////////////////////////////////////////////////////////////////////////
321

    
322
  public int getYearOfInvention()
323
    {
324
    return 1995;
325
    }
326

    
327
///////////////////////////////////////////////////////////////////////////////////////////////////
328

    
329
  public int getComplexity()
330
    {
331
    return 3;
332
    }
333
}
(24-24/26)