Project

General

Profile

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

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

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_NOT_SPLIT;
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.InitData;
23
import org.distorted.objectlib.main.ObjectType;
24
import org.distorted.objectlib.shape.ShapeOctahedron;
25
import org.distorted.objectlib.touchcontrol.TouchControlOctahedron;
26

    
27
import java.io.InputStream;
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(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
52
    {
53
    super(data, meshState, iconMode, data.getNumLayers()[0], quat, move, scale, stream);
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_NOT_SPLIT;
105
    }
106

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

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

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

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

    
122
///////////////////////////////////////////////////////////////////////////////////////////////////
123

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

    
129
///////////////////////////////////////////////////////////////////////////////////////////////////
130

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

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

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

    
161
    return mPositions;
162
    }
163

    
164
///////////////////////////////////////////////////////////////////////////////////////////////////
165

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

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

    
176
///////////////////////////////////////////////////////////////////////////////////////////////////
177

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

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

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

    
201
            {  0, H0,  0 },
202

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

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

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

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

    
236
///////////////////////////////////////////////////////////////////////////////////////////////////
237

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

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

    
262

    
263
          };
264

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

    
315
///////////////////////////////////////////////////////////////////////////////////////////////////
316

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

    
322
///////////////////////////////////////////////////////////////////////////////////////////////////
323

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

    
329
///////////////////////////////////////////////////////////////////////////////////////////////////
330

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

    
336
///////////////////////////////////////////////////////////////////////////////////////////////////
337

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

    
343
///////////////////////////////////////////////////////////////////////////////////////////////////
344

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

    
350
///////////////////////////////////////////////////////////////////////////////////////////////////
351
// PUBLIC API
352

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

    
358
///////////////////////////////////////////////////////////////////////////////////////////////////
359

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

    
368
    return mBasicAngle;
369
    }
370

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

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

    
378
///////////////////////////////////////////////////////////////////////////////////////////////////
379

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

    
385
///////////////////////////////////////////////////////////////////////////////////////////////////
386

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

    
392
///////////////////////////////////////////////////////////////////////////////////////////////////
393

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

    
399
///////////////////////////////////////////////////////////////////////////////////////////////////
400

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

    
406
///////////////////////////////////////////////////////////////////////////////////////////////////
407

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

    
413
///////////////////////////////////////////////////////////////////////////////////////////////////
414

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