Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistySquare1.java @ 57ef6378

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.touchcontrol.TouchControlHexahedron;
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.ObjectSticker;
32
import org.distorted.objectlib.helpers.ScrambleState;
33

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

    
36
public class TwistySquare1 extends TwistySquare
37
{
38
  private static final int NUM_STICKERS = 6;
39

    
40
  private ObjectSticker[] mStickers;
41
  private int[] mQuatNumber;
42
  private float[][] mCenters;
43
  private int[][] mStickerColor;
44
  private int[][] mStickerType;
45

    
46
///////////////////////////////////////////////////////////////////////////////////////////////////
47

    
48
  public TwistySquare1(int[] numL, Static4D quat, Static3D move, float scale, InputStream stream)
49
    {
50
    super(numL, quat, move, scale, stream);
51
    }
52

    
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54

    
55
  public ScrambleState[] getScrambleStates()
56
    {
57
    return null;
58
    }
59

    
60
///////////////////////////////////////////////////////////////////////////////////////////////////
61

    
62
  public int getScrambleType()
63
    {
64
    return 1;
65
    }
66

    
67
///////////////////////////////////////////////////////////////////////////////////////////////////
68

    
69
  public int[] getSolvedQuats(int cubit, int[] numLayers)
70
    {
71
    if( mQuats==null ) initializeQuats();
72
    int status = retCubitSolvedStatus(cubit,numLayers);
73
    return status<0 ? null : buildSolvedQuats(TouchControlHexahedron.FACE_AXIS[status],mQuats);
74
    }
75

    
76
///////////////////////////////////////////////////////////////////////////////////////////////////
77

    
78
  public ObjectShape getObjectShape(int variant)
79
    {
80
    if( variant==0 )
81
      {
82
      float[][] vertices = new float[][]
83
        {
84
         { -1.5f-X, 0.5f, 1.5f },
85
         {    0.0f, 0.5f, 1.5f },
86
         {    0.0f, 0.5f,-1.5f },
87
         { -1.5f+X, 0.5f,-1.5f },
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
        };
93

    
94
      int[][] vert_indices = new int[][]
95
        {
96
         {0,1,2,3},
97
         {4,5,6,7},
98
         {4,5,1,0},
99
         {5,6,2,1},
100
         {6,7,3,2},
101
         {7,4,0,3}
102
        };
103

    
104
      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} };
105
      int[] bandIndices   = new int[] { 2,2,1,1,0,2 };
106
      float[][] corners   = new float[][] { {0.03f,0.05f} };
107
      int[] cornerIndices = new int[] { 0,0,0,0,0,0,0,0 };
108
      float[][] centers   = new float[][] { { -0.75f, 0.0f, 0.0f} };
109
      int[] centerIndices = new int[] { 0,0,0,0,0,0,0,0 };
110

    
111
      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
112
      }
113
    else if( variant==1 )
114
      {
115
      float[][] vertices = new float[][]
116
        {
117
         {  -X, 0.5f, 0.0f },
118
         {  +X, 0.5f, 0.0f },
119
         {0.0f, 0.5f,-1.5f },
120
         {  -X,-0.5f, 0.0f },
121
         {  +X,-0.5f, 0.0f },
122
         {0.0f,-0.5f,-1.5f },
123
        };
124

    
125
      int[][] vert_indices = new int[][]
126
        {
127
         {0,1,2},
128
         {3,4,5},
129
         {3,4,1,0},
130
         {4,5,2,1},
131
         {5,3,0,2}
132
        };
133

    
134
      float[][] bands     = new float[][] { {0.038f,35,0.5f,0.9f, 5,2,1}, {0.001f,35,0.5f,0.9f, 5,2,1} };
135
      int[] bandIndices   = new int[] { 0,1,0,1,1 };
136
      float[][] corners   = new float[][] { {0.04f,0.15f} };
137
      int[] cornerIndices = new int[] { 0,0,-1,0,0,-1 };
138
      float[][] centers   = new float[][] { { 0.0f, 0.0f,-0.5f} };
139
      int[] centerIndices = new int[] { 0,0,-1,0,0,-1 };
140

    
141
      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
142
      }
143
    else
144
      {
145
      float[][] vertices = new float[][]
146
        {
147
         { X-1.5f, 0.5f,  0.0f },
148
         {   0.0f, 0.5f,  0.0f },
149
         {   0.0f, 0.5f,X-1.5f },
150
         {  -1.5f, 0.5f, -1.5f },
151
         { X-1.5f,-0.5f,  0.0f },
152
         {   0.0f,-0.5f,  0.0f },
153
         {   0.0f,-0.5f,X-1.5f },
154
         {  -1.5f,-0.5f, -1.5f }
155
        };
156
      int[][] vert_indices = new int[][]
157
        {
158
         {0,1,2,3},
159
         {4,5,6,7},
160
         {4,5,1,0},
161
         {5,6,2,1},
162
         {7,4,0,3},
163
         {6,7,3,2}
164
        };
165

    
166
      float[][] bands     = new float[][] { {0.038f,35,0.9f,1.0f, 5,2,1}, {0.001f,35,0.9f,1.0f, 5,2,1} };
167
      int[] bandIndices   = new int[] { 0,1,0,0,1,1 };
168
      float[][] corners   = new float[][] { {0.05f,0.13f} };
169
      int[] cornerIndices = new int[] { 0,0,0,-1,0,0,0,-1 };
170
      float[][] centers   = new float[][] { { -0.5f, 0.0f,-0.5f} };
171
      int[] centerIndices = new int[] { -1,0,-1,-1,-1,0,-1,-1 };
172

    
173
      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
174
      }
175
    }
176

    
177
///////////////////////////////////////////////////////////////////////////////////////////////////
178

    
179
  public Static4D getQuat(int cubit, int[] numLayers)
180
    {
181
    if( mQuats==null ) initializeQuats();
182
    if( mQuatNumber ==null )
183
      {
184
      mQuatNumber = new int[]
185
        {
186
        0, 6,
187
        0, 9, 6, 3, 18, 15, 12, 21,
188
        0, 9, 6, 3, 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 ObjectSticker retSticker(int sticker)
212
    {
213
    if( mStickers==null )
214
      {
215
      float[][] STICKERS = new float[][]
216
        {
217
          { -0.5f, -0.26289170f, 0.5f, -0.26289170f, 0.5f, 0.26289170f, -0.5f, 0.26289170f }, // middle front
218
          { -0.5f, -0.16666667f, 0.5f, -0.16666667f, 0.5f, 0.16666667f, -0.5f, 0.16666667f }, // middle right
219
          { -0.5f, -0.45534182f, 0.5f, -0.45534182f, 0.5f, 0.45534182f, -0.5f, 0.45534182f }, // middle back
220
          { -0.20096192f, -0.25f, 0.20096192f, -0.25f, 0.0f, 0.5f },                          // edge top
221
          { -0.40192384f, -0.5f, 0.40192384f, -0.5f, 0.40192384f, 0.5f, -0.40192384f, 0.5f }, // edge face
222
          { -0.2637079f, -0.38185397f, 0.38185397f, -0.38185397f, 0.38185397f, 0.2637079f, -0.5f, 0.5f } // corner top
223
        };
224

    
225
      final float R1 = 0.06f;
226
      final float R2 = 0.04f;
227
      final float R3 = 0.11f;
228
      final float R4 = 0.03f;
229
      final float R5 = 0.11f;
230
      final float R6 = 0.08f;
231
      final float[][] radii  = { {R1,R1,R1,R1},{R2,R2,R2,R2},{R3,R3,R3,R3},{R4,R4,R4},{R5,R5,R5,R5},{R6,R6,R6,R6} };
232
      float[] strokes = { 0.05f,0.04f,0.09f,0.05f,0.08f,0.08f };
233

    
234
      if( ObjectControl.isInIconMode() )
235
        {
236
        float mult = 2.0f;
237
        strokes[0]*=mult;
238
        strokes[1]*=mult;
239
        strokes[2]*=mult;
240
        strokes[3]*=mult;
241
        strokes[4]*=mult;
242
        strokes[5]*=mult;
243
        }
244

    
245
      mStickers = new ObjectSticker[NUM_STICKERS];
246

    
247
      for(int s=0; s<NUM_STICKERS; s++)
248
        {
249
        mStickers[s] = new ObjectSticker(STICKERS[s],null,radii[s],strokes[s]);
250
        }
251
      }
252

    
253
    return mStickers[sticker];
254
    }
255

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

    
258
  public float[][] getCubitPositions(int[] numLayers)
259
    {
260
    if( mCenters==null )
261
      {
262
      mCenters = new float[][]
263
        {
264
         { 1.5f, 0.0f, 0.0f },
265
         {-1.5f, 0.0f, 0.0f },
266

    
267
         { 0.0f, 1.0f, 1.5f },
268
         { 1.5f, 1.0f, 0.0f },
269
         { 0.0f, 1.0f,-1.5f },
270
         {-1.5f, 1.0f, 0.0f },
271
         { 0.0f,-1.0f, 1.5f },
272
         { 1.5f,-1.0f, 0.0f },
273
         { 0.0f,-1.0f,-1.5f },
274
         {-1.5f,-1.0f, 0.0f },
275

    
276
         { 1.0f, 1.0f, 2.0f, 2.0f, 1.0f, 1.0f },
277
         { 1.0f, 1.0f,-2.0f, 2.0f, 1.0f,-1.0f },
278
         {-1.0f, 1.0f,-2.0f,-2.0f, 1.0f,-1.0f },
279
         {-1.0f, 1.0f, 2.0f,-2.0f, 1.0f, 1.0f },
280
         { 1.0f,-1.0f, 2.0f, 2.0f,-1.0f, 1.0f },
281
         { 1.0f,-1.0f,-2.0f, 2.0f,-1.0f,-1.0f },
282
         {-1.0f,-1.0f,-2.0f,-2.0f,-1.0f,-1.0f },
283
         {-1.0f,-1.0f, 2.0f,-2.0f,-1.0f, 1.0f }
284
        };
285
      }
286
    return mCenters;
287
    }
288

    
289
///////////////////////////////////////////////////////////////////////////////////////////////////
290

    
291
  public int getSolvedFunctionIndex()
292
    {
293
    return 0;
294
    }
295

    
296
///////////////////////////////////////////////////////////////////////////////////////////////////
297

    
298
  public int getNumStickerTypes(int[] numLayers)
299
    {
300
    return NUM_STICKERS;
301
    }
302

    
303
///////////////////////////////////////////////////////////////////////////////////////////////////
304

    
305
  public int getVariantFaceColor(int variant, int face, int[] numLayers)
306
    {
307
    if( mStickerType==null )
308
      {
309
      mStickerType = new int[][]
310
        {
311
          { -1,-1, 0, 1, 2,-1 },
312
          {  3,-1, 4,-1,-1,-1 },
313
          {  5,-1, 2, 2,-1,-1 }
314
        };
315
      }
316

    
317
    return mStickerType[variant][face];
318
    }
319

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

    
322
  public int getCubitFaceColor(int cubit, int face, int[] numLayers)
323
    {
324
    if( mStickerColor==null )
325
      {
326
      // YELLOW 0 WHITE 1 BLUE 2 GREEN 3 RED 4 ORANGE 5
327
      mStickerColor = new int[][]
328
        {
329
          { 0, 0, 4, 0, 5, 0 },
330
          { 0, 0, 5, 1, 4, 0 },
331

    
332
          { 2, 0, 4, 0, 0, 0 },
333
          { 2, 0, 0, 0, 0, 0 },
334
          { 2, 0, 5, 0, 0, 0 },
335
          { 2, 0, 1, 0, 0, 0 },
336
          { 3, 0, 4, 0, 0, 0 },
337
          { 3, 0, 0, 0, 0, 0 },
338
          { 3, 0, 5, 0, 0, 0 },
339
          { 3, 0, 1, 0, 0, 0 },
340

    
341
          { 2, 0, 4, 0, 0, 0 },
342
          { 2, 0, 0, 5, 0, 0 },
343
          { 2, 0, 5, 1, 0, 0 },
344
          { 2, 0, 1, 4, 0, 0 },
345
          { 3, 0, 0, 4, 0, 0 },
346
          { 3, 0, 5, 0, 0, 0 },
347
          { 3, 0, 1, 5, 0, 0 },
348
          { 3, 0, 4, 1, 0, 0 },
349
        };
350
      }
351

    
352
    return mStickerColor[cubit][face];
353
    }
354

    
355
///////////////////////////////////////////////////////////////////////////////////////////////////
356
// PUBLIC API
357

    
358
  public ObjectType intGetObjectType(int[] numLayers)
359
    {
360
    return ObjectType.SQU1_3;
361
    }
362

    
363
///////////////////////////////////////////////////////////////////////////////////////////////////
364

    
365
  public String getObjectName()
366
    {
367
    return "Square-1";
368
    }
369

    
370
///////////////////////////////////////////////////////////////////////////////////////////////////
371

    
372
  public String getInventor()
373
    {
374
    return "Vojtech Kopsky, Karel Hrsel";
375
    }
376

    
377
///////////////////////////////////////////////////////////////////////////////////////////////////
378

    
379
  public int getYearOfInvention()
380
    {
381
    return 1999;
382
    }
383

    
384
///////////////////////////////////////////////////////////////////////////////////////////////////
385

    
386
  public int getComplexity()
387
    {
388
    return 9;
389
    }
390
}
(23-23/25)