Project

General

Profile

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

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

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.ObjectType;
21
import org.distorted.objectlib.scrambling.ScrambleState;
22

    
23
import java.io.InputStream;
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 TwistyMinx
33
{
34
  private float[][] mCuts;
35
  private float[][] mPosition;
36
  private int[] mQuatIndex;
37

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

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

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

    
47
  @Override
48
  public ScrambleState[] getScrambleStates()
49
    {
50
    if( mStates==null )
51
      {
52
      int[] ALL = new int[] { 0,-2,0, 0,-1,0, 0,1,0, 0,2,0, 1,-2,0, 1,-1,0, 1,1,0, 1,2,0 };
53

    
54
      mStates = new ScrambleState[]
55
        {
56
        new ScrambleState( new int[][] { ALL,ALL,ALL,ALL,ALL,ALL } )
57
        };
58
      }
59

    
60
    return mStates;
61
    }
62

    
63
///////////////////////////////////////////////////////////////////////////////////////////////////
64

    
65
  @Override
66
  public int getTouchControlSplit()
67
    {
68
    return TYPE_NOT_SPLIT;
69
    }
70

    
71
///////////////////////////////////////////////////////////////////////////////////////////////////
72

    
73
  @Override
74
  public boolean[][] getLayerRotatable(int[] numLayers)
75
    {
76
    boolean[] tmp = new boolean[] {true,true};
77
    return new boolean[][] {tmp,tmp,tmp,tmp,tmp,tmp};
78
    }
79

    
80
///////////////////////////////////////////////////////////////////////////////////////////////////
81

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

    
102
///////////////////////////////////////////////////////////////////////////////////////////////////
103

    
104
  public float[][] getCubitPositions(int[] numLayers)
105
    {
106
    if( mPosition==null )
107
      {
108
      if( mCenterCoords==null ) initializeCenterCoords();
109
      final float A = 2.0f/3;
110

    
111
      mPosition = new float[NUM_CORNERS+NUM_CENTERS][3];
112

    
113
      for(int corner=0; corner<NUM_CORNERS; corner++)
114
        {
115
        mPosition[corner][0] = A*mCorners[corner][0];
116
        mPosition[corner][1] = A*mCorners[corner][1];
117
        mPosition[corner][2] = A*mCorners[corner][2];
118
        }
119

    
120
      for(int center=0; center<NUM_CENTERS; center++)
121
        {
122
        int index = center+NUM_CORNERS;
123
        mPosition[index][0] = A*mCenterCoords[center][0];
124
        mPosition[index][1] = A*mCenterCoords[center][1];
125
        mPosition[index][2] = A*mCenterCoords[center][2];
126
        }
127
      }
128

    
129
    return mPosition;
130
    }
131

    
132
///////////////////////////////////////////////////////////////////////////////////////////////////
133

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

    
145
    return mObjectQuats[mQuatIndex[cubit]];
146
    }
147

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

    
150
  private float[][] getVertices(int variant)
151
    {
152
    final float A = 2.0f/3;
153

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

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

    
186
      float x0 = A*mCorners[i0][0];
187
      float x1 = A*mCorners[i1][0];
188
      float x2 = A*mCorners[i2][0];
189
      float x3 = A*mCorners[i3][0];
190
      float x4 = A*mCorners[i4][0];
191

    
192
      float y0 = A*mCorners[i0][1];
193
      float y1 = A*mCorners[i1][1];
194
      float y2 = A*mCorners[i2][1];
195
      float y3 = A*mCorners[i3][1];
196
      float y4 = A*mCorners[i4][1];
197

    
198
      float z0 = A*mCorners[i0][2];
199
      float z1 = A*mCorners[i1][2];
200
      float z2 = A*mCorners[i2][2];
201
      float z3 = A*mCorners[i3][2];
202
      float z4 = A*mCorners[i4][2];
203

    
204
      float cx = A*mCenterCoords[0][0];
205
      float cy = A*mCenterCoords[0][1];
206
      float cz = A*mCenterCoords[0][2];
207

    
208
      float X0 = (x0+x1)/2 -cx;
209
      float Y0 = (y0+y1)/2 -cy;
210
      float Z0 = (z0+z1)/2 -cz;
211

    
212
      float X1 = (x1+x2)/2 -cx;
213
      float Y1 = (y1+y2)/2 -cy;
214
      float Z1 = (z1+z2)/2 -cz;
215

    
216
      float X2 = (x2+x3)/2 -cx;
217
      float Y2 = (y2+y3)/2 -cy;
218
      float Z2 = (z2+z3)/2 -cz;
219

    
220
      float X3 = (x3+x4)/2 -cx;
221
      float Y3 = (y3+y4)/2 -cy;
222
      float Z3 = (z3+z4)/2 -cz;
223

    
224
      float X4 = (x4+x0)/2 -cx;
225
      float Y4 = (y4+y0)/2 -cy;
226
      float Z4 = (z4+z0)/2 -cz;
227

    
228
      float X5 = -cx;
229
      float Y5 = -cy;
230
      float Z5 = -cz;
231

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

    
244
///////////////////////////////////////////////////////////////////////////////////////////////////
245

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

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

    
274
      return new ObjectShape(getVertices(variant), indices);
275
      }
276
    }
277

    
278
///////////////////////////////////////////////////////////////////////////////////////////////////
279

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

    
298
///////////////////////////////////////////////////////////////////////////////////////////////////
299

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

    
325
///////////////////////////////////////////////////////////////////////////////////////////////////
326

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

    
332
///////////////////////////////////////////////////////////////////////////////////////////////////
333

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

    
339
///////////////////////////////////////////////////////////////////////////////////////////////////
340

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

    
349
    return mCuts;
350
    }
351

    
352
///////////////////////////////////////////////////////////////////////////////////////////////////
353

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

    
359
///////////////////////////////////////////////////////////////////////////////////////////////////
360

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

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

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

    
373
///////////////////////////////////////////////////////////////////////////////////////////////////
374
// PUBLIC API
375

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

    
381
///////////////////////////////////////////////////////////////////////////////////////////////////
382

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

    
388
///////////////////////////////////////////////////////////////////////////////////////////////////
389

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

    
395
///////////////////////////////////////////////////////////////////////////////////////////////////
396

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

    
402
///////////////////////////////////////////////////////////////////////////////////////////////////
403

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

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

    
411
  public int getComplexity()
412
    {
413
    return 3;
414
    }
415

    
416
///////////////////////////////////////////////////////////////////////////////////////////////////
417

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