Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyTrajber.java @ 1d581993

1 4a566e21 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19
20
package org.distorted.objectlib.objects;
21
22
import org.distorted.library.type.Static3D;
23
import org.distorted.library.type.Static4D;
24 3ee1d662 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectFaceShape;
25 4a566e21 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectShape;
26 1d581993 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectSignature;
27 10b7e306 Leszek Koltunski
import org.distorted.objectlib.scrambling.ScrambleState;
28 4a566e21 Leszek Koltunski
import org.distorted.objectlib.main.ObjectType;
29
import org.distorted.objectlib.main.ShapeOctahedron;
30
import org.distorted.objectlib.touchcontrol.TouchControlOctahedron;
31
32
import java.io.InputStream;
33
34
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_OCTAHEDRON;
35
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
36
37
///////////////////////////////////////////////////////////////////////////////////////////////////
38
39
public class TwistyTrajber extends ShapeOctahedron
40
{
41 8d96b92f Leszek Koltunski
  // Trajber 3x3: each cut is at 1/5 of the length of the segment from the center to a vertex.
42
  private static final float CUT3 = 0.20f;
43 e13456ed Leszek Koltunski
  // Trajber 4x4: each cut is at 0.27 of the length of the segment from the center to a vertex.
44
  private static final float CUT4 = 0.27f;
45 4a566e21 Leszek Koltunski
46
  static final Static3D[] ROT_AXIS = new Static3D[]
47
         {
48 26d73f43 Leszek Koltunski
         new Static3D(SQ2/2, 0, SQ2/2),
49
         new Static3D(    0, 1,     0),
50
         new Static3D(SQ2/2, 0,-SQ2/2)
51 4a566e21 Leszek Koltunski
         };
52
53
  private ScrambleState[] mStates;
54 beee90ab Leszek Koltunski
  private int[][] mBasicAngle;
55 4a566e21 Leszek Koltunski
  private float[][] mCuts;
56 82e62580 Leszek Koltunski
  private float[][] mPositions;
57 d0e6cf7f Leszek Koltunski
  private int[] mQuatIndex;
58 4a566e21 Leszek Koltunski
59
///////////////////////////////////////////////////////////////////////////////////////////////////
60
61 3bf19410 Leszek Koltunski
  public TwistyTrajber(int[] numL, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
62 4a566e21 Leszek Koltunski
    {
63 3bf19410 Leszek Koltunski
    super(numL, meshState, iconMode, numL[0], quat, move, scale, stream);
64 4a566e21 Leszek Koltunski
    }
65
66
///////////////////////////////////////////////////////////////////////////////////////////////////
67 e13456ed Leszek Koltunski
68
  @Override
69 690557d9 Leszek Koltunski
  public int[][] getSolvedQuats()
70 e13456ed Leszek Koltunski
    {
71 690557d9 Leszek Koltunski
    int[] numLayers = getNumLayers();
72
    int numL = numLayers[0];
73
74
    if( numL==3 )
75
      {
76
      return super.getSolvedQuats();
77
      }
78
    else
79
      {
80
      // special SolvedQuats for the case where there are no corner of edge cubits.
81
      // first row {0} - means there are no corners or edges.
82
      // each next defines all cubits of a singe face
83
      // (numCubits, firstCubit, cubit1,..,cubitN-1, quat0,..., quatM)
84
85
      return new int[][] {
86
                           {0},
87
                           {7, 0, 8,20,26,34,41,49, 10,23},
88
                           {7, 4,13,16,29,37,47,54, 10,23},
89
                           {7, 5, 9,17,25,36,45,52, 13,20},
90
                           {7, 1,12,21,30,35,43,51, 13,20},
91
                           {7, 6,11,23,27,38,44,53, 12,22},
92
                           {7, 2,14,19,28,33,42,50, 12,22},
93
                           {7, 3,10,18,24,32,40,48, 15,21},
94
                           {7, 7,15,22,31,39,46,55, 15,21},
95
                         };
96
      }
97 e13456ed Leszek Koltunski
    }
98
99
///////////////////////////////////////////////////////////////////////////////////////////////////
100 4a566e21 Leszek Koltunski
101
  public ScrambleState[] getScrambleStates()
102
    {
103
    if( mStates==null )
104
      {
105
      int[][] m = new int[16][];
106
107 26d73f43 Leszek Koltunski
      for(int i=0; i<16; i++) m[i] = new int[] { 0,-1,i,0,1,i,0,2,i, 1,-1,i,1,1,i,1,2,i, 2,-1,i,2,1,i,2,2,i};
108 4a566e21 Leszek Koltunski
109
      mStates = new ScrambleState[]
110
          {
111
          new ScrambleState( new int[][] { m[ 1], m[ 2], m[ 3] } ),  //  0 0
112
          new ScrambleState( new int[][] {  null, m[ 4], m[ 5] } ),  //  1 x
113
          new ScrambleState( new int[][] { m[ 6],  null, m[ 7] } ),  //  2 y
114
          new ScrambleState( new int[][] { m[ 8], m[ 9],  null } ),  //  3 z
115
          new ScrambleState( new int[][] { m[10],  null, m[ 7] } ),  //  4 xy
116
          new ScrambleState( new int[][] { m[11], m[ 9],  null } ),  //  5 xz
117
          new ScrambleState( new int[][] {  null, m[12], m[ 5] } ),  //  6 yx
118
          new ScrambleState( new int[][] { m[ 8], m[13],  null } ),  //  7 yz
119
          new ScrambleState( new int[][] {  null, m[ 4], m[14] } ),  //  8 zx
120
          new ScrambleState( new int[][] { m[ 6],  null, m[15] } ),  //  9 zy
121
          new ScrambleState( new int[][] {  null,  null, m[ 5] } ),  // 10 xyx
122
          new ScrambleState( new int[][] {  null, m[ 4],  null } ),  // 11 xzx
123
          new ScrambleState( new int[][] {  null,  null, m[ 7] } ),  // 12 yxy
124
          new ScrambleState( new int[][] { m[ 6],  null,  null } ),  // 13 yzy
125
          new ScrambleState( new int[][] {  null, m[ 9],  null } ),  // 14 zxz
126
          new ScrambleState( new int[][] { m[ 8],  null,  null } ),  // 15 zyz
127
          };
128
      }
129
130
    return mStates;
131
    }
132
133
///////////////////////////////////////////////////////////////////////////////////////////////////
134
135
  public float[][] getCuts(int[] numLayers)
136
    {
137
    if( mCuts==null )
138
      {
139 8d96b92f Leszek Koltunski
      float[] tmp;
140
141
      if( numLayers[0]==3 )
142
        {
143
        final float cut= CUT3*numLayers[0]*SQ2/2;
144
        tmp = new float[] {-cut,+cut};
145
        }
146
      else
147
        {
148
        final float cut= CUT4*numLayers[0]*SQ2/2;
149
        tmp = new float[] {-cut,0,+cut};
150
        }
151
152
      mCuts = new float[][] { tmp,tmp,tmp };
153 4a566e21 Leszek Koltunski
      }
154
155
    return mCuts;
156
    }
157
158
///////////////////////////////////////////////////////////////////////////////////////////////////
159
160
  public boolean[][] getLayerRotatable(int[] numLayers)
161
    {
162 8d96b92f Leszek Koltunski
    int numL = numLayers[0];
163
    boolean[] tmp = new boolean[numL];
164
    for(int i=0; i<numL; i++) tmp[i] = true;
165 ada5bca1 Leszek Koltunski
    return new boolean[][] { tmp,tmp,tmp };
166 4a566e21 Leszek Koltunski
    }
167
168
///////////////////////////////////////////////////////////////////////////////////////////////////
169
170
  public int getTouchControlType()
171
    {
172
    return TC_OCTAHEDRON;
173
    }
174
175
///////////////////////////////////////////////////////////////////////////////////////////////////
176
177
  public int getTouchControlSplit()
178
    {
179
    return TYPE_NOT_SPLIT;
180
    }
181
182 26d73f43 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
183
184
  public int[][][] getEnabled()
185
    {
186
    return new int[][][]
187
      {
188
          {{0,1,2}},{{0,1,2}},{{0,1,2}},{{0,1,2}},{{0,1,2}},{{0,1,2}},{{0,1,2}},{{0,1,2}}
189
      };
190
    }
191
192 4a566e21 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
193
194
  public float[] getDist3D(int[] numLayers)
195
    {
196 4c9ca251 Leszek Koltunski
    return TouchControlOctahedron.D3D;
197
    }
198
199
///////////////////////////////////////////////////////////////////////////////////////////////////
200
201
  public Static3D[] getFaceAxis()
202
    {
203
    return TouchControlOctahedron.FACE_AXIS;
204 4a566e21 Leszek Koltunski
    }
205
206
///////////////////////////////////////////////////////////////////////////////////////////////////
207
208
  public float[][] getCubitPositions(int[] numLayers)
209
    {
210 82e62580 Leszek Koltunski
    if( mPositions==null )
211 4a566e21 Leszek Koltunski
      {
212 e13456ed Leszek Koltunski
      int numL = numLayers[0];
213
      float LEN = numL*0.5f;
214 8d96b92f Leszek Koltunski
215 e13456ed Leszek Koltunski
      if( numL==3 )
216
        {
217 82e62580 Leszek Koltunski
        mPositions = new float[][]
218 e13456ed Leszek Koltunski
            {
219 ecc01591 Leszek Koltunski
              {  -LEN,       0,   LEN},
220
              {   LEN,       0,  -LEN},
221 26d73f43 Leszek Koltunski
              {   LEN,       0,   LEN},
222
              {  -LEN,       0,  -LEN},
223
              {     0, SQ2*LEN,     0},
224
              {     0,-SQ2*LEN,     0},
225
226
              {     0,     0,   LEN},
227 4a566e21 Leszek Koltunski
              {   LEN,     0,     0},
228
              {  -LEN,     0,     0},
229
              {     0,     0,  -LEN},
230 ecc01591 Leszek Koltunski
              {-LEN/2, (SQ2/2)*LEN, LEN/2},
231
              { LEN/2, (SQ2/2)*LEN,-LEN/2},
232
              {-LEN/2,-(SQ2/2)*LEN, LEN/2},
233
              { LEN/2,-(SQ2/2)*LEN,-LEN/2},
234 26d73f43 Leszek Koltunski
              { LEN/2, (SQ2/2)*LEN, LEN/2},
235
              { LEN/2,-(SQ2/2)*LEN, LEN/2},
236
              {-LEN/2, (SQ2/2)*LEN,-LEN/2},
237
              {-LEN/2,-(SQ2/2)*LEN,-LEN/2},
238
239
              {       0, SQ2*LEN/3, 2*LEN/3},
240
              { 2*LEN/3, SQ2*LEN/3,       0},
241
              {       0,-SQ2*LEN/3, 2*LEN/3},
242
              { 2*LEN/3,-SQ2*LEN/3,       0},
243
              {-2*LEN/3, SQ2*LEN/3,       0},
244
              {       0, SQ2*LEN/3,-2*LEN/3},
245
              {-2*LEN/3,-SQ2*LEN/3,       0},
246
              {       0,-SQ2*LEN/3,-2*LEN/3},
247 e13456ed Leszek Koltunski
            };
248
        }
249
      else
250
        {
251 674d5592 Leszek Koltunski
        final float A = 0.5f*SQ2*CUT4*LEN;
252 e13456ed Leszek Koltunski
        final float B =     CUT4*LEN;
253
        final float C = CUT4/2;
254
        final float D =-1.5f*C+0.5f;
255
        final float E = 0.5f*C+0.5f;
256
        final float F = (SQ2/2)*(1-C);
257
        final float G = C*SQ2;
258
        final float H = 1-C;
259 674d5592 Leszek Koltunski
        final float I = LEN-0.5f*B;
260
        final float J = SQ2*(LEN-B);
261 e13456ed Leszek Koltunski
262 82e62580 Leszek Koltunski
        mPositions = new float[][]
263 e13456ed Leszek Koltunski
            {
264 ecc01591 Leszek Koltunski
              {  -I+B,  A,  I   },
265
              {  -I+B, -A,  I   },
266
              {   I  ,  A, -I+B },
267
              {   I  , -A, -I+B },
268
              {   I-B, -A, -I   },
269
              {   I-B,  A, -I   },
270 674d5592 Leszek Koltunski
              {   I  ,  A,  I-B },
271
              {   I  , -A,  I-B },
272
              {   I-B, -A,  I   },
273
              {   I-B,  A,  I   },
274
              {  -I  , -A, -I+B },
275
              {  -I  ,  A, -I+B },
276
              {  -I+B,  A, -I   },
277
              {  -I+B, -A, -I   },
278
              {     B,  J,  0   },
279
              {    -B,  J,  0   },
280
              {     0,  J,  B   },
281
              {     0,  J, -B   },
282
              {     B, -J,  0   },
283
              {    -B, -J,  0   },
284
              {     0, -J,  B   },
285
              {     0, -J, -B   },
286
              {  -I  , -A,  I-B },
287
              {  -I  ,  A,  I-B },
288 e13456ed Leszek Koltunski
289
              {     0, G*LEN, H*LEN},
290
              {     0,-G*LEN, H*LEN},
291
              { H*LEN, G*LEN,     0},
292
              { H*LEN,-G*LEN,     0},
293
              {-H*LEN, G*LEN,     0},
294
              {-H*LEN,-G*LEN,     0},
295
              {     0, G*LEN,-H*LEN},
296
              {     0,-G*LEN,-H*LEN},
297
298 ecc01591 Leszek Koltunski
              {-D*LEN, F*LEN, E*LEN },
299
              {-E*LEN, F*LEN, D*LEN },
300
              { E*LEN, F*LEN,-D*LEN},
301
              { D*LEN, F*LEN,-E*LEN},
302
              {-D*LEN,-F*LEN, E*LEN },
303
              {-E*LEN,-F*LEN, D*LEN },
304
              { E*LEN,-F*LEN,-D*LEN},
305
              { D*LEN,-F*LEN,-E*LEN},
306
307 e13456ed Leszek Koltunski
              {+D*LEN, F*LEN,+E*LEN},
308
              {+E*LEN, F*LEN,+D*LEN},
309
              {+D*LEN,-F*LEN,+E*LEN},
310
              {+E*LEN,-F*LEN,+D*LEN},
311
              {-D*LEN, F*LEN,-E*LEN},
312
              {-E*LEN, F*LEN,-D*LEN},
313
              {-D*LEN,-F*LEN,-E*LEN},
314
              {-E*LEN,-F*LEN,-D*LEN},
315
316
              {       0, SQ2*LEN/3, 2*LEN/3},
317
              { 2*LEN/3, SQ2*LEN/3,       0},
318
              {       0,-SQ2*LEN/3, 2*LEN/3},
319
              { 2*LEN/3,-SQ2*LEN/3,       0},
320
              {-2*LEN/3, SQ2*LEN/3,       0},
321
              {       0, SQ2*LEN/3,-2*LEN/3},
322
              {-2*LEN/3,-SQ2*LEN/3,       0},
323
              {       0,-SQ2*LEN/3,-2*LEN/3},
324
            };
325
        }
326 4a566e21 Leszek Koltunski
      }
327
328 82e62580 Leszek Koltunski
    return mPositions;
329 4a566e21 Leszek Koltunski
    }
330
331 d0e6cf7f Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
332
333
  public Static4D getCubitQuats(int cubit, int[] numLayers)
334
    {
335 e13456ed Leszek Koltunski
    if( mQuatIndex==null )
336
      {
337
      if( numLayers[0]==3 )
338
        {
339 ecc01591 Leszek Koltunski
        mQuatIndex = new int[] { 0, 2, 6, 4, 1, 3,
340
                                 0, 2, 8, 5, 7,19, 9,18, 1, 3,14,11,
341 e13456ed Leszek Koltunski
                                 0, 1, 3, 2, 7, 5, 8,16 };
342
        }
343
      else
344
        {
345 ecc01591 Leszek Koltunski
        mQuatIndex = new int[] { 0, 9,19, 2,18, 5, 6,12,17,21,20, 4,10,16, 1,14,15,13,23,22, 3,11, 8, 7,
346
                                 0,17, 6, 2, 4, 8, 5,16,15, 7,19,13, 9,22,23,18,21, 1, 3,12,10,14,11,20,
347 e13456ed Leszek Koltunski
                                 0, 1, 3, 2, 7, 5, 8,16 };
348
        }
349
      }
350
351 ada5bca1 Leszek Koltunski
    return mObjectQuats[mQuatIndex[cubit]];
352 d0e6cf7f Leszek Koltunski
    }
353
354 4a566e21 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
355
356
  public ObjectShape getObjectShape(int variant)
357
    {
358 e13456ed Leszek Koltunski
    float numL = getNumLayers()[0];
359
    final float LEN = numL*0.5f;
360
    final float CUT = numL==3 ? CUT3 : CUT4;
361
362 4a566e21 Leszek Koltunski
    if( variant==0 )
363
      {
364 e13456ed Leszek Koltunski
      final float A = SQ2*CUT*LEN;
365
      final float B =     CUT*LEN;
366 4a566e21 Leszek Koltunski
367 e13456ed Leszek Koltunski
      float[][] vertices = numL==3 ?
368
369
        new float[][]
370 4a566e21 Leszek Koltunski
          {
371
             {    0,    0,    0},
372 26d73f43 Leszek Koltunski
             {    B,    A,   -B},
373
             {    B,   -A,   -B},
374
             {  2*B,    0,    0},
375
             {    0,    0, -2*B},
376
             {  3*B,    A,   -B},
377
             {  3*B,   -A,   -B},
378
             {    B,    A, -3*B},
379
             {    B,   -A, -3*B},
380
381 674d5592 Leszek Koltunski
             {  LEN    ,  A, 2*B-LEN},
382
             {  LEN    , -A, 2*B-LEN},
383
             {  LEN-2*B,  A,    -LEN},
384
             {  LEN-2*B, -A,    -LEN},
385 e13456ed Leszek Koltunski
          }
386
        :
387
        new float[][]
388
          {
389
             {  -1.5f*B,  -0.5f*A,  0.5f*B},
390
             {  -0.5f*B,   0.5f*A, -0.5f*B},
391
             {   0.5f*B,  -0.5f*A,  0.5f*B},
392
             {   1.5f*B,   0.5f*A, -0.5f*B},
393
394 674d5592 Leszek Koltunski
             {  LEN-1.5f*B,  0.5f*A, 2.5f*B-LEN},
395
             {  LEN-2.5f*B,  0.5f*A, 1.5f*B-LEN},
396
             {  LEN-2.5f*B, -0.5f*A, 1.5f*B-LEN},
397
             {  LEN-1.5f*B, -0.5f*A, 2.5f*B-LEN},
398 4a566e21 Leszek Koltunski
          };
399
400 e13456ed Leszek Koltunski
      int[][] indices = numL==3 ?
401
402
        new int[][]
403 4a566e21 Leszek Koltunski
          {
404
             {0,3,5,1},
405
             {0,2,6,3},
406
             {0,4,8,2},
407
             {0,1,7,4},
408
             {3,6,10,9,5},
409
             {2,8,12,10,6},
410
             {4,7,11,12,8},
411
             {1,5,9,11,7},
412
             {9,10,12,11}
413 e13456ed Leszek Koltunski
          }
414
        :
415
        new int[][]
416
          {
417
             {0,2,3,1},
418
             {2,7,4,3},
419
             {3,4,5,1},
420
             {0,1,5,6},
421
             {0,6,7,2},
422
             {7,6,5,4}
423 4a566e21 Leszek Koltunski
          };
424
425 59a971c1 Leszek Koltunski
      return new ObjectShape(vertices, indices);
426 4a566e21 Leszek Koltunski
      }
427
    if( variant==1 )
428
      {
429 e13456ed Leszek Koltunski
      final float A = SQ2*CUT*LEN;
430
      final float B = LEN*(1-2*CUT);
431 376f605e Leszek Koltunski
      final float C = (SQ2/2)*A;
432 4a566e21 Leszek Koltunski
433 e13456ed Leszek Koltunski
      float[][] vertices = numL==3 ?
434
435
        new float[][]
436 4a566e21 Leszek Koltunski
          {
437 376f605e Leszek Koltunski
             {    -B, 0,  0 },
438
             {  -B+C, A, -C },
439
             {  -B+C,-A, -C },
440
             {     B, 0,  0 },
441
             {   B-C, A, -C },
442
             {   B-C,-A, -C },
443
             {     0, A, -B },
444
             {     0,-A, -B },
445 e13456ed Leszek Koltunski
          }
446
        :
447
        new float[][]
448
          {
449
             {    -B, -0.5f*A,    C/2 },
450
             {  -B+C, +0.5f*A,   -C/2 },
451
             {     B, -0.5f*A,    C/2 },
452
             {   B-C, +0.5f*A,   -C/2 },
453
             {     0, +0.5f*A, -B+C/2 },
454
             {     0, -0.5f*A, -B+C/2 }
455 4a566e21 Leszek Koltunski
          };
456
457 e13456ed Leszek Koltunski
      int[][] indices = numL==3 ?
458
459
        new int[][]
460 4a566e21 Leszek Koltunski
          {
461
             {0,3,4,1},
462
             {0,2,5,3},
463
             {1,4,6},
464
             {2,7,5},
465
             {0,1,6,7,2},
466
             {3,5,7,6,4}
467 e13456ed Leszek Koltunski
          }
468
        :
469
        new int[][]
470
          {
471
             {0,2,3,1},
472
             {1,3,4},
473
             {0,5,2},
474
             {0,1,4,5},
475
             {2,5,4,3}
476 4a566e21 Leszek Koltunski
          };
477
478 59a971c1 Leszek Koltunski
      return new ObjectShape(vertices, indices);
479 4a566e21 Leszek Koltunski
      }
480
    else
481
      {
482 e13456ed Leszek Koltunski
      final float L = LEN*(1-3*CUT);
483 4a566e21 Leszek Koltunski
484 4e9f2df5 Leszek Koltunski
      float[][] vertices =
485 4a566e21 Leszek Koltunski
          {
486 26d73f43 Leszek Koltunski
             { -L, -(SQ2/3)*L,   L/3 },
487
             {  L, -(SQ2/3)*L,   L/3 },
488
             {  0,(2*SQ2/3)*L,-2*L/3 },
489
             {  0, -(SQ2/3)*L,-2*L/3 },
490 4a566e21 Leszek Koltunski
          };
491
492 4e9f2df5 Leszek Koltunski
      int[][] indices =
493 4a566e21 Leszek Koltunski
          {
494
             {0,1,2},
495 846b69f3 Leszek Koltunski
             {3,1,0},
496 4a566e21 Leszek Koltunski
             {0,2,3},
497
             {1,3,2},
498
          };
499
500 59a971c1 Leszek Koltunski
      return new ObjectShape(vertices, indices);
501 3ee1d662 Leszek Koltunski
      }
502
    }
503
504
///////////////////////////////////////////////////////////////////////////////////////////////////
505
506
  public ObjectFaceShape getObjectFaceShape(int variant)
507
    {
508 e13456ed Leszek Koltunski
    int numL = getNumLayers()[0];
509
    final float LEN = numL*0.5f;
510
    final float CUT = numL==3 ? CUT3 : CUT4;
511 8d96b92f Leszek Koltunski
512 3ee1d662 Leszek Koltunski
    if( variant==0 )
513
      {
514 3bf19410 Leszek Koltunski
      float height = isInIconMode() ? 0.001f : 0.05f;
515
      float[][] bands   = { {height,35,0.15f,0.3f,4,1,1},{0.001f,35,0.15f,0.3f,4,1,1} };
516 e13456ed Leszek Koltunski
      float[][] corners = { {0.03f,0.10f} };
517
      float[][] centers = { { LEN/2, 0.0f, -LEN/2} };
518
      int[] bandIndices = numL==3 ? new int[] { 0,0,0,0,1,1,1,1,1 } : new int[] { 0,1,1,1,1,1 };
519
      int[] indices     = numL==3 ? new int[] { 0,-1,-1,-1,-1,0,0,0,0,-1,-1,-1,-1 } : new int[] { 0,0,0,-1,-1,-1,-1,-1 };
520
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
521 3ee1d662 Leszek Koltunski
      }
522
    if( variant==1 )
523
      {
524 3bf19410 Leszek Koltunski
      float height = isInIconMode() ? 0.001f : 0.03f;
525 e13456ed Leszek Koltunski
      final float B = LEN*(1-2*CUT);
526 3bf19410 Leszek Koltunski
      float[][] bands   = { {height,35,0.15f,0.3f,3,1,1},{0.001f,35,0.15f,0.3f,3,1,1} };
527 e13456ed Leszek Koltunski
      float[][] corners = { {0.02f,0.10f} };
528
      float[][] centers = { { 0, 0, -B} };
529
      int[] bandIndices = numL==3 ? new int[] { 0,0,1,1,1,1 }       : new int[] { 0,1,1,1,1 };
530
      int[] indices     = numL==3 ? new int[] { 0,0,0,0,0,0,-1,-1 } : new int[] { 0,0,0,0,-1,-1 };
531
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
532 3ee1d662 Leszek Koltunski
      }
533
    else
534
      {
535 3bf19410 Leszek Koltunski
      float height = isInIconMode() ? 0.001f : 0.03f;
536 e13456ed Leszek Koltunski
      final float L = LEN*(1-3*CUT);
537 3bf19410 Leszek Koltunski
      float[][] bands   = { {height,35,0.15f,0.3f,4,1,1},{0.001f,35,0.15f,0.3f,4,0,0} };
538 e13456ed Leszek Koltunski
      float[][] corners = { {0.02f,0.10f} };
539
      float[][] centers = { {0, -(SQ2/3)*L,-2*L/3} };
540
      int[] bandIndices = { 0,1,1,1 };
541
      int[] indices     = { 0,0,0,-1 };
542
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
543 4a566e21 Leszek Koltunski
      }
544
    }
545
546
///////////////////////////////////////////////////////////////////////////////////////////////////
547
548
  public int getNumCubitVariants(int[] numLayers)
549
    {
550
    return 3;
551
    }
552
553
///////////////////////////////////////////////////////////////////////////////////////////////////
554
555
  public int getCubitVariant(int cubit, int[] numLayers)
556
    {
557 8d96b92f Leszek Koltunski
    if( numLayers[0]==3 ) return cubit< 6 ? 0 : cubit<18 ? 1 : 2;
558
    else                  return cubit<24 ? 0 : cubit<48 ? 1 : 2;
559 4a566e21 Leszek Koltunski
    }
560
561 d53fb890 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
562 4a566e21 Leszek Koltunski
563 d53fb890 Leszek Koltunski
  public float getStickerRadius()
564
    {
565
    return 0.12f;
566
    }
567
568
///////////////////////////////////////////////////////////////////////////////////////////////////
569
570
  public float getStickerStroke()
571
    {
572 3bf19410 Leszek Koltunski
    return isInIconMode() ? 0.20f : 0.10f;
573 d53fb890 Leszek Koltunski
    }
574
575
///////////////////////////////////////////////////////////////////////////////////////////////////
576
577
  public float[][] getStickerAngles()
578
    {
579
    return null;
580 4a566e21 Leszek Koltunski
    }
581
582
///////////////////////////////////////////////////////////////////////////////////////////////////
583
// PUBLIC API
584
585
  public Static3D[] getRotationAxis()
586
    {
587
    return ROT_AXIS;
588
    }
589
590
///////////////////////////////////////////////////////////////////////////////////////////////////
591
592 beee90ab Leszek Koltunski
  public int[][] getBasicAngles()
593 4a566e21 Leszek Koltunski
    {
594 beee90ab Leszek Koltunski
    if( mBasicAngle ==null )
595
      {
596
      int num = getNumLayers()[0];
597
      int[] tmp = new int[num];
598
      for(int i=0; i<num; i++) tmp[i] = 4;
599
      mBasicAngle = new int[][] { tmp,tmp,tmp };
600
      }
601
602 4a566e21 Leszek Koltunski
    return mBasicAngle;
603
    }
604
605
///////////////////////////////////////////////////////////////////////////////////////////////////
606
607 5f54927b Leszek Koltunski
  public String getShortName()
608 4a566e21 Leszek Koltunski
    {
609 8d96b92f Leszek Koltunski
    int[] numLayers = getNumLayers();
610
    return numLayers[0]==3 ? ObjectType.TRAJ_3.name() : ObjectType.TRAJ_4.name();
611 5f54927b Leszek Koltunski
    }
612
613
///////////////////////////////////////////////////////////////////////////////////////////////////
614
615 1d581993 Leszek Koltunski
  public ObjectSignature getSignature()
616 5f54927b Leszek Koltunski
    {
617 8d96b92f Leszek Koltunski
    int[] numLayers = getNumLayers();
618 1d581993 Leszek Koltunski
619
    switch(numLayers[0])
620
      {
621
      case 3: return new ObjectSignature(ObjectType.TRAJ_3);
622
      case 4: return new ObjectSignature(ObjectType.TRAJ_4);
623
      }
624
625
    return null;
626 4a566e21 Leszek Koltunski
    }
627
628
///////////////////////////////////////////////////////////////////////////////////////////////////
629
630
  public String getObjectName()
631
    {
632 8d96b92f Leszek Koltunski
    int[] numLayers = getNumLayers();
633 1d581993 Leszek Koltunski
634
    switch(numLayers[0])
635
      {
636
      case 3: return "Trajber's Octahedron";
637
      case 4: return "Trajber 4x4";
638
      }
639
640
    return null;
641 4a566e21 Leszek Koltunski
    }
642
643
///////////////////////////////////////////////////////////////////////////////////////////////////
644
645
  public String getInventor()
646
    {
647 8d96b92f Leszek Koltunski
    int[] numLayers = getNumLayers();
648 1d581993 Leszek Koltunski
649
    switch(numLayers[0])
650
      {
651
      case 3: return "Josef Trajber";
652
      case 4: return "Jürgen Brandt";
653
      }
654
655
    return null;
656 4a566e21 Leszek Koltunski
    }
657
658
///////////////////////////////////////////////////////////////////////////////////////////////////
659
660
  public int getYearOfInvention()
661
    {
662 8d96b92f Leszek Koltunski
    int[] numLayers = getNumLayers();
663
    return numLayers[0]==3 ? 1982 : 2001;
664 4a566e21 Leszek Koltunski
    }
665
666
///////////////////////////////////////////////////////////////////////////////////////////////////
667
668
  public int getComplexity()
669
    {
670 8d96b92f Leszek Koltunski
    int[] numLayers = getNumLayers();
671
    return numLayers[0]==3 ? 2 : 3;
672 4a566e21 Leszek Koltunski
    }
673 052e0362 Leszek Koltunski
674
///////////////////////////////////////////////////////////////////////////////////////////////////
675
676
  public String[][] getTutorials()
677
    {
678 8d96b92f Leszek Koltunski
    int[] numLayers = getNumLayers();
679
680
    switch(numLayers[0])
681
      {
682
      case 3: return new String[][] {
683
                                     {"gb","Q2NSiuJWVvk","Trajber and UFO Tutorial","SuperAntoniovivaldi"},
684
                                     {"es","FPBirEJ8ZfY","Resolver Octaedro 3x3","Solución Rubik"},
685
                                     {"de","FjQXlwJGniQ","Trajbers Octahedron Tutorial","GerCubing"},
686
                                     {"br","kO3nMpZKv3Q","Resolver Octaedro Trajber","Rafael Cinoto"},
687
                                    };
688
      case 4: return new String[][] {
689 2addda73 Leszek Koltunski
                                     {"gb","FZlw68I7snM","4x4 Trajber's Tutorial (1/2)","SuperAntoniovivaldi"},
690
                                     {"gb","VM0XFu7gAII","4x4 Trajber's Tutorial (2/2)","SuperAntoniovivaldi"},
691 8d96b92f Leszek Koltunski
                                     {"es","Q8ljV-feLpU","Tutorial Octaedro 4x4 (1/2)","Dany Cuber"},
692
                                     {"es","QyWpDLa1eZQ","Tutorial Octaedro 4x4 (2/2)","Dany Cuber"},
693
                                     {"ru","ikUogVow-58","Как собрать Октаэдр 4х4","RBcuber"},
694
                                     {"fr","4hxZyMVGiTA","Résolution de l'Octaèdre 4x4","asthalis"},
695
                                     {"pl","oPBvAT9lwt4","Octahedron 4x4 TUTORIAL PL","MrUK"},
696
                                     {"br","0ZgaoQ6IS2w","Resolver o octaedro Trajber 4x4 (1/3)","Rafael Cinoto"},
697
                                     {"br","TjxTx3IJy6M","Resolver o octaedro Trajber 4x4 (2/3)","Rafael Cinoto"},
698
                                     {"br","E8k2TXfUS8g","Resolver o octaedro Trajber 4x4 (3/3)","Rafael Cinoto"},
699
                                     {"vn","yorULpIm6Yw","Tutorial N.22 - Octahedron 4x4","Duy Thích Rubik"},
700
                                    };
701
      }
702
703
    return null;
704 052e0362 Leszek Koltunski
    }
705 4a566e21 Leszek Koltunski
}