Project

General

Profile

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

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

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

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

    
34
public class TwistySquare2 extends TwistySquare
35
{
36
  private ScrambleState[] mStates;
37
  private int[] mQuatNumber;
38
  private float[][] mCenters;
39
  private int[][] mStickerColor;
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 ScrambleState[] getScrambleStates()
51
    {
52
    if( mStates==null )
53
      {
54
      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};
55
      int[] SL_1 = new int[] { 0,1,1, 1,1,1 };
56
      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 };
57
      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 };
58
      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 };
59

    
60
      mStates = new ScrambleState[]
61
        {
62
        new ScrambleState( new int[][] { LO_2, SL_6, LO_3 } ),  // 0
63
        new ScrambleState( new int[][] { LO_2, null, LO_3 } ),  // SL
64
        new ScrambleState( new int[][] { null, SL_1, LO_4 } ),  // LO
65
        new ScrambleState( new int[][] { LO_4, SL_1, null } ),  // UP
66
        new ScrambleState( new int[][] { null, SL_1, null } ),  // UL
67
        };
68
      }
69

    
70
    return mStates;
71
    }
72

    
73
///////////////////////////////////////////////////////////////////////////////////////////////////
74

    
75
  public int[] getSolvedQuats(int cubit, int[] numLayers)
76
    {
77
    return null;
78
    }
79

    
80
///////////////////////////////////////////////////////////////////////////////////////////////////
81

    
82
  public ObjectShape getObjectShape(int variant)
83
    {
84
    if( variant==0 )
85
      {
86
      float[][] vertices = new float[][]
87
        {
88
         { -1.5f-X, 0.5f, 1.5f },
89
         {    0.0f, 0.5f, 1.5f },
90
         {    0.0f, 0.5f,-1.5f },
91
         { -1.5f+X, 0.5f,-1.5f },
92
         { -1.5f-X,-0.5f, 1.5f },
93
         {    0.0f,-0.5f, 1.5f },
94
         {    0.0f,-0.5f,-1.5f },
95
         { -1.5f+X,-0.5f,-1.5f }
96
        };
97

    
98
      int[][] vert_indices = new int[][]
99
        {
100
         {4,5,1,0},
101
         {5,6,2,1},
102
         {6,7,3,2},
103
         {7,4,0,3},
104
         {0,1,2,3},
105
         {4,5,6,7}
106
        };
107

    
108
      float[][] bands     = new float[][] { {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} };
109
      int[] bandIndices   = new int[] { 2,2,1,1,0,2 };
110
      float[][] corners   = new float[][] { {0.03f,0.05f} };
111
      int[] cornerIndices = new int[] { 0,0,0,0,0,0,0,0 };
112
      float[][] centers   = new float[][] { { -0.75f, 0.0f, 0.0f} };
113
      int[] centerIndices = new int[] { 0,0,0,0,0,0,0,0 };
114
      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null, 3);
115
      }
116
    else if( variant==1 )
117
      {
118
      float[][] vertices = new float[][]
119
        {
120
         {  -X, 0.5f, 0.0f },
121
         {  +X, 0.5f, 0.0f },
122
         {0.0f, 0.5f,-1.5f },
123
         {  -X,-0.5f, 0.0f },
124
         {  +X,-0.5f, 0.0f },
125
         {0.0f,-0.5f,-1.5f },
126
        };
127

    
128
      int[][] vert_indices = new int[][]
129
        {
130
         {0,1,2},
131
         {3,4,1,0},
132
         {3,4,5},
133
         {4,5,2,1},
134
         {5,3,0,2}
135
        };
136

    
137
      float[][] bands     = new float[][] { {0.038f,35,0.5f,0.9f, 5,2,1}, {0.001f,35,0.5f,0.9f, 5,2,1} };
138
      int[] bandIndices   = new int[] { 0,1,0,1,1 };
139
      float[][] corners   = new float[][] { {0.04f,0.15f} };
140
      int[] cornerIndices = new int[] { 0,0,-1,0,0,-1 };
141
      float[][] centers   = new float[][] { { 0.0f, 0.0f,-0.5f} };
142
      int[] centerIndices = new int[] { 0,0,-1,0,0,-1 };
143
      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null, 2);
144
      }
145
    else
146
      {
147
      float[][] vertices = new float[][]
148
        {
149
         {-0.75f+X/2, 0.5f,  0.0f },
150
         { 0.75f-X/2, 0.5f,  0.0f },
151
         {-0.75f-X/2, 0.5f, -1.5f },
152
         {-0.75f+X/2,-0.5f,  0.0f },
153
         { 0.75f-X/2,-0.5f,  0.0f },
154
         {-0.75f-X/2,-0.5f, -1.5f }
155
        };
156
      int[][] vert_indices = new int[][]
157
        {
158
         {0,1,2},
159
         {3,4,1,0},
160
         {5,4,3},
161
         {4,5,2,1},
162
         {5,3,0,2}
163
        };
164

    
165
      float[][] bands     = new float[][] { {0.030f,35,0.9f,1.0f, 5,2,1}, {0.001f,35,0.9f,1.0f, 5,2,1} };
166
      int[] bandIndices   = new int[] { 0,0,0,1,1 };
167
      float[][] corners   = new float[][] { {0.05f,0.13f} };
168
      int[] cornerIndices = new int[] { 0,0,-1,0,0,-1 };
169
      float[][] centers   = new float[][] { { 0.0f, 0.0f,-0.5f} };
170
      int[] centerIndices = new int[] { 0,0,-1,0,0,-1 };
171
      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null, 2);
172
      }
173
    }
174

    
175
///////////////////////////////////////////////////////////////////////////////////////////////////
176

    
177
  public Static4D getQuat(int cubit, int[] numLayers)
178
    {
179
    if( mQuats==null ) initializeQuats();
180

    
181
    if( mQuatNumber ==null )
182
      {
183
      mQuatNumber = new int[]
184
        {
185
        0, 6,
186
        0, 9, 6, 3, 18, 15, 12, 21,
187
        0, 9, 6, 3, 0, 9, 6, 3,
188
        15, 12, 21, 18, 15, 12, 21, 18
189
        };
190
      }
191

    
192
    return mQuats[mQuatNumber[cubit]];
193
    }
194

    
195
///////////////////////////////////////////////////////////////////////////////////////////////////
196

    
197
  public int getNumCubitVariants(int[] numLayers)
198
    {
199
    return 3;
200
    }
201

    
202
///////////////////////////////////////////////////////////////////////////////////////////////////
203

    
204
  public int getCubitVariant(int cubit, int[] numLayers)
205
    {
206
    return cubit<2 ? 0 : (cubit<10 ? 1:2);
207
    }
208

    
209
///////////////////////////////////////////////////////////////////////////////////////////////////
210

    
211
  public float[][] getCubitPositions(int[] numLayers)
212
    {
213
    if( mCenters ==null )
214
      {
215
      float Y = 0.75f + X/2;
216

    
217
      mCenters = new float[][]
218
        {
219
         { 1.5f, 0.0f, 0.0f },
220
         {-1.5f, 0.0f, 0.0f },
221

    
222
         { 0.0f, 1.0f, 1.5f },
223
         { 1.5f, 1.0f, 0.0f },
224
         { 0.0f, 1.0f,-1.5f },
225
         {-1.5f, 1.0f, 0.0f },
226
         { 0.0f,-1.0f, 1.5f },
227
         { 1.5f,-1.0f, 0.0f },
228
         { 0.0f,-1.0f,-1.5f },
229
         {-1.5f,-1.0f, 0.0f },
230

    
231
         {    Y, 1.0f, 1.5f },
232
         { 1.5f, 1.0f,   -Y },
233
         {   -Y, 1.0f,-1.5f },
234
         {-1.5f, 1.0f,    Y },
235
         {    Y,-1.0f, 1.5f },
236
         { 1.5f,-1.0f,   -Y },
237
         {   -Y,-1.0f,-1.5f },
238
         {-1.5f,-1.0f,    Y },
239

    
240
         { 1.5f, 1.0f,    Y },
241
         {    Y, 1.0f,-1.5f },
242
         {-1.5f, 1.0f,   -Y },
243
         {   -Y, 1.0f, 1.5f },
244
         { 1.5f,-1.0f,    Y },
245
         {    Y,-1.0f,-1.5f },
246
         {-1.5f,-1.0f,   -Y },
247
         {   -Y,-1.0f, 1.5f },
248
        };
249
      }
250

    
251
    return mCenters;
252
    }
253

    
254
///////////////////////////////////////////////////////////////////////////////////////////////////
255

    
256
  public int getSolvedFunctionIndex()
257
    {
258
    return 3;
259
    }
260

    
261
///////////////////////////////////////////////////////////////////////////////////////////////////
262

    
263
  public int getCubitFaceColor(int cubit, int face, int[] numLayers)
264
    {
265
    if( mStickerColor==null )
266
      {
267
      // YELLOW 0 WHITE 1 BLUE 2 GREEN 3 RED 4 ORANGE 5
268
      mStickerColor = new int[][]
269
        {
270
         { 4, 0, 5,-1,-1,-1 }, // 0
271
         { 5, 1, 4,-1,-1,-1 },
272

    
273
         { 2, 4,-1,-1,-1,-1 }, // 2
274
         { 2, 0,-1,-1,-1,-1 },
275
         { 2, 5,-1,-1,-1,-1 },
276
         { 2, 1,-1,-1,-1,-1 },
277
         { 3, 4,-1,-1,-1,-1 },
278
         { 3, 0,-1,-1,-1,-1 },
279
         { 3, 5,-1,-1,-1,-1 },
280
         { 3, 1,-1,-1,-1,-1 },
281

    
282
         { 2, 4,-1,-1,-1,-1 }, // 10
283
         { 2, 0,-1,-1,-1,-1 },
284
         { 2, 5,-1,-1,-1,-1 },
285
         { 2, 1,-1,-1,-1,-1 },
286
         {-1, 4, 3,-1,-1,-1 },
287
         {-1, 0, 3,-1,-1,-1 },
288
         {-1, 5, 3,-1,-1,-1 },
289
         {-1, 1, 3,-1,-1,-1 },
290

    
291
         {-1, 0, 2,-1,-1,-1 }, // 18
292
         {-1, 5, 2,-1,-1,-1 },
293
         {-1, 1, 2,-1,-1,-1 },
294
         {-1, 4, 2,-1,-1,-1 },
295
         { 3, 0,-1,-1,-1,-1 },
296
         { 3, 5,-1,-1,-1,-1 },
297
         { 3, 1,-1,-1,-1,-1 },
298
         { 3, 4,-1,-1,-1,-1 },
299
        };
300
      }
301

    
302
    return mStickerColor[cubit][face];
303
    }
304

    
305
///////////////////////////////////////////////////////////////////////////////////////////////////
306

    
307
  public int getVariantFaceColor(int variant, int face, int[] numLayers)
308
    {
309
    return face>=mStickerVariants[variant].length ? -1 : mStickerVariants[variant][face];
310
    }
311

    
312
///////////////////////////////////////////////////////////////////////////////////////////////////
313

    
314
  public float getStickerRadius()
315
    {
316
    return 0.12f;
317
    }
318

    
319
///////////////////////////////////////////////////////////////////////////////////////////////////
320

    
321
  public float getStickerStroke()
322
    {
323
    return ObjectControl.isInIconMode() ? 0.20f : 0.10f;
324
    }
325

    
326
///////////////////////////////////////////////////////////////////////////////////////////////////
327

    
328
  public float[][] getStickerAngles()
329
    {
330
    return null;
331
    }
332

    
333
///////////////////////////////////////////////////////////////////////////////////////////////////
334
// PUBLIC API
335

    
336
  public ObjectType intGetObjectType(int[] numLayers)
337
    {
338
    return ObjectType.SQU2_3;
339
    }
340

    
341
///////////////////////////////////////////////////////////////////////////////////////////////////
342

    
343
  public String getObjectName()
344
    {
345
    return "Square-2";
346
    }
347

    
348
///////////////////////////////////////////////////////////////////////////////////////////////////
349

    
350
  public String getInventor()
351
    {
352
    return "David Litwin";
353
    }
354

    
355
///////////////////////////////////////////////////////////////////////////////////////////////////
356

    
357
  public int getYearOfInvention()
358
    {
359
    return 1995;
360
    }
361

    
362
///////////////////////////////////////////////////////////////////////////////////////////////////
363

    
364
  public int getComplexity()
365
    {
366
    return 3;
367
    }
368
}
(24-24/26)