Project

General

Profile

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

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

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.helpers.ObjectSignature;
21
import org.distorted.objectlib.helpers.ObjectVertexEffects;
22
import org.distorted.objectlib.main.InitAssets;
23
import org.distorted.objectlib.main.InitData;
24
import org.distorted.objectlib.main.ObjectSignatures;
25
import org.distorted.objectlib.main.ObjectType;
26
import org.distorted.objectlib.shape.ShapeOctahedron;
27
import org.distorted.objectlib.touchcontrol.TouchControlOctahedron;
28

    
29
///////////////////////////////////////////////////////////////////////////////////////////////////
30

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

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

    
43
  private int[][] mEdges;
44
  private int[][] mBasicAngle;
45
  private float[][] mCuts;
46
  private float[][] mPositions;
47
  private int[] mQuatIndex;
48

    
49
///////////////////////////////////////////////////////////////////////////////////////////////////
50

    
51
  public TwistyPyraminxDiamond(int meshState, int iconMode, Static4D quat, Static3D move, float scale, InitData data, InitAssets asset)
52
    {
53
    super(meshState, iconMode, data.getNumLayers()[0], quat, move, scale, data, asset);
54
    }
55

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

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

    
66
///////////////////////////////////////////////////////////////////////////////////////////////////
67
// single edge; middle layers don't move
68

    
69
  public int[][] getScrambleEdges()
70
    {
71
    if( mEdges==null )
72
      {
73
      mEdges = new int[][]
74
        {
75
          {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}
76
        };
77
      }
78
    return mEdges;
79
    }
80

    
81
///////////////////////////////////////////////////////////////////////////////////////////////////
82

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

    
92
    return mCuts;
93
    }
94

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

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

    
103
///////////////////////////////////////////////////////////////////////////////////////////////////
104

    
105
  public int getTouchControlType()
106
    {
107
    return TC_OCTAHEDRON;
108
    }
109

    
110
///////////////////////////////////////////////////////////////////////////////////////////////////
111

    
112
  public int getTouchControlSplit()
113
    {
114
    return TYPE_SPLIT_EDGE;
115
    }
116

    
117
///////////////////////////////////////////////////////////////////////////////////////////////////
118

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

    
126
///////////////////////////////////////////////////////////////////////////////////////////////////
127

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

    
133
///////////////////////////////////////////////////////////////////////////////////////////////////
134

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

    
140
///////////////////////////////////////////////////////////////////////////////////////////////////
141

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

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

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

    
172
    return mPositions;
173
    }
174

    
175
///////////////////////////////////////////////////////////////////////////////////////////////////
176

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

    
184
    return mObjectQuats[mQuatIndex[cubit]];
185
    }
186

    
187
///////////////////////////////////////////////////////////////////////////////////////////////////
188

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

    
203
      return new float[][]
204
        {
205
            {  0,  0,  0 }, //0
206

    
207
            {  0, H0, A0 },
208
            { A0, H0,  0 },
209
            {  0, H0,-A0 },
210
            {-A0, H0,  0 }, //4
211

    
212
            {  0, H0,  0 },
213

    
214
            { A1, H1, A1 },
215
            { A1, H1,-A1 },
216
            {-A1, H1,-A1 },
217
            {-A1, H1, A1 }, //9
218

    
219
            { A2, H2, B2 },
220
            { B2, H2,-A2 },
221
            {-A2, H2,-B2 },
222
            {-B2, H2, A2 },
223

    
224
            { B2, H2, A2 }, //14
225
            { A2, H2,-B2 },
226
            {-B2, H2,-A2 },
227
            {-A2, H2, B2 },
228

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

    
247
///////////////////////////////////////////////////////////////////////////////////////////////////
248

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

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

    
273

    
274
          };
275

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

    
285
///////////////////////////////////////////////////////////////////////////////////////////////////
286

    
287
  public ObjectFaceShape getObjectFaceShape(int variant)
288
    {
289
    if( variant==0 )
290
      {
291
      float height = isInIconMode() ? 0.001f : 0.03f;
292
      float[][] bands = { {height,35,0.2f,0.5f,5,1,0},{0.001f,35,0.2f,0.5f,5,0,0} };
293
      int[] indices = { 0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1 };
294
      return new ObjectFaceShape(bands,indices,null);
295
      }
296
    else
297
      {
298
      float height = isInIconMode() ? 0.001f : 0.03f;
299
      float[][] bands = { {height,35,0.15f,0.3f,5,1,0},{0.001f,35,0.15f,0.3f,5,0,0} };
300
      int[] indices   = { 0,1,1,1 };
301
      return new ObjectFaceShape(bands,indices,null);
302
      }
303
    }
304

    
305
///////////////////////////////////////////////////////////////////////////////////////////////////
306

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

    
326
///////////////////////////////////////////////////////////////////////////////////////////////////
327

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

    
333
///////////////////////////////////////////////////////////////////////////////////////////////////
334

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

    
340
///////////////////////////////////////////////////////////////////////////////////////////////////
341

    
342
  public float getStickerRadius()
343
    {
344
    return 0.12f;
345
    }
346

    
347
///////////////////////////////////////////////////////////////////////////////////////////////////
348

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

    
354
///////////////////////////////////////////////////////////////////////////////////////////////////
355

    
356
  public float[][] getStickerAngles()
357
    {
358
    return null;
359
    }
360

    
361
///////////////////////////////////////////////////////////////////////////////////////////////////
362
// PUBLIC API
363

    
364
  public Static3D[] getRotationAxis()
365
    {
366
    return ROT_AXIS;
367
    }
368

    
369
///////////////////////////////////////////////////////////////////////////////////////////////////
370

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

    
379
    return mBasicAngle;
380
    }
381

    
382
///////////////////////////////////////////////////////////////////////////////////////////////////
383

    
384
  public String getShortName()
385
    {
386
    return ObjectType.PDIA_3.name();
387
    }
388

    
389
///////////////////////////////////////////////////////////////////////////////////////////////////
390

    
391
  public ObjectSignature getSignature()
392
    {
393
    return new ObjectSignature(ObjectSignatures.PDIA_3);
394
    }
395

    
396
///////////////////////////////////////////////////////////////////////////////////////////////////
397

    
398
  public String getObjectName()
399
    {
400
    return "Pyraminx Diamond";
401
    }
402

    
403
///////////////////////////////////////////////////////////////////////////////////////////////////
404

    
405
  public String getInventor()
406
    {
407
    return "Oskar van Deventer";
408
    }
409

    
410
///////////////////////////////////////////////////////////////////////////////////////////////////
411

    
412
  public int getYearOfInvention()
413
    {
414
    return 2014;
415
    }
416

    
417
///////////////////////////////////////////////////////////////////////////////////////////////////
418

    
419
  public int getComplexity()
420
    {
421
    return 1;
422
    }
423

    
424
///////////////////////////////////////////////////////////////////////////////////////////////////
425

    
426
  public String[][] getTutorials()
427
    {
428
    return new String[][] {
429
                           {"gb","s5TdrKGH-DE","Solve the Pyraminx Diamond","TDRP Cubing"},
430
                           {"es","006L2qc1XoA","el Pyraminx Diamond","Spartan626"},
431
                           {"pl","AVRRHVgIeh4","Pyraminx Diamond TUTORIAL PL","MrUK"},
432
                           {"br","6SWwZUAK4U0","Pyraminx Diamond Solve","Cubo vicio"},
433
                          };
434
    }
435
}
(33-33/47)