Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyMasterball.java @ da5551f4

1 54588439 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2021 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is proprietary software licensed under an EULA which you should have received      //
7
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html        //
8
///////////////////////////////////////////////////////////////////////////////////////////////////
9
10
package org.distorted.objectlib.objects;
11
12
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_BALL;
13
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
14
15
import org.distorted.library.type.Static3D;
16
import org.distorted.library.type.Static4D;
17 84a17011 Leszek Koltunski
import org.distorted.objectlib.helpers.FactoryCubit;
18 54588439 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectFaceShape;
19
import org.distorted.objectlib.helpers.ObjectShape;
20 97a75106 leszek
import org.distorted.objectlib.signature.ObjectSignature;
21 84a17011 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectVertexEffects;
22 cf93ea4e Leszek Koltunski
import org.distorted.objectlib.main.InitAssets;
23 54588439 Leszek Koltunski
import org.distorted.objectlib.main.InitData;
24 97a75106 leszek
import org.distorted.objectlib.signature.ObjectConstants;
25 54588439 Leszek Koltunski
import org.distorted.objectlib.main.ObjectType;
26 b31249d6 Leszek Koltunski
import org.distorted.objectlib.shape.ShapeDiamond;
27 b63235a0 Leszek Koltunski
import org.distorted.objectlib.touchcontrol.TouchControlBall;
28 54588439 Leszek Koltunski
29
///////////////////////////////////////////////////////////////////////////////////////////////////
30
31
public class TwistyMasterball extends ShapeDiamond
32
{
33
  static final Static3D[] ROT_AXIS = new Static3D[]
34
         {
35
           new Static3D(     0, 1,     0),
36
           new Static3D(     1, 0,     0),
37
           new Static3D( SQ2/2, 0, SQ2/2),
38
           new Static3D(     0, 0,     1),
39
           new Static3D(-SQ2/2, 0, SQ2/2),
40
         };
41
42 f2259427 Leszek Koltunski
  private static final float D = 0.1f; // shape; keep between (-0.5,0.5)
43
44 9ba7f3f6 Leszek Koltunski
  private int[][] mEdges;
45 54588439 Leszek Koltunski
  private int[][] mBasicAngle;
46
  private int[] mQuatIndex;
47
  private float[][] mCuts;
48
  private float[][] mCenters;
49
50
///////////////////////////////////////////////////////////////////////////////////////////////////
51
52 1fda81c4 leszek
  public TwistyMasterball(int iconMode, Static4D quat, Static3D move, float scale, InitData data, InitAssets asset)
53 54588439 Leszek Koltunski
    {
54 1fda81c4 leszek
    super(iconMode, data.getNumLayers()[0], quat, move, scale, data, asset);
55 54588439 Leszek Koltunski
    }
56
57 a70b1e96 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
58
59
  @Override
60
  public float[][] returnRotationFactor()
61
    {
62
    float C1 = 1.0f;
63
    float C2 = 1.7f;
64
    float[] f1 = new float[] { C1,C1,C1,C1 };
65
    float[] f2 = new float[] { C2,C2};
66
    return new float[][] { f1,f2,f2,f2,f2 };
67
    }
68
69 f2259427 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
70
// make the equator a bit thicker
71
72
  @Override
73
  public void adjustStickerCoords()
74
    {
75
    final float X1 = -0.38861537f;
76
    final float Y1 = -0.4252297f;
77 9ba7f3f6 Leszek Koltunski
    final float X2 =  0.5f;
78 f2259427 Leszek Koltunski
    final float Y2 = -0.2860808f;
79 9ba7f3f6 Leszek Koltunski
    final float X3 =  0.18867691f;
80
    final float Y3 =  0.39392126f;
81 f2259427 Leszek Koltunski
    final float X4 = -0.30006152f;
82 9ba7f3f6 Leszek Koltunski
    final float Y4 =  0.3173893f;
83 f2259427 Leszek Koltunski
84
    final float Y = 0.02f;
85
86 ebe8c08e leszek
    mStickerCoords = new float[][][][]
87 f2259427 Leszek Koltunski
          {
88 ebe8c08e leszek
            { { {X1+Y*(X4-X1), Y1+Y*(Y4-Y1)}, {X2+Y*(X3-X2), Y2+Y*(Y3-Y2)}, {X3, Y3}, {X4, Y4} } },
89
            { { {-0.17166577f, -0.28301144f}, {0.24996112f, -0.21698855f}, {-0.07829534f, 0.5f} } }
90 f2259427 Leszek Koltunski
          };
91
    }
92
93 c1452814 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
94
95
  @Override
96
  public float getPillowCoeff()
97
    {
98 f2259427 Leszek Koltunski
    return 100f;
99 c1452814 Leszek Koltunski
    }
100
101 55bdf62b Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
102
103
  @Override
104
  public int[][] getSolvedQuats()
105
    {
106
    // special SolvedQuats for the case where there are no corner of edge cubits.
107
    // first row {0} - means there are no corners or edges.
108
    // each next defines all cubits of a singe face
109
    // (numCubits, firstCubit, cubit1,..,cubitN-1, quat0,..., quatM)
110
111
    return new int[][] {
112
                         {0},
113
                         {4, 0, 1,16,17, 13},
114 1247bb16 Leszek Koltunski
                         {4, 2, 3,18,19, 12},
115
                         {4, 4, 5,20,21, 15},
116
                         {4, 6, 7,22,23, 14},
117
                         {4, 8, 9,24,25, 13},
118
                         {4,10,11,26,27, 12},
119
                         {4,12,13,28,29, 15},
120
                         {4,14,15,30,31, 14},
121 55bdf62b Leszek Koltunski
                       };
122
    }
123
124 54588439 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
125
126 9ba7f3f6 Leszek Koltunski
  public int[][] getScrambleEdges()
127 54588439 Leszek Koltunski
    {
128 9ba7f3f6 Leszek Koltunski
    if( mEdges==null )
129 54588439 Leszek Koltunski
      {
130 9ba7f3f6 Leszek Koltunski
      mEdges = new int[][]
131 27249eea Leszek Koltunski
        {
132 fd271599 Leszek Koltunski
          { 0,1, 1,1, 2,1, 3,1, 4,1, 5,1, 6,1, 7,1, 8,1, 9,1,
133
           10,1,11,1,12,1,13,1,14,1,15,1,16,1,17,1,18,1,19,1,
134
           20,1,21,1,22,1,23,1,24,1,25,1,26,1,27,1
135
          },
136
137 27249eea Leszek Koltunski
          {28,2,29,2,30,2,31,2,32,2,33,2,34,2,35,2 },
138 fd271599 Leszek Koltunski
139
          { 0,1, 1,1, 2,1, 3,1, 4,1, 5,1, 6,1, 7,1, 8,1, 9,1,
140
           10,1,11,1,12,1,13,1,14,1,15,1,16,1,17,1,18,1,19,1,
141
           20,1,21,1,22,1,23,1,24,1,25,1,26,1,27,1,
142
           28,0,29,0,30,0,31,0,32,0,33,0,34,0,35,0
143
          }
144 27249eea Leszek Koltunski
        };
145 54588439 Leszek Koltunski
      }
146
147 9ba7f3f6 Leszek Koltunski
    return mEdges;
148 54588439 Leszek Koltunski
    }
149
150
///////////////////////////////////////////////////////////////////////////////////////////////////
151
152
  public float[][] getCuts(int[] numLayers)
153
    {
154
    if( mCuts==null )
155
      {
156 bfdb9aa5 Leszek Koltunski
      float cut = 1.0f;
157
      float[] cutH = { -cut,0.0f,cut };
158 54588439 Leszek Koltunski
      float[] cutV = { 0.0f };
159
      mCuts = new float[][] { cutH,cutV,cutV,cutV,cutV };
160
      }
161
162
    return mCuts;
163
    }
164
165
///////////////////////////////////////////////////////////////////////////////////////////////////
166
167
  public boolean[][] getLayerRotatable(int[] numLayers)
168
    {
169
    boolean[] LV = {true,true,true,true};
170
    boolean[] LH = {true,true};
171
    return new boolean[][] { LV,LH,LH,LH,LH };
172
    }
173
174
///////////////////////////////////////////////////////////////////////////////////////////////////
175
176
  public int getTouchControlType()
177
    {
178
    return TC_BALL;
179
    }
180
181
///////////////////////////////////////////////////////////////////////////////////////////////////
182
// not used
183
184
  public int getTouchControlSplit()
185
    {
186
    return TYPE_NOT_SPLIT;
187
    }
188
189
///////////////////////////////////////////////////////////////////////////////////////////////////
190 b31249d6 Leszek Koltunski
// Each 'face' is a vertical strip of 1/8 of longitude (PI/4).
191
// The first one spans longitude from -PI/8 to +PI/8, where Greenwich is long=0.
192 86ee4ac3 Leszek Koltunski
// Next successively to the east.
193 54588439 Leszek Koltunski
194
  public int[][][] getEnabled()
195
    {
196 b31249d6 Leszek Koltunski
    return new int[][][] { {{0,1}},{{0,4}},{{0,3}},{{0,2}},{{0,1}},{{0,4}},{{0,3}},{{0,2}} };
197 54588439 Leszek Koltunski
    }
198
199
///////////////////////////////////////////////////////////////////////////////////////////////////
200
201
  public float[] getDist3D(int[] numLayers)
202
    {
203 c1452814 Leszek Koltunski
    final float D = 0.5f*(float)Math.sqrt((2*SQ2+5)/17);
204 54588439 Leszek Koltunski
    return new float[] { D,D,D,D,D,D,D,D,D,D,D,D,D,D,D,D };
205
    }
206
207
///////////////////////////////////////////////////////////////////////////////////////////////////
208
209
  public Static3D[] getFaceAxis()
210
    {
211 b63235a0 Leszek Koltunski
    return TouchControlBall.FACE_AXIS;
212 54588439 Leszek Koltunski
    }
213
214
///////////////////////////////////////////////////////////////////////////////////////////////////
215
216
  public float[][] getCubitPositions(int[] numLayers)
217
    {
218
    if( mCenters==null )
219
      {
220 c1452814 Leszek Koltunski
      final float X1 = 3*SQ2/8;
221
      final float Y1 = 0.5f;
222
      final float Z1 = 0.750f+3*SQ2/8;
223 1247bb16 Leszek Koltunski
      final float X2 = X1/3;
224 c1452814 Leszek Koltunski
      final float Y2 = 1.5f;
225 1247bb16 Leszek Koltunski
      final float Z2 = Z1/3;
226 c1452814 Leszek Koltunski
227 54588439 Leszek Koltunski
      mCenters = new float[][]
228
         {
229 c1452814 Leszek Koltunski
             { X1, Y1, Z1 },
230
             { X1,-Y1, Z1 },
231
             { Z1, Y1, X1 },
232
             { Z1,-Y1, X1 },
233
             { Z1, Y1,-X1 },
234
             { Z1,-Y1,-X1 },
235
             { X1, Y1,-Z1 },
236
             { X1,-Y1,-Z1 },
237
             {-X1, Y1,-Z1 },
238
             {-X1,-Y1,-Z1 },
239
             {-Z1, Y1,-X1 },
240
             {-Z1,-Y1,-X1 },
241
             {-Z1, Y1, X1 },
242
             {-Z1,-Y1, X1 },
243
             {-X1, Y1, Z1 },
244
             {-X1,-Y1, Z1 },
245
246
             { X2, Y2, Z2 },
247
             { X2,-Y2, Z2 },
248
             { Z2, Y2, X2 },
249
             { Z2,-Y2, X2 },
250
             { Z2, Y2,-X2 },
251
             { Z2,-Y2,-X2 },
252
             { X2, Y2,-Z2 },
253
             { X2,-Y2,-Z2 },
254
             {-X2, Y2,-Z2 },
255
             {-X2,-Y2,-Z2 },
256
             {-Z2, Y2,-X2 },
257
             {-Z2,-Y2,-X2 },
258
             {-Z2, Y2, X2 },
259
             {-Z2,-Y2, X2 },
260
             {-X2, Y2, Z2 },
261
             {-X2,-Y2, Z2 },
262 54588439 Leszek Koltunski
         };
263
      }
264
265
    return mCenters;
266
    }
267
268
///////////////////////////////////////////////////////////////////////////////////////////////////
269
270
  public Static4D getCubitQuats(int cubit, int[] numLayers)
271
    {
272 c1452814 Leszek Koltunski
    if( mQuatIndex==null ) mQuatIndex = new int[] { 0,13,7,9,6,12,5,8,4,15,3,11,2,14,1,10,
273
                                                    0,13,7,9,6,12,5,8,4,15,3,11,2,14,1,10 };
274 54588439 Leszek Koltunski
    return mObjectQuats[mQuatIndex[cubit]];
275
    }
276
277
///////////////////////////////////////////////////////////////////////////////////////////////////
278
279 84a17011 Leszek Koltunski
  private float[][] getVertices(int variant)
280 54588439 Leszek Koltunski
    {
281
    if( variant==0 )
282
      {
283 84a17011 Leszek Koltunski
      return new float[][]
284 54588439 Leszek Koltunski
          {
285 ed7a9bfb Leszek Koltunski
              { -3*SQ2/8             ,        -0.5f  ,  1.250f-3*SQ2/8 },
286
              {  5*SQ2/8             ,        -0.5f  , -0.750f+5*SQ2/8 },
287
              { -3*SQ2/8             ,         0.5f-D,  0.250f-3*SQ2/8 +D },
288
              {    SQ2/8 +D*(4*SQ2/8),         0.5f-D, -0.750f+  SQ2/8 +D*(4*SQ2/8) },
289
              { -3*SQ2/8             ,        -0.5f  , -0.750f-3*SQ2/8 },
290
              { -3*SQ2/8             , 0.01f*(0.5f-D), -0.750f-3*SQ2/8 },
291 54588439 Leszek Koltunski
          };
292 84a17011 Leszek Koltunski
      }
293
    else
294
      {
295
      return new float[][]
296
          {
297
              { -SQ2/8             , -0.5f -D,  -SQ2/8+0.75f +D },
298
              {3*SQ2/8 +D*(4*SQ2/8), -0.5f -D, 3*SQ2/8-0.25f +D*(4*SQ2/8) },
299
              { -SQ2/8             , -0.5f -D,  -SQ2/8-0.25f },
300
              { -SQ2/8             , +0.5f   ,  -SQ2/8-0.25f }
301
          };
302
      }
303
    }
304
305
///////////////////////////////////////////////////////////////////////////////////////////////////
306
307
  public ObjectShape getObjectShape(int variant)
308
    {
309
    if( variant==0 )
310
      {
311 54588439 Leszek Koltunski
      int[][] indices =
312
          {
313
              {0,1,3,2},
314
              {4,0,2,5},
315
              {1,4,5,3},
316
              {2,3,5},
317
              {4,1,0}
318
          };
319
320 84a17011 Leszek Koltunski
      return new ObjectShape(getVertices(variant), indices);
321 54588439 Leszek Koltunski
      }
322
    else
323
      {
324
      int[][] indices =
325
          {
326
              {0,1,3},
327
              {2,0,3},
328
              {1,2,3},
329
              {2,1,0}
330
          };
331
332 84a17011 Leszek Koltunski
      return new ObjectShape(getVertices(variant), indices);
333 54588439 Leszek Koltunski
      }
334
    }
335
336
///////////////////////////////////////////////////////////////////////////////////////////////////
337
338
  public ObjectFaceShape getObjectFaceShape(int variant)
339
    {
340
    if( variant==0 )
341
      {
342
      float height = isInIconMode() ? 0.001f : 0.015f;
343 84a17011 Leszek Koltunski
      float[][] bands = { {height,35,0.25f,0.5f,10,0,0},{0.001f,35,0.25f,0.5f,4,0,0} };
344
      int[] indices   = { 0,1,1,1,1 };
345
      return new ObjectFaceShape(bands,indices,null);
346
      }
347
    else
348
      {
349
      float height = isInIconMode() ? 0.001f : 0.020f;
350
      float[][] bands = { {height,35,0.20f,0.6f,9,0,0}, {0.001f,35,0.20f,0.6f,4,0,0} };
351
      int[] indices   = { 0,1,1,1 };
352
      return new ObjectFaceShape(bands,indices,null);
353
      }
354
    }
355
356
///////////////////////////////////////////////////////////////////////////////////////////////////
357
358
  public ObjectVertexEffects getVertexEffects(int variant)
359
    {
360
    if( variant==0 )
361
      {
362 54588439 Leszek Koltunski
      float[][] corners   = { {0.04f,0.10f} };
363 c1452814 Leszek Koltunski
      int[] cornerIndices = { -1,-1,-1,-1,-1,-1 };
364 54588439 Leszek Koltunski
      float[][] centers   = { { -3*SQ2/16, -0.5f,-0.375f-3*SQ2/16 } };
365
      int[] centerIndices = { 0,0,0,0,-1,-1 };
366 84a17011 Leszek Koltunski
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
367 54588439 Leszek Koltunski
      }
368
    else
369
      {
370
      float[][] corners   = { {0.02f,0.10f} };
371 c1452814 Leszek Koltunski
      int[] cornerIndices = { -1,-1,-1,-1 };
372 54588439 Leszek Koltunski
      float[][] centers   = {  { -SQ2/8, -0.5f, -SQ2/8-0.25f } };
373
      int[] centerIndices = { 0,0,-1,0 };
374 84a17011 Leszek Koltunski
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
375 54588439 Leszek Koltunski
      }
376
    }
377
378
///////////////////////////////////////////////////////////////////////////////////////////////////
379
380
  public int getNumCubitVariants(int[] numLayers)
381
    {
382
    return 2;
383
    }
384
385
///////////////////////////////////////////////////////////////////////////////////////////////////
386
387
  public int getCubitVariant(int cubit, int[] numLayers)
388
    {
389
    return cubit<16 ? 0:1;
390
    }
391
392
///////////////////////////////////////////////////////////////////////////////////////////////////
393
394
  public float getStickerRadius()
395
    {
396 c1452814 Leszek Koltunski
    return 0.10f;
397 54588439 Leszek Koltunski
    }
398
399
///////////////////////////////////////////////////////////////////////////////////////////////////
400
401
  public float getStickerStroke()
402
    {
403 bbb12178 Leszek Koltunski
    return isInIconMode() ? 0.13f : 0.07f;
404 54588439 Leszek Koltunski
    }
405
406
///////////////////////////////////////////////////////////////////////////////////////////////////
407
408 ebe8c08e leszek
  public float[][][] getStickerAngles()
409 54588439 Leszek Koltunski
    {
410
    return null;
411
    }
412
413
///////////////////////////////////////////////////////////////////////////////////////////////////
414
// PUBLIC API
415
416
  public Static3D[] getRotationAxis()
417
    {
418
    return ROT_AXIS;
419
    }
420
421
///////////////////////////////////////////////////////////////////////////////////////////////////
422
423
  public int[][] getBasicAngles()
424
    {
425
    if( mBasicAngle==null )
426
      {
427
      int[] AV = {8,8,8,8};
428
      int[] AH = {2,2};
429
      mBasicAngle = new int[][] { AV,AH,AH,AH,AH };
430
      }
431
432
    return mBasicAngle;
433
    }
434
435
///////////////////////////////////////////////////////////////////////////////////////////////////
436
437
  public String getShortName()
438
    {
439
    return ObjectType.BALL_4.name();
440
    }
441
442
///////////////////////////////////////////////////////////////////////////////////////////////////
443
444
  public ObjectSignature getSignature()
445
    {
446 97a75106 leszek
    return new ObjectSignature(ObjectConstants.BALL_4);
447 54588439 Leszek Koltunski
    }
448
449
///////////////////////////////////////////////////////////////////////////////////////////////////
450
451
  public String getObjectName()
452
    {
453
    return "Masterball";
454
    }
455
456
///////////////////////////////////////////////////////////////////////////////////////////////////
457
458
  public String getInventor()
459
    {
460
    return "Geza Gyovai";
461
    }
462
463
///////////////////////////////////////////////////////////////////////////////////////////////////
464
465
  public int getYearOfInvention()
466
    {
467
    return 1992;
468
    }
469
470
///////////////////////////////////////////////////////////////////////////////////////////////////
471
472 da5551f4 leszek
  public float getComplexity()
473 54588439 Leszek Koltunski
    {
474
    return 2;
475
    }
476
477
///////////////////////////////////////////////////////////////////////////////////////////////////
478
479
  public String[][] getTutorials()
480
    {
481
    return new String[][]{
482
                          {"gb","n41Rng0g65c","How to solve Masterball","javahamburg"},
483
                          {"es","zmdgV15BQi0","Tutorial para la Masterball","Robert Cubes"},
484
                          {"de","EjGf-VytMcA","Masterball Tutorial Deutsch","javahamburg"},
485
                         };
486
    }
487
}