Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyPentultimate.java @ 08a8ebc7

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.helpers.ObjectSignature;
18
import org.distorted.objectlib.helpers.ObjectVertexEffects;
19
import org.distorted.objectlib.main.InitData;
20
import org.distorted.objectlib.main.ObjectSignatures;
21
import org.distorted.objectlib.main.ObjectType;
22
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator;
23

    
24
import java.io.InputStream;
25

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

    
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32

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

    
39
///////////////////////////////////////////////////////////////////////////////////////////////////
40

    
41
  public TwistyPentultimate(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
42
    {
43
    super(data, meshState, iconMode, quat, move, scale, stream);
44
    }
45

    
46
///////////////////////////////////////////////////////////////////////////////////////////////////
47

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

    
56
    return mEdges;
57
    }
58

    
59
///////////////////////////////////////////////////////////////////////////////////////////////////
60

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

    
67
///////////////////////////////////////////////////////////////////////////////////////////////////
68

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

    
76
///////////////////////////////////////////////////////////////////////////////////////////////////
77

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

    
98
///////////////////////////////////////////////////////////////////////////////////////////////////
99

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

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

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

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

    
125
    return mPosition;
126
    }
127

    
128
///////////////////////////////////////////////////////////////////////////////////////////////////
129

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

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

    
144
///////////////////////////////////////////////////////////////////////////////////////////////////
145

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
240
///////////////////////////////////////////////////////////////////////////////////////////////////
241

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

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

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

    
274
///////////////////////////////////////////////////////////////////////////////////////////////////
275

    
276
  public ObjectFaceShape getObjectFaceShape(int variant)
277
    {
278
    if( variant==0 )
279
      {
280
      float H = isInIconMode() ? 0.001f : 0.03f;
281
      float[][] bands = { {H,10,0.5f,0.2f,4,0,0}, {0.001f, 1,0.5f,0.2f,3,0,0} };
282
      int[] indices   = { 0,0,0,1,1,1 };
283
      return new ObjectFaceShape(bands,indices,null);
284
      }
285
    else
286
      {
287
      float H = isInIconMode() ? 0.001f : 0.03f;
288
      float[][] bands = { {H,15,0.5f,0.2f,6,0,0}, {0.001f, 1,0.5f,0.2f,3,0,0} };
289
      int[] indices   = { 0,1,1,1,1,1 };
290
      return new ObjectFaceShape(bands,indices,null);
291
      }
292
    }
293

    
294
///////////////////////////////////////////////////////////////////////////////////////////////////
295

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

    
321
///////////////////////////////////////////////////////////////////////////////////////////////////
322

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

    
328
///////////////////////////////////////////////////////////////////////////////////////////////////
329

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

    
335
///////////////////////////////////////////////////////////////////////////////////////////////////
336

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

    
345
    return mCuts;
346
    }
347

    
348
///////////////////////////////////////////////////////////////////////////////////////////////////
349

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

    
355
///////////////////////////////////////////////////////////////////////////////////////////////////
356

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

    
362
///////////////////////////////////////////////////////////////////////////////////////////////////
363

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

    
369
///////////////////////////////////////////////////////////////////////////////////////////////////
370
// PUBLIC API
371

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

    
377
///////////////////////////////////////////////////////////////////////////////////////////////////
378

    
379
  public ObjectSignature getSignature()
380
    {
381
    return new ObjectSignature(ObjectSignatures.PENT_2);
382
    }
383

    
384
///////////////////////////////////////////////////////////////////////////////////////////////////
385

    
386
  public String getObjectName()
387
    {
388
    return "Pentultimate";
389
    }
390

    
391
///////////////////////////////////////////////////////////////////////////////////////////////////
392

    
393
  public String getInventor()
394
    {
395
    return "Jason Smith";
396
    }
397

    
398
///////////////////////////////////////////////////////////////////////////////////////////////////
399

    
400
  public int getYearOfInvention()
401
    {
402
    return 2008;
403
    }
404

    
405
///////////////////////////////////////////////////////////////////////////////////////////////////
406

    
407
  public int getComplexity()
408
    {
409
    return 3;
410
    }
411

    
412
///////////////////////////////////////////////////////////////////////////////////////////////////
413

    
414
  public String[][] getTutorials()
415
    {
416
    return new String[][]{
417
                          {"gb","raeskk-whbU","Pentultimate classification and solve","SuperAntoniovivaldi"},
418
                          {"gb","QamIeNJBB1M","How to solve a Pentultimate","bmenrigh"},
419
                         };
420
    }
421
}
(27-27/41)