Project

General

Profile

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

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

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
// single edge; middle layers don't move
58

    
59
  public int[][] getScrambleEdges()
60
    {
61
    if( mEdges==null )
62
      {
63
      mEdges = new int[][]
64
        {
65
          {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}
66
        };
67
      }
68
    return mEdges;
69
    }
70

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

    
73
  public float[][] getCuts(int[] numLayers)
74
    {
75
    if( mCuts==null )
76
      {
77
      float C = 0.5f*SQ2;
78
      float[] cut = { -C,C};
79
      mCuts = new float[][] { cut,cut,cut };
80
      }
81

    
82
    return mCuts;
83
    }
84

    
85
///////////////////////////////////////////////////////////////////////////////////////////////////
86

    
87
  public boolean[][] getLayerRotatable(int[] numLayers)
88
    {
89
    boolean[] tmp = {true,false,true};
90
    return new boolean[][] { tmp,tmp,tmp };
91
    }
92

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

    
95
  public int getTouchControlType()
96
    {
97
    return TC_OCTAHEDRON;
98
    }
99

    
100
///////////////////////////////////////////////////////////////////////////////////////////////////
101

    
102
  public int getTouchControlSplit()
103
    {
104
    return TYPE_SPLIT_EDGE;
105
    }
106

    
107
///////////////////////////////////////////////////////////////////////////////////////////////////
108

    
109
  public int[][][] getEnabled()
110
    {
111
    int[][] e0 = {{1},{2},{0}};
112
    int[][] e1 = {{1},{0},{2}};
113
    return new int[][][] { e0,e0,e0,e0,e1,e1,e1,e1 };
114
    }
115

    
116
///////////////////////////////////////////////////////////////////////////////////////////////////
117

    
118
  public float[] getDist3D(int[] numLayers)
119
    {
120
    return TouchControlOctahedron.D3D;
121
    }
122

    
123
///////////////////////////////////////////////////////////////////////////////////////////////////
124

    
125
  public Static3D[] getFaceAxis()
126
    {
127
    return TouchControlOctahedron.FACE_AXIS;
128
    }
129

    
130
///////////////////////////////////////////////////////////////////////////////////////////////////
131

    
132
  public float[][] getCubitPositions(int[] numLayers)
133
    {
134
    if( mPositions==null )
135
      {
136
      float B0 = 1.5f*SQ2;
137
      float C0 = 1.5f;
138
      float A = 1.03f;  // move the centers 3% out - otherwise they look hidden.
139
      float B1 = 0.5f*SQ2*A;
140
      float C1 = A;
141

    
142
      mPositions = new float[][]
143
         {
144
             {  0, B0,  0 },
145
             {  0,-B0,  0 },
146
             { C0,  0, C0 },
147
             { C0,  0,-C0 },
148
             {-C0,  0, C0 },
149
             {-C0,  0,-C0 },
150

    
151
             {  0, B1, C1 },
152
             {  0, B1,-C1 },
153
             {  0,-B1, C1 },
154
             {  0,-B1,-C1 },
155
             { C1, B1,  0 },
156
             { C1,-B1,  0 },
157
             {-C1, B1,  0 },
158
             {-C1,-B1,  0 },
159
         };
160
      }
161

    
162
    return mPositions;
163
    }
164

    
165
///////////////////////////////////////////////////////////////////////////////////////////////////
166

    
167
  public Static4D getCubitQuats(int cubit, int[] numLayers)
168
    {
169
    if( mQuatIndex==null )
170
      {
171
      mQuatIndex = new int[] { 0,2,9,1,3,7, 0,5,3,11,1,2,4,8 };
172
      }
173

    
174
    return mObjectQuats[mQuatIndex[cubit]];
175
    }
176

    
177
///////////////////////////////////////////////////////////////////////////////////////////////////
178

    
179
  private float[][] getVertices(int variant)
180
    {
181
    if( variant==0 )
182
      {
183
      final float A0 = 1-D;
184
      final float H0 = -SQ2*(1-D);
185
      final float A1 = 0.75f;
186
      final float H1 = -0.75f*SQ2;
187
      final float H2 = -SQ2 + 0.25f*SQ2*D;
188
      final float A2 = 0.0f + 0.75f*D;
189
      final float B2 = 1.0f - 0.25f*D;
190
      final float A3 = 0.25f + 0.5f*D;
191
      final float H3 = (-1.25f + 0.5f*D)*SQ2;
192

    
193
      return new float[][]
194
        {
195
            {  0,  0,  0 }, //0
196

    
197
            {  0, H0, A0 },
198
            { A0, H0,  0 },
199
            {  0, H0,-A0 },
200
            {-A0, H0,  0 }, //4
201

    
202
            {  0, H0,  0 },
203

    
204
            { A1, H1, A1 },
205
            { A1, H1,-A1 },
206
            {-A1, H1,-A1 },
207
            {-A1, H1, A1 }, //9
208

    
209
            { A2, H2, B2 },
210
            { B2, H2,-A2 },
211
            {-A2, H2,-B2 },
212
            {-B2, H2, A2 },
213

    
214
            { B2, H2, A2 }, //14
215
            { A2, H2,-B2 },
216
            {-B2, H2,-A2 },
217
            {-A2, H2, B2 },
218

    
219
            { A3, H3, A3 },
220
            { A3, H3,-A3 }, //19
221
            {-A3, H3,-A3 },
222
            {-A3, H3, A3 }
223
        };
224
      }
225
    else
226
      {
227
      return new float[][]
228
        {
229
            {-1.5f*D, -0.5f*SQ2*D, 0.5f*D},
230
            { 1.5f*D, -0.5f*SQ2*D, 0.5f*D},
231
            { 0.0f  ,       SQ2*D,     -D},
232
            { 0.0f  , -0.5f*SQ2  ,-1.0f  }
233
        };
234
      }
235
    }
236

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

    
239
  public ObjectShape getObjectShape(int variant)
240
    {
241
    if( variant==0 )
242
      {
243
      int[][] indices =
244
          {
245
              {0,9,17,1,10,6},
246
              {0,6,14,2,11,7},
247
              {0,7,15,3,12,8},
248
              {0,8,16,4,13,9},
249
              {6,10,18,14},
250
              {7,11,19,15},
251
              {8,12,20,16},
252
              {9,13,21,17},
253

    
254
              {5,18,10,1},
255
              {5,1,17,21},
256
              {5,21,13,4},
257
              {5,4,16,20},
258
              {5,20,12,3},
259
              {5,3,15,19},
260
              {5,19,11,2},
261
              {5,2,14,18}
262

    
263

    
264
          };
265

    
266
      return new ObjectShape(getVertices(variant), indices);
267
      }
268
    else
269
      {
270
      int[][] indices = { {0,1,2},{3,1,0},{3,2,1},{3,0,2} };
271
      return new ObjectShape(getVertices(variant), indices);
272
      }
273
    }
274

    
275
///////////////////////////////////////////////////////////////////////////////////////////////////
276

    
277
  public ObjectFaceShape getObjectFaceShape(int variant)
278
    {
279
    if( variant==0 )
280
      {
281
      float height = isInIconMode() ? 0.001f : 0.03f;
282
      float[][] bands = { {height,35,0.2f,0.5f,5,1,0},{0.001f,35,0.2f,0.5f,5,0,0} };
283
      int[] indices = { 0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1 };
284
      return new ObjectFaceShape(bands,indices,null);
285
      }
286
    else
287
      {
288
      float height = isInIconMode() ? 0.001f : 0.03f;
289
      float[][] bands = { {height,35,0.15f,0.3f,5,1,0},{0.001f,35,0.15f,0.3f,5,0,0} };
290
      int[] indices   = { 0,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[][] corners  = { {0.03f,0.20f},{0.03f,0.15f} };
302
      int[] cornerIndices= { 0,-1,-1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 };
303
      float[][] centers = { {0.0f,-1.5f*SQ2,0.0f} };
304
      int[] centerIndices= { 0,-1,-1,-1,-1,-1,0,0,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 };
305
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
306
      }
307
    else
308
      {
309
      float[][] corners = { {0.02f,0.10f} };
310
      int[] indices     = { 0,0,0,-1 };
311
      float[][] centers = { {0,-SQ2/2,-1.0f} };
312
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
313
      }
314
    }
315

    
316
///////////////////////////////////////////////////////////////////////////////////////////////////
317

    
318
  public int getNumCubitVariants(int[] numLayers)
319
    {
320
    return 2;
321
    }
322

    
323
///////////////////////////////////////////////////////////////////////////////////////////////////
324

    
325
  public int getCubitVariant(int cubit, int[] numLayers)
326
    {
327
    return cubit<6 ? 0:1;
328
    }
329

    
330
///////////////////////////////////////////////////////////////////////////////////////////////////
331

    
332
  public float getStickerRadius()
333
    {
334
    return 0.12f;
335
    }
336

    
337
///////////////////////////////////////////////////////////////////////////////////////////////////
338

    
339
  public float getStickerStroke()
340
    {
341
    return isInIconMode() ? 0.20f : 0.10f;
342
    }
343

    
344
///////////////////////////////////////////////////////////////////////////////////////////////////
345

    
346
  public float[][] getStickerAngles()
347
    {
348
    return null;
349
    }
350

    
351
///////////////////////////////////////////////////////////////////////////////////////////////////
352
// PUBLIC API
353

    
354
  public Static3D[] getRotationAxis()
355
    {
356
    return ROT_AXIS;
357
    }
358

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

    
361
  public int[][] getBasicAngles()
362
    {
363
    if( mBasicAngle ==null )
364
      {
365
      int[] tmp = {4,4,4};
366
      mBasicAngle = new int[][] { tmp,tmp,tmp };
367
      }
368

    
369
    return mBasicAngle;
370
    }
371

    
372
///////////////////////////////////////////////////////////////////////////////////////////////////
373

    
374
  public String getShortName()
375
    {
376
    return ObjectType.PDIA_3.name();
377
    }
378

    
379
///////////////////////////////////////////////////////////////////////////////////////////////////
380

    
381
  public ObjectSignature getSignature()
382
    {
383
    return new ObjectSignature(ObjectSignatures.PDIA_3);
384
    }
385

    
386
///////////////////////////////////////////////////////////////////////////////////////////////////
387

    
388
  public String getObjectName()
389
    {
390
    return "Pyraminx Diamond";
391
    }
392

    
393
///////////////////////////////////////////////////////////////////////////////////////////////////
394

    
395
  public String getInventor()
396
    {
397
    return "Oskar van Deventer";
398
    }
399

    
400
///////////////////////////////////////////////////////////////////////////////////////////////////
401

    
402
  public int getYearOfInvention()
403
    {
404
    return 2014;
405
    }
406

    
407
///////////////////////////////////////////////////////////////////////////////////////////////////
408

    
409
  public int getComplexity()
410
    {
411
    return 1;
412
    }
413

    
414
///////////////////////////////////////////////////////////////////////////////////////////////////
415

    
416
  public String[][] getTutorials()
417
    {
418
    return new String[][] {
419
                           {"gb","s5TdrKGH-DE","Solve the Pyraminx Diamond","TDRP Cubing"},
420
                           {"es","006L2qc1XoA","el Pyraminx Diamond","Spartan626"},
421
                           {"pl","AVRRHVgIeh4","Pyraminx Diamond TUTORIAL PL","MrUK"},
422
                           {"br","6SWwZUAK4U0","Pyraminx Diamond Solve","Cubo vicio"},
423
                          };
424
    }
425
}
(29-29/41)