Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistySquare1.java @ 59a971c1

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

    
34
///////////////////////////////////////////////////////////////////////////////////////////////////
35

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

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

    
43
  public TwistySquare1(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
    return null;
53
    }
54

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

    
57
  public int getScrambleType()
58
    {
59
    return 1;
60
    }
61

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

    
64
  public int[] getSolvedQuats(int cubit, int[] numLayers)
65
    {
66
    if( mQuats==null ) initializeQuats();
67
    int status = retCubitSolvedStatus(cubit,numLayers);
68
    return status<0 ? null : buildSolvedQuats(TouchControlHexahedron.FACE_AXIS[status],mQuats);
69
    }
70

    
71
///////////////////////////////////////////////////////////////////////////////////////////////////
72

    
73
  public ObjectShape getObjectShape(int variant)
74
    {
75
    if( variant==0 )
76
      {
77
      float[][] vertices =
78
        {
79
         { -1.5f-X, 0.5f, 1.5f },
80
         {    0.0f, 0.5f, 1.5f },
81
         {    0.0f, 0.5f,-1.5f },
82
         { -1.5f+X, 0.5f,-1.5f },
83
         { -1.5f-X,-0.5f, 1.5f },
84
         {    0.0f,-0.5f, 1.5f },
85
         {    0.0f,-0.5f,-1.5f },
86
         { -1.5f+X,-0.5f,-1.5f }
87
        };
88

    
89
      int[][] indices =
90
        {
91
         {4,5,1,0},
92
         {5,6,2,1},
93
         {6,7,3,2},
94
         {7,4,0,3},
95
         {0,1,2,3},
96
         {4,5,6,7}
97
        };
98

    
99
      return new ObjectShape(vertices, indices);
100
      }
101
    else if( variant==1 )
102
      {
103
      float[][] vertices =
104
        {
105
         {  -X, 0.5f, 0.0f },
106
         {  +X, 0.5f, 0.0f },
107
         {0.0f, 0.5f,-1.5f },
108
         {  -X,-0.5f, 0.0f },
109
         {  +X,-0.5f, 0.0f },
110
         {0.0f,-0.5f,-1.5f },
111
        };
112

    
113
      int[][] indices =
114
        {
115
         {0,1,2},
116
         {3,4,1,0},
117
         {3,4,5},
118
         {4,5,2,1},
119
         {5,3,0,2}
120
        };
121

    
122
      return new ObjectShape(vertices, indices);
123
      }
124
    else
125
      {
126
      float[][] vertices =
127
        {
128
         { X-1.5f, 0.5f,  0.0f },
129
         {   0.0f, 0.5f,  0.0f },
130
         {   0.0f, 0.5f,X-1.5f },
131
         {  -1.5f, 0.5f, -1.5f },
132
         { X-1.5f,-0.5f,  0.0f },
133
         {   0.0f,-0.5f,  0.0f },
134
         {   0.0f,-0.5f,X-1.5f },
135
         {  -1.5f,-0.5f, -1.5f }
136
        };
137
      int[][] indices =
138
        {
139
         {0,1,2,3},
140
         {4,5,1,0},
141
         {5,6,2,1},
142
         {7,4,0,3},
143
         {6,7,3,2},
144
         {4,5,6,7}
145
        };
146

    
147
      return new ObjectShape(vertices, indices);
148
      }
149
    }
150

    
151
///////////////////////////////////////////////////////////////////////////////////////////////////
152

    
153
  public ObjectFaceShape getObjectFaceShape(int variant)
154
    {
155
    if( variant==0 )
156
      {
157
      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} };
158
      int[] bandIndices   = { 2,2,1,1,0,2 };
159
      float[][] corners   = { {0.03f,0.05f} };
160
      int[] cornerIndices = { 0,0,0,0,0,0,0,0 };
161
      float[][] centers   = { { -0.75f, 0.0f, 0.0f} };
162
      int[] centerIndices = { 0,0,0,0,0,0,0,0 };
163
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
164
      }
165
    else if( variant==1 )
166
      {
167
      float[][] bands     = { {0.038f,35,0.5f,0.9f, 5,2,1}, {0.001f,35,0.5f,0.9f, 5,2,1} };
168
      int[] bandIndices   = { 0,1,0,1,1 };
169
      float[][] corners   = { {0.04f,0.15f} };
170
      int[] cornerIndices = { 0,0,-1,0,0,-1 };
171
      float[][] centers   = { { 0.0f, 0.0f,-0.5f} };
172
      int[] centerIndices = { 0,0,-1,0,0,-1 };
173
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
174
      }
175
    else
176
      {
177
      float[][] bands     = { {0.038f,35,0.9f,1.0f, 5,2,1}, {0.001f,35,0.9f,1.0f, 5,2,1} };
178
      int[] bandIndices   = { 0,1,0,0,1,1 };
179
      float[][] corners   = { {0.05f,0.13f} };
180
      int[] cornerIndices = { 0,0,0,-1,0,0,0,-1 };
181
      float[][] centers   = { { -0.5f, 0.0f,-0.5f} };
182
      int[] centerIndices = { -1,0,-1,-1,-1,0,-1,-1 };
183
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
184
      }
185
    }
186

    
187
///////////////////////////////////////////////////////////////////////////////////////////////////
188

    
189
  public Static4D getQuat(int cubit, int[] numLayers)
190
    {
191
    if( mQuats==null ) initializeQuats();
192
    if( mQuatNumber ==null )
193
      {
194
      mQuatNumber = new int[]
195
        {
196
        0, 6,
197
        0, 9, 6, 3, 18, 15, 12, 21,
198
        0, 9, 6, 3, 15, 12, 21, 18
199
        };
200
      }
201

    
202
    return mQuats[mQuatNumber[cubit]];
203
    }
204

    
205
///////////////////////////////////////////////////////////////////////////////////////////////////
206

    
207
  public int getNumCubitVariants(int[] numLayers)
208
    {
209
    return 3;
210
    }
211

    
212
///////////////////////////////////////////////////////////////////////////////////////////////////
213

    
214
  public int getCubitVariant(int cubit, int[] numLayers)
215
    {
216
    return cubit<2 ? 0 : (cubit<10 ? 1:2);
217
    }
218

    
219
///////////////////////////////////////////////////////////////////////////////////////////////////
220

    
221
  public float[][] getCubitPositions(int[] numLayers)
222
    {
223
    if( mCenters==null )
224
      {
225
      mCenters = new float[][]
226
        {
227
         { 1.5f, 0.0f, 0.0f },
228
         {-1.5f, 0.0f, 0.0f },
229

    
230
         { 0.0f, 1.0f, 1.5f },
231
         { 1.5f, 1.0f, 0.0f },
232
         { 0.0f, 1.0f,-1.5f },
233
         {-1.5f, 1.0f, 0.0f },
234
         { 0.0f,-1.0f, 1.5f },
235
         { 1.5f,-1.0f, 0.0f },
236
         { 0.0f,-1.0f,-1.5f },
237
         {-1.5f,-1.0f, 0.0f },
238

    
239
         { 1.0f, 1.0f, 2.0f, 2.0f, 1.0f, 1.0f },
240
         { 1.0f, 1.0f,-2.0f, 2.0f, 1.0f,-1.0f },
241
         {-1.0f, 1.0f,-2.0f,-2.0f, 1.0f,-1.0f },
242
         {-1.0f, 1.0f, 2.0f,-2.0f, 1.0f, 1.0f },
243
         { 1.0f,-1.0f, 2.0f, 2.0f,-1.0f, 1.0f },
244
         { 1.0f,-1.0f,-2.0f, 2.0f,-1.0f,-1.0f },
245
         {-1.0f,-1.0f,-2.0f,-2.0f,-1.0f,-1.0f },
246
         {-1.0f,-1.0f, 2.0f,-2.0f,-1.0f, 1.0f }
247
        };
248
      }
249
    return mCenters;
250
    }
251

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

    
254
  public int getSolvedFunctionIndex()
255
    {
256
    return 0;
257
    }
258

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

    
261
  public float getStickerRadius()
262
    {
263
    return 0.12f;
264
    }
265

    
266
///////////////////////////////////////////////////////////////////////////////////////////////////
267

    
268
  public float getStickerStroke()
269
    {
270
    return ObjectControl.isInIconMode() ? 0.20f : 0.10f;
271
    }
272

    
273
///////////////////////////////////////////////////////////////////////////////////////////////////
274

    
275
  public float[][] getStickerAngles()
276
    {
277
    return null;
278
    }
279

    
280
///////////////////////////////////////////////////////////////////////////////////////////////////
281
// PUBLIC API
282

    
283
  public ObjectType intGetObjectType(int[] numLayers)
284
    {
285
    return ObjectType.SQU1_3;
286
    }
287

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

    
290
  public String getObjectName()
291
    {
292
    return "Square-1";
293
    }
294

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

    
297
  public String getInventor()
298
    {
299
    return "V. Kopsky, K. Hrsel";
300
    }
301

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

    
304
  public int getYearOfInvention()
305
    {
306
    return 1999;
307
    }
308

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

    
311
  public int getComplexity()
312
    {
313
    return 3;
314
    }
315
}
(23-23/26)