Project

General

Profile

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

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

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 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 float[][] getCubitPositions(int[] numLayers)
83
    {
84
    if( mCenters ==null )
85
      {
86
      float Y = 0.75f + X/2;
87

    
88
      mCenters = new float[][]
89
        {
90
         { 1.5f, 0.0f, 0.0f },
91
         {-1.5f, 0.0f, 0.0f },
92

    
93
         { 0.0f, 1.0f, 1.5f },
94
         { 1.5f, 1.0f, 0.0f },
95
         { 0.0f, 1.0f,-1.5f },
96
         {-1.5f, 1.0f, 0.0f },
97
         { 0.0f,-1.0f, 1.5f },
98
         { 1.5f,-1.0f, 0.0f },
99
         { 0.0f,-1.0f,-1.5f },
100
         {-1.5f,-1.0f, 0.0f },
101

    
102
         {    Y, 1.0f, 1.5f },
103
         { 1.5f, 1.0f,   -Y },
104
         {   -Y, 1.0f,-1.5f },
105
         {-1.5f, 1.0f,    Y },
106
         {    Y,-1.0f, 1.5f },
107
         { 1.5f,-1.0f,   -Y },
108
         {   -Y,-1.0f,-1.5f },
109
         {-1.5f,-1.0f,    Y },
110

    
111
         { 1.5f, 1.0f,    Y },
112
         {    Y, 1.0f,-1.5f },
113
         {-1.5f, 1.0f,   -Y },
114
         {   -Y, 1.0f, 1.5f },
115
         { 1.5f,-1.0f,    Y },
116
         {    Y,-1.0f,-1.5f },
117
         {-1.5f,-1.0f,   -Y },
118
         {   -Y,-1.0f, 1.5f },
119
        };
120
      }
121

    
122
    return mCenters;
123
    }
124

    
125
///////////////////////////////////////////////////////////////////////////////////////////////////
126

    
127
  public Static4D getCubitQuats(int cubit, int[] numLayers)
128
    {
129
    if( mQuatNumber ==null )
130
      {
131
      mQuatNumber = new int[]
132
        {
133
        0, 6,
134
        0, 9, 6, 3, 17, 14, 23, 20,
135
        0, 9, 6, 3, 0, 9, 6, 3,
136
        14, 23, 20, 17, 14, 23, 20, 17
137
        };
138
      }
139

    
140
    return mObjectQuats[mQuatNumber[cubit]];
141
    }
142

    
143
///////////////////////////////////////////////////////////////////////////////////////////////////
144

    
145
  public ObjectShape getObjectShape(int variant)
146
    {
147
    if( variant==0 )
148
      {
149
      float[][] vertices =
150
        {
151
         { -1.5f-X, 0.5f, 1.5f },
152
         {    0.0f, 0.5f, 1.5f },
153
         {    0.0f, 0.5f,-1.5f },
154
         { -1.5f+X, 0.5f,-1.5f },
155
         { -1.5f-X,-0.5f, 1.5f },
156
         {    0.0f,-0.5f, 1.5f },
157
         {    0.0f,-0.5f,-1.5f },
158
         { -1.5f+X,-0.5f,-1.5f }
159
        };
160

    
161
      int[][] indices =
162
        {
163
         {4,5,1,0},
164
         {5,6,2,1},
165
         {6,7,3,2},
166
         {7,4,0,3},
167
         {0,1,2,3},
168
         {4,5,6,7}
169
        };
170

    
171
      return new ObjectShape(vertices, indices);
172
      }
173
    else if( variant==1 )
174
      {
175
      float[][] vertices =
176
        {
177
         {  -X, 0.5f, 0.0f },
178
         {  +X, 0.5f, 0.0f },
179
         {0.0f, 0.5f,-1.5f },
180
         {  -X,-0.5f, 0.0f },
181
         {  +X,-0.5f, 0.0f },
182
         {0.0f,-0.5f,-1.5f },
183
        };
184

    
185
      int[][] indices =
186
        {
187
         {0,1,2},
188
         {3,4,1,0},
189
         {3,4,5},
190
         {4,5,2,1},
191
         {5,3,0,2}
192
        };
193

    
194
      return new ObjectShape(vertices, indices);
195
      }
196
    else
197
      {
198
      float[][] vertices =
199
        {
200
         {-0.75f+X/2, 0.5f,  0.0f },
201
         { 0.75f-X/2, 0.5f,  0.0f },
202
         {-0.75f-X/2, 0.5f, -1.5f },
203
         {-0.75f+X/2,-0.5f,  0.0f },
204
         { 0.75f-X/2,-0.5f,  0.0f },
205
         {-0.75f-X/2,-0.5f, -1.5f }
206
        };
207
      int[][] indices =
208
        {
209
         {0,1,2},
210
         {3,4,1,0},
211
         {5,4,3},
212
         {4,5,2,1},
213
         {5,3,0,2}
214
        };
215

    
216
      return new ObjectShape(vertices, indices);
217
      }
218
    }
219

    
220
///////////////////////////////////////////////////////////////////////////////////////////////////
221

    
222
  public ObjectFaceShape getObjectFaceShape(int variant)
223
    {
224
    if( variant==0 )
225
      {
226
      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} };
227
      int[] bandIndices   = { 2,2,1,1,0,2 };
228
      float[][] corners   = { {0.03f,0.05f} };
229
      int[] cornerIndices = { 0,0,0,0,0,0,0,0 };
230
      float[][] centers   = { { -0.75f, 0.0f, 0.0f} };
231
      int[] centerIndices = { 0,0,0,0,0,0,0,0 };
232
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
233
      }
234
    else if( variant==1 )
235
      {
236
      float[][] bands     = { {0.038f,35,0.5f,0.9f, 5,2,1}, {0.001f,35,0.5f,0.9f, 5,2,1} };
237
      int[] bandIndices   = { 0,1,0,1,1 };
238
      float[][] corners   = { {0.04f,0.15f} };
239
      int[] cornerIndices = { 0,0,-1,0,0,-1 };
240
      float[][] centers   = { { 0.0f, 0.0f,-0.5f} };
241
      int[] centerIndices = { 0,0,-1,0,0,-1 };
242
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
243
      }
244
    else
245
      {
246
      float[][] bands     = { {0.030f,35,0.9f,1.0f, 5,2,1}, {0.001f,35,0.9f,1.0f, 5,2,1} };
247
      int[] bandIndices   = { 0,0,0,1,1 };
248
      float[][] corners   = { {0.05f,0.13f} };
249
      int[] cornerIndices = { 0,0,-1,0,0,-1 };
250
      float[][] centers   = { { 0.0f, 0.0f,-0.5f} };
251
      int[] centerIndices = { 0,0,-1,0,0,-1 };
252
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
253
      }
254
    }
255

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

    
258
  public int getNumCubitVariants(int[] numLayers)
259
    {
260
    return 3;
261
    }
262

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

    
265
  public int getCubitVariant(int cubit, int[] numLayers)
266
    {
267
    return cubit<2 ? 0 : (cubit<10 ? 1:2);
268
    }
269

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

    
272
  public int getSolvedFunctionIndex()
273
    {
274
    return 3;
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)