Project

General

Profile

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

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

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.FactoryCubit;
18
import org.distorted.objectlib.helpers.ObjectFaceShape;
19
import org.distorted.objectlib.helpers.ObjectShape;
20
import org.distorted.objectlib.helpers.ObjectSignature;
21
import org.distorted.objectlib.helpers.ObjectVertexEffects;
22
import org.distorted.objectlib.main.InitAssets;
23
import org.distorted.objectlib.main.InitData;
24
import org.distorted.objectlib.main.ObjectSignatures;
25
import org.distorted.objectlib.main.ObjectType;
26
import org.distorted.objectlib.shape.ShapeDiamond;
27
import org.distorted.objectlib.touchcontrol.TouchControlBall;
28

    
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
  private static final float D = 0.1f; // shape; keep between (-0.5,0.5)
43

    
44
  private int[][] mEdges;
45
  private int[][] mBasicAngle;
46
  private int[] mQuatIndex;
47
  private float[][] mCuts;
48
  private float[][] mCenters;
49

    
50
///////////////////////////////////////////////////////////////////////////////////////////////////
51

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

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

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

    
72
    final float Y = 0.02f;
73

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

    
81
///////////////////////////////////////////////////////////////////////////////////////////////////
82

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

    
89
///////////////////////////////////////////////////////////////////////////////////////////////////
90

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

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

    
112
///////////////////////////////////////////////////////////////////////////////////////////////////
113

    
114
  public int[][] getScrambleEdges()
115
    {
116
    if( mEdges==null )
117
      {
118
      mEdges = new int[][]
119
        {
120
          {0,1,1,1,2,1,3,1,4,1,5,1,6,1,7,1,8,1,9,1,10,1,11,1,12,1,13,1,14,1,15,1,16,1,17,1,18,1,19,1,20,1,21,1,22,1,23,1,24,1,25,1,26,1,27,1},
121
          {28,2,29,2,30,2,31,2,32,2,33,2,34,2,35,2 },
122
          {0,1,1,1,2,1,3,1,4,1,5,1,6,1,7,1,8,1,9,1,10,1,11,1,12,1,13,1,14,1,15,1,16,1,17,1,18,1,19,1,20,1,21,1,22,1,23,1,24,1,25,1,26,1,27,1,
123
           28,0,29,0,30,0,31,0,32,0,33,0,34,0,35,0 }
124
        };
125
      }
126

    
127
    return mEdges;
128
    }
129

    
130
///////////////////////////////////////////////////////////////////////////////////////////////////
131

    
132
  public float[][] getCuts(int[] numLayers)
133
    {
134
    if( mCuts==null )
135
      {
136
      float cut = 1.0f;
137
      float[] cutH = { -cut,0.0f,cut };
138
      float[] cutV = { 0.0f };
139
      mCuts = new float[][] { cutH,cutV,cutV,cutV,cutV };
140
      }
141

    
142
    return mCuts;
143
    }
144

    
145
///////////////////////////////////////////////////////////////////////////////////////////////////
146

    
147
  public boolean[][] getLayerRotatable(int[] numLayers)
148
    {
149
    boolean[] LV = {true,true,true,true};
150
    boolean[] LH = {true,true};
151
    return new boolean[][] { LV,LH,LH,LH,LH };
152
    }
153

    
154
///////////////////////////////////////////////////////////////////////////////////////////////////
155

    
156
  public int getTouchControlType()
157
    {
158
    return TC_BALL;
159
    }
160

    
161
///////////////////////////////////////////////////////////////////////////////////////////////////
162
// not used
163

    
164
  public int getTouchControlSplit()
165
    {
166
    return TYPE_NOT_SPLIT;
167
    }
168

    
169
///////////////////////////////////////////////////////////////////////////////////////////////////
170
// Each 'face' is a vertical strip of 1/8 of longitude (PI/4).
171
// The first one spans longitude from -PI/8 to +PI/8, where Greenwich is long=0.
172
// Next successively to the east.
173

    
174
  public int[][][] getEnabled()
175
    {
176
    return new int[][][] { {{0,1}},{{0,4}},{{0,3}},{{0,2}},{{0,1}},{{0,4}},{{0,3}},{{0,2}} };
177
    }
178

    
179
///////////////////////////////////////////////////////////////////////////////////////////////////
180

    
181
  public float[] getDist3D(int[] numLayers)
182
    {
183
    final float D = 0.5f*(float)Math.sqrt((2*SQ2+5)/17);
184
    return new float[] { D,D,D,D,D,D,D,D,D,D,D,D,D,D,D,D };
185
    }
186

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

    
189
  public Static3D[] getFaceAxis()
190
    {
191
    return TouchControlBall.FACE_AXIS;
192
    }
193

    
194
///////////////////////////////////////////////////////////////////////////////////////////////////
195

    
196
  public float[][] getCubitPositions(int[] numLayers)
197
    {
198
    if( mCenters==null )
199
      {
200
      final float X1 = 3*SQ2/8;
201
      final float Y1 = 0.5f;
202
      final float Z1 = 0.750f+3*SQ2/8;
203
      final float X2 = SQ2/8;
204
      final float Y2 = 1.5f;
205
      final float Z2 = 0.25f+SQ2/8;
206

    
207
      mCenters = new float[][]
208
         {
209
             { X1, Y1, Z1 },
210
             { X1,-Y1, Z1 },
211
             { Z1, Y1, X1 },
212
             { Z1,-Y1, X1 },
213
             { Z1, Y1,-X1 },
214
             { Z1,-Y1,-X1 },
215
             { X1, Y1,-Z1 },
216
             { X1,-Y1,-Z1 },
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

    
226
             { X2, Y2, Z2 },
227
             { X2,-Y2, Z2 },
228
             { Z2, Y2, X2 },
229
             { Z2,-Y2, X2 },
230
             { Z2, Y2,-X2 },
231
             { Z2,-Y2,-X2 },
232
             { X2, Y2,-Z2 },
233
             { X2,-Y2,-Z2 },
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
         };
243
      }
244

    
245
    return mCenters;
246
    }
247

    
248
///////////////////////////////////////////////////////////////////////////////////////////////////
249

    
250
  public Static4D getCubitQuats(int cubit, int[] numLayers)
251
    {
252
    if( mQuatIndex==null ) mQuatIndex = new int[] { 0,13,7,9,6,12,5,8,4,15,3,11,2,14,1,10,
253
                                                    0,13,7,9,6,12,5,8,4,15,3,11,2,14,1,10 };
254
    return mObjectQuats[mQuatIndex[cubit]];
255
    }
256

    
257
///////////////////////////////////////////////////////////////////////////////////////////////////
258

    
259
  private float[][] getVertices(int variant)
260
    {
261
    if( variant==0 )
262
      {
263
      return new float[][]
264
          {
265
              { -3*SQ2/8             ,        -0.5f  ,  1.250f-3*SQ2/8 },
266
              {  5*SQ2/8             ,        -0.5f  , -0.750f+5*SQ2/8 },
267
              { -3*SQ2/8             ,         0.5f-D,  0.250f-3*SQ2/8 +D },
268
              {    SQ2/8 +D*(4*SQ2/8),         0.5f-D, -0.750f+  SQ2/8 +D*(4*SQ2/8) },
269
              { -3*SQ2/8             ,        -0.5f  , -0.750f-3*SQ2/8 },
270
              { -3*SQ2/8             , 0.01f*(0.5f-D), -0.750f-3*SQ2/8 },
271
          };
272
      }
273
    else
274
      {
275
      return new float[][]
276
          {
277
              { -SQ2/8             , -0.5f -D,  -SQ2/8+0.75f +D },
278
              {3*SQ2/8 +D*(4*SQ2/8), -0.5f -D, 3*SQ2/8-0.25f +D*(4*SQ2/8) },
279
              { -SQ2/8             , -0.5f -D,  -SQ2/8-0.25f },
280
              { -SQ2/8             , +0.5f   ,  -SQ2/8-0.25f }
281
          };
282
      }
283
    }
284

    
285
///////////////////////////////////////////////////////////////////////////////////////////////////
286

    
287
  public ObjectShape getObjectShape(int variant)
288
    {
289
    if( variant==0 )
290
      {
291
      int[][] indices =
292
          {
293
              {0,1,3,2},
294
              {4,0,2,5},
295
              {1,4,5,3},
296
              {2,3,5},
297
              {4,1,0}
298
          };
299

    
300
      return new ObjectShape(getVertices(variant), indices);
301
      }
302
    else
303
      {
304
      int[][] indices =
305
          {
306
              {0,1,3},
307
              {2,0,3},
308
              {1,2,3},
309
              {2,1,0}
310
          };
311

    
312
      return new ObjectShape(getVertices(variant), indices);
313
      }
314
    }
315

    
316
///////////////////////////////////////////////////////////////////////////////////////////////////
317

    
318
  public ObjectFaceShape getObjectFaceShape(int variant)
319
    {
320
    if( variant==0 )
321
      {
322
      float height = isInIconMode() ? 0.001f : 0.015f;
323
      float[][] bands = { {height,35,0.25f,0.5f,10,0,0},{0.001f,35,0.25f,0.5f,4,0,0} };
324
      int[] indices   = { 0,1,1,1,1 };
325
      return new ObjectFaceShape(bands,indices,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[] indices   = { 0,1,1,1 };
332
      return new ObjectFaceShape(bands,indices,null);
333
      }
334
    }
335

    
336
///////////////////////////////////////////////////////////////////////////////////////////////////
337

    
338
  public ObjectVertexEffects getVertexEffects(int variant)
339
    {
340
    if( variant==0 )
341
      {
342
      float[][] corners   = { {0.04f,0.10f} };
343
      int[] cornerIndices = { -1,-1,-1,-1,-1,-1 };
344
      float[][] centers   = { { -3*SQ2/16, -0.5f,-0.375f-3*SQ2/16 } };
345
      int[] centerIndices = { 0,0,0,0,-1,-1 };
346
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
347
      }
348
    else
349
      {
350
      float[][] corners   = { {0.02f,0.10f} };
351
      int[] cornerIndices = { -1,-1,-1,-1 };
352
      float[][] centers   = {  { -SQ2/8, -0.5f, -SQ2/8-0.25f } };
353
      int[] centerIndices = { 0,0,-1,0 };
354
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
355
      }
356
    }
357

    
358
///////////////////////////////////////////////////////////////////////////////////////////////////
359

    
360
  public int getNumCubitVariants(int[] numLayers)
361
    {
362
    return 2;
363
    }
364

    
365
///////////////////////////////////////////////////////////////////////////////////////////////////
366

    
367
  public int getCubitVariant(int cubit, int[] numLayers)
368
    {
369
    return cubit<16 ? 0:1;
370
    }
371

    
372
///////////////////////////////////////////////////////////////////////////////////////////////////
373

    
374
  public float getStickerRadius()
375
    {
376
    return 0.10f;
377
    }
378

    
379
///////////////////////////////////////////////////////////////////////////////////////////////////
380

    
381
  public float getStickerStroke()
382
    {
383
    return isInIconMode() ? 0.13f : 0.07f;
384
    }
385

    
386
///////////////////////////////////////////////////////////////////////////////////////////////////
387

    
388
  public float[][] getStickerAngles()
389
    {
390
    return null;
391
    }
392

    
393
///////////////////////////////////////////////////////////////////////////////////////////////////
394
// PUBLIC API
395

    
396
  public Static3D[] getRotationAxis()
397
    {
398
    return ROT_AXIS;
399
    }
400

    
401
///////////////////////////////////////////////////////////////////////////////////////////////////
402

    
403
  public int[][] getBasicAngles()
404
    {
405
    if( mBasicAngle==null )
406
      {
407
      int[] AV = {8,8,8,8};
408
      int[] AH = {2,2};
409
      mBasicAngle = new int[][] { AV,AH,AH,AH,AH };
410
      }
411

    
412
    return mBasicAngle;
413
    }
414

    
415
///////////////////////////////////////////////////////////////////////////////////////////////////
416

    
417
  public String getShortName()
418
    {
419
    return ObjectType.BALL_4.name();
420
    }
421

    
422
///////////////////////////////////////////////////////////////////////////////////////////////////
423

    
424
  public ObjectSignature getSignature()
425
    {
426
    return new ObjectSignature(ObjectSignatures.BALL_4);
427
    }
428

    
429
///////////////////////////////////////////////////////////////////////////////////////////////////
430

    
431
  public String getObjectName()
432
    {
433
    return "Masterball";
434
    }
435

    
436
///////////////////////////////////////////////////////////////////////////////////////////////////
437

    
438
  public String getInventor()
439
    {
440
    return "Geza Gyovai";
441
    }
442

    
443
///////////////////////////////////////////////////////////////////////////////////////////////////
444

    
445
  public int getYearOfInvention()
446
    {
447
    return 1992;
448
    }
449

    
450
///////////////////////////////////////////////////////////////////////////////////////////////////
451

    
452
  public int getComplexity()
453
    {
454
    return 2;
455
    }
456

    
457
///////////////////////////////////////////////////////////////////////////////////////////////////
458

    
459
  public String[][] getTutorials()
460
    {
461
    return new String[][]{
462
                          {"gb","n41Rng0g65c","How to solve Masterball","javahamburg"},
463
                          {"es","zmdgV15BQi0","Tutorial para la Masterball","Robert Cubes"},
464
                          {"de","EjGf-VytMcA","Masterball Tutorial Deutsch","javahamburg"},
465
                         };
466
    }
467
}
(20-20/41)