Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyPentultimate.java @ 361fd0de

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2022 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 org.distorted.library.type.Static3D;
13
import org.distorted.library.type.Static4D;
14
import org.distorted.objectlib.helpers.FactoryCubit;
15
import org.distorted.objectlib.helpers.ObjectFaceShape;
16
import org.distorted.objectlib.helpers.ObjectShape;
17
import org.distorted.objectlib.metadata.Metadata;
18
import org.distorted.objectlib.signature.ObjectSignature;
19
import org.distorted.objectlib.helpers.ObjectVertexEffects;
20
import org.distorted.objectlib.main.InitAssets;
21
import org.distorted.objectlib.signature.ObjectConstants;
22
import org.distorted.objectlib.metadata.ListObjects;
23
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator;
24

    
25
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
26
import static org.distorted.objectlib.touchcontrol.TouchControlDodecahedron.C2;
27
import static org.distorted.objectlib.touchcontrol.TouchControlDodecahedron.COS54;
28
import static org.distorted.objectlib.touchcontrol.TouchControlDodecahedron.SIN54;
29

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

    
32
public class TwistyPentultimate extends TwistyDodecahedron
33
{
34
  private float[][] mCuts;
35
  private float[][] mPosition;
36
  private int[] mQuatIndex;
37

    
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39

    
40
  public TwistyPentultimate(int iconMode, Static4D quat, Static3D move, float scale, Metadata meta, InitAssets asset)
41
    {
42
    super(iconMode, quat, move, scale, meta, asset);
43
    }
44

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

    
47
  public int[][] getScrambleEdges()
48
    {
49
    if( mEdges==null )
50
      {
51
      int[][] basicAngle = getBasicAngles();
52
      mEdges = ScrambleEdgeGenerator.getScrambleEdgesSingle(basicAngle);
53
      }
54

    
55
    return mEdges;
56
    }
57

    
58
///////////////////////////////////////////////////////////////////////////////////////////////////
59

    
60
  @Override
61
  public int getTouchControlSplit()
62
    {
63
    return TYPE_NOT_SPLIT;
64
    }
65

    
66
///////////////////////////////////////////////////////////////////////////////////////////////////
67

    
68
  @Override
69
  public boolean[][] getLayerRotatable(int[] numLayers)
70
    {
71
    boolean[] tmp = new boolean[] {true,true};
72
    return new boolean[][] {tmp,tmp,tmp,tmp,tmp,tmp};
73
    }
74

    
75
///////////////////////////////////////////////////////////////////////////////////////////////////
76

    
77
  @Override
78
  public int[][][] getEnabled()
79
    {
80
    return new int[][][]
81
      {
82
          {{1,2,3,4,5}},
83
          {{0,2,3,4,5}},
84
          {{0,2,3,4,5}},
85
          {{1,2,3,4,5}},
86
          {{0,1,3,4,5}},
87
          {{0,1,2,4,5}},
88
          {{0,1,2,4,5}},
89
          {{0,1,3,4,5}},
90
          {{0,1,2,3,5}},
91
          {{0,1,2,3,4}},
92
          {{0,1,2,3,4}},
93
          {{0,1,2,3,5}},
94
      };
95
    }
96

    
97
///////////////////////////////////////////////////////////////////////////////////////////////////
98

    
99
  public float[][] getCubitPositions(int[] numLayers)
100
    {
101
    if( mPosition==null )
102
      {
103
      if( mCenterCoords==null ) initializeCenterCoords();
104
      final float A = 2.0f/3;
105

    
106
      mPosition = new float[NUM_CORNERS+NUM_CENTERS][3];
107

    
108
      for(int corner=0; corner<NUM_CORNERS; corner++)
109
        {
110
        mPosition[corner][0] = A*mCorners[corner][0];
111
        mPosition[corner][1] = A*mCorners[corner][1];
112
        mPosition[corner][2] = A*mCorners[corner][2];
113
        }
114

    
115
      for(int center=0; center<NUM_CENTERS; center++)
116
        {
117
        int index = center+NUM_CORNERS;
118
        mPosition[index][0] = A*mCenterCoords[center][0];
119
        mPosition[index][1] = A*mCenterCoords[center][1];
120
        mPosition[index][2] = A*mCenterCoords[center][2];
121
        }
122
      }
123

    
124
    return mPosition;
125
    }
126

    
127
///////////////////////////////////////////////////////////////////////////////////////////////////
128

    
129
  public Static4D getCubitQuats(int cubit, int[] numLayers)
130
    {
131
    if( mQuatIndex==null )
132
      {
133
      mQuatIndex = new int[]
134
        {
135
         0,29,59,48,18,53,22,49,11,54,10,52,17,27,19,26, 9,28,23,45,
136
         0, 4, 5, 6,26, 3, 2, 7,16,13, 1,19
137
        };
138
      }
139

    
140
    return mObjectQuats[mQuatIndex[cubit]];
141
    }
142

    
143
///////////////////////////////////////////////////////////////////////////////////////////////////
144

    
145
  private float[][] getVertices(int variant)
146
    {
147
    final float A = 2.0f/3;
148

    
149
    if( variant==0 )
150
      {
151
      float x0  = A*mCorners[ 0][0];
152
      float x2  = A*mCorners[ 2][0];
153
      float x12 = A*mCorners[12][0];
154
      float x16 = A*mCorners[16][0];
155
      float y0  = A*mCorners[ 0][1];
156
      float y2  = A*mCorners[ 2][1];
157
      float y12 = A*mCorners[12][1];
158
      float y16 = A*mCorners[16][1];
159
      float z0  = A*mCorners[ 0][2];
160
      float z2  = A*mCorners[ 2][2];
161
      float z12 = A*mCorners[12][2];
162
      float z16 = A*mCorners[16][2];
163

    
164
      return new float[][]
165
        {
166
            { 0,0,0 },
167
            { (x16-x0)/2, (y16-y0)/2, (z16-z0)/2, },
168
            { (x12-x0)/2, (y12-y0)/2, (z12-z0)/2, },
169
            { (x2 -x0)/2, (y2 -y0)/2, (z2 -z0)/2, },
170
            { 0,-1,-2*C2 },
171
        };
172
      }
173
    else
174
      {
175
      int i0 = mCenterMap[0][0];
176
      int i1 = mCenterMap[0][1];
177
      int i2 = mCenterMap[0][2];
178
      int i3 = mCenterMap[0][3];
179
      int i4 = mCenterMap[0][4];
180

    
181
      float x0 = A*mCorners[i0][0];
182
      float x1 = A*mCorners[i1][0];
183
      float x2 = A*mCorners[i2][0];
184
      float x3 = A*mCorners[i3][0];
185
      float x4 = A*mCorners[i4][0];
186

    
187
      float y0 = A*mCorners[i0][1];
188
      float y1 = A*mCorners[i1][1];
189
      float y2 = A*mCorners[i2][1];
190
      float y3 = A*mCorners[i3][1];
191
      float y4 = A*mCorners[i4][1];
192

    
193
      float z0 = A*mCorners[i0][2];
194
      float z1 = A*mCorners[i1][2];
195
      float z2 = A*mCorners[i2][2];
196
      float z3 = A*mCorners[i3][2];
197
      float z4 = A*mCorners[i4][2];
198

    
199
      float cx = A*mCenterCoords[0][0];
200
      float cy = A*mCenterCoords[0][1];
201
      float cz = A*mCenterCoords[0][2];
202

    
203
      float X0 = (x0+x1)/2 -cx;
204
      float Y0 = (y0+y1)/2 -cy;
205
      float Z0 = (z0+z1)/2 -cz;
206

    
207
      float X1 = (x1+x2)/2 -cx;
208
      float Y1 = (y1+y2)/2 -cy;
209
      float Z1 = (z1+z2)/2 -cz;
210

    
211
      float X2 = (x2+x3)/2 -cx;
212
      float Y2 = (y2+y3)/2 -cy;
213
      float Z2 = (z2+z3)/2 -cz;
214

    
215
      float X3 = (x3+x4)/2 -cx;
216
      float Y3 = (y3+y4)/2 -cy;
217
      float Z3 = (z3+z4)/2 -cz;
218

    
219
      float X4 = (x4+x0)/2 -cx;
220
      float Y4 = (y4+y0)/2 -cy;
221
      float Z4 = (z4+z0)/2 -cz;
222

    
223
      float X5 = -cx;
224
      float Y5 = -cy;
225
      float Z5 = -cz;
226

    
227
      return new float[][]
228
         {
229
             { X0,Y0,Z0 },
230
             { X1,Y1,Z1 },
231
             { X2,Y2,Z2 },
232
             { X3,Y3,Z3 },
233
             { X4,Y4,Z4 },
234
             { X5,Y5,Z5 }
235
         };
236
      }
237
    }
238

    
239
///////////////////////////////////////////////////////////////////////////////////////////////////
240

    
241
  public ObjectShape getObjectShape(int variant)
242
    {
243
    if( variant==0 ) // corner
244
      {
245
      int[][] indices =
246
        {
247
            {0,1,3},
248
            {0,3,2},
249
            {0,2,1},
250
            {4,3,1},
251
            {4,2,3},
252
            {4,1,2}
253
        };
254

    
255
      return new ObjectShape(getVertices(variant), indices);
256
      }
257
    else
258
      {
259
      int[][] indices =
260
         {
261
             {0,1,2,3,4},
262
             {0,5,1},
263
             {1,5,2},
264
             {2,5,3},
265
             {3,5,4},
266
             {4,5,0}
267
         };
268

    
269
      return new ObjectShape(getVertices(variant), indices);
270
      }
271
    }
272

    
273
///////////////////////////////////////////////////////////////////////////////////////////////////
274

    
275
  public ObjectFaceShape getObjectFaceShape(int variant)
276
    {
277
    int angle = 15;
278
    float R = 0.7f;
279
    float S = 0.5f;
280

    
281
    if( variant==0 )
282
      {
283
      float H = isInIconMode() ? 0.001f : 0.03f;
284
      float[][] bands = { {H,angle,R,S,4,0,0}, {0.001f,angle,R,S,3,0,0} };
285
      int[] indices   = { 0,0,0,1,1,1 };
286
      return new ObjectFaceShape(bands,indices,null);
287
      }
288
    else
289
      {
290
      float H = isInIconMode() ? 0.001f : 0.03f;
291
      float[][] bands = { {H,angle,R,S,6,0,0}, {0.001f,angle,R,S,3,0,0} };
292
      int[] indices   = { 0,1,1,1,1,1 };
293
      return new ObjectFaceShape(bands,indices,null);
294
      }
295
    }
296

    
297
///////////////////////////////////////////////////////////////////////////////////////////////////
298

    
299
  public ObjectVertexEffects getVertexEffects(int variant)
300
    {
301
    if( variant==0 )
302
      {
303
      float A = (2*SQ3/3)*SIN54;
304
      float B = 0.4f;
305
      float[][] corners = { { 0.025f, 0.20f } };
306
      int[] indices     = { 0,0,0,-1,-1,-1 };
307
      float[][] centers = { {0.0f, -(float)Math.sqrt(1-A*A)*B,-A*B} };
308
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
309
      }
310
    else
311
      {
312
      final double ANGLE = 0.825f*Math.PI;
313
      final float cosA  = (float)Math.cos(ANGLE);
314
      final float sinA  = (float)Math.sin(ANGLE);
315
      float TAN54 = SIN54/COS54;
316
      float R  = 1.5f*(TAN54-(1/TAN54));
317
      float[][] corners = { { 0.025f, 0.20f } };
318
      int[] indices     = { 0,0,0,0,0,-1 };
319
      float[][] centers = { { 0.0f,R*cosA,-R*sinA } };
320
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
321
      }
322
    }
323

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

    
326
  public int getNumCubitVariants(int[] numLayers)
327
    {
328
    return 2;
329
    }
330

    
331
///////////////////////////////////////////////////////////////////////////////////////////////////
332

    
333
  public int getCubitVariant(int cubit, int[] numLayers)
334
    {
335
    return cubit<NUM_CORNERS ? 0:1;
336
    }
337

    
338
///////////////////////////////////////////////////////////////////////////////////////////////////
339

    
340
  public float[][] getCuts(int[] numLayers)
341
    {
342
    if( mCuts==null )
343
      {
344
      float[] cut = new float[] { 0 };
345
      mCuts = new float[][] { cut,cut,cut,cut,cut,cut };
346
      }
347

    
348
    return mCuts;
349
    }
350

    
351
///////////////////////////////////////////////////////////////////////////////////////////////////
352

    
353
  public float getStickerRadius()
354
    {
355
    return 0.15f;
356
    }
357

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

    
360
  public float getStickerStroke()
361
    {
362
    return isInIconMode() ? 0.20f : 0.13f;
363
    }
364

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

    
367
  public float[][][] getStickerAngles()
368
    {
369
    return null;
370
    }
371

    
372
///////////////////////////////////////////////////////////////////////////////////////////////////
373
// PUBLIC API
374

    
375
  public String getShortName()
376
    {
377
    return ListObjects.PENT_2.name();
378
    }
379

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

    
382
  public ObjectSignature getSignature()
383
    {
384
    return new ObjectSignature(ObjectConstants.PENT_2);
385
    }
386

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

    
389
  public String getObjectName()
390
    {
391
    return "Pentultimate";
392
    }
393

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

    
396
  public String getInventor()
397
    {
398
    return "Jason Smith";
399
    }
400

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

    
403
  public int getYearOfInvention()
404
    {
405
    return 2008;
406
    }
407

    
408
///////////////////////////////////////////////////////////////////////////////////////////////////
409

    
410
  public float getComplexity()
411
    {
412
    return 3.9f;
413
    }
414

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

    
417
  public String[][] getTutorials()
418
    {
419
    return new String[][]{
420
                          {"gb","raeskk-whbU","Pentultimate classification and solve","SuperAntoniovivaldi"},
421
                          {"gb","QamIeNJBB1M","How to solve a Pentultimate","bmenrigh"},
422
                         };
423
    }
424
}
(40-40/57)