Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyMorphix.java @ fd271599

1 f8e0d6be Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2022 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6 6133be67 Leszek Koltunski
// 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 f8e0d6be Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
9
10
package org.distorted.objectlib.objects;
11
12
import org.distorted.library.type.Static3D;
13
import org.distorted.library.type.Static4D;
14 84a17011 Leszek Koltunski
import org.distorted.objectlib.helpers.FactoryCubit;
15 f8e0d6be Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectFaceShape;
16
import org.distorted.objectlib.helpers.ObjectShape;
17 1d581993 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectSignature;
18 84a17011 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectVertexEffects;
19 cf93ea4e Leszek Koltunski
import org.distorted.objectlib.main.InitAssets;
20 a8295031 Leszek Koltunski
import org.distorted.objectlib.main.InitData;
21 2dffaf22 Leszek Koltunski
import org.distorted.objectlib.main.ObjectSignatures;
22 f8e0d6be Leszek Koltunski
import org.distorted.objectlib.main.ObjectType;
23 27249eea Leszek Koltunski
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator;
24 b31249d6 Leszek Koltunski
import org.distorted.objectlib.shape.ShapeTetrahedron;
25 f8e0d6be Leszek Koltunski
import org.distorted.objectlib.touchcontrol.TouchControlTetrahedron;
26
27
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_CHANGING_SHAPEMOD;
28
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
29
30
///////////////////////////////////////////////////////////////////////////////////////////////////
31
32 052e0362 Leszek Koltunski
public class TwistyMorphix extends ShapeTetrahedron
33 f8e0d6be Leszek Koltunski
{
34 17e17769 Leszek Koltunski
  // size>=3: if length of the edge of the whole tetrahedron is = 1.0, then
35
  // length of the edge of the corner cubit is equal to DIST. (separate for size 3 and 4)
36
  private static final float DIST3 = 0.39f;
37
  private static final float DIST4 = 0.365f;
38
39 f8e0d6be Leszek Koltunski
  static final Static3D[] ROT_AXIS = new Static3D[]
40
         {
41
           new Static3D( SQ2/2, 0.0f, SQ2/2),
42
           new Static3D(  0.0f, 1.0f,  0.0f),
43
           new Static3D( SQ2/2, 0.0f,-SQ2/2),
44
         };
45
46 9ba7f3f6 Leszek Koltunski
  private int[][] mEdges;
47 beee90ab Leszek Koltunski
  private int[][] mBasicAngle;
48 f8e0d6be Leszek Koltunski
  private float[][] mCuts;
49
  private float[][] mCenters;
50
  private int[] mQuatIndex;
51
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53
54 cf93ea4e Leszek Koltunski
  public TwistyMorphix(int meshState, int iconMode, Static4D quat, Static3D move, float scale, InitData data, InitAssets asset)
55 f8e0d6be Leszek Koltunski
    {
56 cf93ea4e Leszek Koltunski
    super(meshState, iconMode, data.getNumLayers()[0], quat, move, scale, data, asset);
57 f8e0d6be Leszek Koltunski
    }
58
59 6db8fe2e Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
60
61
  @Override
62
  public float getPillowCoeff()
63
    {
64 f2259427 Leszek Koltunski
    return 1.5f;
65 6db8fe2e Leszek Koltunski
    }
66
67 f8e0d6be Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
68 17e17769 Leszek Koltunski
69
  @Override
70
  public int getInternalColor()
71
    {
72
    return getNumLayers()[0]==2 ? 0xff000000 : 0xff333333;
73
    }
74
75
///////////////////////////////////////////////////////////////////////////////////////////////////
76 f8e0d6be Leszek Koltunski
77 9ba7f3f6 Leszek Koltunski
  public int[][] getScrambleEdges()
78
    {
79
    if( mEdges==null )
80 f8e0d6be Leszek Koltunski
      {
81 27249eea Leszek Koltunski
      int nL = getNumLayers()[0];
82
      mEdges = ScrambleEdgeGenerator.getScrambleEdgesCuboid(nL,nL,nL);
83 f8e0d6be Leszek Koltunski
      }
84
85 9ba7f3f6 Leszek Koltunski
    return mEdges;
86 f8e0d6be Leszek Koltunski
    }
87
88
///////////////////////////////////////////////////////////////////////////////////////////////////
89
90
  public float[][] getCuts(int[] numLayers)
91
    {
92
    if( mCuts==null )
93
      {
94 17e17769 Leszek Koltunski
      int numL = numLayers[0];
95
      float[] cut = new float[numL-1];
96
      float DIST = numL==3 ? DIST3:DIST4;
97
      float dist = numL*(SQ2/2)*(0.5f-DIST);
98
99
      switch(numL)
100
        {
101
        case 2: cut[0] = 0;
102
                break;
103
        case 3: cut[0] = -dist;
104 84a17011 Leszek Koltunski
                cut[1] =  dist;
105 17e17769 Leszek Koltunski
                break;
106
        case 4: cut[0] = -dist;
107
                cut[1] = 0.0f;
108 84a17011 Leszek Koltunski
                cut[2] =  dist;
109 17e17769 Leszek Koltunski
                break;
110
        }
111
112 f8e0d6be Leszek Koltunski
      mCuts = new float[][] { cut,cut,cut };
113
      }
114
115
    return mCuts;
116
    }
117
118
///////////////////////////////////////////////////////////////////////////////////////////////////
119
120
  public boolean[][] getLayerRotatable(int[] numLayers)
121
    {
122 17e17769 Leszek Koltunski
    int numL = numLayers[0];
123
    boolean[] tmp = new boolean[numL];
124
    for(int i=0; i<numL; i++) tmp[i] = true;
125
126 f8e0d6be Leszek Koltunski
    return new boolean[][] { tmp,tmp,tmp };
127
    }
128
129
///////////////////////////////////////////////////////////////////////////////////////////////////
130
131
  public int getTouchControlType()
132
    {
133
    return TC_CHANGING_SHAPEMOD;
134
    }
135
136
///////////////////////////////////////////////////////////////////////////////////////////////////
137
138
  public int getTouchControlSplit()
139
    {
140
    return TYPE_NOT_SPLIT;
141
    }
142
143
///////////////////////////////////////////////////////////////////////////////////////////////////
144
145
  public int[][][] getEnabled()
146
    {
147
    return null;
148
    }
149
150
///////////////////////////////////////////////////////////////////////////////////////////////////
151
152
  public float[] getDist3D(int[] numLayers)
153
    {
154
    return TouchControlTetrahedron.D3D;
155
    }
156
157
///////////////////////////////////////////////////////////////////////////////////////////////////
158
159
  public Static3D[] getFaceAxis()
160
    {
161
    return TouchControlTetrahedron.FACE_AXIS;
162
    }
163
164
///////////////////////////////////////////////////////////////////////////////////////////////////
165
166
  public float[][] getCubitPositions(int[] numLayers)
167
    {
168
    if( mCenters==null )
169
      {
170 17e17769 Leszek Koltunski
      int numL = numLayers[0];
171
      float DIST = numL==3 ? DIST3:DIST4;
172
      final float C = numL==2 ? 1.0f : 6*numL*(0.25f-DIST/3);
173
      final float A = C*SQ2/6;
174
      final float B = C/3;
175
      final float D = (SQ2/12)*numL;
176
      final float E = (1.0f/6)*numL;
177
178
      if( numL==2 )
179
        {
180
        mCenters = new float[][]
181
           {
182
             {0.0f, -A,   +B},
183
             {0.0f, -A,   -B},
184
             {  +B,  A, 0.0f},
185
             {  -B,  A, 0.0f},
186 f8e0d6be Leszek Koltunski
187 17e17769 Leszek Koltunski
             {0.0f,  D,   +E},
188
             {0.0f,  D,   -E},
189
             {  +E, -D, 0.0f},
190
             {  -E, -D, 0.0f}
191
           };
192
        }
193
      else if( numL==3 )
194
        {
195
        final float X1 = 0.5f*(3*DIST-1)*numL;
196
        final float X2 = 0.5f*DIST*numL;
197
        final float X = 0.25f*numL*(1-DIST);
198
        final float Y = numL*(1-DIST)*(SQ2/4);
199
        final float F = 0.5f*(1-DIST)*numL - X2 + X1/2;
200
        final float G = 0.5f*F;
201
        final float H = (SQ2/2)*F;
202
203
        mCenters = new float[][]
204
           {
205 f8e0d6be Leszek Koltunski
             {0.0f, -A,   +B},
206
             {0.0f, -A,   -B},
207
             {  +B,  A, 0.0f},
208
             {  -B,  A, 0.0f},
209 17e17769 Leszek Koltunski
210
             {0.0f,  D,   +E},
211
             {0.0f,  D,   -E},
212
             {  +E, -D, 0.0f},
213
             {  -E, -D, 0.0f},
214
215
             {0.0f,  +Y,0.0f},
216
             {0.0f,  -Y,0.0f},
217
             {  +X,0.0f,  +X},
218
             {  +X,0.0f,  -X},
219
             {  -X,0.0f,  +X},
220
             {  -X,0.0f,  -X},
221
222
             {0.0f,0.0f,   F},
223
             {   G,   H,   G},
224
             {  -G,   H,   G},
225
             {0.0f,0.0f,  -F},
226
             {   G,   H,  -G},
227
             {  -G,   H,  -G},
228
             {   F,0.0f,0.0f},
229
             {   G,  -H,   G},
230
             {   G,  -H,  -G},
231
             {  -F,0.0f,0.0f},
232
             {  -G,  -H,   G},
233
             {  -G,  -H,  -G},
234
           };
235
        }
236
      else
237
        {
238
        final float X1 = 0.5f*(3*DIST-1)*numL;
239
        final float X2 = 0.5f*DIST*numL;
240
        final float X = 0.25f*numL*(1-DIST);
241
        final float Y = numL*(1-DIST)*(SQ2/4);
242
        final float Z = numL*(1-2*DIST)/(2*numL-4);
243
        final float F = 0.5f*(1-DIST)*numL - X2 + X1/2;
244
        final float G = 0.5f*F;
245
        final float H = (SQ2/2)*F;
246
        final float I = (0.25f-DIST/2)*numL;
247
248
        mCenters = new float[][]
249
           {
250
             {0.0f, -A,   +B},
251
             {0.0f, -A,   -B},
252
             {  +B,  A, 0.0f},
253
             {  -B,  A, 0.0f},
254
255
             {0.0f,  D,   +E},
256
             {0.0f,  D,   -E},
257
             {  +E, -D, 0.0f},
258
             {  -E, -D, 0.0f},
259
260
             {  +Z,  +Y,0.0f},
261
             {  -Z,  +Y,0.0f},
262
             {0.0f,  -Y,  +Z},
263
             {0.0f,  -Y,  -Z},
264 84a17011 Leszek Koltunski
             {   X-Z/2,-(SQ2/2)*Z,   X+Z/2},
265
             {   X+Z/2, (SQ2/2)*Z,   X-Z/2},
266
             {   X-Z/2,-(SQ2/2)*Z,  -X-Z/2},
267
             {   X+Z/2, (SQ2/2)*Z,  -X+Z/2},
268
             {  -X+Z/2,-(SQ2/2)*Z,   X+Z/2},
269
             {  -X-Z/2, (SQ2/2)*Z,   X-Z/2},
270 17e17769 Leszek Koltunski
             {  -X+Z/2,-(SQ2/2)*Z,  -X-Z/2},
271
             {  -X-Z/2, (SQ2/2)*Z,  -X+Z/2},
272
273
             {0.0f,-I*(SQ2/2),   F+I*0.5f},
274
             {   G+0.75f*I,   H+(SQ2/4)*I,   G-0.25f*I},
275
             {  -G-0.75f*I,   H+(SQ2/4)*I,   G-0.25f*I},
276
             {0.0f,-I*(SQ2/2),  -F-I*0.5f},
277
             {   G+0.75f*I,   H+(SQ2/4)*I,  -G+0.25f*I},
278
             {  -G-0.75f*I,   H+(SQ2/4)*I,  -G+0.25f*I},
279
             {   F+0.5f*I, I*(SQ2/2),0.0f},
280
             {   G-0.25f*I,  -H-(SQ2/4)*I,   G+0.75f*I},
281
             {   G-0.25f*I,  -H-(SQ2/4)*I,  -G-0.75f*I},
282
             {  -F-0.5f*I, I*(SQ2/2),0.0f},
283
             {  -G+0.25f*I,  -H-(SQ2/4)*I,   G+0.75f*I},
284
             {  -G+0.25f*I,  -H-(SQ2/4)*I,  -G-0.75f*I},
285
286 84a17011 Leszek Koltunski
             {        0.0f,   I*(SQ2/2),     F+I*0.5f},
287 17e17769 Leszek Koltunski
             {   G-0.25f*I,   H+(SQ2/4)*I,   G+0.75f*I},
288
             {  -G+0.25f*I,   H+(SQ2/4)*I,   G+0.75f*I},
289 84a17011 Leszek Koltunski
             {        0.0f,   I*(SQ2/2),    -F-I*0.5f},
290 17e17769 Leszek Koltunski
             {   G-0.25f*I,   H+(SQ2/4)*I,  -G-0.75f*I},
291
             {  -G+0.25f*I,   H+(SQ2/4)*I,  -G-0.75f*I},
292 84a17011 Leszek Koltunski
             {   F+0.5f*I,   -I*(SQ2/2),          0.0f},
293 17e17769 Leszek Koltunski
             {   G+0.75f*I,  -H-(SQ2/4)*I,   G-0.25f*I},
294
             {   G+0.75f*I,  -H-(SQ2/4)*I,  -G+0.25f*I},
295 84a17011 Leszek Koltunski
             {  -F-0.5f*I,   -I*(SQ2/2),          0.0f},
296 17e17769 Leszek Koltunski
             {  -G-0.75f*I,  -H-(SQ2/4)*I,   G-0.25f*I},
297
             {  -G-0.75f*I,  -H-(SQ2/4)*I,  -G+0.25f*I},
298
299
             {0.0f,    Y,   +Z},
300
             {0.0f,    Y,   -Z},
301
             {  +Z,   -Y, 0.0f},
302
             {  -Z,   -Y, 0.0f},
303
             { (SQ2/2)*Y-Z/2, (SQ2/2)*Z, (SQ2/2)*Y+Z/2},
304
             { (SQ2/2)*Y+Z/2,-(SQ2/2)*Z, (SQ2/2)*Y-Z/2},
305
             {-(SQ2/2)*Y+Z/2, (SQ2/2)*Z, (SQ2/2)*Y+Z/2},
306
             {-(SQ2/2)*Y-Z/2,-(SQ2/2)*Z, (SQ2/2)*Y-Z/2},
307
             { (SQ2/2)*Y-Z/2, (SQ2/2)*Z,-(SQ2/2)*Y-Z/2},
308
             { (SQ2/2)*Y+Z/2,-(SQ2/2)*Z,-(SQ2/2)*Y+Z/2},
309
             {-(SQ2/2)*Y+Z/2, (SQ2/2)*Z,-(SQ2/2)*Y-Z/2},
310
             {-(SQ2/2)*Y-Z/2,-(SQ2/2)*Z,-(SQ2/2)*Y+Z/2},
311
           };
312
        }
313 f8e0d6be Leszek Koltunski
      }
314
315
    return mCenters;
316
    }
317
318
///////////////////////////////////////////////////////////////////////////////////////////////////
319
320
  public Static4D getCubitQuats(int cubit, int[] numLayers)
321
    {
322 17e17769 Leszek Koltunski
    if( mQuatIndex==null )
323
      {
324
      switch(numLayers[0])
325
        {
326
        case 2: mQuatIndex = new int[] { 0,5,2,8,
327
                                         0,5,2,8
328
                                       };
329
                break;
330
        case 3: mQuatIndex = new int[] { 0,5,2,8,
331
                                         0,5,2,8,
332
                                         0,2,15,10,20,13,
333
                                         0,21,15,5,13,10,2,12,23,8,22,20
334
                                       };
335
                break;
336
        default:mQuatIndex = new int[] { 0,5,2,8,
337
                                         0,5,2,8,
338
                                         0,0,2,2,15,15,10,10,20,20,13,13,
339
                                         0,21,15,5,13,10,2,12,23,8,22,20,
340
                                         0,21,15,5,13,10,2,12,23,8,22,20,
341
                                         0,5,2,8,15,23,21,20,10,12,13,22
342
                                       };
343
        }
344
345
      }
346
347 f8e0d6be Leszek Koltunski
    return mObjectQuats[mQuatIndex[cubit]];
348
    }
349
350
///////////////////////////////////////////////////////////////////////////////////////////////////
351
352 84a17011 Leszek Koltunski
  private float[][] getVertices(int variant)
353 f8e0d6be Leszek Koltunski
    {
354 17e17769 Leszek Koltunski
    int numL = getNumLayers()[0];
355
    float DIST = numL==3 ? DIST3:DIST4;
356
357 f8e0d6be Leszek Koltunski
    if( variant==0 )
358
      {
359 17e17769 Leszek Koltunski
      final float Z = numL==2 ? 1.0f : numL*DIST;
360
      final float Y = (SQ2/2)*Z;
361 f8e0d6be Leszek Koltunski
362 84a17011 Leszek Koltunski
      return new float[][]
363 f8e0d6be Leszek Koltunski
          {
364
              {0.0f,-2*Y/3, 2*Z/3 },
365
              {0.0f,-2*Y/3,  -Z/3 },
366
              { Z/2,   Y/3,   Z/6 },
367
              {-Z/2,   Y/3,   Z/6 },
368
              {0.0f,   Y/3,  -Z/3 }
369
          };
370
      }
371 17e17769 Leszek Koltunski
    else if( variant==1 )
372 f8e0d6be Leszek Koltunski
      {
373 17e17769 Leszek Koltunski
      final float X = numL==2 ? 1.0f : numL*(3*DIST-1);
374
      final float Y = (SQ2/2)*X;
375
      final float Z = 0.5f*X;
376 f8e0d6be Leszek Koltunski
377 84a17011 Leszek Koltunski
      return new float[][]
378 f8e0d6be Leszek Koltunski
          {
379
              {-X/2,  -Y/3,   Z/3 },
380
              { X/2,  -Y/3,   Z/3 },
381
              {0.0f, 2*Y/3,-2*Z/3 },
382
              {0.0f,  -Y/3,-2*Z/3 }
383
          };
384 17e17769 Leszek Koltunski
      }
385
    else if( variant==2 )
386
      {
387
      final float X = numL*(1-2*DIST)/(2*numL-4);
388
      final float Y = (SQ2/4)*DIST*numL;
389
390 84a17011 Leszek Koltunski
      return new float[][]
391 17e17769 Leszek Koltunski
          {
392
              {  +X,     +Y,  0.0f },
393
              {  -X,     +Y,  0.0f },
394
              {0.0f,Y-X*SQ2,    +X },
395
              {0.0f,Y-X*SQ2,    -X },
396
              {  +X,     -Y,  0.0f },
397
              {  -X,     -Y,  0.0f },
398
              {0.0f,     -Y,    +X },
399
              {0.0f,     -Y,    -X },
400
          };
401
      }
402
    else if( variant==3 )
403
      {
404
      final float C = numL==3 ? 3*DIST-1 : 2*DIST-0.5f;
405
      final float X1 = 0.5f*C*numL;
406
      final float X2 = 0.5f*DIST*numL;
407
      final float Y  = (SQ2/4)*numL*(1-2*DIST)/(numL-2);
408
409 84a17011 Leszek Koltunski
      return new float[][]
410 17e17769 Leszek Koltunski
          {
411 84a17011 Leszek Koltunski
              {  +X1,+Y, X1/2 },
412
              {  -X1,+Y, X1/2 },
413 17e17769 Leszek Koltunski
              { 0.0f,+Y,-X1/2 },
414 84a17011 Leszek Koltunski
              {  +X2,-Y, X2-X1/2 },
415
              {  -X2,-Y, X2-X1/2 },
416 17e17769 Leszek Koltunski
              { 0.0f,-Y,-X1/2 },
417
          };
418
      }
419
    else if( variant==4 )
420
      {
421
      final float X1 = 0.5f*(3*DIST-1)*numL;
422
      final float X2 = 0.5f*(2*DIST-0.5f)*numL;
423
      final float Y  = (SQ2/4)*numL*(1-2*DIST)/(numL-2);
424
425 84a17011 Leszek Koltunski
      return new float[][]
426 17e17769 Leszek Koltunski
          {
427
              {  +X1,+Y,+X1-X2/2 },
428
              {  -X1,+Y,+X1-X2/2 },
429
              { 0.0f,+Y,-X2/2 },
430
              {  +X2,-Y,+X2/2 },
431
              {  -X2,-Y,+X2/2 },
432
              { 0.0f,-Y,-X2/2 },
433
          };
434
      }
435
    else
436
      {
437
      final float X = numL*(1-2*DIST)/(2*numL-4);
438
      final float Y = (SQ2/4)*DIST*numL;
439
440 84a17011 Leszek Koltunski
      return new float[][]
441 17e17769 Leszek Koltunski
          {
442
              {  +X,  Y-X*SQ2,  0.0f },
443
              {  -X,  Y-X*SQ2,  0.0f },
444
              {0.0f,Y-2*X*SQ2,    +X },
445
              {0.0f,Y        ,    -X },
446
              {  +X,       -Y,  0.0f },
447
              {  -X,       -Y,  0.0f },
448
              {0.0f,       -Y,    +X },
449
              {0.0f,       -Y,    -X },
450
          };
451 84a17011 Leszek Koltunski
      }
452
    }
453 17e17769 Leszek Koltunski
454 84a17011 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
455 17e17769 Leszek Koltunski
456 84a17011 Leszek Koltunski
  public ObjectShape getObjectShape(int variant)
457
    {
458
    if( variant==0 )
459
      {
460
      int[][] indices = { {0,2,3},{0,1,2},{0,3,1},{4,2,1},{4,1,3},{4,3,2} };
461
      return new ObjectShape(getVertices(variant), indices);
462
      }
463
    else if( variant==1 )
464
      {
465
      int[][] indices = { {1,2,0},{3,1,0},{1,3,2},{3,0,2} };
466
      return new ObjectShape(getVertices(variant), indices);
467
      }
468
    else if( variant==2 )
469
      {
470
      int[][] indices = { {0,1,2},{0,3,1},{0,2,6,4},{2,1,5,6},{3,0,4,7},{1,3,7,5},{6,5,7,4} };
471
      return new ObjectShape(getVertices(variant), indices);
472
      }
473
    else if( variant==3 )
474
      {
475
      int[][] indices = { {0,1,4,3},{0,3,5,2},{2,5,4,1},{0,2,1},{5,3,4} };
476
      return new ObjectShape(getVertices(variant), indices);
477
      }
478
    else if( variant==4 )
479
      {
480
      int[][] indices = { {0,1,4,3},{0,3,5,2},{2,5,4,1},{0,2,1},{5,3,4} };
481
      return new ObjectShape(getVertices(variant), indices);
482
      }
483
    else
484
      {
485
      int[][] indices = { {3,1,2,0},{0,2,6,4},{2,1,5,6},{3,0,4,7},{1,3,7,5},{6,5,7,4} };
486
      return new ObjectShape(getVertices(variant), indices);
487 f8e0d6be Leszek Koltunski
      }
488
    }
489
490
///////////////////////////////////////////////////////////////////////////////////////////////////
491
492
  public ObjectFaceShape getObjectFaceShape(int variant)
493
    {
494 3bf19410 Leszek Koltunski
    float height = isInIconMode() ? 0.001f : 0.03f;
495 4bd1b3d6 Leszek Koltunski
    float internal = 0.02f;
496 17e17769 Leszek Koltunski
    int numL = getNumLayers()[0];
497 3bf19410 Leszek Koltunski
498 f8e0d6be Leszek Koltunski
    if( variant==0 )
499
      {
500 b5cc50ae Leszek Koltunski
      float eV = numL==2 ? 2 : 0;
501 84a17011 Leszek Koltunski
      float[][] bands = { {height,30,0.15f,0.5f,5,1,eV}, {internal,30,0.2f,0.4f,5,1,eV} };
502
      int[] indices   = { 0,0,0,1,1,1 };
503
      return new ObjectFaceShape(bands,indices,null);
504
      }
505
    else if( variant==1 )
506
      {
507
      float eI = numL==2 ? 1 : 0;
508
      float eV = numL==2 ? 1 : 0;
509
      int N = numL==2 ? 5 : 4;
510
      float[][] bands = { {height,30,0.15f,0.5f,N,eI,eV}, {internal,30,0.25f,0.5f,N,eI,eV} };
511
      int[] indices   = { 0,1,1,1 };
512
      return new ObjectFaceShape(bands,indices,null);
513
      }
514
    else if( variant==2 )
515
      {
516
      float[][] bands = { {height,30,0.15f,0.5f,5,1,0}, {internal,30,0.25f,0.5f,5,1,0} };
517
      int[] indices   = { 0,0,1,1,1,1,1 };
518
      return new ObjectFaceShape(bands,indices,null);
519
      }
520
    else if( variant==3 || variant==4 )
521
      {
522
      float[][] bands = { {height,30,0.15f,0.5f,5,0,0}, {internal,30,0.25f,0.5f,4,0,0} };
523
      int[] indices   = { 0,1,1,1,1 };
524
      return new ObjectFaceShape(bands,indices,null);
525
      }
526
    else
527
      {
528
      float[][] bands = { {height,30,0.15f,0.5f,5,0,0}, {internal,30,0.25f,0.5f,3,0,0} };
529
      int[] indices   = { 0,1,1,1,1,1 };
530
      return new ObjectFaceShape(bands,indices,null);
531
      }
532
    }
533
534
///////////////////////////////////////////////////////////////////////////////////////////////////
535
536
  public ObjectVertexEffects getVertexEffects(int variant)
537
    {
538
    int numL = getNumLayers()[0];
539
    float DIST = numL==3 ? DIST3:DIST4;
540
541
    if( variant==0 )
542
      {
543 17e17769 Leszek Koltunski
      float push1 = numL<=3 ? 0.07f : 0.06f;
544
      float push2 = numL<=3 ? 0.06f : 0.05f;
545
      float[][] corners = { {push1,0.025f}, {push2,0.020f} };
546 f8e0d6be Leszek Koltunski
      int[] indices     = { 0,0,0,0,-1 };
547
      float[][] centers = { { 0.0f,0.0f,0.0f } };
548 84a17011 Leszek Koltunski
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
549 f8e0d6be Leszek Koltunski
      }
550 17e17769 Leszek Koltunski
    else if( variant==1 )
551 f8e0d6be Leszek Koltunski
      {
552 17e17769 Leszek Koltunski
      final float C = numL==2 ? 1.0f : numL*(3*DIST-1);
553
      final float Y = (SQ2/2)*C;
554
      final float Z = 0.5f*C;
555
      float[][] corners = { {0.08f,0.013f} };
556 4bd1b3d6 Leszek Koltunski
      int[] indices     = { -1,-1,-1,-1 };
557 f8e0d6be Leszek Koltunski
      float[][] centers = { { 0.0f,-Y/3,-2*Z/3 } };
558 84a17011 Leszek Koltunski
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
559 f8e0d6be Leszek Koltunski
      }
560 17e17769 Leszek Koltunski
    else if( variant==2 )
561
      {
562
      float[][] corners = { {0.07f,0.013f} };
563
      int[] indices     = { 0,0,-1,-1,-1,-1,-1,-1 };
564
      float[][] centers = { { 0.0f,0.0f,0.0f } };
565 84a17011 Leszek Koltunski
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
566 17e17769 Leszek Koltunski
      }
567
    else if( variant==3 || variant==4 )
568
      {
569 84a17011 Leszek Koltunski
      int C = variant==3 ? 0 : -1;
570 17e17769 Leszek Koltunski
      final float Y = (SQ2/4)*numL*(1-2*DIST)/(numL-2);
571
      float[][] corners = { {0.05f,0.023f} };
572 84a17011 Leszek Koltunski
      int[] indices     = { -1,-1,-1,C,C,-1, };
573 17e17769 Leszek Koltunski
      float[][] centers = { { 0.0f,-Y,0.0f } };
574 84a17011 Leszek Koltunski
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
575 17e17769 Leszek Koltunski
      }
576
    else
577
      {
578
      final float Z = numL*(1-2*DIST)/(2*numL-4);
579
      float[][] corners = { {0.02f,0.023f} };
580
      int[] indices     = { 0,0,0,0,-1,-1,-1,-1 };
581
      float[][] centers = { { 0.0f,0.0f,-Z } };
582 84a17011 Leszek Koltunski
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
583 17e17769 Leszek Koltunski
      }
584 f8e0d6be Leszek Koltunski
    }
585
586
///////////////////////////////////////////////////////////////////////////////////////////////////
587
588
  public int getNumCubitVariants(int[] numLayers)
589
    {
590 17e17769 Leszek Koltunski
    switch(numLayers[0])
591
      {
592
      case 2: return 2;
593
      case 3: return 4;
594
      case 4: return 6;
595
      }
596
597
    return 0;
598 f8e0d6be Leszek Koltunski
    }
599
600
///////////////////////////////////////////////////////////////////////////////////////////////////
601
602
  public int getCubitVariant(int cubit, int[] numLayers)
603
    {
604 17e17769 Leszek Koltunski
    switch(numLayers[0])
605
      {
606
      case 2: return cubit<4 ? 0 : 1;
607
      case 3: return cubit<4 ? 0 : ( cubit<8 ? 1: (cubit<14 ? 2:3) );
608
      case 4: return cubit<4 ? 0 : ( cubit<8 ? 1: (cubit<20 ? 2: (cubit<32 ? 3: (cubit<44 ? 4:5) ) ) );
609
      }
610
611
    return 0;
612 f8e0d6be Leszek Koltunski
    }
613
614
///////////////////////////////////////////////////////////////////////////////////////////////////
615
616
  public float getStickerRadius()
617
    {
618
    return 0.10f;
619
    }
620
621
///////////////////////////////////////////////////////////////////////////////////////////////////
622
623
  public float getStickerStroke()
624
    {
625 b5cc50ae Leszek Koltunski
    float stroke = 0.07f;
626
627
    if( isInIconMode() )
628
      {
629
      int[] numLayers = getNumLayers();
630
631
      switch(numLayers[0])
632
        {
633 5d09301e Leszek Koltunski
        case 2: stroke*=1.4f; break;
634
        case 3: stroke*=2.1f; break;
635
        case 4: stroke*=2.5f; break;
636
        default:stroke*=3.2f; break;
637 b5cc50ae Leszek Koltunski
        }
638
      }
639
640
    return stroke;
641 f8e0d6be Leszek Koltunski
    }
642
643
///////////////////////////////////////////////////////////////////////////////////////////////////
644
645
  public float[][] getStickerAngles()
646
    {
647
    return null;
648
    }
649
650
///////////////////////////////////////////////////////////////////////////////////////////////////
651
// PUBLIC API
652
653
  public Static3D[] getRotationAxis()
654
    {
655
    return ROT_AXIS;
656
    }
657
658
///////////////////////////////////////////////////////////////////////////////////////////////////
659
660 beee90ab Leszek Koltunski
  public int[][] getBasicAngles()
661 f8e0d6be Leszek Koltunski
    {
662 beee90ab Leszek Koltunski
    if( mBasicAngle==null )
663
      {
664
      int num = getNumLayers()[0];
665
      int[] tmp = new int[num];
666
      for(int i=0; i<num; i++) tmp[i] = 4;
667
      mBasicAngle = new int[][] { tmp,tmp,tmp };
668
      }
669
670 f8e0d6be Leszek Koltunski
    return mBasicAngle;
671
    }
672
673
///////////////////////////////////////////////////////////////////////////////////////////////////
674
675 5f54927b Leszek Koltunski
  public String getShortName()
676 f8e0d6be Leszek Koltunski
    {
677 17e17769 Leszek Koltunski
    switch(getNumLayers()[0])
678
      {
679
      case 2: return ObjectType.MORP_2.name();
680
      case 3: return ObjectType.MORP_3.name();
681
      case 4: return ObjectType.MORP_4.name();
682
      }
683
    return null;
684 5f54927b Leszek Koltunski
    }
685
686
///////////////////////////////////////////////////////////////////////////////////////////////////
687
688 1d581993 Leszek Koltunski
  public ObjectSignature getSignature()
689 5f54927b Leszek Koltunski
    {
690 17e17769 Leszek Koltunski
    switch(getNumLayers()[0])
691
      {
692 2dffaf22 Leszek Koltunski
      case 2: return new ObjectSignature(ObjectSignatures.MORP_2);
693
      case 3: return new ObjectSignature(ObjectSignatures.MORP_3);
694
      case 4: return new ObjectSignature(ObjectSignatures.MORP_4);
695 17e17769 Leszek Koltunski
      }
696
    return null;
697 f8e0d6be Leszek Koltunski
    }
698
699
///////////////////////////////////////////////////////////////////////////////////////////////////
700
701
  public String getObjectName()
702
    {
703 17e17769 Leszek Koltunski
    switch(getNumLayers()[0])
704
      {
705
      case 2: return "Pyramorphix";
706
      case 3: return "Mastermorphix";
707
      case 4: return "Megamorphix";
708
      }
709
    return null;
710 f8e0d6be Leszek Koltunski
    }
711
712
///////////////////////////////////////////////////////////////////////////////////////////////////
713
714
  public String getInventor()
715
    {
716 17e17769 Leszek Koltunski
    switch(getNumLayers()[0])
717
      {
718
      case 2: return "Manfred Fritsche";
719
      case 3: return "Tony Fisher";
720
      case 4: return "Adam Zamora";
721
      }
722
    return null;
723 f8e0d6be Leszek Koltunski
    }
724
725
///////////////////////////////////////////////////////////////////////////////////////////////////
726
727
  public int getYearOfInvention()
728
    {
729 17e17769 Leszek Koltunski
    switch(getNumLayers()[0])
730
      {
731
      case 2: return 0;
732
      case 3: return 1991;
733
      case 4: return 2004;
734
      }
735 f8e0d6be Leszek Koltunski
    return 0;
736
    }
737
738
///////////////////////////////////////////////////////////////////////////////////////////////////
739
740
  public int getComplexity()
741
    {
742 17e17769 Leszek Koltunski
    switch(getNumLayers()[0])
743
      {
744
      case 2: return 1;
745
      case 3: return 2;
746
      case 4: return 3;
747
      }
748 f8e0d6be Leszek Koltunski
    return 1;
749
    }
750 052e0362 Leszek Koltunski
751
///////////////////////////////////////////////////////////////////////////////////////////////////
752
753
  public String[][] getTutorials()
754
    {
755 17e17769 Leszek Koltunski
    switch(getNumLayers()[0])
756
      {
757
      case 2: return new String[][] {
758 052e0362 Leszek Koltunski
                          {"gb","dD67B3cRaFw","Pyramorphix Solve Tutorial","SpeedCubeReview"},
759
                          {"es","RA37LhYlEW8","Resolver Pyramorphix","Cuby"},
760
                          {"ru","fTNXLAAuGAI","Как собрать Пираморфикс 2х2","Алексей Ярыгин"},
761
                          {"fr","SfEqoud5KRc","Résolution du Pyramorphix","Asthalis"},
762
                          {"de","1VDGoVJZCug","Pyramorphix - Tutorial","GerCubing"},
763 17e17769 Leszek Koltunski
                          {"pl","b7VpuXloBNU","Mastermorphix 2x2 Tutorial PL","MrUK"},
764 052e0362 Leszek Koltunski
                          {"br","wByfDxTrbC8","Como resolver o Pyramorphix","Rafael Cinoto"},
765
                          {"kr","WIy5ZvTXsOY","피라몰픽스 쉽게 맞추기","큐브놀이터"},
766 a399e91b Leszek Koltunski
                          {"vn","6CuTRLjKHho","Tutorial N.14 - Pyramorphix","Duy Thích Rubik"},
767 052e0362 Leszek Koltunski
                         };
768 17e17769 Leszek Koltunski
      case 3: return new String[][] {
769
                          {"gb","Q1DXmDGyebc","How to Solve the Mastermorphix","Z3"},
770
                          {"es","8kOuV-O4jGA","Resolver Mastermorphix 3x3","Cuby"},
771
                          {"ru","hs5jZee0XUo","Как собрать Мастерморфикс 3х3","Алексей Ярыгин"},
772
                          {"fr","73j0APwbWzc","Résolution du Mastermorphix","Asthalis"},
773
                          {"de","gbo7yTTHx5A","Mastermorphix - Tutorial","GerCubing"},
774
                          {"pl","_ZgduvWVx14","Mastermorphix Tutorial PL","MrUK"},
775
                          {"br","bFJjjWPsDoY","Mastermorphix - tutorial","Cubo da Loucura"},
776
                          {"kr","yKW48BaE91M","마스터 몰픽스 해법","듀나메스 큐브 해법연구소"},
777
                          {"vn","QcJ7E8_Duws","Giải Rubik - Mastermorphix","Duy Thích Rubik"},
778
                         };
779
      case 4: return new String[][] {
780
                          {"gb","su4ELv85wiY","Megamorphix Tutorial","CrazyBadCuber"},
781
                          {"es","riQY9fdspbI","Megamorphix del rubikeo","Tutoriales Rubik"},
782
                          {"ru","ZE_zPegnYTY","Как собрать Мастерморфикс 4х4","Алексей Ярыгин"},
783
                          {"fr","oLjjky1QCaA","Résolution du Megamorphix","Asthalis"},
784
                          {"pl","pF_9SaFI_fg","Mastermorphix 4x4 Tutorial PL","MrUK"},
785
                          {"br","J_V0TNDBc-M","Megamorphix Walkthrough Solve","cubo vicio"},
786
                          {"vn","20T2dIHZWHk","Megamorphix 4x4 tutorial","VĂN CÔNG TÙNG"},
787
                         };
788
      }
789
    return null;
790 052e0362 Leszek Koltunski
    }
791 f8e0d6be Leszek Koltunski
}