Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistySquare1.java @ 7ba38dd4

1 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
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 android.content.res.Resources;
23
24 ecf3d6e3 Leszek Koltunski
import org.distorted.library.type.Static3D;
25 29b82486 Leszek Koltunski
import org.distorted.library.type.Static4D;
26
27
import org.distorted.objectlib.R;
28
import org.distorted.objectlib.main.Movement6;
29 8592461c Leszek Koltunski
import org.distorted.objectlib.main.ObjectControl;
30 8005e762 Leszek Koltunski
import org.distorted.objectlib.main.ObjectType;
31 198c5bf0 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectShape;
32
import org.distorted.objectlib.helpers.ObjectSticker;
33
import org.distorted.objectlib.helpers.ScrambleState;
34 29b82486 Leszek Koltunski
35
///////////////////////////////////////////////////////////////////////////////////////////////////
36
37
public class TwistySquare1 extends TwistySquare
38
{
39
  private static final int NUM_STICKERS = 6;
40
41
  private ObjectSticker[] mStickers;
42
  private int[] mQuatNumber;
43
  private float[][] mCenters;
44
  private int[][] mStickerColor;
45
  private int[][] mStickerType;
46
47
///////////////////////////////////////////////////////////////////////////////////////////////////
48
49 7ba38dd4 Leszek Koltunski
  public TwistySquare1(int[] numL, Static4D quat, Static3D move, Resources res)
50 29b82486 Leszek Koltunski
    {
51 7ba38dd4 Leszek Koltunski
    super(numL, quat, move, res);
52 29b82486 Leszek Koltunski
    }
53
54
///////////////////////////////////////////////////////////////////////////////////////////////////
55
56 f9a81f52 Leszek Koltunski
  public ScrambleState[] getScrambleStates()
57 29b82486 Leszek Koltunski
    {
58
    return null;
59
    }
60
61 4e1dc313 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
62
63 a57e6870 Leszek Koltunski
  protected int getResource(int[] numLayers)
64 4e1dc313 Leszek Koltunski
    {
65 55fa6993 Leszek Koltunski
    return R.raw.squ1_3;
66 4e1dc313 Leszek Koltunski
    }
67
68 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
69
70 f9a81f52 Leszek Koltunski
  public int getScrambleType()
71 29b82486 Leszek Koltunski
    {
72
    return 1;
73
    }
74
75
///////////////////////////////////////////////////////////////////////////////////////////////////
76
77 7b832206 Leszek Koltunski
  public int[] getSolvedQuats(int cubit, int[] numLayers)
78 29b82486 Leszek Koltunski
    {
79
    if( mQuats==null ) initializeQuats();
80
    int status = retCubitSolvedStatus(cubit,numLayers);
81
    return status<0 ? null : buildSolvedQuats(Movement6.FACE_AXIS[status],mQuats);
82
    }
83
84
///////////////////////////////////////////////////////////////////////////////////////////////////
85
86 e30c522a Leszek Koltunski
  public ObjectShape getObjectShape(int variant)
87 29b82486 Leszek Koltunski
    {
88
    if( variant==0 )
89
      {
90
      double[][] vertices = new double[][]
91
        {
92
         { -1.5-X, 0.5, 1.5 },
93
         {    0.0, 0.5, 1.5 },
94
         {    0.0, 0.5,-1.5 },
95
         { -1.5+X, 0.5,-1.5 },
96
         { -1.5-X,-0.5, 1.5 },
97
         {    0.0,-0.5, 1.5 },
98
         {    0.0,-0.5,-1.5 },
99
         { -1.5+X,-0.5,-1.5 }
100
        };
101
102
      int[][] vert_indices = new int[][]
103
        {
104
         {0,1,2,3},
105
         {4,5,6,7},
106
         {4,5,1,0},
107
         {5,6,2,1},
108
         {6,7,3,2},
109
         {7,4,0,3}
110
        };
111
112
      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} };
113
      int[] bandIndices   = new int[] { 2,2,1,1,0,2 };
114
      float[][] corners   = new float[][] { {0.03f,0.05f} };
115
      int[] cornerIndices = new int[] { 0,0,0,0,0,0,0,0 };
116
      float[][] centers   = new float[][] { { -0.75f, 0.0f, 0.0f} };
117
      int[] centerIndices = new int[] { 0,0,0,0,0,0,0,0 };
118
119
      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
120
      }
121
    else if( variant==1 )
122
      {
123
      double[][] vertices = new double[][]
124
        {
125
         { -X, 0.5, 0.0 },
126
         { +X, 0.5, 0.0 },
127
         {0.0, 0.5,-1.5 },
128
         { -X,-0.5, 0.0 },
129
         { +X,-0.5, 0.0 },
130
         {0.0,-0.5,-1.5 },
131
        };
132
133
      int[][] vert_indices = new int[][]
134
        {
135
         {0,1,2},
136
         {3,4,5},
137
         {3,4,1,0},
138
         {4,5,2,1},
139
         {5,3,0,2}
140
        };
141
142
      float[][] bands     = new float[][] { {0.038f,35,0.5f,0.9f, 5,2,1}, {0.001f,35,0.5f,0.9f, 5,2,1} };
143
      int[] bandIndices   = new int[] { 0,1,0,1,1 };
144
      float[][] corners   = new float[][] { {0.04f,0.15f} };
145
      int[] cornerIndices = new int[] { 0,0,-1,0,0,-1 };
146
      float[][] centers   = new float[][] { { 0.0f, 0.0f,-0.5f} };
147
      int[] centerIndices = new int[] { 0,0,-1,0,0,-1 };
148
149
      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
150
      }
151
    else
152
      {
153
      double[][] vertices = new double[][]
154
        {
155
         { X-1.5, 0.5,  0.0 },
156
         {   0.0, 0.5,  0.0 },
157
         {   0.0, 0.5,X-1.5 },
158
         {  -1.5, 0.5, -1.5 },
159
         { X-1.5,-0.5,  0.0 },
160
         {   0.0,-0.5,  0.0 },
161
         {   0.0,-0.5,X-1.5 },
162
         {  -1.5,-0.5, -1.5 }
163
        };
164
      int[][] vert_indices = new int[][]
165
        {
166
         {0,1,2,3},
167
         {4,5,6,7},
168
         {4,5,1,0},
169
         {5,6,2,1},
170
         {7,4,0,3},
171
         {6,7,3,2}
172
        };
173
174
      float[][] bands     = new float[][] { {0.038f,35,0.9f,1.0f, 5,2,1}, {0.001f,35,0.9f,1.0f, 5,2,1} };
175
      int[] bandIndices   = new int[] { 0,1,0,0,1,1 };
176
      float[][] corners   = new float[][] { {0.05f,0.13f} };
177
      int[] cornerIndices = new int[] { 0,0,0,-1,0,0,0,-1 };
178
      float[][] centers   = new float[][] { { -0.5f, 0.0f,-0.5f} };
179
      int[] centerIndices = new int[] { -1,0,-1,-1,-1,0,-1,-1 };
180
181
      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
182
      }
183
    }
184
185
///////////////////////////////////////////////////////////////////////////////////////////////////
186
187 7b832206 Leszek Koltunski
  public Static4D getQuat(int cubit, int[] numLayers)
188 29b82486 Leszek Koltunski
    {
189
    if( mQuats==null ) initializeQuats();
190
    if( mQuatNumber ==null )
191
      {
192
      mQuatNumber = new int[]
193
        {
194
        0, 6,
195
        0, 9, 6, 3, 18, 15, 12, 21,
196
        0, 9, 6, 3, 15, 12, 21, 18
197
        };
198
      }
199
200
    return mQuats[mQuatNumber[cubit]];
201
    }
202
203
///////////////////////////////////////////////////////////////////////////////////////////////////
204
205 e30c522a Leszek Koltunski
  public int getNumCubitVariants(int[] numLayers)
206 29b82486 Leszek Koltunski
    {
207
    return 3;
208
    }
209
210
///////////////////////////////////////////////////////////////////////////////////////////////////
211
212 e30c522a Leszek Koltunski
  public int getCubitVariant(int cubit, int[] numLayers)
213 29b82486 Leszek Koltunski
    {
214
    return cubit<2 ? 0 : (cubit<10 ? 1:2);
215
    }
216
217
///////////////////////////////////////////////////////////////////////////////////////////////////
218
219 1bb09f88 Leszek Koltunski
  public ObjectSticker retSticker(int sticker)
220 29b82486 Leszek Koltunski
    {
221
    if( mStickers==null )
222
      {
223
      float[][] STICKERS = new float[][]
224
        {
225
          { -0.5f, -0.26289170f, 0.5f, -0.26289170f, 0.5f, 0.26289170f, -0.5f, 0.26289170f }, // middle front
226
          { -0.5f, -0.16666667f, 0.5f, -0.16666667f, 0.5f, 0.16666667f, -0.5f, 0.16666667f }, // middle right
227
          { -0.5f, -0.45534182f, 0.5f, -0.45534182f, 0.5f, 0.45534182f, -0.5f, 0.45534182f }, // middle back
228
          { -0.20096192f, -0.25f, 0.20096192f, -0.25f, 0.0f, 0.5f },                          // edge top
229
          { -0.40192384f, -0.5f, 0.40192384f, -0.5f, 0.40192384f, 0.5f, -0.40192384f, 0.5f }, // edge face
230
          { -0.2637079f, -0.38185397f, 0.38185397f, -0.38185397f, 0.38185397f, 0.2637079f, -0.5f, 0.5f } // corner top
231
        };
232
233
      final float R1 = 0.06f;
234
      final float R2 = 0.04f;
235
      final float R3 = 0.11f;
236
      final float R4 = 0.03f;
237
      final float R5 = 0.11f;
238
      final float R6 = 0.08f;
239
      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} };
240 8592461c Leszek Koltunski
      float[] strokes = { 0.05f,0.04f,0.09f,0.05f,0.08f,0.08f };
241
242
      if( ObjectControl.isInIconMode() )
243
        {
244
        float mult = 2.0f;
245
        strokes[0]*=mult;
246
        strokes[1]*=mult;
247
        strokes[2]*=mult;
248
        strokes[3]*=mult;
249
        strokes[4]*=mult;
250
        strokes[5]*=mult;
251
        }
252 29b82486 Leszek Koltunski
253
      mStickers = new ObjectSticker[NUM_STICKERS];
254
255
      for(int s=0; s<NUM_STICKERS; s++)
256
        {
257
        mStickers[s] = new ObjectSticker(STICKERS[s],null,radii[s],strokes[s]);
258
        }
259
      }
260
261 1bb09f88 Leszek Koltunski
    return mStickers[sticker];
262
    }
263
264 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
265
266 7b832206 Leszek Koltunski
  public float[][] getCubitPositions(int[] numLayers)
267 29b82486 Leszek Koltunski
    {
268
    if( mCenters==null )
269
      {
270
      mCenters = new float[][]
271
        {
272
         { 1.5f, 0.0f, 0.0f },
273
         {-1.5f, 0.0f, 0.0f },
274
275
         { 0.0f, 1.0f, 1.5f },
276
         { 1.5f, 1.0f, 0.0f },
277
         { 0.0f, 1.0f,-1.5f },
278
         {-1.5f, 1.0f, 0.0f },
279
         { 0.0f,-1.0f, 1.5f },
280
         { 1.5f,-1.0f, 0.0f },
281
         { 0.0f,-1.0f,-1.5f },
282
         {-1.5f,-1.0f, 0.0f },
283
284
         { 1.0f, 1.0f, 2.0f, 2.0f, 1.0f, 1.0f },
285
         { 1.0f, 1.0f,-2.0f, 2.0f, 1.0f,-1.0f },
286
         {-1.0f, 1.0f,-2.0f,-2.0f, 1.0f,-1.0f },
287
         {-1.0f, 1.0f, 2.0f,-2.0f, 1.0f, 1.0f },
288
         { 1.0f,-1.0f, 2.0f, 2.0f,-1.0f, 1.0f },
289
         { 1.0f,-1.0f,-2.0f, 2.0f,-1.0f,-1.0f },
290
         {-1.0f,-1.0f,-2.0f,-2.0f,-1.0f,-1.0f },
291
         {-1.0f,-1.0f, 2.0f,-2.0f,-1.0f, 1.0f }
292
        };
293
      }
294
    return mCenters;
295
    }
296
297
///////////////////////////////////////////////////////////////////////////////////////////////////
298
299 59c20632 Leszek Koltunski
  public int getSolvedFunctionIndex()
300 29b82486 Leszek Koltunski
    {
301
    return 0;
302
    }
303
304
///////////////////////////////////////////////////////////////////////////////////////////////////
305
306 1bb09f88 Leszek Koltunski
  public int getNumStickerTypes(int[] numLayers)
307 29b82486 Leszek Koltunski
    {
308
    return NUM_STICKERS;
309
    }
310
311
///////////////////////////////////////////////////////////////////////////////////////////////////
312
313 a75ae1ee Leszek Koltunski
  public int getVariantFaceColor(int variant, int face, int[] numLayers)
314
    {
315
    if( mStickerType==null )
316
      {
317
      mStickerType = new int[][]
318
        {
319
          { -1,-1, 0, 1, 2,-1 },
320
          {  3,-1, 4,-1,-1,-1 },
321
          {  5,-1, 2, 2,-1,-1 }
322
        };
323
      }
324
325
    return mStickerType[variant][face];
326
    }
327
328
///////////////////////////////////////////////////////////////////////////////////////////////////
329
330
  public int getCubitFaceColor(int cubit, int face, int[] numLayers)
331 29b82486 Leszek Koltunski
    {
332
    if( mStickerColor==null )
333
      {
334
      // YELLOW 0 WHITE 1 BLUE 2 GREEN 3 RED 4 ORANGE 5
335
      mStickerColor = new int[][]
336
        {
337
          { 0, 0, 4, 0, 5, 0 },
338
          { 0, 0, 5, 1, 4, 0 },
339
340
          { 2, 0, 4, 0, 0, 0 },
341
          { 2, 0, 0, 0, 0, 0 },
342
          { 2, 0, 5, 0, 0, 0 },
343
          { 2, 0, 1, 0, 0, 0 },
344
          { 3, 0, 4, 0, 0, 0 },
345
          { 3, 0, 0, 0, 0, 0 },
346
          { 3, 0, 5, 0, 0, 0 },
347
          { 3, 0, 1, 0, 0, 0 },
348
349
          { 2, 0, 4, 0, 0, 0 },
350
          { 2, 0, 0, 5, 0, 0 },
351
          { 2, 0, 5, 1, 0, 0 },
352
          { 2, 0, 1, 4, 0, 0 },
353
          { 3, 0, 0, 4, 0, 0 },
354
          { 3, 0, 5, 0, 0, 0 },
355
          { 3, 0, 1, 5, 0, 0 },
356
          { 3, 0, 4, 1, 0, 0 },
357
        };
358
      }
359
360 a75ae1ee Leszek Koltunski
    return mStickerColor[cubit][face];
361 29b82486 Leszek Koltunski
    }
362
363
///////////////////////////////////////////////////////////////////////////////////////////////////
364
// PUBLIC API
365
366 a57e6870 Leszek Koltunski
  public ObjectType intGetObjectType(int[] numLayers)
367 61aa85e4 Leszek Koltunski
    {
368 8005e762 Leszek Koltunski
    return ObjectType.SQU1_3;
369 61aa85e4 Leszek Koltunski
    }
370
371
///////////////////////////////////////////////////////////////////////////////////////////////////
372
373 a57e6870 Leszek Koltunski
  public int getObjectName(int[] numLayers)
374 29b82486 Leszek Koltunski
    {
375
    return R.string.squa1;
376
    }
377
378
///////////////////////////////////////////////////////////////////////////////////////////////////
379
380 a57e6870 Leszek Koltunski
  public int getInventor(int[] numLayers)
381 29b82486 Leszek Koltunski
    {
382
    return R.string.squa1_inventor;
383
    }
384
385 59c20632 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
386
387
  public int getYearOfInvention(int[] numLayers)
388
    {
389
    return 1999;
390
    }
391
392 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
393
394 a57e6870 Leszek Koltunski
  public int getComplexity(int[] numLayers)
395 29b82486 Leszek Koltunski
    {
396
    return 9;
397
    }
398
}