Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyPentultimate.java @ 3a0990b1

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.helpers.ObjectVertexEffects;
19
import org.distorted.objectlib.main.InitAssets;
20
import org.distorted.objectlib.metadata.ListObjects;
21
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator;
22

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

    
28
///////////////////////////////////////////////////////////////////////////////////////////////////
29

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

    
36
///////////////////////////////////////////////////////////////////////////////////////////////////
37

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

    
43
///////////////////////////////////////////////////////////////////////////////////////////////////
44

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

    
53
    return mEdges;
54
    }
55

    
56
///////////////////////////////////////////////////////////////////////////////////////////////////
57

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

    
64
///////////////////////////////////////////////////////////////////////////////////////////////////
65

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

    
73
///////////////////////////////////////////////////////////////////////////////////////////////////
74

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

    
95
///////////////////////////////////////////////////////////////////////////////////////////////////
96

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

    
104
      mPosition = new float[NUM_CORNERS+NUM_CENTERS][3];
105

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

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

    
122
    return mPosition;
123
    }
124

    
125
///////////////////////////////////////////////////////////////////////////////////////////////////
126

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

    
138
    return mObjectQuats[mQuatIndex[cubit]];
139
    }
140

    
141
///////////////////////////////////////////////////////////////////////////////////////////////////
142

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

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

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

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

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

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

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

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

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

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

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

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

    
221
      float X5 = -cx;
222
      float Y5 = -cy;
223
      float Z5 = -cz;
224

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

    
237
///////////////////////////////////////////////////////////////////////////////////////////////////
238

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

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

    
267
      return new ObjectShape(getVertices(variant), indices);
268
      }
269
    }
270

    
271
///////////////////////////////////////////////////////////////////////////////////////////////////
272

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

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

    
295
///////////////////////////////////////////////////////////////////////////////////////////////////
296

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

    
322
///////////////////////////////////////////////////////////////////////////////////////////////////
323

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

    
329
///////////////////////////////////////////////////////////////////////////////////////////////////
330

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

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

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

    
346
    return mCuts;
347
    }
348

    
349
///////////////////////////////////////////////////////////////////////////////////////////////////
350

    
351
  public float getStickerRadius()
352
    {
353
    return 0.15f;
354
    }
355

    
356
///////////////////////////////////////////////////////////////////////////////////////////////////
357

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

    
363
///////////////////////////////////////////////////////////////////////////////////////////////////
364

    
365
  public float[][][] getStickerAngles()
366
    {
367
    return null;
368
    }
369

    
370
///////////////////////////////////////////////////////////////////////////////////////////////////
371
// PUBLIC API
372

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

    
378
///////////////////////////////////////////////////////////////////////////////////////////////////
379

    
380
  public String[][] getTutorials()
381
    {
382
    return new String[][]{
383
                          {"gb","raeskk-whbU","Pentultimate classification and solve","SuperAntoniovivaldi"},
384
                          {"gb","QamIeNJBB1M","How to solve a Pentultimate","bmenrigh"},
385
                         };
386
    }
387
}
(42-42/59)