Project

General

Profile

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

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

1 def7cee2 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
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 621a672c Leszek Koltunski
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_SPLIT_EDGE;
14 def7cee2 Leszek Koltunski
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 ae9d9227 leszek
import org.distorted.objectlib.metadata.Metadata;
21 97a75106 leszek
import org.distorted.objectlib.signature.ObjectSignature;
22 def7cee2 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectVertexEffects;
23 cf93ea4e Leszek Koltunski
import org.distorted.objectlib.main.InitAssets;
24 97a75106 leszek
import org.distorted.objectlib.signature.ObjectConstants;
25 361fd0de leszek
import org.distorted.objectlib.metadata.ListObjects;
26 def7cee2 Leszek Koltunski
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 9ba7f3f6 Leszek Koltunski
  private int[][] mEdges;
44 def7cee2 Leszek Koltunski
  private int[][] mBasicAngle;
45
  private float[][] mCuts;
46
  private float[][] mPositions;
47
  private int[] mQuatIndex;
48
49
///////////////////////////////////////////////////////////////////////////////////////////////////
50
51 ae9d9227 leszek
  public TwistyPyraminxDiamond(int iconMode, Static4D quat, Static3D move, float scale, Metadata meta, InitAssets asset)
52 def7cee2 Leszek Koltunski
    {
53 ae9d9227 leszek
    super(iconMode, meta.getNumLayers()[0], quat, move, scale, meta, asset);
54 def7cee2 Leszek Koltunski
    }
55
56 a70b1e96 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
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 def7cee2 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
67 5abb9a18 Leszek Koltunski
// single edge; middle layers don't move
68 def7cee2 Leszek Koltunski
69 9ba7f3f6 Leszek Koltunski
  public int[][] getScrambleEdges()
70 def7cee2 Leszek Koltunski
    {
71 5abb9a18 Leszek Koltunski
    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 9ba7f3f6 Leszek Koltunski
    return mEdges;
79 def7cee2 Leszek Koltunski
    }
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 621a672c Leszek Koltunski
    return TYPE_SPLIT_EDGE;
115 def7cee2 Leszek Koltunski
    }
116
117
///////////////////////////////////////////////////////////////////////////////////////////////////
118
119
  public int[][][] getEnabled()
120
    {
121 621a672c Leszek Koltunski
    int[][] e0 = {{1},{2},{0}};
122
    int[][] e1 = {{1},{0},{2}};
123
    return new int[][][] { e0,e0,e0,e0,e1,e1,e1,e1 };
124 def7cee2 Leszek Koltunski
    }
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 347f6cc1 Leszek Koltunski
    int angle = 20;
290
    float R = 0.7f;
291
    float S = 0.5f;
292
293 def7cee2 Leszek Koltunski
    if( variant==0 )
294
      {
295
      float height = isInIconMode() ? 0.001f : 0.03f;
296 347f6cc1 Leszek Koltunski
      float[][] bands = { {height,angle,R,S,5,1,0},{0.001f,angle,R,S,5,0,0} };
297 def7cee2 Leszek Koltunski
      int[] indices = { 0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1 };
298
      return new ObjectFaceShape(bands,indices,null);
299
      }
300
    else
301
      {
302
      float height = isInIconMode() ? 0.001f : 0.03f;
303 347f6cc1 Leszek Koltunski
      float[][] bands = { {height,angle,R,S,5,1,0},{0.001f,angle,R,S,5,0,0} };
304 def7cee2 Leszek Koltunski
      int[] indices   = { 0,1,1,1 };
305
      return new ObjectFaceShape(bands,indices,null);
306
      }
307
    }
308
309
///////////////////////////////////////////////////////////////////////////////////////////////////
310
311
  public ObjectVertexEffects getVertexEffects(int variant)
312
    {
313
    if( variant==0 )
314
      {
315
      float[][] corners  = { {0.03f,0.20f},{0.03f,0.15f} };
316
      int[] cornerIndices= { 0,-1,-1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 };
317
      float[][] centers = { {0.0f,-1.5f*SQ2,0.0f} };
318
      int[] centerIndices= { 0,-1,-1,-1,-1,-1,0,0,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 };
319
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
320
      }
321
    else
322
      {
323
      float[][] corners = { {0.02f,0.10f} };
324
      int[] indices     = { 0,0,0,-1 };
325
      float[][] centers = { {0,-SQ2/2,-1.0f} };
326
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
327
      }
328
    }
329
330
///////////////////////////////////////////////////////////////////////////////////////////////////
331
332
  public int getNumCubitVariants(int[] numLayers)
333
    {
334
    return 2;
335
    }
336
337
///////////////////////////////////////////////////////////////////////////////////////////////////
338
339
  public int getCubitVariant(int cubit, int[] numLayers)
340
    {
341
    return cubit<6 ? 0:1;
342
    }
343
344
///////////////////////////////////////////////////////////////////////////////////////////////////
345
346
  public float getStickerRadius()
347
    {
348
    return 0.12f;
349
    }
350
351
///////////////////////////////////////////////////////////////////////////////////////////////////
352
353
  public float getStickerStroke()
354
    {
355
    return isInIconMode() ? 0.20f : 0.10f;
356
    }
357
358
///////////////////////////////////////////////////////////////////////////////////////////////////
359
360 ebe8c08e leszek
  public float[][][] getStickerAngles()
361 def7cee2 Leszek Koltunski
    {
362
    return null;
363
    }
364
365
///////////////////////////////////////////////////////////////////////////////////////////////////
366
// PUBLIC API
367
368
  public Static3D[] getRotationAxis()
369
    {
370
    return ROT_AXIS;
371
    }
372
373
///////////////////////////////////////////////////////////////////////////////////////////////////
374
375
  public int[][] getBasicAngles()
376
    {
377
    if( mBasicAngle ==null )
378
      {
379
      int[] tmp = {4,4,4};
380
      mBasicAngle = new int[][] { tmp,tmp,tmp };
381
      }
382
383
    return mBasicAngle;
384
    }
385
386
///////////////////////////////////////////////////////////////////////////////////////////////////
387
388
  public String getShortName()
389
    {
390 361fd0de leszek
    return ListObjects.PDIA_3.name();
391 def7cee2 Leszek Koltunski
    }
392
393
///////////////////////////////////////////////////////////////////////////////////////////////////
394
395
  public ObjectSignature getSignature()
396
    {
397 97a75106 leszek
    return new ObjectSignature(ObjectConstants.PDIA_3);
398 def7cee2 Leszek Koltunski
    }
399
400
///////////////////////////////////////////////////////////////////////////////////////////////////
401
402
  public String getObjectName()
403
    {
404
    return "Pyraminx Diamond";
405
    }
406
407
///////////////////////////////////////////////////////////////////////////////////////////////////
408
409
  public String getInventor()
410
    {
411
    return "Oskar van Deventer";
412
    }
413
414
///////////////////////////////////////////////////////////////////////////////////////////////////
415
416
  public int getYearOfInvention()
417
    {
418
    return 2014;
419
    }
420
421
///////////////////////////////////////////////////////////////////////////////////////////////////
422
423 da5551f4 leszek
  public float getComplexity()
424 def7cee2 Leszek Koltunski
    {
425 da5551f4 leszek
    return 1.25f;
426 def7cee2 Leszek Koltunski
    }
427
428
///////////////////////////////////////////////////////////////////////////////////////////////////
429
430
  public String[][] getTutorials()
431
    {
432
    return new String[][] {
433
                           {"gb","s5TdrKGH-DE","Solve the Pyraminx Diamond","TDRP Cubing"},
434
                           {"es","006L2qc1XoA","el Pyraminx Diamond","Spartan626"},
435
                           {"pl","AVRRHVgIeh4","Pyraminx Diamond TUTORIAL PL","MrUK"},
436
                           {"br","6SWwZUAK4U0","Pyraminx Diamond Solve","Cubo vicio"},
437 2318a72a leszek
                           {"tw","76M-RMl70w0","Pyraminx Diamond","不正常魔術方塊研究中心"},
438 def7cee2 Leszek Koltunski
                          };
439
    }
440
}