Project

General

Profile

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

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

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

    
25
import java.io.InputStream;
26

    
27
///////////////////////////////////////////////////////////////////////////////////////////////////
28

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

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

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

    
48
///////////////////////////////////////////////////////////////////////////////////////////////////
49

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

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

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

    
70
    final float Y = 0.02f;
71

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

    
79
///////////////////////////////////////////////////////////////////////////////////////////////////
80

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

    
87
///////////////////////////////////////////////////////////////////////////////////////////////////
88

    
89
  public ScrambleState[] getScrambleStates()
90
    {
91
    if( mStates==null )
92
      {
93
      int[] H = {
94
                  0,-3,1, 0,-2,1, 0,-1,1, 0,1,1, 0,2,1, 0,3,1, 0,4,1,
95
                  1,-3,1, 1,-2,1, 1,-1,1, 1,1,1, 1,2,1, 1,3,1, 1,4,1,
96
                  2,-3,1, 2,-2,1, 2,-1,1, 2,1,1, 2,2,1, 2,3,1, 2,4,1,
97
                  3,-3,1, 3,-2,1, 3,-1,1, 3,1,1, 3,2,1, 3,3,1, 3,4,1
98
                };
99
      int[] V2= { 0,1,2, 1,1,2 };
100
      int[] V3= { 0,1,3, 1,1,3 };
101

    
102
      mStates = new ScrambleState[]
103
          {
104
          new ScrambleState( new int[][] {    H,  V2,  V2,  V2,  V2 } ),  //  0: beginning
105
          new ScrambleState( new int[][] { null,  V2,  V2,  V2,  V2 } ),  //  1: last was horizontal (i.e. along (0,1,0))
106
          new ScrambleState( new int[][] {    H,  V3,  V3,  V3,  V3 } ),  //  2: last was vertical and forelast horizontal
107
          new ScrambleState( new int[][] {    H,null,null,null,null } ),  //  3: two last were vertical
108
          };
109
      }
110

    
111
    return mStates;
112
    }
113

    
114
///////////////////////////////////////////////////////////////////////////////////////////////////
115

    
116
  public float[][] getCuts(int[] numLayers)
117
    {
118
    if( mCuts==null )
119
      {
120
      float cut = 0.25f-D/4;
121
      float[] cutH = { cut,0.0f,cut };
122
      float[] cutV = { 0.0f };
123
      mCuts = new float[][] { cutH,cutV,cutV,cutV,cutV };
124
      }
125

    
126
    return mCuts;
127
    }
128

    
129
///////////////////////////////////////////////////////////////////////////////////////////////////
130

    
131
  public boolean[][] getLayerRotatable(int[] numLayers)
132
    {
133
    boolean[] LV = {true,true,true,true};
134
    boolean[] LH = {true,true};
135
    return new boolean[][] { LV,LH,LH,LH,LH };
136
    }
137

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

    
140
  public int getTouchControlType()
141
    {
142
    return TC_BALL;
143
    }
144

    
145
///////////////////////////////////////////////////////////////////////////////////////////////////
146
// not used
147

    
148
  public int getTouchControlSplit()
149
    {
150
    return TYPE_NOT_SPLIT;
151
    }
152

    
153
///////////////////////////////////////////////////////////////////////////////////////////////////
154
// Each 'face' is a vertical strip of 1/8 of longitude (PI/4).
155
// The first one spans longitude from -PI/8 to +PI/8, where Greenwich is long=0.
156
// Next to successively to the east.
157

    
158
  public int[][][] getEnabled()
159
    {
160
    return new int[][][] { {{0,1}},{{0,4}},{{0,3}},{{0,2}},{{0,1}},{{0,4}},{{0,3}},{{0,2}} };
161
    }
162

    
163
///////////////////////////////////////////////////////////////////////////////////////////////////
164

    
165
  public float[] getDist3D(int[] numLayers)
166
    {
167
    final float D = 0.5f*(float)Math.sqrt((2*SQ2+5)/17);
168
    return new float[] { D,D,D,D,D,D,D,D,D,D,D,D,D,D,D,D };
169
    }
170

    
171
///////////////////////////////////////////////////////////////////////////////////////////////////
172
// A = PI/8
173

    
174
  public Static3D[] getFaceAxis()
175
    {
176
    final float sinA = (float)(0.5f*Math.sqrt(2-SQ2));
177
    final float cosA = (float)(0.5f*Math.sqrt(2+SQ2));
178

    
179
    float X = sinA*cosA/(1+cosA*cosA);
180
    float Y = cosA*cosA/(1+cosA*cosA);
181
    float Z = cosA*cosA/(1+cosA*cosA);
182

    
183
    float LEN = (float)Math.sqrt(X*X + Y*Y + Z*Z);
184
    X /= LEN;
185
    Y /= LEN;
186
    Z /= LEN;
187

    
188
    return new Static3D[]
189
        {
190
          new Static3D( X, Y, Z),
191
          new Static3D( X,-Y, Z),
192
          new Static3D( Z, Y, X),
193
          new Static3D( Z,-Y, X),
194
          new Static3D( Z, Y,-X),
195
          new Static3D( Z,-Y,-X),
196
          new Static3D( X, Y,-Z),
197
          new Static3D( X,-Y,-Z),
198
          new Static3D(-X, Y,-Z),
199
          new Static3D(-X,-Y,-Z),
200
          new Static3D(-Z, Y,-X),
201
          new Static3D(-Z,-Y,-X),
202
          new Static3D(-Z, Y, X),
203
          new Static3D(-Z,-Y, X),
204
          new Static3D(-X, Y, Z),
205
          new Static3D(-X,-Y, Z),
206
        };
207
    }
208

    
209
///////////////////////////////////////////////////////////////////////////////////////////////////
210

    
211
  public float[][] getCubitPositions(int[] numLayers)
212
    {
213
    if( mCenters==null )
214
      {
215
      final float X1 = 3*SQ2/8;
216
      final float Y1 = 0.5f;
217
      final float Z1 = 0.750f+3*SQ2/8;
218
      final float X2 = SQ2/8;
219
      final float Y2 = 1.5f;
220
      final float Z2 = 0.25f+SQ2/8;
221

    
222
      mCenters = new float[][]
223
         {
224
             { X1, Y1, Z1 },
225
             { X1,-Y1, Z1 },
226
             { Z1, Y1, X1 },
227
             { Z1,-Y1, X1 },
228
             { Z1, Y1,-X1 },
229
             { Z1,-Y1,-X1 },
230
             { X1, Y1,-Z1 },
231
             { X1,-Y1,-Z1 },
232
             {-X1, Y1,-Z1 },
233
             {-X1,-Y1,-Z1 },
234
             {-Z1, Y1,-X1 },
235
             {-Z1,-Y1,-X1 },
236
             {-Z1, Y1, X1 },
237
             {-Z1,-Y1, X1 },
238
             {-X1, Y1, Z1 },
239
             {-X1,-Y1, Z1 },
240

    
241
             { X2, Y2, Z2 },
242
             { X2,-Y2, Z2 },
243
             { Z2, Y2, X2 },
244
             { Z2,-Y2, X2 },
245
             { Z2, Y2,-X2 },
246
             { Z2,-Y2,-X2 },
247
             { X2, Y2,-Z2 },
248
             { X2,-Y2,-Z2 },
249
             {-X2, Y2,-Z2 },
250
             {-X2,-Y2,-Z2 },
251
             {-Z2, Y2,-X2 },
252
             {-Z2,-Y2,-X2 },
253
             {-Z2, Y2, X2 },
254
             {-Z2,-Y2, X2 },
255
             {-X2, Y2, Z2 },
256
             {-X2,-Y2, Z2 },
257
         };
258
      }
259

    
260
    return mCenters;
261
    }
262

    
263
///////////////////////////////////////////////////////////////////////////////////////////////////
264

    
265
  public Static4D getCubitQuats(int cubit, int[] numLayers)
266
    {
267
    if( mQuatIndex==null ) mQuatIndex = new int[] { 0,13,7,9,6,12,5,8,4,15,3,11,2,14,1,10,
268
                                                    0,13,7,9,6,12,5,8,4,15,3,11,2,14,1,10 };
269
    return mObjectQuats[mQuatIndex[cubit]];
270
    }
271

    
272
///////////////////////////////////////////////////////////////////////////////////////////////////
273

    
274
  public ObjectShape getObjectShape(int variant)
275
    {
276
    if( variant==0 )
277
      {
278
      float[][] vertices =
279
          {
280
              { -3*SQ2/8             , -0.5f  , 1.250f-3*SQ2/8 },
281
              {  5*SQ2/8             , -0.5f  ,-0.750f+5*SQ2/8 },
282
              { -3*SQ2/8             ,  0.5f-D, 0.250f-3*SQ2/8 +D },
283
              {    SQ2/8 +D*(4*SQ2/8),  0.5f-D,-0.750f+  SQ2/8 +D*(4*SQ2/8) },
284
              { -3*SQ2/8             , -0.5f  ,-0.750f-3*SQ2/8 },
285
              { -3*SQ2/8             ,  0.5f-D,-0.750f-3*SQ2/8 },
286
          };
287
      int[][] indices =
288
          {
289
              {0,1,3,2},
290
              {4,0,2,5},
291
              {1,4,5,3},
292
              {2,3,5},
293
              {4,1,0}
294
          };
295

    
296
      return new ObjectShape(vertices, indices);
297
      }
298
    else
299
      {
300
      float[][] vertices =
301
          {
302
              { -SQ2/8             , -0.5f -D,  -SQ2/8+0.75f +D },
303
              {3*SQ2/8 +D*(4*SQ2/8), -0.5f -D, 3*SQ2/8-0.25f +D*(4*SQ2/8) },
304
              { -SQ2/8             , -0.5f -D,  -SQ2/8-0.25f },
305
              { -SQ2/8             , +0.5f   ,  -SQ2/8-0.25f }
306
          };
307
      int[][] indices =
308
          {
309
              {0,1,3},
310
              {2,0,3},
311
              {1,2,3},
312
              {2,1,0}
313
          };
314

    
315
      return new ObjectShape(vertices, indices);
316
      }
317
    }
318

    
319
///////////////////////////////////////////////////////////////////////////////////////////////////
320

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

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

    
349
  public int getNumCubitVariants(int[] numLayers)
350
    {
351
    return 2;
352
    }
353

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

    
356
  public int getCubitVariant(int cubit, int[] numLayers)
357
    {
358
    return cubit<16 ? 0:1;
359
    }
360

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

    
363
  public float getStickerRadius()
364
    {
365
    return 0.10f;
366
    }
367

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

    
370
  public float getStickerStroke()
371
    {
372
    return isInIconMode() ? 0.09f : 0.07f;
373
    }
374

    
375
///////////////////////////////////////////////////////////////////////////////////////////////////
376

    
377
  public float[][] getStickerAngles()
378
    {
379
    return null;
380
    }
381

    
382
///////////////////////////////////////////////////////////////////////////////////////////////////
383
// PUBLIC API
384

    
385
  public Static3D[] getRotationAxis()
386
    {
387
    return ROT_AXIS;
388
    }
389

    
390
///////////////////////////////////////////////////////////////////////////////////////////////////
391

    
392
  public int[][] getBasicAngles()
393
    {
394
    if( mBasicAngle==null )
395
      {
396
      int[] AV = {8,8,8,8};
397
      int[] AH = {2,2};
398
      mBasicAngle = new int[][] { AV,AH,AH,AH,AH };
399
      }
400

    
401
    return mBasicAngle;
402
    }
403

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

    
406
  public String getShortName()
407
    {
408
    return ObjectType.BALL_4.name();
409
    }
410

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

    
413
  public ObjectSignature getSignature()
414
    {
415
    return new ObjectSignature(ObjectType.BALL_4);
416
    }
417

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

    
420
  public String getObjectName()
421
    {
422
    return "Masterball";
423
    }
424

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

    
427
  public String getInventor()
428
    {
429
    return "Geza Gyovai";
430
    }
431

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

    
434
  public int getYearOfInvention()
435
    {
436
    return 1992;
437
    }
438

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

    
441
  public int getComplexity()
442
    {
443
    return 2;
444
    }
445

    
446
///////////////////////////////////////////////////////////////////////////////////////////////////
447

    
448
  public String[][] getTutorials()
449
    {
450
    return new String[][]{
451
                          {"gb","n41Rng0g65c","How to solve Masterball","javahamburg"},
452
                          {"es","zmdgV15BQi0","Tutorial para la Masterball","Robert Cubes"},
453
                          {"de","EjGf-VytMcA","Masterball Tutorial Deutsch","javahamburg"},
454
                         };
455
    }
456
}
(17-17/38)