Project

General

Profile

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

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

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,
121
           10,1,11,1,12,1,13,1,14,1,15,1,16,1,17,1,18,1,19,1,
122
           20,1,21,1,22,1,23,1,24,1,25,1,26,1,27,1
123
          },
124

    
125
          {28,2,29,2,30,2,31,2,32,2,33,2,34,2,35,2 },
126

    
127
          { 0,1, 1,1, 2,1, 3,1, 4,1, 5,1, 6,1, 7,1, 8,1, 9,1,
128
           10,1,11,1,12,1,13,1,14,1,15,1,16,1,17,1,18,1,19,1,
129
           20,1,21,1,22,1,23,1,24,1,25,1,26,1,27,1,
130
           28,0,29,0,30,0,31,0,32,0,33,0,34,0,35,0
131
          }
132
        };
133
      }
134

    
135
    return mEdges;
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 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
  private float[][] getVertices(int variant)
268
    {
269
    if( variant==0 )
270
      {
271
      return new float[][]
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.01f*(0.5f-D), -0.750f-3*SQ2/8 },
279
          };
280
      }
281
    else
282
      {
283
      return new float[][]
284
          {
285
              { -SQ2/8             , -0.5f -D,  -SQ2/8+0.75f +D },
286
              {3*SQ2/8 +D*(4*SQ2/8), -0.5f -D, 3*SQ2/8-0.25f +D*(4*SQ2/8) },
287
              { -SQ2/8             , -0.5f -D,  -SQ2/8-0.25f },
288
              { -SQ2/8             , +0.5f   ,  -SQ2/8-0.25f }
289
          };
290
      }
291
    }
292

    
293
///////////////////////////////////////////////////////////////////////////////////////////////////
294

    
295
  public ObjectShape getObjectShape(int variant)
296
    {
297
    if( variant==0 )
298
      {
299
      int[][] indices =
300
          {
301
              {0,1,3,2},
302
              {4,0,2,5},
303
              {1,4,5,3},
304
              {2,3,5},
305
              {4,1,0}
306
          };
307

    
308
      return new ObjectShape(getVertices(variant), indices);
309
      }
310
    else
311
      {
312
      int[][] indices =
313
          {
314
              {0,1,3},
315
              {2,0,3},
316
              {1,2,3},
317
              {2,1,0}
318
          };
319

    
320
      return new ObjectShape(getVertices(variant), indices);
321
      }
322
    }
323

    
324
///////////////////////////////////////////////////////////////////////////////////////////////////
325

    
326
  public ObjectFaceShape getObjectFaceShape(int variant)
327
    {
328
    if( variant==0 )
329
      {
330
      float height = isInIconMode() ? 0.001f : 0.015f;
331
      float[][] bands = { {height,35,0.25f,0.5f,10,0,0},{0.001f,35,0.25f,0.5f,4,0,0} };
332
      int[] indices   = { 0,1,1,1,1 };
333
      return new ObjectFaceShape(bands,indices,null);
334
      }
335
    else
336
      {
337
      float height = isInIconMode() ? 0.001f : 0.020f;
338
      float[][] bands = { {height,35,0.20f,0.6f,9,0,0}, {0.001f,35,0.20f,0.6f,4,0,0} };
339
      int[] indices   = { 0,1,1,1 };
340
      return new ObjectFaceShape(bands,indices,null);
341
      }
342
    }
343

    
344
///////////////////////////////////////////////////////////////////////////////////////////////////
345

    
346
  public ObjectVertexEffects getVertexEffects(int variant)
347
    {
348
    if( variant==0 )
349
      {
350
      float[][] corners   = { {0.04f,0.10f} };
351
      int[] cornerIndices = { -1,-1,-1,-1,-1,-1 };
352
      float[][] centers   = { { -3*SQ2/16, -0.5f,-0.375f-3*SQ2/16 } };
353
      int[] centerIndices = { 0,0,0,0,-1,-1 };
354
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
355
      }
356
    else
357
      {
358
      float[][] corners   = { {0.02f,0.10f} };
359
      int[] cornerIndices = { -1,-1,-1,-1 };
360
      float[][] centers   = {  { -SQ2/8, -0.5f, -SQ2/8-0.25f } };
361
      int[] centerIndices = { 0,0,-1,0 };
362
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
363
      }
364
    }
365

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

    
368
  public int getNumCubitVariants(int[] numLayers)
369
    {
370
    return 2;
371
    }
372

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

    
375
  public int getCubitVariant(int cubit, int[] numLayers)
376
    {
377
    return cubit<16 ? 0:1;
378
    }
379

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

    
382
  public float getStickerRadius()
383
    {
384
    return 0.10f;
385
    }
386

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

    
389
  public float getStickerStroke()
390
    {
391
    return isInIconMode() ? 0.13f : 0.07f;
392
    }
393

    
394
///////////////////////////////////////////////////////////////////////////////////////////////////
395

    
396
  public float[][] getStickerAngles()
397
    {
398
    return null;
399
    }
400

    
401
///////////////////////////////////////////////////////////////////////////////////////////////////
402
// PUBLIC API
403

    
404
  public Static3D[] getRotationAxis()
405
    {
406
    return ROT_AXIS;
407
    }
408

    
409
///////////////////////////////////////////////////////////////////////////////////////////////////
410

    
411
  public int[][] getBasicAngles()
412
    {
413
    if( mBasicAngle==null )
414
      {
415
      int[] AV = {8,8,8,8};
416
      int[] AH = {2,2};
417
      mBasicAngle = new int[][] { AV,AH,AH,AH,AH };
418
      }
419

    
420
    return mBasicAngle;
421
    }
422

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

    
425
  public String getShortName()
426
    {
427
    return ObjectType.BALL_4.name();
428
    }
429

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

    
432
  public ObjectSignature getSignature()
433
    {
434
    return new ObjectSignature(ObjectSignatures.BALL_4);
435
    }
436

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

    
439
  public String getObjectName()
440
    {
441
    return "Masterball";
442
    }
443

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

    
446
  public String getInventor()
447
    {
448
    return "Geza Gyovai";
449
    }
450

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

    
453
  public int getYearOfInvention()
454
    {
455
    return 1992;
456
    }
457

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

    
460
  public int getComplexity()
461
    {
462
    return 2;
463
    }
464

    
465
///////////////////////////////////////////////////////////////////////////////////////////////////
466

    
467
  public String[][] getTutorials()
468
    {
469
    return new String[][]{
470
                          {"gb","n41Rng0g65c","How to solve Masterball","javahamburg"},
471
                          {"es","zmdgV15BQi0","Tutorial para la Masterball","Robert Cubes"},
472
                          {"de","EjGf-VytMcA","Masterball Tutorial Deutsch","javahamburg"},
473
                         };
474
    }
475
}
(21-21/42)