Project

General

Profile

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

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

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.scrambling.ScrambleState;
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 ScrambleState[] mStates;
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 ScrambleState[] getScrambleStates()
60
    {
61
    if( mStates==null )
62
      {
63
      int[] m = new int[] { 0,-1,0,0,1,0,0,2,0, 2,-1,0,2,1,0,2,2,0};
64

    
65
      mStates = new ScrambleState[]
66
          {
67
          new ScrambleState( new int[][] { m, m, m } )
68
          };
69
      }
70

    
71
    return mStates;
72
    }
73

    
74
///////////////////////////////////////////////////////////////////////////////////////////////////
75

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

    
85
    return mCuts;
86
    }
87

    
88
///////////////////////////////////////////////////////////////////////////////////////////////////
89

    
90
  public boolean[][] getLayerRotatable(int[] numLayers)
91
    {
92
    boolean[] tmp = {true,false,true};
93
    return new boolean[][] { tmp,tmp,tmp };
94
    }
95

    
96
///////////////////////////////////////////////////////////////////////////////////////////////////
97

    
98
  public int getTouchControlType()
99
    {
100
    return TC_OCTAHEDRON;
101
    }
102

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

    
105
  public int getTouchControlSplit()
106
    {
107
    return TYPE_NOT_SPLIT;
108
    }
109

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

    
112
  public int[][][] getEnabled()
113
    {
114
    int[][] e = {{0,1,2}};
115
    return new int[][][] {e,e,e,e,e,e,e,e};
116
    }
117

    
118
///////////////////////////////////////////////////////////////////////////////////////////////////
119

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

    
125
///////////////////////////////////////////////////////////////////////////////////////////////////
126

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

    
132
///////////////////////////////////////////////////////////////////////////////////////////////////
133

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

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

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

    
164
    return mPositions;
165
    }
166

    
167
///////////////////////////////////////////////////////////////////////////////////////////////////
168

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

    
176
    return mObjectQuats[mQuatIndex[cubit]];
177
    }
178

    
179
///////////////////////////////////////////////////////////////////////////////////////////////////
180

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

    
195
      return new float[][]
196
        {
197
            {  0,  0,  0 }, //0
198

    
199
            {  0, H0, A0 },
200
            { A0, H0,  0 },
201
            {  0, H0,-A0 },
202
            {-A0, H0,  0 }, //4
203

    
204
            {  0, H0,  0 },
205

    
206
            { A1, H1, A1 },
207
            { A1, H1,-A1 },
208
            {-A1, H1,-A1 },
209
            {-A1, H1, A1 }, //9
210

    
211
            { A2, H2, B2 },
212
            { B2, H2,-A2 },
213
            {-A2, H2,-B2 },
214
            {-B2, H2, A2 },
215

    
216
            { B2, H2, A2 }, //14
217
            { A2, H2,-B2 },
218
            {-B2, H2,-A2 },
219
            {-A2, H2, B2 },
220

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

    
239
///////////////////////////////////////////////////////////////////////////////////////////////////
240

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

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

    
265

    
266
          };
267

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

    
277
///////////////////////////////////////////////////////////////////////////////////////////////////
278

    
279
  public ObjectFaceShape getObjectFaceShape(int variant)
280
    {
281
    if( variant==0 )
282
      {
283
      float height = isInIconMode() ? 0.001f : 0.03f;
284
      float[][] bands = { {height,35,0.2f,0.5f,5,1,0},{0.001f,35,0.2f,0.5f,5,0,0} };
285
      int[] indices = { 0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1 };
286
      return new ObjectFaceShape(bands,indices,null);
287
      }
288
    else
289
      {
290
      float height = isInIconMode() ? 0.001f : 0.03f;
291
      float[][] bands = { {height,35,0.15f,0.3f,5,1,0},{0.001f,35,0.15f,0.3f,5,0,0} };
292
      int[] indices   = { 0,1,1,1 };
293
      return new ObjectFaceShape(bands,indices,null);
294
      }
295
    }
296

    
297
///////////////////////////////////////////////////////////////////////////////////////////////////
298

    
299
  public ObjectVertexEffects getVertexEffects(int variant)
300
    {
301
    if( variant==0 )
302
      {
303
      float[][] corners  = { {0.03f,0.20f},{0.03f,0.15f} };
304
      int[] cornerIndices= { 0,-1,-1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 };
305
      float[][] centers = { {0.0f,-1.5f*SQ2,0.0f} };
306
      int[] centerIndices= { 0,-1,-1,-1,-1,-1,0,0,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 };
307
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
308
      }
309
    else
310
      {
311
      float[][] corners = { {0.02f,0.10f} };
312
      int[] indices     = { 0,0,0,-1 };
313
      float[][] centers = { {0,-SQ2/2,-1.0f} };
314
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
315
      }
316
    }
317

    
318
///////////////////////////////////////////////////////////////////////////////////////////////////
319

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

    
325
///////////////////////////////////////////////////////////////////////////////////////////////////
326

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

    
332
///////////////////////////////////////////////////////////////////////////////////////////////////
333

    
334
  public float getStickerRadius()
335
    {
336
    return 0.12f;
337
    }
338

    
339
///////////////////////////////////////////////////////////////////////////////////////////////////
340

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

    
346
///////////////////////////////////////////////////////////////////////////////////////////////////
347

    
348
  public float[][] getStickerAngles()
349
    {
350
    return null;
351
    }
352

    
353
///////////////////////////////////////////////////////////////////////////////////////////////////
354
// PUBLIC API
355

    
356
  public Static3D[] getRotationAxis()
357
    {
358
    return ROT_AXIS;
359
    }
360

    
361
///////////////////////////////////////////////////////////////////////////////////////////////////
362

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

    
371
    return mBasicAngle;
372
    }
373

    
374
///////////////////////////////////////////////////////////////////////////////////////////////////
375

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

    
381
///////////////////////////////////////////////////////////////////////////////////////////////////
382

    
383
  public ObjectSignature getSignature()
384
    {
385
    return new ObjectSignature(ObjectType.PDIA_3);
386
    }
387

    
388
///////////////////////////////////////////////////////////////////////////////////////////////////
389

    
390
  public String getObjectName()
391
    {
392
    return "Pyraminx Diamond";
393
    }
394

    
395
///////////////////////////////////////////////////////////////////////////////////////////////////
396

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

    
402
///////////////////////////////////////////////////////////////////////////////////////////////////
403

    
404
  public int getYearOfInvention()
405
    {
406
    return 2014;
407
    }
408

    
409
///////////////////////////////////////////////////////////////////////////////////////////////////
410

    
411
  public int getComplexity()
412
    {
413
    return 1;
414
    }
415

    
416
///////////////////////////////////////////////////////////////////////////////////////////////////
417

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