Project

General

Profile

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

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

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.InitData;
23
import org.distorted.objectlib.main.ObjectSignatures;
24
import org.distorted.objectlib.main.ObjectType;
25
import org.distorted.objectlib.shape.ShapeDiamond;
26
import org.distorted.objectlib.touchcontrol.TouchControlBall;
27

    
28
import java.io.InputStream;
29

    
30
///////////////////////////////////////////////////////////////////////////////////////////////////
31

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

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

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

    
51
///////////////////////////////////////////////////////////////////////////////////////////////////
52

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

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

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

    
73
    final float Y = 0.02f;
74

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

    
82
///////////////////////////////////////////////////////////////////////////////////////////////////
83

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

    
90
///////////////////////////////////////////////////////////////////////////////////////////////////
91

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

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

    
113
///////////////////////////////////////////////////////////////////////////////////////////////////
114

    
115
  public int[][] getScrambleEdges()
116
    {
117
    if( mEdges==null )
118
      {
119
      mEdges = new int[][]
120
        {
121
          {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},
122
          {28,2,29,2,30,2,31,2,32,2,33,2,34,2,35,2 },
123
          {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,
124
           28,0,29,0,30,0,31,0,32,0,33,0,34,0,35,0 }
125
        };
126
      }
127

    
128
    return mEdges;
129
    }
130

    
131
///////////////////////////////////////////////////////////////////////////////////////////////////
132

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

    
143
    return mCuts;
144
    }
145

    
146
///////////////////////////////////////////////////////////////////////////////////////////////////
147

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

    
155
///////////////////////////////////////////////////////////////////////////////////////////////////
156

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

    
162
///////////////////////////////////////////////////////////////////////////////////////////////////
163
// not used
164

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

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

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

    
180
///////////////////////////////////////////////////////////////////////////////////////////////////
181

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

    
188
///////////////////////////////////////////////////////////////////////////////////////////////////
189

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

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

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

    
208
      mCenters = new float[][]
209
         {
210
             { X1, Y1, Z1 },
211
             { X1,-Y1, Z1 },
212
             { Z1, Y1, X1 },
213
             { Z1,-Y1, X1 },
214
             { Z1, Y1,-X1 },
215
             { Z1,-Y1,-X1 },
216
             { X1, Y1,-Z1 },
217
             { X1,-Y1,-Z1 },
218
             {-X1, Y1,-Z1 },
219
             {-X1,-Y1,-Z1 },
220
             {-Z1, Y1,-X1 },
221
             {-Z1,-Y1,-X1 },
222
             {-Z1, Y1, X1 },
223
             {-Z1,-Y1, X1 },
224
             {-X1, Y1, Z1 },
225
             {-X1,-Y1, Z1 },
226

    
227
             { X2, Y2, Z2 },
228
             { X2,-Y2, Z2 },
229
             { Z2, Y2, X2 },
230
             { Z2,-Y2, X2 },
231
             { Z2, Y2,-X2 },
232
             { Z2,-Y2,-X2 },
233
             { X2, Y2,-Z2 },
234
             { X2,-Y2,-Z2 },
235
             {-X2, Y2,-Z2 },
236
             {-X2,-Y2,-Z2 },
237
             {-Z2, Y2,-X2 },
238
             {-Z2,-Y2,-X2 },
239
             {-Z2, Y2, X2 },
240
             {-Z2,-Y2, X2 },
241
             {-X2, Y2, Z2 },
242
             {-X2,-Y2, Z2 },
243
         };
244
      }
245

    
246
    return mCenters;
247
    }
248

    
249
///////////////////////////////////////////////////////////////////////////////////////////////////
250

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

    
258
///////////////////////////////////////////////////////////////////////////////////////////////////
259

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

    
286
///////////////////////////////////////////////////////////////////////////////////////////////////
287

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

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

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

    
317
///////////////////////////////////////////////////////////////////////////////////////////////////
318

    
319
  public ObjectFaceShape getObjectFaceShape(int variant)
320
    {
321
    if( variant==0 )
322
      {
323
      float height = isInIconMode() ? 0.001f : 0.015f;
324
      float[][] bands = { {height,35,0.25f,0.5f,10,0,0},{0.001f,35,0.25f,0.5f,4,0,0} };
325
      int[] indices   = { 0,1,1,1,1 };
326
      return new ObjectFaceShape(bands,indices,null);
327
      }
328
    else
329
      {
330
      float height = isInIconMode() ? 0.001f : 0.020f;
331
      float[][] bands = { {height,35,0.20f,0.6f,9,0,0}, {0.001f,35,0.20f,0.6f,4,0,0} };
332
      int[] indices   = { 0,1,1,1 };
333
      return new ObjectFaceShape(bands,indices,null);
334
      }
335
    }
336

    
337
///////////////////////////////////////////////////////////////////////////////////////////////////
338

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

    
359
///////////////////////////////////////////////////////////////////////////////////////////////////
360

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

    
366
///////////////////////////////////////////////////////////////////////////////////////////////////
367

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

    
373
///////////////////////////////////////////////////////////////////////////////////////////////////
374

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

    
380
///////////////////////////////////////////////////////////////////////////////////////////////////
381

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

    
387
///////////////////////////////////////////////////////////////////////////////////////////////////
388

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

    
394
///////////////////////////////////////////////////////////////////////////////////////////////////
395
// PUBLIC API
396

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

    
402
///////////////////////////////////////////////////////////////////////////////////////////////////
403

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

    
413
    return mBasicAngle;
414
    }
415

    
416
///////////////////////////////////////////////////////////////////////////////////////////////////
417

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

    
423
///////////////////////////////////////////////////////////////////////////////////////////////////
424

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

    
430
///////////////////////////////////////////////////////////////////////////////////////////////////
431

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

    
437
///////////////////////////////////////////////////////////////////////////////////////////////////
438

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

    
444
///////////////////////////////////////////////////////////////////////////////////////////////////
445

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

    
451
///////////////////////////////////////////////////////////////////////////////////////////////////
452

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

    
458
///////////////////////////////////////////////////////////////////////////////////////////////////
459

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