Project

General

Profile

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

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

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

    
28
import java.io.InputStream;
29

    
30
///////////////////////////////////////////////////////////////////////////////////////////////////
31

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

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

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

    
50
///////////////////////////////////////////////////////////////////////////////////////////////////
51

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

    
57
///////////////////////////////////////////////////////////////////////////////////////////////////
58

    
59
  public int[][] getScrambleEdges()
60
    {
61
    if( mEdges==null ) mEdges = ScrambleEdgeGenerator.getScrambleEdgesSingle(mBasicAngle);
62
    return mEdges;
63
    }
64

    
65
///////////////////////////////////////////////////////////////////////////////////////////////////
66

    
67
  public float[][] getCuts(int[] numLayers)
68
    {
69
    if( mCuts==null )
70
      {
71
      float C = 0.5f*SQ2;
72
      float[] cut = { -C,C};
73
      mCuts = new float[][] { cut,cut,cut };
74
      }
75

    
76
    return mCuts;
77
    }
78

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

    
81
  public boolean[][] getLayerRotatable(int[] numLayers)
82
    {
83
    boolean[] tmp = {true,false,true};
84
    return new boolean[][] { tmp,tmp,tmp };
85
    }
86

    
87
///////////////////////////////////////////////////////////////////////////////////////////////////
88

    
89
  public int getTouchControlType()
90
    {
91
    return TC_OCTAHEDRON;
92
    }
93

    
94
///////////////////////////////////////////////////////////////////////////////////////////////////
95

    
96
  public int getTouchControlSplit()
97
    {
98
    return TYPE_NOT_SPLIT;
99
    }
100

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

    
103
  public int[][][] getEnabled()
104
    {
105
    int[][] e = {{0,1,2}};
106
    return new int[][][] {e,e,e,e,e,e,e,e};
107
    }
108

    
109
///////////////////////////////////////////////////////////////////////////////////////////////////
110

    
111
  public float[] getDist3D(int[] numLayers)
112
    {
113
    return TouchControlOctahedron.D3D;
114
    }
115

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

    
118
  public Static3D[] getFaceAxis()
119
    {
120
    return TouchControlOctahedron.FACE_AXIS;
121
    }
122

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

    
125
  public float[][] getCubitPositions(int[] numLayers)
126
    {
127
    if( mPositions==null )
128
      {
129
      float B0 = 1.5f*SQ2;
130
      float C0 = 1.5f;
131
      float A = 1.03f;  // move the centers 3% out - otherwise they look hidden.
132
      float B1 = 0.5f*SQ2*A;
133
      float C1 = A;
134

    
135
      mPositions = new float[][]
136
         {
137
             {  0, B0,  0 },
138
             {  0,-B0,  0 },
139
             { C0,  0, C0 },
140
             { C0,  0,-C0 },
141
             {-C0,  0, C0 },
142
             {-C0,  0,-C0 },
143

    
144
             {  0, B1, C1 },
145
             {  0, B1,-C1 },
146
             {  0,-B1, C1 },
147
             {  0,-B1,-C1 },
148
             { C1, B1,  0 },
149
             { C1,-B1,  0 },
150
             {-C1, B1,  0 },
151
             {-C1,-B1,  0 },
152
         };
153
      }
154

    
155
    return mPositions;
156
    }
157

    
158
///////////////////////////////////////////////////////////////////////////////////////////////////
159

    
160
  public Static4D getCubitQuats(int cubit, int[] numLayers)
161
    {
162
    if( mQuatIndex==null )
163
      {
164
      mQuatIndex = new int[] { 0,2,9,1,3,7, 0,5,3,11,1,2,4,8 };
165
      }
166

    
167
    return mObjectQuats[mQuatIndex[cubit]];
168
    }
169

    
170
///////////////////////////////////////////////////////////////////////////////////////////////////
171

    
172
  private float[][] getVertices(int variant)
173
    {
174
    if( variant==0 )
175
      {
176
      final float A0 = 1-D;
177
      final float H0 = -SQ2*(1-D);
178
      final float A1 = 0.75f;
179
      final float H1 = -0.75f*SQ2;
180
      final float H2 = -SQ2 + 0.25f*SQ2*D;
181
      final float A2 = 0.0f + 0.75f*D;
182
      final float B2 = 1.0f - 0.25f*D;
183
      final float A3 = 0.25f + 0.5f*D;
184
      final float H3 = (-1.25f + 0.5f*D)*SQ2;
185

    
186
      return new float[][]
187
        {
188
            {  0,  0,  0 }, //0
189

    
190
            {  0, H0, A0 },
191
            { A0, H0,  0 },
192
            {  0, H0,-A0 },
193
            {-A0, H0,  0 }, //4
194

    
195
            {  0, H0,  0 },
196

    
197
            { A1, H1, A1 },
198
            { A1, H1,-A1 },
199
            {-A1, H1,-A1 },
200
            {-A1, H1, A1 }, //9
201

    
202
            { A2, H2, B2 },
203
            { B2, H2,-A2 },
204
            {-A2, H2,-B2 },
205
            {-B2, H2, A2 },
206

    
207
            { B2, H2, A2 }, //14
208
            { A2, H2,-B2 },
209
            {-B2, H2,-A2 },
210
            {-A2, H2, B2 },
211

    
212
            { A3, H3, A3 },
213
            { A3, H3,-A3 }, //19
214
            {-A3, H3,-A3 },
215
            {-A3, H3, A3 }
216
        };
217
      }
218
    else
219
      {
220
      return new float[][]
221
        {
222
            {-1.5f*D, -0.5f*SQ2*D, 0.5f*D},
223
            { 1.5f*D, -0.5f*SQ2*D, 0.5f*D},
224
            { 0.0f  ,       SQ2*D,     -D},
225
            { 0.0f  , -0.5f*SQ2  ,-1.0f  }
226
        };
227
      }
228
    }
229

    
230
///////////////////////////////////////////////////////////////////////////////////////////////////
231

    
232
  public ObjectShape getObjectShape(int variant)
233
    {
234
    if( variant==0 )
235
      {
236
      int[][] indices =
237
          {
238
              {0,9,17,1,10,6},
239
              {0,6,14,2,11,7},
240
              {0,7,15,3,12,8},
241
              {0,8,16,4,13,9},
242
              {6,10,18,14},
243
              {7,11,19,15},
244
              {8,12,20,16},
245
              {9,13,21,17},
246

    
247
              {5,18,10,1},
248
              {5,1,17,21},
249
              {5,21,13,4},
250
              {5,4,16,20},
251
              {5,20,12,3},
252
              {5,3,15,19},
253
              {5,19,11,2},
254
              {5,2,14,18}
255

    
256

    
257
          };
258

    
259
      return new ObjectShape(getVertices(variant), indices);
260
      }
261
    else
262
      {
263
      int[][] indices = { {0,1,2},{3,1,0},{3,2,1},{3,0,2} };
264
      return new ObjectShape(getVertices(variant), indices);
265
      }
266
    }
267

    
268
///////////////////////////////////////////////////////////////////////////////////////////////////
269

    
270
  public ObjectFaceShape getObjectFaceShape(int variant)
271
    {
272
    if( variant==0 )
273
      {
274
      float height = isInIconMode() ? 0.001f : 0.03f;
275
      float[][] bands = { {height,35,0.2f,0.5f,5,1,0},{0.001f,35,0.2f,0.5f,5,0,0} };
276
      int[] indices = { 0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1 };
277
      return new ObjectFaceShape(bands,indices,null);
278
      }
279
    else
280
      {
281
      float height = isInIconMode() ? 0.001f : 0.03f;
282
      float[][] bands = { {height,35,0.15f,0.3f,5,1,0},{0.001f,35,0.15f,0.3f,5,0,0} };
283
      int[] indices   = { 0,1,1,1 };
284
      return new ObjectFaceShape(bands,indices,null);
285
      }
286
    }
287

    
288
///////////////////////////////////////////////////////////////////////////////////////////////////
289

    
290
  public ObjectVertexEffects getVertexEffects(int variant)
291
    {
292
    if( variant==0 )
293
      {
294
      float[][] corners  = { {0.03f,0.20f},{0.03f,0.15f} };
295
      int[] cornerIndices= { 0,-1,-1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 };
296
      float[][] centers = { {0.0f,-1.5f*SQ2,0.0f} };
297
      int[] centerIndices= { 0,-1,-1,-1,-1,-1,0,0,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 };
298
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
299
      }
300
    else
301
      {
302
      float[][] corners = { {0.02f,0.10f} };
303
      int[] indices     = { 0,0,0,-1 };
304
      float[][] centers = { {0,-SQ2/2,-1.0f} };
305
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
306
      }
307
    }
308

    
309
///////////////////////////////////////////////////////////////////////////////////////////////////
310

    
311
  public int getNumCubitVariants(int[] numLayers)
312
    {
313
    return 2;
314
    }
315

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

    
318
  public int getCubitVariant(int cubit, int[] numLayers)
319
    {
320
    return cubit<6 ? 0:1;
321
    }
322

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

    
325
  public float getStickerRadius()
326
    {
327
    return 0.12f;
328
    }
329

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

    
332
  public float getStickerStroke()
333
    {
334
    return isInIconMode() ? 0.20f : 0.10f;
335
    }
336

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

    
339
  public float[][] getStickerAngles()
340
    {
341
    return null;
342
    }
343

    
344
///////////////////////////////////////////////////////////////////////////////////////////////////
345
// PUBLIC API
346

    
347
  public Static3D[] getRotationAxis()
348
    {
349
    return ROT_AXIS;
350
    }
351

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

    
354
  public int[][] getBasicAngles()
355
    {
356
    if( mBasicAngle ==null )
357
      {
358
      int[] tmp = {4,4,4};
359
      mBasicAngle = new int[][] { tmp,tmp,tmp };
360
      }
361

    
362
    return mBasicAngle;
363
    }
364

    
365
///////////////////////////////////////////////////////////////////////////////////////////////////
366

    
367
  public String getShortName()
368
    {
369
    return ObjectType.PDIA_3.name();
370
    }
371

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

    
374
  public ObjectSignature getSignature()
375
    {
376
    return new ObjectSignature(ObjectType.PDIA_3);
377
    }
378

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

    
381
  public String getObjectName()
382
    {
383
    return "Pyraminx Diamond";
384
    }
385

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

    
388
  public String getInventor()
389
    {
390
    return "Oskar van Deventer";
391
    }
392

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

    
395
  public int getYearOfInvention()
396
    {
397
    return 2014;
398
    }
399

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

    
402
  public int getComplexity()
403
    {
404
    return 1;
405
    }
406

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

    
409
  public String[][] getTutorials()
410
    {
411
    return new String[][] {
412
                           {"gb","s5TdrKGH-DE","Solve the Pyraminx Diamond","TDRP Cubing"},
413
                           {"es","006L2qc1XoA","el Pyraminx Diamond","Spartan626"},
414
                           {"pl","AVRRHVgIeh4","Pyraminx Diamond TUTORIAL PL","MrUK"},
415
                           {"br","6SWwZUAK4U0","Pyraminx Diamond Solve","Cubo vicio"},
416
                          };
417
    }
418
}
(29-29/41)