Project

General

Profile

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

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

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