Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyCheese.java @ 09d5cf2b

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_BARREL;
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.ObjectVertexEffects;
21
import org.distorted.objectlib.main.InitAssets;
22
import org.distorted.objectlib.metadata.ListObjects;
23
import org.distorted.objectlib.metadata.Metadata;
24
import org.distorted.objectlib.shape.ShapeBarrel;
25
import org.distorted.objectlib.touchcontrol.TouchControlBarrel;
26

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

    
29
public class TwistyCheese extends ShapeBarrel
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( 0.5f, 0, SQ3/2),
36
           new Static3D(-0.5f, 0, SQ3/2),
37
         };
38

    
39
  private int[][] mEdges;
40
  private int[][] mBasicAngle;
41
  private int[] mQuatIndex;
42
  private float[][] mCuts;
43
  private float[][] mCenters;
44

    
45
///////////////////////////////////////////////////////////////////////////////////////////////////
46

    
47
  public TwistyCheese(int iconMode, Static4D quat, Static3D move, float scale, Metadata meta, InitAssets asset)
48
    {
49
    super(iconMode, meta.getNumLayers()[0], quat, move, scale, meta, asset);
50
    }
51

    
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53
// here we cannot automatically detect the outer monochromatic walls -> use the old way.
54

    
55
  @Override
56
  public int getSolvedFunctionIndex()
57
    {
58
    return 0;
59
    }
60

    
61
///////////////////////////////////////////////////////////////////////////////////////////////////
62

    
63
  @Override
64
  public float[][] returnRotationFactor()
65
    {
66
    float C1 = 1.0f;
67
    float C2 = 1.7f;
68
    float[] f1 = new float[] { C1,C1 };
69
    float[] f2 = new float[] { C2,C2 };
70
    return new float[][] { f1,f2,f2,f2 };
71
    }
72

    
73
///////////////////////////////////////////////////////////////////////////////////////////////////
74
// make the equator a bit thicker
75
/*
76
  @Override
77
  public void adjustStickerCoords()
78
    {
79
    final float X1 = -0.38861537f;
80
    final float Y1 = -0.4252297f;
81
    final float X2 =  0.5f;
82
    final float Y2 = -0.2860808f;
83
    final float X3 =  0.18867691f;
84
    final float Y3 =  1.05f*0.39392126f;
85
    final float X4 = -0.30006152f;
86
    final float Y4 =  1.05f*0.3173893f;
87

    
88
    final float Y = 0.02f;
89

    
90
    mStickerCoords = new float[][][][]
91
          {
92
            { { {X1+Y*(X4-X1), Y1+Y*(Y4-Y1)}, {X2+Y*(X3-X2), Y2+Y*(Y3-Y2)}, {X3, Y3}, {X4, Y4} } },
93
            { { {-0.17166577f, 0.92f*-0.28301144f}, {0.24996112f, 0.92f*-0.21698855f}, {-0.07829534f, 0.5f} } }
94
          };
95
    }
96
*/
97

    
98
///////////////////////////////////////////////////////////////////////////////////////////////////
99
/*
100
  @Override
101
  public int[][] getSolvedQuats()
102
    {
103
    // special SolvedQuats for the case where there are no corner of edge cubits.
104
    // first row {0} - means there are no corners or edges.
105
    // each next defines all cubits of a singe face
106
    // (numCubits, firstCubit, cubit1,..,cubitN-1, quat0,..., quatM)
107

    
108
    return new int[][] {
109
                         {0},
110
                         {4, 0, 1,16,17, 13},
111
                         {4, 2, 3,18,19, 12},
112
                         {4, 4, 5,20,21, 15},
113
                         {4, 6, 7,22,23, 14},
114
                         {4, 8, 9,24,25, 13},
115
                         {4,10,11,26,27, 12},
116
                         {4,12,13,28,29, 15},
117
                         {4,14,15,30,31, 14},
118
                       };
119
    }
120
*/
121
///////////////////////////////////////////////////////////////////////////////////////////////////
122
// TODO
123

    
124
  public int[][] getScrambleEdges()
125
    {
126
    if( mEdges==null )
127
      {
128
      mEdges = new int[][]
129
        {
130
          { 0,1, 1,1, 2,1, 3,1, 4,1, 5,1, 6,1, 7,1, 8,1, 9,1,
131
           10,1,11,1,12,1,13,1,14,1,15,1,16,1,17,1,18,1,19,1,
132
           20,1,21,1,22,1,23,1,24,1,25,1,26,1,27,1
133
          },
134

    
135
          {28,2,29,2,30,2,31,2,32,2,33,2,34,2,35,2 },
136

    
137
          { 0,1, 1,1, 2,1, 3,1, 4,1, 5,1, 6,1, 7,1, 8,1, 9,1,
138
           10,1,11,1,12,1,13,1,14,1,15,1,16,1,17,1,18,1,19,1,
139
           20,1,21,1,22,1,23,1,24,1,25,1,26,1,27,1,
140
           28,0,29,0,30,0,31,0,32,0,33,0,34,0,35,0
141
          }
142
        };
143
      }
144

    
145
    return mEdges;
146
    }
147

    
148
///////////////////////////////////////////////////////////////////////////////////////////////////
149

    
150
  public float[][] getCuts(int[] numLayers)
151
    {
152
    if( mCuts==null )
153
      {
154
      float[] c = { 0.0f };
155
      mCuts = new float[][] { c,c,c,c };
156
      }
157

    
158
    return mCuts;
159
    }
160

    
161
///////////////////////////////////////////////////////////////////////////////////////////////////
162

    
163
  public boolean[][] getLayerRotatable(int[] numLayers)
164
    {
165
    boolean[] l = {true,true};
166
    return new boolean[][] { l,l,l,l };
167
    }
168

    
169
///////////////////////////////////////////////////////////////////////////////////////////////////
170

    
171
  public int getTouchControlType()
172
    {
173
    return TC_BARREL;
174
    }
175

    
176
///////////////////////////////////////////////////////////////////////////////////////////////////
177
// not used
178

    
179
  public int getTouchControlSplit()
180
    {
181
    return TYPE_NOT_SPLIT;
182
    }
183

    
184
///////////////////////////////////////////////////////////////////////////////////////////////////
185
// Each 'face' is a vertical strip of 1/8 of longitude (PI/4).
186
// The first one spans longitude from -PI/8 to +PI/8, where Greenwich is long=0.
187
// Next successively to the east.
188

    
189
  public int[][][] getEnabled()
190
    {
191
    return new int[][][] { {{0,1}},{{0,4}},{{0,3}},{{0,2}},{{0,1}},{{0,4}},{{0,3}},{{0,2}} };
192
    }
193

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

    
196
  public float[] getDist3D(int[] numLayers)
197
    {
198
    final float D = 0.5f*(float)Math.sqrt((2*SQ2+5)/17);
199
    return new float[] { D,D,D,D,D,D,D,D,D,D,D,D,D,D,D,D };
200
    }
201

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

    
204
  public Static3D[] getFaceAxis()
205
    {
206
    return TouchControlBarrel.FACE_AXIS;
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 = X1/3;
219
      final float Y2 = 1.5f;
220
      final float Z2 = Z1/3;
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
  private float[][] getVertices(int variant)
275
    {
276
    final float D = 0.1f;
277

    
278
    if( variant==0 )
279
      {
280
      return new float[][]
281
          {
282
              { -3*SQ2/8             ,        -0.5f  ,  1.250f-3*SQ2/8 },
283
              {  5*SQ2/8             ,        -0.5f  , -0.750f+5*SQ2/8 },
284
              { -3*SQ2/8             ,         0.5f-D,  0.250f-3*SQ2/8 +D },
285
              {    SQ2/8 +D*(4*SQ2/8),         0.5f-D, -0.750f+  SQ2/8 +D*(4*SQ2/8) },
286
              { -3*SQ2/8             ,        -0.5f  , -0.750f-3*SQ2/8 },
287
              { -3*SQ2/8             , 0.01f*(0.5f-D), -0.750f-3*SQ2/8 },
288
          };
289
      }
290
    else
291
      {
292
      return new float[][]
293
          {
294
              { -SQ2/8             , -0.5f -D,  -SQ2/8+0.75f +D },
295
              {3*SQ2/8 +D*(4*SQ2/8), -0.5f -D, 3*SQ2/8-0.25f +D*(4*SQ2/8) },
296
              { -SQ2/8             , -0.5f -D,  -SQ2/8-0.25f },
297
              { -SQ2/8             , +0.5f   ,  -SQ2/8-0.25f }
298
          };
299
      }
300
    }
301

    
302
///////////////////////////////////////////////////////////////////////////////////////////////////
303

    
304
  public ObjectShape getObjectShape(int variant)
305
    {
306
    if( variant==0 )
307
      {
308
      int[][] indices =
309
          {
310
              {0,1,3,2},
311
              {4,0,2,5},
312
              {1,4,5,3},
313
              {2,3,5},
314
              {4,1,0}
315
          };
316

    
317
      return new ObjectShape(getVertices(variant), indices);
318
      }
319
    else
320
      {
321
      int[][] indices =
322
          {
323
              {0,1,3},
324
              {2,0,3},
325
              {1,2,3},
326
              {2,1,0}
327
          };
328

    
329
      return new ObjectShape(getVertices(variant), indices);
330
      }
331
    }
332

    
333
///////////////////////////////////////////////////////////////////////////////////////////////////
334

    
335
  public ObjectFaceShape getObjectFaceShape(int variant)
336
    {
337
    if( variant==0 )
338
      {
339
      float height = isInIconMode() ? 0.001f : 0.015f;
340
      float[][] bands = { {height,35,0.25f,0.5f,10,0,0},{0.001f,35,0.25f,0.5f,4,0,0} };
341
      int[] indices   = { 0,1,1,1,1 };
342
      return new ObjectFaceShape(bands,indices,null);
343
      }
344
    else
345
      {
346
      float height = isInIconMode() ? 0.001f : 0.020f;
347
      float[][] bands = { {height,35,0.20f,0.6f,9,0,0}, {0.001f,35,0.20f,0.6f,4,0,0} };
348
      int[] indices   = { 0,1,1,1 };
349
      return new ObjectFaceShape(bands,indices,null);
350
      }
351
    }
352

    
353
///////////////////////////////////////////////////////////////////////////////////////////////////
354

    
355
  public ObjectVertexEffects getVertexEffects(int variant)
356
    {
357
    if( variant==0 )
358
      {
359
      float[][] corners   = { {0.04f,0.10f} };
360
      int[] cornerIndices = { -1,-1,-1,-1,-1,-1 };
361
      float[][] centers   = { { -3*SQ2/16, -0.5f,-0.375f-3*SQ2/16 } };
362
      int[] centerIndices = { 0,0,0,0,-1,-1 };
363
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
364
      }
365
    else
366
      {
367
      float[][] corners   = { {0.02f,0.10f} };
368
      int[] cornerIndices = { -1,-1,-1,-1 };
369
      float[][] centers   = {  { -SQ2/8, -0.5f, -SQ2/8-0.25f } };
370
      int[] centerIndices = { 0,0,-1,0 };
371
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
372
      }
373
    }
374

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

    
377
  public int getNumCubitVariants(int[] numLayers)
378
    {
379
    return 2;
380
    }
381

    
382
///////////////////////////////////////////////////////////////////////////////////////////////////
383

    
384
  public int getCubitVariant(int cubit, int[] numLayers)
385
    {
386
    return cubit<16 ? 0:1;
387
    }
388

    
389
///////////////////////////////////////////////////////////////////////////////////////////////////
390

    
391
  public float getStickerRadius()
392
    {
393
    return 0.10f;
394
    }
395

    
396
///////////////////////////////////////////////////////////////////////////////////////////////////
397

    
398
  public float getStickerStroke()
399
    {
400
    return isInIconMode() ? 0.13f : 0.10f;
401
    }
402

    
403
///////////////////////////////////////////////////////////////////////////////////////////////////
404

    
405
  public float[][][] getStickerAngles()
406
    {
407
    float A = (float)(Math.PI/12);
408
    return new float[][][] { {{ 0,0,-A,0 }} , {{A,0,0}}  };
409
    }
410

    
411
///////////////////////////////////////////////////////////////////////////////////////////////////
412
// PUBLIC API
413

    
414
  public Static3D[] getRotationAxis()
415
    {
416
    return ROT_AXIS;
417
    }
418

    
419
///////////////////////////////////////////////////////////////////////////////////////////////////
420

    
421
  public int[][] getBasicAngles()
422
    {
423
    if( mBasicAngle==null )
424
      {
425
      int[] AV = {8,8,8,8};
426
      int[] AH = {2,2};
427
      mBasicAngle = new int[][] { AV,AH,AH,AH,AH };
428
      }
429

    
430
    return mBasicAngle;
431
    }
432

    
433
///////////////////////////////////////////////////////////////////////////////////////////////////
434

    
435
  public String getShortName()
436
    {
437
    return ListObjects.BALL_4.name();
438
    }
439

    
440
///////////////////////////////////////////////////////////////////////////////////////////////////
441

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