Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyPyraminxDiamond.java @ 074a0284

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 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_OCTAHEDRON;
13
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_SPLIT_EDGE;
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.metadata.Metadata;
21
import org.distorted.objectlib.helpers.ObjectVertexEffects;
22
import org.distorted.objectlib.main.InitAssets;
23
import org.distorted.objectlib.metadata.ListObjects;
24
import org.distorted.objectlib.shape.ShapeOctahedron;
25
import org.distorted.objectlib.touchcontrol.TouchControlOctahedron;
26

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

    
29
public class TwistyPyraminxDiamond extends ShapeOctahedron
30
{
31
  static final Static3D[] ROT_AXIS = new Static3D[]
32
         {
33
         new Static3D(SQ2/2, 0, SQ2/2),
34
         new Static3D(    0, 1,     0),
35
         new Static3D(SQ2/2, 0,-SQ2/2)
36
         };
37

    
38
  private static final float D = 0.3f;  // Size of the small cubit in relation to the face of the octahedron.
39
                                        // Keep below 1/3.
40

    
41
  private int[][] mEdges;
42
  private int[][] mBasicAngle;
43
  private float[][] mCuts;
44
  private float[][] mPositions;
45
  private int[] mQuatIndex;
46

    
47
///////////////////////////////////////////////////////////////////////////////////////////////////
48

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

    
54
///////////////////////////////////////////////////////////////////////////////////////////////////
55

    
56
  @Override
57
  public float[][] returnRotationFactor()
58
    {
59
    float C = 1.5f;
60
    float[] f = new float[] {C,C,C};
61
    return new float[][] { f,f,f };
62
    }
63

    
64
///////////////////////////////////////////////////////////////////////////////////////////////////
65
// single edge; middle layers don't move
66

    
67
  public int[][] getScrambleEdges()
68
    {
69
    if( mEdges==null )
70
      {
71
      mEdges = new int[][]
72
        {
73
          {0,0,1,0,2,0,6,0,7,0,8,0,  9,0,10,0,11,0,15,0,16,0,17,0,  18,0,19,0,20,0,24,0,25,0,26,0}
74
        };
75
      }
76
    return mEdges;
77
    }
78

    
79
///////////////////////////////////////////////////////////////////////////////////////////////////
80

    
81
  public float[][] getCuts(int[] numLayers)
82
    {
83
    if( mCuts==null )
84
      {
85
      float C = 0.5f*SQ2;
86
      float[] cut = { -C,C};
87
      mCuts = new float[][] { cut,cut,cut };
88
      }
89

    
90
    return mCuts;
91
    }
92

    
93
///////////////////////////////////////////////////////////////////////////////////////////////////
94

    
95
  public boolean[][] getLayerRotatable(int[] numLayers)
96
    {
97
    boolean[] tmp = {true,false,true};
98
    return new boolean[][] { tmp,tmp,tmp };
99
    }
100

    
101
///////////////////////////////////////////////////////////////////////////////////////////////////
102

    
103
  public int getTouchControlType()
104
    {
105
    return TC_OCTAHEDRON;
106
    }
107

    
108
///////////////////////////////////////////////////////////////////////////////////////////////////
109

    
110
  public int getTouchControlSplit()
111
    {
112
    return TYPE_SPLIT_EDGE;
113
    }
114

    
115
///////////////////////////////////////////////////////////////////////////////////////////////////
116

    
117
  public int[][][] getEnabled()
118
    {
119
    int[][] e0 = {{1},{2},{0}};
120
    int[][] e1 = {{1},{0},{2}};
121
    return new int[][][] { e0,e0,e0,e0,e1,e1,e1,e1 };
122
    }
123

    
124
///////////////////////////////////////////////////////////////////////////////////////////////////
125

    
126
  public float[] getDist3D(int[] numLayers)
127
    {
128
    return TouchControlOctahedron.D3D;
129
    }
130

    
131
///////////////////////////////////////////////////////////////////////////////////////////////////
132

    
133
  public Static3D[] getFaceAxis()
134
    {
135
    return TouchControlOctahedron.FACE_AXIS;
136
    }
137

    
138
///////////////////////////////////////////////////////////////////////////////////////////////////
139

    
140
  public float[][] getCubitPositions(int[] numLayers)
141
    {
142
    if( mPositions==null )
143
      {
144
      float B0 = 1.5f*SQ2;
145
      float C0 = 1.5f;
146
      float A = 1.03f;  // move the centers 3% out - otherwise they look hidden.
147
      float B1 = 0.5f*SQ2*A;
148
      float C1 = A;
149

    
150
      mPositions = new float[][]
151
         {
152
             {  0, B0,  0 },
153
             {  0,-B0,  0 },
154
             { C0,  0, C0 },
155
             { C0,  0,-C0 },
156
             {-C0,  0, C0 },
157
             {-C0,  0,-C0 },
158

    
159
             {  0, B1, C1 },
160
             {  0, B1,-C1 },
161
             {  0,-B1, C1 },
162
             {  0,-B1,-C1 },
163
             { C1, B1,  0 },
164
             { C1,-B1,  0 },
165
             {-C1, B1,  0 },
166
             {-C1,-B1,  0 },
167
         };
168
      }
169

    
170
    return mPositions;
171
    }
172

    
173
///////////////////////////////////////////////////////////////////////////////////////////////////
174

    
175
  public Static4D getCubitQuats(int cubit, int[] numLayers)
176
    {
177
    if( mQuatIndex==null )
178
      {
179
      mQuatIndex = new int[] { 0,2,9,1,3,7, 0,5,3,11,1,2,4,8 };
180
      }
181

    
182
    return mObjectQuats[mQuatIndex[cubit]];
183
    }
184

    
185
///////////////////////////////////////////////////////////////////////////////////////////////////
186

    
187
  private float[][] getVertices(int variant)
188
    {
189
    if( variant==0 )
190
      {
191
      final float A0 = 1-D;
192
      final float H0 = -SQ2*(1-D);
193
      final float A1 = 0.75f;
194
      final float H1 = -0.75f*SQ2;
195
      final float H2 = -SQ2 + 0.25f*SQ2*D;
196
      final float A2 = 0.0f + 0.75f*D;
197
      final float B2 = 1.0f - 0.25f*D;
198
      final float A3 = 0.25f + 0.5f*D;
199
      final float H3 = (-1.25f + 0.5f*D)*SQ2;
200

    
201
      return new float[][]
202
        {
203
            {  0,  0,  0 }, //0
204

    
205
            {  0, H0, A0 },
206
            { A0, H0,  0 },
207
            {  0, H0,-A0 },
208
            {-A0, H0,  0 }, //4
209

    
210
            {  0, H0,  0 },
211

    
212
            { A1, H1, A1 },
213
            { A1, H1,-A1 },
214
            {-A1, H1,-A1 },
215
            {-A1, H1, A1 }, //9
216

    
217
            { A2, H2, B2 },
218
            { B2, H2,-A2 },
219
            {-A2, H2,-B2 },
220
            {-B2, H2, A2 },
221

    
222
            { B2, H2, A2 }, //14
223
            { A2, H2,-B2 },
224
            {-B2, H2,-A2 },
225
            {-A2, H2, B2 },
226

    
227
            { A3, H3, A3 },
228
            { A3, H3,-A3 }, //19
229
            {-A3, H3,-A3 },
230
            {-A3, H3, A3 }
231
        };
232
      }
233
    else
234
      {
235
      return new float[][]
236
        {
237
            {-1.5f*D, -0.5f*SQ2*D, 0.5f*D},
238
            { 1.5f*D, -0.5f*SQ2*D, 0.5f*D},
239
            { 0.0f  ,       SQ2*D,     -D},
240
            { 0.0f  , -0.5f*SQ2  ,-1.0f  }
241
        };
242
      }
243
    }
244

    
245
///////////////////////////////////////////////////////////////////////////////////////////////////
246

    
247
  public ObjectShape getObjectShape(int variant)
248
    {
249
    if( variant==0 )
250
      {
251
      int[][] indices =
252
          {
253
              {0,9,17,1,10,6},
254
              {0,6,14,2,11,7},
255
              {0,7,15,3,12,8},
256
              {0,8,16,4,13,9},
257
              {6,10,18,14},
258
              {7,11,19,15},
259
              {8,12,20,16},
260
              {9,13,21,17},
261

    
262
              {5,18,10,1},
263
              {5,1,17,21},
264
              {5,21,13,4},
265
              {5,4,16,20},
266
              {5,20,12,3},
267
              {5,3,15,19},
268
              {5,19,11,2},
269
              {5,2,14,18}
270

    
271

    
272
          };
273

    
274
      return new ObjectShape(getVertices(variant), indices);
275
      }
276
    else
277
      {
278
      int[][] indices = { {0,1,2},{3,1,0},{3,2,1},{3,0,2} };
279
      return new ObjectShape(getVertices(variant), indices);
280
      }
281
    }
282

    
283
///////////////////////////////////////////////////////////////////////////////////////////////////
284

    
285
  public ObjectFaceShape getObjectFaceShape(int variant)
286
    {
287
    int angle = 20;
288
    float R = 0.7f;
289
    float S = 0.5f;
290

    
291
    if( variant==0 )
292
      {
293
      float height = isInIconMode() ? 0.001f : 0.03f;
294
      float[][] bands = { {height,angle,R,S,5,1,0},{0.001f,angle,R,S,5,0,0} };
295
      int[] indices = { 0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1 };
296
      return new ObjectFaceShape(bands,indices,null);
297
      }
298
    else
299
      {
300
      float height = isInIconMode() ? 0.001f : 0.03f;
301
      float[][] bands = { {height,angle,R,S,5,1,0},{0.001f,angle,R,S,5,0,0} };
302
      int[] indices   = { 0,1,1,1 };
303
      return new ObjectFaceShape(bands,indices,null);
304
      }
305
    }
306

    
307
///////////////////////////////////////////////////////////////////////////////////////////////////
308

    
309
  public ObjectVertexEffects getVertexEffects(int variant)
310
    {
311
    if( variant==0 )
312
      {
313
      float[][] corners  = { {0.03f,0.20f},{0.03f,0.15f} };
314
      int[] cornerIndices= { 0,-1,-1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 };
315
      float[][] centers = { {0.0f,-1.5f*SQ2,0.0f} };
316
      int[] centerIndices= { 0,-1,-1,-1,-1,-1,0,0,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 };
317
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
318
      }
319
    else
320
      {
321
      float[][] corners = { {0.02f,0.10f} };
322
      int[] indices     = { 0,0,0,-1 };
323
      float[][] centers = { {0,-SQ2/2,-1.0f} };
324
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
325
      }
326
    }
327

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

    
330
  public int getNumCubitVariants(int[] numLayers)
331
    {
332
    return 2;
333
    }
334

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

    
337
  public int getCubitVariant(int cubit, int[] numLayers)
338
    {
339
    return cubit<6 ? 0:1;
340
    }
341

    
342
///////////////////////////////////////////////////////////////////////////////////////////////////
343

    
344
  public float getStickerRadius()
345
    {
346
    return 0.12f;
347
    }
348

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

    
351
  public float getStickerStroke()
352
    {
353
    return isInIconMode() ? 0.20f : 0.10f;
354
    }
355

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

    
358
  public float[][][] getStickerAngles()
359
    {
360
    return null;
361
    }
362

    
363
///////////////////////////////////////////////////////////////////////////////////////////////////
364
// PUBLIC API
365

    
366
  public Static3D[] getRotationAxis()
367
    {
368
    return ROT_AXIS;
369
    }
370

    
371
///////////////////////////////////////////////////////////////////////////////////////////////////
372

    
373
  public int[][] getBasicAngles()
374
    {
375
    if( mBasicAngle ==null )
376
      {
377
      int[] tmp = {4,4,4};
378
      mBasicAngle = new int[][] { tmp,tmp,tmp };
379
      }
380

    
381
    return mBasicAngle;
382
    }
383

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

    
386
  public String getShortName()
387
    {
388
    return ListObjects.PDIA_3.name();
389
    }
390

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

    
393
  public String[][] getTutorials()
394
    {
395
    return new String[][] {
396
                           {"gb","s5TdrKGH-DE","Solve the Pyraminx Diamond","TDRP Cubing"},
397
                           {"es","006L2qc1XoA","el Pyraminx Diamond","Spartan626"},
398
                           {"pl","AVRRHVgIeh4","Pyraminx Diamond TUTORIAL PL","MrUK"},
399
                           {"br","6SWwZUAK4U0","Pyraminx Diamond Solve","Cubo vicio"},
400
                           {"tw","76M-RMl70w0","Pyraminx Diamond","不正常魔術方塊研究中心"},
401
                          };
402
    }
403
}
(44-44/59)