Project

General

Profile

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

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

1
///////////////////////////////////////////////////////////////////////////////////////////////////
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
import org.distorted.objectlib.helpers.ObjectFaceShape;
18
import org.distorted.objectlib.helpers.ObjectShape;
19
import org.distorted.objectlib.helpers.ObjectSignature;
20
import org.distorted.objectlib.main.InitData;
21
import org.distorted.objectlib.main.ObjectType;
22
import org.distorted.objectlib.shape.ShapeDiamond;
23
import org.distorted.objectlib.scrambling.ScrambleState;
24
import org.distorted.objectlib.touchcontrol.TouchControlBall;
25

    
26
import java.io.InputStream;
27

    
28
///////////////////////////////////////////////////////////////////////////////////////////////////
29

    
30
public class TwistyMasterball extends ShapeDiamond
31
{
32
  static final Static3D[] ROT_AXIS = new Static3D[]
33
         {
34
           new Static3D(     0, 1,     0),
35
           new Static3D(     1, 0,     0),
36
           new Static3D( SQ2/2, 0, SQ2/2),
37
           new Static3D(     0, 0,     1),
38
           new Static3D(-SQ2/2, 0, SQ2/2),
39
         };
40

    
41
  private static final float D = 0.1f; // shape; keep between (-0.5,0.5)
42

    
43
  private ScrambleState[] mStates;
44
  private int[][] mBasicAngle;
45
  private int[] mQuatIndex;
46
  private float[][] mCuts;
47
  private float[][] mCenters;
48

    
49
///////////////////////////////////////////////////////////////////////////////////////////////////
50

    
51
  public TwistyMasterball(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
52
    {
53
    super(data, meshState, iconMode, data.getNumLayers()[0], quat, move, scale, stream);
54
    }
55

    
56
///////////////////////////////////////////////////////////////////////////////////////////////////
57
// make the equator a bit thicker
58

    
59
  @Override
60
  public void adjustStickerCoords()
61
    {
62
    final float X1 = -0.38861537f;
63
    final float Y1 = -0.4252297f;
64
    final float X2 = 0.5f;
65
    final float Y2 = -0.2860808f;
66
    final float X3 = 0.18867691f;
67
    final float Y3 = 0.39392126f;
68
    final float X4 = -0.30006152f;
69
    final float Y4 = 0.3173893f;
70

    
71
    final float Y = 0.02f;
72

    
73
    mStickerCoords = new float[][]
74
          {
75
            { X1+Y*(X4-X1), Y1+Y*(Y4-Y1), X2+Y*(X3-X2), Y2+Y*(Y3-Y2), X3, Y3, X4, Y4 },
76
            { -0.17166577f, -0.28301144f, 0.24996112f, -0.21698855f, -0.07829534f, 0.5f, }
77
          };
78
    }
79

    
80
///////////////////////////////////////////////////////////////////////////////////////////////////
81

    
82
  @Override
83
  public float getPillowCoeff()
84
    {
85
    return 100f;
86
    }
87

    
88
///////////////////////////////////////////////////////////////////////////////////////////////////
89

    
90
  @Override
91
  public int[][] getSolvedQuats()
92
    {
93
    // special SolvedQuats for the case where there are no corner of edge cubits.
94
    // first row {0} - means there are no corners or edges.
95
    // each next defines all cubits of a singe face
96
    // (numCubits, firstCubit, cubit1,..,cubitN-1, quat0,..., quatM)
97

    
98
    return new int[][] {
99
                         {0},
100
                         {4, 0, 1,16,17, 13},
101
                         {4, 2, 3,18,19,  9},
102
                         {4, 4, 5,20,21, 12},
103
                         {4, 6, 7,22,23,  8},
104
                         {4, 8, 9,24,25, 15},
105
                         {4,10,11,26,27, 11},
106
                         {4,12,13,28,29, 14},
107
                         {4,14,15,30,31, 10},
108
                       };
109
    }
110

    
111
///////////////////////////////////////////////////////////////////////////////////////////////////
112

    
113
  public ScrambleState[] getScrambleStates()
114
    {
115
    if( mStates==null )
116
      {
117
      int[] H = {
118
                  0,-3,1, 0,-2,1, 0,-1,1, 0,1,1, 0,2,1, 0,3,1, 0,4,1,
119
                  1,-3,1, 1,-2,1, 1,-1,1, 1,1,1, 1,2,1, 1,3,1, 1,4,1,
120
                  2,-3,1, 2,-2,1, 2,-1,1, 2,1,1, 2,2,1, 2,3,1, 2,4,1,
121
                  3,-3,1, 3,-2,1, 3,-1,1, 3,1,1, 3,2,1, 3,3,1, 3,4,1
122
                };
123
      int[] V2= { 0,1,2, 1,1,2 };
124
      int[] V3= { 0,1,3, 1,1,3 };
125

    
126
      mStates = new ScrambleState[]
127
          {
128
          new ScrambleState( new int[][] {    H,  V2,  V2,  V2,  V2 } ),  //  0: beginning
129
          new ScrambleState( new int[][] { null,  V2,  V2,  V2,  V2 } ),  //  1: last was horizontal (i.e. along (0,1,0))
130
          new ScrambleState( new int[][] {    H,  V3,  V3,  V3,  V3 } ),  //  2: last was vertical and forelast horizontal
131
          new ScrambleState( new int[][] {    H,null,null,null,null } ),  //  3: two last were vertical
132
          };
133
      }
134

    
135
    return mStates;
136
    }
137

    
138
///////////////////////////////////////////////////////////////////////////////////////////////////
139

    
140
  public float[][] getCuts(int[] numLayers)
141
    {
142
    if( mCuts==null )
143
      {
144
      float cut = 1.0f;
145
      float[] cutH = { -cut,0.0f,cut };
146
      float[] cutV = { 0.0f };
147
      mCuts = new float[][] { cutH,cutV,cutV,cutV,cutV };
148
      }
149

    
150
    return mCuts;
151
    }
152

    
153
///////////////////////////////////////////////////////////////////////////////////////////////////
154

    
155
  public boolean[][] getLayerRotatable(int[] numLayers)
156
    {
157
    boolean[] LV = {true,true,true,true};
158
    boolean[] LH = {true,true};
159
    return new boolean[][] { LV,LH,LH,LH,LH };
160
    }
161

    
162
///////////////////////////////////////////////////////////////////////////////////////////////////
163

    
164
  public int getTouchControlType()
165
    {
166
    return TC_BALL;
167
    }
168

    
169
///////////////////////////////////////////////////////////////////////////////////////////////////
170
// not used
171

    
172
  public int getTouchControlSplit()
173
    {
174
    return TYPE_NOT_SPLIT;
175
    }
176

    
177
///////////////////////////////////////////////////////////////////////////////////////////////////
178
// Each 'face' is a vertical strip of 1/8 of longitude (PI/4).
179
// The first one spans longitude from -PI/8 to +PI/8, where Greenwich is long=0.
180
// Next to successively to the east.
181

    
182
  public int[][][] getEnabled()
183
    {
184
    return new int[][][] { {{0,1}},{{0,4}},{{0,3}},{{0,2}},{{0,1}},{{0,4}},{{0,3}},{{0,2}} };
185
    }
186

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

    
189
  public float[] getDist3D(int[] numLayers)
190
    {
191
    final float D = 0.5f*(float)Math.sqrt((2*SQ2+5)/17);
192
    return new float[] { D,D,D,D,D,D,D,D,D,D,D,D,D,D,D,D };
193
    }
194

    
195
///////////////////////////////////////////////////////////////////////////////////////////////////
196

    
197
  public Static3D[] getFaceAxis()
198
    {
199
    return TouchControlBall.FACE_AXIS;
200
    }
201

    
202
///////////////////////////////////////////////////////////////////////////////////////////////////
203

    
204
  public float[][] getCubitPositions(int[] numLayers)
205
    {
206
    if( mCenters==null )
207
      {
208
      final float X1 = 3*SQ2/8;
209
      final float Y1 = 0.5f;
210
      final float Z1 = 0.750f+3*SQ2/8;
211
      final float X2 = SQ2/8;
212
      final float Y2 = 1.5f;
213
      final float Z2 = 0.25f+SQ2/8;
214

    
215
      mCenters = new float[][]
216
         {
217
             { X1, Y1, Z1 },
218
             { X1,-Y1, Z1 },
219
             { Z1, Y1, X1 },
220
             { Z1,-Y1, X1 },
221
             { Z1, Y1,-X1 },
222
             { Z1,-Y1,-X1 },
223
             { X1, Y1,-Z1 },
224
             { X1,-Y1,-Z1 },
225
             {-X1, Y1,-Z1 },
226
             {-X1,-Y1,-Z1 },
227
             {-Z1, Y1,-X1 },
228
             {-Z1,-Y1,-X1 },
229
             {-Z1, Y1, X1 },
230
             {-Z1,-Y1, X1 },
231
             {-X1, Y1, Z1 },
232
             {-X1,-Y1, Z1 },
233

    
234
             { X2, Y2, Z2 },
235
             { X2,-Y2, Z2 },
236
             { Z2, Y2, X2 },
237
             { Z2,-Y2, X2 },
238
             { Z2, Y2,-X2 },
239
             { Z2,-Y2,-X2 },
240
             { X2, Y2,-Z2 },
241
             { X2,-Y2,-Z2 },
242
             {-X2, Y2,-Z2 },
243
             {-X2,-Y2,-Z2 },
244
             {-Z2, Y2,-X2 },
245
             {-Z2,-Y2,-X2 },
246
             {-Z2, Y2, X2 },
247
             {-Z2,-Y2, X2 },
248
             {-X2, Y2, Z2 },
249
             {-X2,-Y2, Z2 },
250
         };
251
      }
252

    
253
    return mCenters;
254
    }
255

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

    
258
  public Static4D getCubitQuats(int cubit, int[] numLayers)
259
    {
260
    if( mQuatIndex==null ) mQuatIndex = new int[] { 0,13,7,9,6,12,5,8,4,15,3,11,2,14,1,10,
261
                                                    0,13,7,9,6,12,5,8,4,15,3,11,2,14,1,10 };
262
    return mObjectQuats[mQuatIndex[cubit]];
263
    }
264

    
265
///////////////////////////////////////////////////////////////////////////////////////////////////
266

    
267
  public ObjectShape getObjectShape(int variant)
268
    {
269
    if( variant==0 )
270
      {
271
      float[][] vertices =
272
          {
273
              { -3*SQ2/8             , -0.5f  , 1.250f-3*SQ2/8 },
274
              {  5*SQ2/8             , -0.5f  ,-0.750f+5*SQ2/8 },
275
              { -3*SQ2/8             ,  0.5f-D, 0.250f-3*SQ2/8 +D },
276
              {    SQ2/8 +D*(4*SQ2/8),  0.5f-D,-0.750f+  SQ2/8 +D*(4*SQ2/8) },
277
              { -3*SQ2/8             , -0.5f  ,-0.750f-3*SQ2/8 },
278
              { -3*SQ2/8             ,  0.5f-D,-0.750f-3*SQ2/8 },
279
          };
280
      int[][] indices =
281
          {
282
              {0,1,3,2},
283
              {4,0,2,5},
284
              {1,4,5,3},
285
              {2,3,5},
286
              {4,1,0}
287
          };
288

    
289
      return new ObjectShape(vertices, indices);
290
      }
291
    else
292
      {
293
      float[][] vertices =
294
          {
295
              { -SQ2/8             , -0.5f -D,  -SQ2/8+0.75f +D },
296
              {3*SQ2/8 +D*(4*SQ2/8), -0.5f -D, 3*SQ2/8-0.25f +D*(4*SQ2/8) },
297
              { -SQ2/8             , -0.5f -D,  -SQ2/8-0.25f },
298
              { -SQ2/8             , +0.5f   ,  -SQ2/8-0.25f }
299
          };
300
      int[][] indices =
301
          {
302
              {0,1,3},
303
              {2,0,3},
304
              {1,2,3},
305
              {2,1,0}
306
          };
307

    
308
      return new ObjectShape(vertices, indices);
309
      }
310
    }
311

    
312
///////////////////////////////////////////////////////////////////////////////////////////////////
313

    
314
  public ObjectFaceShape getObjectFaceShape(int variant)
315
    {
316
    if( variant==0 )
317
      {
318
      float height = isInIconMode() ? 0.001f : 0.015f;
319
      float[][] bands     = { {height,35,0.25f,0.5f,10,0,0},{0.001f,35,0.25f,0.5f,4,0,0} };
320
      int[] bandIndices   = { 0,1,1,1,1 };
321
      float[][] corners   = { {0.04f,0.10f} };
322
      int[] cornerIndices = { -1,-1,-1,-1,-1,-1 };
323
      float[][] centers   = { { -3*SQ2/16, -0.5f,-0.375f-3*SQ2/16 } };
324
      int[] centerIndices = { 0,0,0,0,-1,-1 };
325
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
326
      }
327
    else
328
      {
329
      float height = isInIconMode() ? 0.001f : 0.020f;
330
      float[][] bands     = { {height,35,0.20f,0.6f,9,0,0}, {0.001f,35,0.20f,0.6f,4,0,0} };
331
      int[] bandIndices   = { 0,1,1,1 };
332
      float[][] corners   = { {0.02f,0.10f} };
333
      int[] cornerIndices = { -1,-1,-1,-1 };
334
      float[][] centers   = {  { -SQ2/8, -0.5f, -SQ2/8-0.25f } };
335
      int[] centerIndices = { 0,0,-1,0 };
336
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
337
      }
338
    }
339

    
340
///////////////////////////////////////////////////////////////////////////////////////////////////
341

    
342
  public int getNumCubitVariants(int[] numLayers)
343
    {
344
    return 2;
345
    }
346

    
347
///////////////////////////////////////////////////////////////////////////////////////////////////
348

    
349
  public int getCubitVariant(int cubit, int[] numLayers)
350
    {
351
    return cubit<16 ? 0:1;
352
    }
353

    
354
///////////////////////////////////////////////////////////////////////////////////////////////////
355

    
356
  public float getStickerRadius()
357
    {
358
    return 0.10f;
359
    }
360

    
361
///////////////////////////////////////////////////////////////////////////////////////////////////
362

    
363
  public float getStickerStroke()
364
    {
365
    return isInIconMode() ? 0.13f : 0.07f;
366
    }
367

    
368
///////////////////////////////////////////////////////////////////////////////////////////////////
369

    
370
  public float[][] getStickerAngles()
371
    {
372
    return null;
373
    }
374

    
375
///////////////////////////////////////////////////////////////////////////////////////////////////
376
// PUBLIC API
377

    
378
  public Static3D[] getRotationAxis()
379
    {
380
    return ROT_AXIS;
381
    }
382

    
383
///////////////////////////////////////////////////////////////////////////////////////////////////
384

    
385
  public int[][] getBasicAngles()
386
    {
387
    if( mBasicAngle==null )
388
      {
389
      int[] AV = {8,8,8,8};
390
      int[] AH = {2,2};
391
      mBasicAngle = new int[][] { AV,AH,AH,AH,AH };
392
      }
393

    
394
    return mBasicAngle;
395
    }
396

    
397
///////////////////////////////////////////////////////////////////////////////////////////////////
398

    
399
  public String getShortName()
400
    {
401
    return ObjectType.BALL_4.name();
402
    }
403

    
404
///////////////////////////////////////////////////////////////////////////////////////////////////
405

    
406
  public ObjectSignature getSignature()
407
    {
408
    return new ObjectSignature(ObjectType.BALL_4);
409
    }
410

    
411
///////////////////////////////////////////////////////////////////////////////////////////////////
412

    
413
  public String getObjectName()
414
    {
415
    return "Masterball";
416
    }
417

    
418
///////////////////////////////////////////////////////////////////////////////////////////////////
419

    
420
  public String getInventor()
421
    {
422
    return "Geza Gyovai";
423
    }
424

    
425
///////////////////////////////////////////////////////////////////////////////////////////////////
426

    
427
  public int getYearOfInvention()
428
    {
429
    return 1992;
430
    }
431

    
432
///////////////////////////////////////////////////////////////////////////////////////////////////
433

    
434
  public int getComplexity()
435
    {
436
    return 2;
437
    }
438

    
439
///////////////////////////////////////////////////////////////////////////////////////////////////
440

    
441
  public String[][] getTutorials()
442
    {
443
    return new String[][]{
444
                          {"gb","n41Rng0g65c","How to solve Masterball","javahamburg"},
445
                          {"es","zmdgV15BQi0","Tutorial para la Masterball","Robert Cubes"},
446
                          {"de","EjGf-VytMcA","Masterball Tutorial Deutsch","javahamburg"},
447
                         };
448
    }
449
}
(17-17/38)