Project

General

Profile

« Previous | Next » 

Revision b00a0004

Added by Leszek Koltunski almost 2 years ago

Minor correction.

View differences:

src/main/java/org/distorted/objectlib/main/ObjectType.java
79 79
  SKEW_3 ( TwistySkewb.class         , 21, R.drawable.skew_3, true, new InitData(new int[] {3,3,3,3})),
80 80
  CONT_2 ( TwistyContainer.class     , 12, R.drawable.cont_2, true, new InitData(new int[] {2,2,2,2})),
81 81

  
82
  CRA1_3 ( TwistyCrazy.class         , 22, R.drawable.cra1_3, true, new InitData(new int[] {3,3,3}, TwistyCrazy.CRAZY  )),
83
  CRA2_3 ( TwistyCrazy.class         , 22, R.drawable.cra1_3, true, new InitData(new int[] {3,3,3}, TwistyCrazy.MERCURY)),
84
  CRA3_3 ( TwistyCrazy.class         , 22, R.drawable.cra1_3, true, new InitData(new int[] {3,3,3}, TwistyCrazy.VENUS  )),
85
  CRA4_3 ( TwistyCrazy.class         , 22, R.drawable.cra1_3, true, new InitData(new int[] {3,3,3}, TwistyCrazy.EARTH  )),
86
  CRA5_3 ( TwistyCrazy.class         , 22, R.drawable.cra1_3, true, new InitData(new int[] {3,3,3}, TwistyCrazy.MARS   )),
87
  CRA6_3 ( TwistyCrazy.class         , 22, R.drawable.cra1_3, true, new InitData(new int[] {3,3,3}, TwistyCrazy.JUPITER)),
88
  CRA7_3 ( TwistyCrazy.class         , 22, R.drawable.cra1_3, true, new InitData(new int[] {3,3,3}, TwistyCrazy.SATURN )),
89
  CRA8_3 ( TwistyCrazy.class         , 22, R.drawable.cra1_3, true, new InitData(new int[] {3,3,3}, TwistyCrazy.URANUS )),
90
  CRA9_3 ( TwistyCrazy.class         , 22, R.drawable.cra1_3, true, new InitData(new int[] {3,3,3}, TwistyCrazy.NEPTUNE)),
82
  CRA1_3 ( TwistyCrazy3x3.class      , 22, R.drawable.cra1_3, true, new InitData(new int[] {3,3,3}, TwistyCrazy3x3.CRAZY  )),
83
  CRA2_3 ( TwistyCrazy3x3.class      , 22, R.drawable.cra1_3, true, new InitData(new int[] {3,3,3}, TwistyCrazy3x3.MERCURY)),
84
  CRA3_3 ( TwistyCrazy3x3.class      , 22, R.drawable.cra1_3, true, new InitData(new int[] {3,3,3}, TwistyCrazy3x3.VENUS  )),
85
  CRA4_3 ( TwistyCrazy3x3.class      , 22, R.drawable.cra1_3, true, new InitData(new int[] {3,3,3}, TwistyCrazy3x3.EARTH  )),
86
  CRA5_3 ( TwistyCrazy3x3.class      , 22, R.drawable.cra1_3, true, new InitData(new int[] {3,3,3}, TwistyCrazy3x3.MARS   )),
87
  CRA6_3 ( TwistyCrazy3x3.class      , 22, R.drawable.cra1_3, true, new InitData(new int[] {3,3,3}, TwistyCrazy3x3.JUPITER)),
88
  CRA7_3 ( TwistyCrazy3x3.class      , 22, R.drawable.cra1_3, true, new InitData(new int[] {3,3,3}, TwistyCrazy3x3.SATURN )),
89
  CRA8_3 ( TwistyCrazy3x3.class      , 22, R.drawable.cra1_3, true, new InitData(new int[] {3,3,3}, TwistyCrazy3x3.URANUS )),
90
  CRA9_3 ( TwistyCrazy3x3.class      , 22, R.drawable.cra1_3, true, new InitData(new int[] {3,3,3}, TwistyCrazy3x3.NEPTUNE)),
91 91

  
92 92
  VOID_3 ( TwistyVoid.class          , 17, R.drawable.void_3, false, new InitData(new int[] {3,3,3})),        // wasDownloadableButNowIsBuiltIn()
93 93
  CRYS_3 ( TwistyCrystal.class       , 27, R.drawable.crys_3, false, new InitData(new int[] {3,3,3,3,3,3})),  // function!
src/main/java/org/distorted/objectlib/objects/TwistyCrazy.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2022 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 java.io.InputStream;
23

  
24
import org.distorted.library.type.Static3D;
25
import org.distorted.library.type.Static4D;
26
import org.distorted.objectlib.helpers.ObjectFaceShape;
27
import org.distorted.objectlib.helpers.ObjectShape;
28
import org.distorted.objectlib.helpers.ObjectSignature;
29
import org.distorted.objectlib.main.Cubit;
30
import org.distorted.objectlib.main.InitData;
31
import org.distorted.objectlib.main.ObjectType;
32
import org.distorted.objectlib.main.ShapeHexahedron;
33
import org.distorted.objectlib.scrambling.ScrambleState;
34
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
35

  
36
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_HEXAHEDRON;
37
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
38

  
39
///////////////////////////////////////////////////////////////////////////////////////////////////
40

  
41
public class TwistyCrazy extends ShapeHexahedron
42
{
43
  public static final int CRAZY   = 0x3f;
44
  public static final int MERCURY = 0x2f;
45
  public static final int VENUS   = 0x0f;
46
  public static final int EARTH   = 0x2b;
47
  public static final int MARS    = 0x0b;
48
  public static final int JUPITER = 0x10;
49
  public static final int SATURN  = 0x30;
50
  public static final int URANUS  = 0x14;
51
  public static final int NEPTUNE = 0x16;
52

  
53
  private static final float DIAMETER_RATIO = 0.75f;
54
  private static final float DIFF = 0.6f;
55
  private static final int NUMBER_CORNER_SEGMENTS = 4;
56
  private static final int NUMBER_EDGE_SEGMENTS = 4;
57

  
58
  static final Static3D[] ROT_AXIS = new Static3D[]
59
         {
60
           new Static3D(1,0,0),
61
           new Static3D(0,1,0),
62
           new Static3D(0,0,1)
63
         };
64

  
65
  private ScrambleState[] mStates;
66
  private int[][] mBasicAngle;
67
  private float[][] mCuts;
68
  private float[][] mPositions;
69
  private int[] mQuatIndex;
70
  private float[][] mOffsets;
71

  
72
///////////////////////////////////////////////////////////////////////////////////////////////////
73

  
74
  public TwistyCrazy(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
75
    {
76
    super(data, meshState, iconMode, data.getNumLayers()[0], quat, move, scale, stream);
77
    }
78

  
79
///////////////////////////////////////////////////////////////////////////////////////////////////
80

  
81
  @Override
82
  public void adjustStickerCoords()
83
    {
84
    final float A = 0.3645522f;
85
    final float B = 0.0744520f;
86
    final float C = 0.1823852f;
87
    final float D = 0.3098326f;
88
    final float E = 0.1033291f;
89
    final float F = 0.4044531f;
90
    final float G = 0.4103489f;
91

  
92
    mStickerCoords = new float[][]
93
      {
94
         { A, 0.5f, -0.5f, 0.5f, -0.5f, -A, -B, -A, A, B },
95
         { 0.5f, -C, 0.5f, D, -0.5f, D, -0.5f, -C },
96
         { -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f },
97
         { -0.5f, E, -0.5f, -F, 0.5f, -F, 0.5f, E },
98
         { -G, 0.5f, -G, -G, 0.5f, -G }
99
      };
100
    }
101

  
102
///////////////////////////////////////////////////////////////////////////////////////////////////
103

  
104
  @Override
105
  public int getCubitRotationType(int cubit)
106
    {
107
    int[] numLayers = getNumLayers();
108
    int variant = getCubitVariant(cubit,numLayers);
109

  
110
    switch(variant)
111
      {
112
      case  2: return Cubit.TYPE_DECIDER;
113
      case  3:
114
      case  4: return Cubit.TYPE_FOLLOWER;
115
      default: return Cubit.TYPE_NORMAL;
116
      }
117
    }
118

  
119
///////////////////////////////////////////////////////////////////////////////////////////////////
120

  
121
  @Override
122
  public float[] getCubitRowOffset(int cubitIndex)
123
    {
124
    if( mOffsets==null )
125
      {
126
      float[] tmp = new float[] {0,0,0};
127
      int numCubits = mPositions.length;
128
      mOffsets = new float[numCubits][];
129

  
130
      int param = getInitData().getParam();
131

  
132
      int R = (param>>5)&0x1;
133
      int L = (param>>4)&0x1;
134
      int U = (param>>3)&0x1;
135
      int D = (param>>2)&0x1;
136
      int F = (param>>1)&0x1;
137
      int B = (param   )&0x1;
138

  
139
      for(int i=0; i<numCubits; i++)
140
        {
141
        switch(i)
142
          {
143
          case 20: mOffsets[i] = new float[] {0,0,-DIFF*F}; break;
144
          case 21: mOffsets[i] = new float[] {0,0,+DIFF*B}; break;
145
          case 22: mOffsets[i] = new float[] {0,-DIFF*U,0}; break;
146
          case 23: mOffsets[i] = new float[] {0,+DIFF*D,0}; break;
147
          case 24: mOffsets[i] = new float[] {-DIFF*R,0,0}; break;
148
          case 25: mOffsets[i] = new float[] {+DIFF*L,0,0}; break;
149
          default: mOffsets[i] = tmp;
150
          }
151
        }
152
      }
153

  
154
    return mOffsets[cubitIndex];
155
    }
156

  
157
///////////////////////////////////////////////////////////////////////////////////////////////////
158
// Normal 3x3
159

  
160
  public ScrambleState[] getScrambleStates()
161
    {
162
    if( mStates==null )
163
      {
164
      int[][] m = new int[16][];
165

  
166
      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};
167

  
168
      mStates = new ScrambleState[]
169
          {
170
          new ScrambleState( new int[][] { m[ 1], m[ 2], m[ 3] } ),  //  0 0
171
          new ScrambleState( new int[][] {  null, m[ 4], m[ 5] } ),  //  1 x
172
          new ScrambleState( new int[][] { m[ 6],  null, m[ 7] } ),  //  2 y
173
          new ScrambleState( new int[][] { m[ 8], m[ 9],  null } ),  //  3 z
174
          new ScrambleState( new int[][] { m[10],  null, m[ 7] } ),  //  4 xy
175
          new ScrambleState( new int[][] { m[11], m[ 9],  null } ),  //  5 xz
176
          new ScrambleState( new int[][] {  null, m[12], m[ 5] } ),  //  6 yx
177
          new ScrambleState( new int[][] { m[ 8], m[13],  null } ),  //  7 yz
178
          new ScrambleState( new int[][] {  null, m[ 4], m[14] } ),  //  8 zx
179
          new ScrambleState( new int[][] { m[ 6],  null, m[15] } ),  //  9 zy
180
          new ScrambleState( new int[][] {  null,  null, m[ 5] } ),  // 10 xyx
181
          new ScrambleState( new int[][] {  null, m[ 4],  null } ),  // 11 xzx
182
          new ScrambleState( new int[][] {  null,  null, m[ 7] } ),  // 12 yxy
183
          new ScrambleState( new int[][] { m[ 6],  null,  null } ),  // 13 yzy
184
          new ScrambleState( new int[][] {  null, m[ 9],  null } ),  // 14 zxz
185
          new ScrambleState( new int[][] { m[ 8],  null,  null } ),  // 15 zyz
186
          };
187
      }
188

  
189
    return mStates;
190
    }
191

  
192
///////////////////////////////////////////////////////////////////////////////////////////////////
193

  
194
  public float[][] getCuts(int[] numLayers)
195
    {
196
    if( mCuts==null )
197
      {
198
      float C = 0.5f;
199
      float[] cut = new float[] {-C,+C};
200
      mCuts = new float[][] { cut,cut,cut };
201
      }
202

  
203
    return mCuts;
204
    }
205

  
206
///////////////////////////////////////////////////////////////////////////////////////////////////
207

  
208
  public boolean[][] getLayerRotatable(int[] numLayers)
209
    {
210
    boolean[] tmp = new boolean[] {true,true,true};
211
    return new boolean[][] { tmp,tmp,tmp };
212
    }
213

  
214
///////////////////////////////////////////////////////////////////////////////////////////////////
215

  
216
  public int getTouchControlType()
217
    {
218
    return TC_HEXAHEDRON;
219
    }
220

  
221
///////////////////////////////////////////////////////////////////////////////////////////////////
222

  
223
  public int getTouchControlSplit()
224
    {
225
    return TYPE_NOT_SPLIT;
226
    }
227

  
228
///////////////////////////////////////////////////////////////////////////////////////////////////
229

  
230
  public int[][][] getEnabled()
231
    {
232
    return new int[][][] { {{1,2}},{{1,2}},{{0,2}},{{0,2}},{{0,1}},{{0,1}} };
233
    }
234

  
235
///////////////////////////////////////////////////////////////////////////////////////////////////
236

  
237
  public float[] getDist3D(int[] numLayers)
238
    {
239
    return TouchControlHexahedron.D3D;
240
    }
241

  
242
///////////////////////////////////////////////////////////////////////////////////////////////////
243

  
244
  public Static3D[] getFaceAxis()
245
    {
246
    return TouchControlHexahedron.FACE_AXIS;
247
    }
248

  
249
///////////////////////////////////////////////////////////////////////////////////////////////////
250

  
251
  public float[][] getCubitPositions(int[] numLayers)
252
    {
253
    if( mPositions==null )
254
      {
255
      mPositions = new float[][]
256
         {
257
             { 1.0f, 1.0f, 1.0f},
258
             { 1.0f, 1.0f,-1.0f},
259
             { 1.0f,-1.0f, 1.0f},
260
             { 1.0f,-1.0f,-1.0f},
261
             {-1.0f, 1.0f, 1.0f},
262
             {-1.0f, 1.0f,-1.0f},
263
             {-1.0f,-1.0f, 1.0f},
264
             {-1.0f,-1.0f,-1.0f},
265

  
266
             { 1.0f, 1.0f, 0.0f},
267
             { 1.0f,-1.0f, 0.0f},
268
             { 1.0f, 0.0f, 1.0f},
269
             { 1.0f, 0.0f,-1.0f},
270
             {-1.0f, 1.0f, 0.0f},
271
             {-1.0f,-1.0f, 0.0f},
272
             {-1.0f, 0.0f, 1.0f},
273
             {-1.0f, 0.0f,-1.0f},
274
             { 0.0f, 1.0f, 1.0f},
275
             { 0.0f, 1.0f,-1.0f},
276
             { 0.0f,-1.0f, 1.0f},
277
             { 0.0f,-1.0f,-1.0f},
278

  
279
             { 0.0f, 0.0f, DIFF},
280
             { 0.0f, 0.0f,-DIFF},
281
             { 0.0f, DIFF, 0.0f},
282
             { 0.0f,-DIFF, 0.0f},
283
             { DIFF, 0.0f, 0.0f},
284
             {-DIFF, 0.0f, 0.0f},
285

  
286
             { 0.0f, 1.0f, DIFF},
287
             {-DIFF, 1.0f, 0.0f},
288
             { 0.0f, 1.0f,-DIFF},
289
             { DIFF, 1.0f, 0.0f},
290
             { 0.0f,-1.0f, DIFF},
291
             {-DIFF,-1.0f, 0.0f},
292
             { 0.0f,-1.0f,-DIFF},
293
             { DIFF,-1.0f, 0.0f},
294
             { DIFF, 0.0f, 1.0f},
295
             { 0.0f,-DIFF, 1.0f},
296
             {-DIFF, 0.0f, 1.0f},
297
             { 0.0f, DIFF, 1.0f},
298
             { DIFF, 0.0f,-1.0f},
299
             { 0.0f,-DIFF,-1.0f},
300
             {-DIFF, 0.0f,-1.0f},
301
             { 0.0f, DIFF,-1.0f},
302
             { 1.0f, DIFF, 0.0f},
303
             { 1.0f, 0.0f,-DIFF},
304
             { 1.0f,-DIFF, 0.0f},
305
             { 1.0f, 0.0f, DIFF},
306
             {-1.0f, DIFF, 0.0f},
307
             {-1.0f, 0.0f,-DIFF},
308
             {-1.0f,-DIFF, 0.0f},
309
             {-1.0f, 0.0f, DIFF},
310

  
311
             { 1.0f, 1.0f, DIFF},
312
             { 1.0f, 1.0f,-DIFF},
313
             { 1.0f,-1.0f, DIFF},
314
             { 1.0f,-1.0f,-DIFF},
315
             {-1.0f, 1.0f, DIFF},
316
             {-1.0f, 1.0f,-DIFF},
317
             {-1.0f,-1.0f, DIFF},
318
             {-1.0f,-1.0f,-DIFF},
319
             { 1.0f, DIFF, 1.0f},
320
             { 1.0f,-DIFF, 1.0f},
321
             { 1.0f, DIFF,-1.0f},
322
             { 1.0f,-DIFF,-1.0f},
323
             {-1.0f, DIFF, 1.0f},
324
             {-1.0f,-DIFF, 1.0f},
325
             {-1.0f, DIFF,-1.0f},
326
             {-1.0f,-DIFF,-1.0f},
327
             { DIFF, 1.0f, 1.0f},
328
             {-DIFF, 1.0f, 1.0f},
329
             { DIFF, 1.0f,-1.0f},
330
             {-DIFF, 1.0f,-1.0f},
331
             { DIFF,-1.0f, 1.0f},
332
             {-DIFF,-1.0f, 1.0f},
333
             { DIFF,-1.0f,-1.0f},
334
             {-DIFF,-1.0f,-1.0f},
335
         };
336
      }
337

  
338
    return mPositions;
339
    }
340

  
341
///////////////////////////////////////////////////////////////////////////////////////////////////
342

  
343
  public Static4D getCubitQuats(int cubit, int[] numLayers)
344
    {
345
    if( mQuatIndex==null ) mQuatIndex = new int[] { 0,1,17,22,4,5,8,19,
346
                                                    6,17,7,12,4,16,9,10,0,5,3,2,
347
                                                    0,2,1,3,6,4,
348
                                                    0,4,5,6, 8,16,2,17, 21,3,20,14, 12,11,10,1, 13,18,22,7, 15,19,23,9,
349
                                                    0,18,7,2, 9,5,8,19, 13,3,1,22, 14,23,15,11, 21,4,6,10, 17,20,12,16 };
350
    return mObjectQuats[mQuatIndex[cubit]];
351
    }
352

  
353
///////////////////////////////////////////////////////////////////////////////////////////////////
354

  
355
  private ObjectShape getCornerShape()
356
    {
357
    final float INIT_ALPHA = (float)Math.asin(1/(3*DIAMETER_RATIO));
358
    final float STEP_CORNER= (float)((Math.PI/2-2*INIT_ALPHA)/NUMBER_CORNER_SEGMENTS);
359
    final int SINGLE_ARC = NUMBER_CORNER_SEGMENTS+1;
360
    final int SINGLE_INNER_ARC = (NUMBER_CORNER_SEGMENTS+1)/2;
361
    final int NUM_VERTICES = 4 + 3*SINGLE_ARC + 1 + 3*SINGLE_INNER_ARC;
362
    float[][] tmp = new float[SINGLE_ARC][2];
363

  
364
    for(int i=0; i<SINGLE_ARC; i++)
365
      {
366
      float alpha = INIT_ALPHA + i*STEP_CORNER;
367
      tmp[i][0] = (float)(1.5f*DIAMETER_RATIO*Math.sin(alpha) - 1.0f);
368
      tmp[i][1] = (float)(1.5f*DIAMETER_RATIO*Math.cos(alpha) - 1.0f);
369
      }
370

  
371
    float[][] vertices = new float[NUM_VERTICES][];
372

  
373
    vertices[0] = new float[] { +0.5f, +0.5f, +0.5f };
374
    vertices[1] = new float[] { -0.5f, +0.5f, +0.5f };
375
    vertices[2] = new float[] { +0.5f, -0.5f, +0.5f };
376
    vertices[3] = new float[] { +0.5f, +0.5f, -0.5f };
377

  
378
    for(int i=0; i<SINGLE_ARC; i++)
379
      {
380
      float s = tmp[i][0];
381
      float c = tmp[i][1];
382

  
383
      vertices[4             +i] = new float[] {0.5f,+s,+c};
384
      vertices[4+  SINGLE_ARC+i] = new float[] {+c,0.5f,+s};
385
      vertices[4+2*SINGLE_ARC+i] = new float[] {+s,+c,0.5f};
386
      }
387

  
388
    final float EXTRA = (NUMBER_CORNER_SEGMENTS%2)==0 ? 1.0f : (float)Math.cos((Math.PI/2-2*INIT_ALPHA)/(2*NUMBER_CORNER_SEGMENTS));
389
    final float LEN = 1.5f*DIAMETER_RATIO*EXTRA;
390
    final float M = (float)(LEN*Math.sin(Math.PI/4) - 1.0f);
391
    vertices[4+3*SINGLE_ARC] = new float[] {M,M,M};
392

  
393
    for(int i=0; i<SINGLE_INNER_ARC; i++)
394
      {
395
      float s = tmp[i][0];
396
      float c = tmp[i][1];
397

  
398
      vertices[4+3*SINGLE_ARC+1                   +i] = new float[] {s,c,c};
399
      vertices[4+3*SINGLE_ARC+1+  SINGLE_INNER_ARC+i] = new float[] {c,s,c};
400
      vertices[4+3*SINGLE_ARC+1+2*SINGLE_INNER_ARC+i] = new float[] {c,c,s};
401
      }
402

  
403
    final int NUM_FACES = 6 + 3*NUMBER_CORNER_SEGMENTS;
404
    final int NUM_VERTS = 4 +   NUMBER_CORNER_SEGMENTS;
405

  
406
    int[][] indices = new int[NUM_FACES][];
407

  
408
    indices[0] = new int[NUM_VERTS];
409
    indices[1] = new int[NUM_VERTS];
410
    indices[2] = new int[NUM_VERTS];
411

  
412
    indices[0][0] = 3;
413
    indices[0][1] = 0;
414
    indices[0][2] = 2;
415
    indices[1][0] = 1;
416
    indices[1][1] = 0;
417
    indices[1][2] = 3;
418
    indices[2][0] = 2;
419
    indices[2][1] = 0;
420
    indices[2][2] = 1;
421

  
422
    for(int i=0; i<SINGLE_ARC; i++)
423
      {
424
      indices[0][3+i] = 4+i;
425
      indices[1][3+i] = 4+i+  SINGLE_ARC;
426
      indices[2][3+i] = 4+i+2*SINGLE_ARC;
427
      }
428

  
429
    indices[3] = new int[] { 1, 4+2*SINGLE_ARC-1, 4+3*SINGLE_ARC+1                   , 4+2*SINGLE_ARC};
430
    indices[4] = new int[] { 2, 4+3*SINGLE_ARC-1, 4+3*SINGLE_ARC+1+  SINGLE_INNER_ARC, 4             };
431
    indices[5] = new int[] { 3, 4+  SINGLE_ARC-1, 4+3*SINGLE_ARC+1+2*SINGLE_INNER_ARC, 4+  SINGLE_ARC};
432

  
433
    int start,i0,i1,i2,i3;
434
    int MID = (NUMBER_CORNER_SEGMENTS)/2;
435
    int MID2= (NUMBER_CORNER_SEGMENTS+1)/2;
436

  
437
    if( (NUMBER_CORNER_SEGMENTS%2) == 0 )
438
      {
439
      start = 12;
440
      indices[ 6] = new int[] { 4+3*SINGLE_ARC, 4+SINGLE_ARC+MID, 4+SINGLE_ARC+MID-1, 4+3*SINGLE_ARC+1+2*SINGLE_INNER_ARC+MID-1};
441
      indices[ 7] = new int[] { 4+3*SINGLE_ARC, 4+3*SINGLE_ARC+1+MID-1,  4+SINGLE_ARC+MID+1, 4+SINGLE_ARC+MID};
442
      indices[ 8] = new int[] { 4+3*SINGLE_ARC, 4+3*SINGLE_ARC+1+2*SINGLE_INNER_ARC+MID-1, 4+MID+1, 4+MID };
443
      indices[ 9] = new int[] { 4+3*SINGLE_ARC, 4+MID, 4+MID-1, 4+3*SINGLE_ARC+1+SINGLE_INNER_ARC+MID-1 };
444
      indices[10] = new int[] { 4+3*SINGLE_ARC, 4+2*SINGLE_ARC+MID, 4+2*SINGLE_ARC+MID-1, 4+3*SINGLE_ARC+1+MID-1 };
445
      indices[11] = new int[] { 4+3*SINGLE_ARC, 4+3*SINGLE_ARC+1+SINGLE_INNER_ARC+MID-1, 4+2*SINGLE_ARC+MID+1, 4+2*SINGLE_ARC+MID };
446
      }
447
    else
448
      {
449
      start = 9;
450
      indices[ 6] = new int[] { 4+3*SINGLE_ARC, 4+3*SINGLE_ARC+1+MID, 4+SINGLE_ARC+MID+1, 4+SINGLE_ARC+MID, 4+3*SINGLE_ARC+1+2*SINGLE_INNER_ARC+MID};
451
      indices[ 7] = new int[] { 4+3*SINGLE_ARC, 4+3*SINGLE_ARC+1+2*SINGLE_INNER_ARC+MID,  4+MID+1, 4+MID, 4+3*SINGLE_ARC+1+SINGLE_INNER_ARC+MID};
452
      indices[ 8] = new int[] { 4+3*SINGLE_ARC, 4+3*SINGLE_ARC+1+SINGLE_INNER_ARC+MID, 4+2*SINGLE_ARC+MID+1, 4+2*SINGLE_ARC+MID, 4+3*SINGLE_ARC+1+MID};
453
      }
454

  
455
    for(int j=0; j<MID2-1; j++)
456
      {
457
      i0 = 4+3*SINGLE_ARC+1+2*SINGLE_INNER_ARC+j;
458
      i1 = 4+3*SINGLE_ARC+1+2*SINGLE_INNER_ARC+j+1;
459
      i2 = 4+SINGLE_ARC+j+1;
460
      i3 = 4+SINGLE_ARC+j;
461

  
462
      indices[start+j] = new int[] {i0,i1,i2,i3};
463

  
464
      i0 = 4+3*SINGLE_ARC+1+2*SINGLE_INNER_ARC+j+1;
465
      i1 = 4+3*SINGLE_ARC+1+2*SINGLE_INNER_ARC+j;
466
      i2 = 4+(SINGLE_ARC-1)-j;
467
      i3 = 4+(SINGLE_ARC-1)-(j+1);
468

  
469
      indices[start+j+(MID2-1)] = new int[] {i0,i1,i2,i3};
470

  
471
      i0 = 4+3*SINGLE_ARC+1+j;
472
      i1 = 4+3*SINGLE_ARC+1+j+1;
473
      i2 = 4+2*SINGLE_ARC+j+1;
474
      i3 = 4+2*SINGLE_ARC+j;
475

  
476
      indices[start+j+2*(MID2-1)] = new int[] {i0,i1,i2,i3};
477

  
478
      i0 = 4+3*SINGLE_ARC+1+j+1;
479
      i1 = 4+3*SINGLE_ARC+1+j;
480
      i2 = 4+(2*SINGLE_ARC-1)-j;
481
      i3 = 4+(2*SINGLE_ARC-1)-(j+1);
482

  
483
      indices[start+j+3*(MID2-1)] = new int[] {i0,i1,i2,i3};
484

  
485
      i0 = 4+3*SINGLE_ARC+1+SINGLE_INNER_ARC+j;
486
      i1 = 4+3*SINGLE_ARC+1+SINGLE_INNER_ARC+j+1;
487
      i2 = 4+j+1;
488
      i3 = 4+j;
489

  
490
      indices[start+j+4*(MID2-1)] = new int[] {i0,i1,i2,i3};
491

  
492
      i0 = 4+3*SINGLE_ARC+1+SINGLE_INNER_ARC+j+1;
493
      i1 = 4+3*SINGLE_ARC+1+SINGLE_INNER_ARC+j;
494
      i2 = 4+(3*SINGLE_ARC-1)-j;
495
      i3 = 4+(3*SINGLE_ARC-1)-(j+1);
496

  
497
      indices[start+j+5*(MID2-1)] = new int[] {i0,i1,i2,i3};
498
      }
499

  
500
    return new ObjectShape(vertices,indices);
501
    }
502

  
503
///////////////////////////////////////////////////////////////////////////////////////////////////
504

  
505
  private ObjectShape getEdgeShape()
506
    {
507
    final int NUM_VERTICES = 8 + 3*(NUMBER_EDGE_SEGMENTS-1);
508
    final float INIT_ALPHA = (float)Math.asin(1/(3*DIAMETER_RATIO));
509
    final float H = 0.5f*((float)Math.sqrt(9*DIAMETER_RATIO*DIAMETER_RATIO-1))-1.0f;
510
    float[][] vertices = new float[NUM_VERTICES][];
511

  
512
    vertices[0] = new float[] {-0.5f,+0.5f,+0.5f};
513
    vertices[1] = new float[] {+0.5f,+0.5f,+0.5f};
514
    vertices[2] = new float[] {-0.5f,    H,+0.5f};
515
    vertices[3] = new float[] {+0.5f,    H,+0.5f};
516
    vertices[4] = new float[] {-0.5f,+0.5f,    H};
517
    vertices[5] = new float[] {+0.5f,+0.5f,    H};
518
    vertices[6] = new float[] {-0.5f,    H,    H};
519
    vertices[7] = new float[] {+0.5f,    H,    H};
520

  
521
    final int NUM_VERTS = NUMBER_EDGE_SEGMENTS-1;
522
    for(int i=0; i<NUM_VERTS; i++)
523
      {
524
      float beta = INIT_ALPHA*((2.0f*(i+1))/NUMBER_EDGE_SEGMENTS -1 );
525
      float A = (float)(1.5f*DIAMETER_RATIO*Math.sin(beta));
526
      float B = (float)(1.5f*DIAMETER_RATIO*Math.cos(beta)-1.0f);
527
      vertices[8            +i] = new float[] {A,B,0.5f};
528
      vertices[8+  NUM_VERTS+i] = new float[] {A,0.5f,B};
529
      vertices[8+2*NUM_VERTS+i] = new float[] {A,B,B};
530
      }
531

  
532
    final int NUM_FACES = 4 + 2*NUMBER_EDGE_SEGMENTS;
533
    int[][] indices = new int[NUM_FACES][];
534

  
535
    int NUMV = 3+NUMBER_EDGE_SEGMENTS;
536

  
537
    indices[0] = new int[NUMV];
538
    indices[0][0] = 3;
539
    indices[0][1] = 1;
540
    indices[0][2] = 0;
541
    indices[0][3] = 2;
542
    for(int i=0; i<NUM_VERTS; i++) indices[0][4+i] = 8+i;
543

  
544
    indices[1] = new int[NUMV];
545
    indices[1][0] = 4;
546
    indices[1][1] = 0;
547
    indices[1][2] = 1;
548
    indices[1][3] = 5;
549
    for(int i=0; i<NUM_VERTS; i++) indices[1][4+i] = 7+2*NUM_VERTS-i;
550

  
551
    indices[2] = new int[] {5,1,3,7};
552
    indices[3] = new int[] {0,4,6,2};
553
    indices[4] = new int[] {8,2,6,8+2*NUM_VERTS};
554
    indices[5] = new int[] {3,7+NUM_VERTS,7+3*NUM_VERTS,7};
555
    indices[6] = new int[] {6,4,8+NUM_VERTS,8+2*NUM_VERTS};
556
    indices[7] = new int[] {5,7,7+3*NUM_VERTS,7+2*NUM_VERTS};
557

  
558
    int i0,i1,i2,i3;
559

  
560
    for(int i=0; i<NUMBER_EDGE_SEGMENTS-2; i++)
561
      {
562
      i0 = 9+i;
563
      i1 = 8+i;
564
      i2 = 8+2*NUM_VERTS+i;
565
      i3 = 9+2*NUM_VERTS+i;
566

  
567
      indices[8+i] = new int[] {i0,i1,i2,i3};
568

  
569
      i0 = 9+2*NUM_VERTS+i;
570
      i1 = 8+2*NUM_VERTS+i;
571
      i2 = 8+NUM_VERTS+i;
572
      i3 = 9+NUM_VERTS+i;
573

  
574
      indices[8+NUMBER_EDGE_SEGMENTS-2+i] = new int[] {i0,i1,i2,i3};
575
      }
576

  
577
    return new ObjectShape(vertices,indices);
578
    }
579

  
580
///////////////////////////////////////////////////////////////////////////////////////////////////
581

  
582
  private ObjectShape getCenterShape(float D)
583
    {
584
    float[][] vertices = new float[][]
585
        {
586
            {-0.5f,-0.5f,-0.5f+D},
587
            {-0.5f,-0.5f,+0.5f+D},
588
            {-0.5f,+0.5f,-0.5f+D},
589
            {-0.5f,+0.5f,+0.5f+D},
590
            {+0.5f,-0.5f,-0.5f+D},
591
            {+0.5f,-0.5f,+0.5f+D},
592
            {+0.5f,+0.5f,-0.5f+D},
593
            {+0.5f,+0.5f,+0.5f+D},
594
        };
595

  
596
    int[][] indices = new int[][]
597
        {
598
            {1,5,7,3},
599
            {5,4,6,7},
600
            {0,1,3,2},
601
            {3,7,6,2},
602
            {0,4,5,1},
603
            {4,0,2,6}
604
        };
605

  
606
    return new ObjectShape(vertices,indices);
607
    }
608

  
609
///////////////////////////////////////////////////////////////////////////////////////////////////
610

  
611
  private ObjectShape getBigCircleShape(float D)
612
    {
613
    final float INIT_ALPHA = (float)Math.asin(1/(3*DIAMETER_RATIO));
614
    final float H = 0.5f*((float)Math.sqrt(9*DIAMETER_RATIO*DIAMETER_RATIO-1))-1.0f;
615
    final int NUM_VERTICES = 8 + 2*(NUMBER_EDGE_SEGMENTS-1);
616
    float[][] vertices = new float[NUM_VERTICES][];
617

  
618
    vertices[0] = new float[] {-0.5f,-0.5f,+0.5f+D};
619
    vertices[1] = new float[] {-0.5f,-0.5f,-0.5f+D};
620
    vertices[2] = new float[] {+0.5f,-0.5f,+0.5f+D};
621
    vertices[3] = new float[] {+0.5f,-0.5f,-0.5f+D};
622
    vertices[4] = new float[] {-0.5f,    H,+0.5f+D};
623
    vertices[5] = new float[] {-0.5f,    H,-0.5f+D};
624
    vertices[6] = new float[] {+0.5f,    H,+0.5f+D};
625
    vertices[7] = new float[] {+0.5f,    H,-0.5f+D};
626

  
627
    final int NUM_VERTS = NUMBER_EDGE_SEGMENTS-1;
628
    for(int i=0; i<NUM_VERTS; i++)
629
      {
630
      float beta = INIT_ALPHA*((2.0f*(i+1))/NUMBER_EDGE_SEGMENTS -1 );
631
      float A = (float)(1.5f*DIAMETER_RATIO*Math.sin(beta));
632
      float B = (float)(1.5f*DIAMETER_RATIO*Math.cos(beta)-1.0f);
633
      vertices[8          +i] = new float[] {A,B,+0.5f+D};
634
      vertices[8+NUM_VERTS+i] = new float[] {A,B,-0.5f+D};
635
      }
636

  
637
    final int NUM_FACES = 5 + NUMBER_EDGE_SEGMENTS;
638
    int[][] indices = new int[NUM_FACES][];
639

  
640
    int NUMV = 4+NUM_VERTS;
641
    indices[0] = new int[NUMV];
642
    indices[0][0] = 4;
643
    indices[0][1] = 0;
644
    indices[0][2] = 2;
645
    indices[0][3] = 6;
646
    for(int i=0; i<NUM_VERTS; i++) indices[0][4+i] = 7+NUM_VERTS-i;
647

  
648
    indices[1] = new int[NUMV];
649
    indices[1][0] = 7;
650
    indices[1][1] = 3;
651
    indices[1][2] = 1;
652
    indices[1][3] = 5;
653
    for(int i=0; i<NUM_VERTS; i++) indices[1][4+i] = 8+NUM_VERTS+i;
654

  
655
    indices[2] = new int[] {7,3,2,6};
656
    indices[3] = new int[] {4,0,1,5};
657
    indices[4] = new int[] {1,3,2,0};
658

  
659
    indices[5] = new int[] {5,4,8,8+NUM_VERTS};
660
    indices[6] = new int[] {7+NUM_VERTS,6,7,7+2*NUM_VERTS};
661

  
662
    for(int i=0; i<NUMBER_EDGE_SEGMENTS-2; i++)
663
      {
664
      int i0 = 8+i;
665
      int i1 = 9+i;
666
      int i2 = 9+NUM_VERTS+i;
667
      int i3 = 8+NUM_VERTS+i;
668

  
669
      indices[7+i] = new int[] {i0,i1,i2,i3};
670
      }
671

  
672
    return new ObjectShape(vertices,indices);
673
    }
674

  
675
///////////////////////////////////////////////////////////////////////////////////////////////////
676

  
677
  private ObjectShape getSmallCircleShape(float D)
678
    {
679
    final float H = 0.5f*((float)Math.sqrt(9*DIAMETER_RATIO*DIAMETER_RATIO-1))-1.0f;
680
    final float INIT_ALPHA = (float)Math.asin(1/(3*DIAMETER_RATIO));
681
    final float STEP_CORNER= (float)((Math.PI/2-2*INIT_ALPHA)/NUMBER_CORNER_SEGMENTS);
682
    final int NUM_VERTICES = 6 + 2*(NUMBER_CORNER_SEGMENTS-1);
683
    float[][] vertices = new float[NUM_VERTICES][];
684

  
685
    vertices[0] = new float[] {-0.5f,    H, 0.5f+D};
686
    vertices[1] = new float[] {    H,-0.5f, 0.5f+D};
687
    vertices[2] = new float[] {-0.5f,-0.5f, 0.5f+D};
688
    vertices[3] = new float[] {-0.5f,    H,-0.5f+D};
689
    vertices[4] = new float[] {    H,-0.5f,-0.5f+D};
690
    vertices[5] = new float[] {-0.5f,-0.5f,-0.5f+D};
691

  
692
    for(int i=0; i<NUMBER_CORNER_SEGMENTS-1; i++)
693
      {
694
      float alpha = INIT_ALPHA + (i+1)*STEP_CORNER;
695
      float A = (float)(1.5f*DIAMETER_RATIO*Math.sin(alpha) - 1.0f);
696
      float B = (float)(1.5f*DIAMETER_RATIO*Math.cos(alpha) - 1.0f);
697

  
698
      vertices[6                       +i] = new float[] {A,B, 0.5f+D};
699
      vertices[5+NUMBER_CORNER_SEGMENTS+i] = new float[] {A,B,-0.5f+D};
700
      }
701

  
702
    final int NUM_FACES = 4 + NUMBER_CORNER_SEGMENTS;
703
    int[][] indices = new int[NUM_FACES][];
704

  
705
    int NUMV = 2+NUMBER_CORNER_SEGMENTS;
706
    indices[0] = new int[NUMV];
707
    indices[0][0] = 0;
708
    indices[0][1] = 2;
709
    indices[0][2] = 1;
710
    for(int i=3; i<NUMV; i++) indices[0][i] = 5+(NUMBER_CORNER_SEGMENTS-1)-(i-3);
711

  
712
    indices[1] = new int[NUMV];
713
    indices[1][0] = 4;
714
    indices[1][1] = 5;
715
    indices[1][2] = 3;
716
    for(int i=3; i<NUMV; i++) indices[1][i] = 5+NUMBER_CORNER_SEGMENTS+(i-3);
717

  
718
    indices[2] = new int[] {0,3,5,2};
719
    indices[3] = new int[] {1,2,5,4};
720

  
721
    indices[4] = new int[] {5+NUMBER_CORNER_SEGMENTS,3,0,6};
722
    indices[5] = new int[] {1,4,5+2*(NUMBER_CORNER_SEGMENTS-1),5+(NUMBER_CORNER_SEGMENTS-1)};
723

  
724
    for(int i=0; i<NUMBER_CORNER_SEGMENTS-2; i++)
725
      {
726
      int i0 = 6+i;
727
      int i1 = 7+i;
728
      int i2 = 6+NUMBER_CORNER_SEGMENTS+i;
729
      int i3 = 5+NUMBER_CORNER_SEGMENTS+i;
730

  
731
      indices[6+i] = new int[] {i0,i1,i2,i3};
732
      }
733

  
734
    return new ObjectShape(vertices,indices);
735
    }
736

  
737
///////////////////////////////////////////////////////////////////////////////////////////////////
738

  
739
  public ObjectShape getObjectShape(int variant)
740
    {
741
    switch(variant)
742
      {
743
      case 0: return getCornerShape();
744
      case 1: return getEdgeShape();
745
      case 2: return getCenterShape(1.0f-DIFF);
746
      case 3: return getBigCircleShape(1.0f-DIFF);
747
      case 4: return getSmallCircleShape(1.02f-DIFF);
748
      }
749

  
750
    return null;
751
    }
752

  
753
///////////////////////////////////////////////////////////////////////////////////////////////////
754

  
755
  public ObjectFaceShape getObjectFaceShape(int variant)
756
    {
757
    if( variant==0 )
758
      {
759
      float h1 = isInIconMode() ? 0.001f : 0.04f;
760
      float h2 = 0.001f;
761
      float[][] bands   = { {h1,45,0.3f,0.7f,5,0,0}, {h2,5,0.3f,0.2f,2,0,0} };
762
      final int NUM_BANDS = 6+3*NUMBER_CORNER_SEGMENTS;
763
      int[] bandIndices = new int[NUM_BANDS];
764
      bandIndices[0] = bandIndices[1] = bandIndices[2] = 0;
765
      for(int i=3; i<NUM_BANDS; i++) bandIndices[i] = 1;
766
      float[][] corners = { {0.02f,0.09f} };
767
      float[][] centers = { { 0.0f, 0.0f, 0.0f } };
768
      final int SINGLE_ARC = NUMBER_CORNER_SEGMENTS+1;
769
      final int SINGLE_INNER_ARC = (NUMBER_CORNER_SEGMENTS+1)/2;
770
      final int NUM_VERTICES = 4 + 3*SINGLE_ARC + 1 + 3*SINGLE_INNER_ARC;
771
      int[] indices = new int[NUM_VERTICES];
772
      indices[0] = indices[1] = indices[2] = indices[3] = 0;
773
      for(int i=4; i<NUM_VERTICES; i++) indices[i] = -1;
774
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
775
      }
776
    if( variant==1 )
777
      {
778
      float h1 = isInIconMode() ? 0.001f : 0.03f;
779
      float[][] bands   = { {h1,45,0.2f,0.4f,5,0,0}, {0.001f,1,0.3f,0.5f,3,0,0}, {0.001f,1,0.3f,0.5f,2,0,0} };
780
      final int NUM_BANDS = 4 + 2*NUMBER_EDGE_SEGMENTS;
781
      int[] bandIndices = new int[NUM_BANDS];
782
      bandIndices[0] = bandIndices[1] = 0;
783
      bandIndices[2] = bandIndices[3] = 1;
784
      for(int i=4; i<NUM_BANDS; i++) bandIndices[i] = 2;
785
      float[][] corners = { {0.02f,0.09f} };
786
      float[][] centers = { { 0.0f, 0.0f, 0.0f } };
787
      final int NUM_VERTICES = 8 + 3*(NUMBER_EDGE_SEGMENTS-1);
788
      int[] indices = new int[NUM_VERTICES];
789
      indices[0] = indices[1] = indices[2] = indices[3] = indices[4] = indices[5] = 0;
790
      for(int i=6; i<NUM_VERTICES; i++) indices[i] = -1;
791
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
792
      }
793
    if( variant==2 )
794
      {
795
      float h1 = isInIconMode() ? 0.001f : 0.05f;
796
      float[][] bands   = { {h1,45,0.2f,0.4f,5,0,0}, {0.001f,1,0.3f,0.5f,2,0,0} };
797
      int[] bandIndices = new int[] {0,1,1,1,1,1};
798
      float[][] corners = { {0.02f,0.09f} };
799
      float[][] centers = { { 0.0f, 0.0f, 1.0f } };
800
      int[] indices = new int[] {0,0,0,0,-1,-1,-1,-1};
801
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
802
      }
803
    if( variant==3 )
804
      {
805
      float h1 = isInIconMode() ? 0.001f : 0.03f;
806
      float[][] bands   = { {h1,45,0.2f,0.4f,5,0,0}, {0.001f,1,0.3f,0.5f,3,0,0}, {0.001f,1,0.3f,0.5f,2,0,0} };
807
      final int NUM_BANDS = 5 + NUMBER_EDGE_SEGMENTS;
808
      int[] bandIndices = new int[NUM_BANDS];
809
      bandIndices[0] = 0;
810
      bandIndices[1] = 2;
811
      bandIndices[2] = bandIndices[3] = bandIndices[4] = 1;
812
      for(int i=5; i<NUM_BANDS; i++) bandIndices[i] = 2;
813
      float[][] corners = { {0.02f,0.09f} };
814
      float[][] centers = { { 0.0f, 0.0f, 1.0f } };
815
      final int NUM_VERTICES = 8 + 2*(NUMBER_EDGE_SEGMENTS-1);
816
      int[] indices = new int[NUM_VERTICES];
817
      for(int i=0; i<NUM_VERTICES; i++) indices[i] = -1;
818
      indices[0] = indices[2] = indices[4] = indices[6] = 0;
819
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
820
      }
821
    else
822
      {
823
      float h1 = isInIconMode() ? 0.001f : 0.02f;
824
      float[][] bands   = { {h1,45,0.2f,0.4f,5,0,0}, {0.001f,1,0.3f,0.5f,3,0,0}, {0.001f,1,0.3f,0.5f,2,0,0} };
825
      final int NUM_BANDS = 4 + NUMBER_CORNER_SEGMENTS;
826
      int[] bandIndices = new int[NUM_BANDS];
827
      bandIndices[0] = 0;
828
      bandIndices[1] = 2;
829
      bandIndices[2] = bandIndices[3] = 1;
830
      for(int i=4; i<NUM_BANDS; i++) bandIndices[i] = 2;
831
      float[][] corners = { {0.02f,0.09f} };
832
      float[][] centers = { { 0.0f, 0.0f, 1.0f } };
833
      final int NUM_VERTICES = 6 + 2*(NUMBER_CORNER_SEGMENTS-1);
834
      int[] indices = new int[NUM_VERTICES];
835
      for(int i=0; i<NUM_VERTICES; i++) indices[i] = -1;
836
      indices[0] = indices[1] = indices[2] = 0;
837
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
838
      }
839
    }
840

  
841
///////////////////////////////////////////////////////////////////////////////////////////////////
842

  
843
  public int getNumCubitVariants(int[] numLayers)
844
    {
845
    return 5;
846
    }
847

  
848
///////////////////////////////////////////////////////////////////////////////////////////////////
849

  
850
  public int getCubitVariant(int cubit, int[] numLayers)
851
    {
852
    if( cubit< 8 ) return 0;
853
    if( cubit<20 ) return 1;
854
    if( cubit<26 ) return 2;
855
    if( cubit<50 ) return 3;
856

  
857
    return 4;
858
    }
859

  
860
///////////////////////////////////////////////////////////////////////////////////////////////////
861

  
862
  public float getStickerRadius()
863
    {
864
    return 0.07f;
865
    }
866

  
867
///////////////////////////////////////////////////////////////////////////////////////////////////
868

  
869
  public float getStickerStroke()
870
    {
871
    return isInIconMode() ? 0.22f : 0.12f;
872
    }
873

  
874
///////////////////////////////////////////////////////////////////////////////////////////////////
875

  
876
  public float[][] getStickerAngles()
877
    {
878
    float D1 = (float)(Math.PI/8);
879
    float D2 = (float)(Math.PI/6);
880
    return new float[][] { { 0,0,0,-D1,0 },{ 0,0,0,-D2 },{0,0,0,0},{ 0,0,0,D2 },{ 0,0,D1 } };
881
    }
882

  
883
///////////////////////////////////////////////////////////////////////////////////////////////////
884
// PUBLIC API
885

  
886
  public Static3D[] getRotationAxis()
887
    {
888
    return ROT_AXIS;
889
    }
890

  
891
///////////////////////////////////////////////////////////////////////////////////////////////////
892

  
893
  public int[][] getBasicAngles()
894
    {
895
    if( mBasicAngle==null )
896
      {
897
      int[] tmp = new int[] {4,4,4};
898
      mBasicAngle = new int[][] { tmp,tmp,tmp };
899
      }
900

  
901
    return mBasicAngle;
902
    }
903

  
904
///////////////////////////////////////////////////////////////////////////////////////////////////
905

  
906
  public String getShortName()
907
    {
908
    int param = getInitData().getParam();
909

  
910
    switch(param)
911
      {
912
      case CRAZY  : return ObjectType.CRA1_3.name();
913
      case MERCURY: return ObjectType.CRA2_3.name();
914
      case VENUS  : return ObjectType.CRA3_3.name();
915
      case EARTH  : return ObjectType.CRA4_3.name();
916
      case MARS   : return ObjectType.CRA5_3.name();
917
      case JUPITER: return ObjectType.CRA6_3.name();
918
      case SATURN : return ObjectType.CRA7_3.name();
919
      case URANUS : return ObjectType.CRA8_3.name();
920
      case NEPTUNE: return ObjectType.CRA9_3.name();
921
      }
922

  
923
    return null;
924
    }
925

  
926
///////////////////////////////////////////////////////////////////////////////////////////////////
927

  
928
  public ObjectSignature getSignature()
929
    {
930
    int param = getInitData().getParam();
931

  
932
    switch(param)
933
      {
934
      case CRAZY  : return new ObjectSignature(ObjectType.CRA1_3);
935
      case MERCURY: return new ObjectSignature(ObjectType.CRA2_3);
936
      case VENUS  : return new ObjectSignature(ObjectType.CRA3_3);
937
      case EARTH  : return new ObjectSignature(ObjectType.CRA4_3);
938
      case MARS   : return new ObjectSignature(ObjectType.CRA5_3);
939
      case JUPITER: return new ObjectSignature(ObjectType.CRA6_3);
940
      case SATURN : return new ObjectSignature(ObjectType.CRA7_3);
941
      case URANUS : return new ObjectSignature(ObjectType.CRA8_3);
942
      case NEPTUNE: return new ObjectSignature(ObjectType.CRA9_3);
943
      }
944

  
945
    return null;
946
    }
947

  
948
///////////////////////////////////////////////////////////////////////////////////////////////////
949

  
950
  public String getObjectName()
951
    {
952
    int param = getInitData().getParam();
953

  
954
    switch(param)
955
      {
956
      case CRAZY  : return "Crazy 3x3";
957
      case MERCURY: return "Crazy Plus Mercury";
958
      case VENUS  : return "Crazy Plus Venus";
959
      case EARTH  : return "Crazy Plus Earth";
960
      case MARS   : return "Crazy Plus Mars";
961
      case JUPITER: return "Crazy Plus Jupiter";
962
      case SATURN : return "Crazy Plus Saturn";
963
      case URANUS : return "Crazy Plus Uranus";
964
      case NEPTUNE: return "Crazy Plus Neptune";
965
      }
966

  
967
    return null;
968
    }
969

  
970
///////////////////////////////////////////////////////////////////////////////////////////////////
971

  
972
  public String getInventor()
973
    {
974

  
975
    return getInitData().getParam()==CRAZY ? "Aleh Hladzilin" : "Daqing Bao";
976
    }
977

  
978
///////////////////////////////////////////////////////////////////////////////////////////////////
979

  
980
  public int getYearOfInvention()
981
    {
982
    return getInitData().getParam()==CRAZY ? 2008 : 2010;
983
    }
984

  
985
///////////////////////////////////////////////////////////////////////////////////////////////////
986

  
987
  public int getComplexity()
988
    {
989
    int param = getInitData().getParam();
990

  
991
    switch(param)
992
      {
993
      case CRAZY  : return 2;
994
      case MERCURY: return 4;
995
      case VENUS  : return 4;
996
      case EARTH  : return 4;
997
      case MARS   : return 4;
998
      case JUPITER: return 3;
999
      case SATURN : return 4;
1000
      case URANUS : return 3;
1001
      case NEPTUNE: return 4;
1002
      }
1003

  
1004
    return 2;
1005
    }
1006

  
1007
///////////////////////////////////////////////////////////////////////////////////////////////////
1008

  
1009
  public String[][] getTutorials()
1010
    {
1011
    int param = getInitData().getParam();
1012

  
1013
    switch(param)
1014
      {
1015
      case CRAZY  : return new String[][]{
1016
                                          {"gb","7xUE8ond_Mg","Crazy 3x3x3 Cube Tutorial","SuperAntoniovivaldi"},
1017
                                          {"vn","N_AWJjHzqk0","Circle Crazy 3x3 Tutorial","VĂN CÔNG TÙNG"},
1018
                                         };
1019
      case MERCURY: return new String[][]{
1020
                                          {"gb","SeLGhxZP0E8","Crazy 3x3 Plus Mercury 1/3","SuperAntoniovivaldi"},
1021
                                          {"gb","nTBabfkdMe8","Crazy 3x3 Plus Mercury 2/3","SuperAntoniovivaldi"},
1022
                                          {"gb","Hd87z-VpTgM","Crazy 3x3 Plus Mercury 3a/3","SuperAntoniovivaldi"},
1023
                                          {"gb","MeMJ21vJLBc","Crazy 3x3 Plus Mercury 3b/3","SuperAntoniovivaldi"},
1024
                                          {"gb","s-kUXY5o5AQ","Crazy Mercury Plus Tutorial","twistypuzzling"},
1025
                                          {"es","LYMTrcGiAho","Crazy 3x3 Plus Mercurio","QBAndo"},
1026
                                          {"ru","2jtTsBwu3WY","Как собрать Crazy Mercury","RBcuber"},
1027
                                          {"fr","uxW652tv3_c","Solution crazy 3x3x3 Mercure 1/4","Laurent Boss"},
1028
                                          {"fr","QKuesX-0DaU","Solution crazy 3x3x3 Mercure 2a/4","Laurent Boss"},
1029
                                          {"fr","vDnAy1qYSCc","Solution crazy 3x3x3 Mercure 2b/4","Laurent Boss"},
1030
                                          {"fr","_eEILlsLurc","Solution crazy 3x3x3 Mercure 3/4","Laurent Boss"},
1031
                                          {"fr","4D3V9c3u7so","Solution crazy 3x3x3 Mercure 4/4","Laurent Boss"},
1032
                                          {"br","bMuDIEemCkI","Resolver Crazy Mercurio 1/5","Rafael Cinoto"},
1033
                                          {"br","FPP_nvOsnIQ","Resolver Crazy Mercurio 2/5","Rafael Cinoto"},
1034
                                          {"br","ouz20eYDlLM","Resolver Crazy Mercurio 3/5","Rafael Cinoto"},
1035
                                          {"br","IDHXszSX-UQ","Resolver Crazy Mercurio 4/5","Rafael Cinoto"},
1036
                                          {"br","Wbq701nq900","Resolver Crazy Mercurio 5/5","Rafael Cinoto"},
1037
                                          {"kr","NYBrUY9ngnc","크레이지 333 수성 1/3","듀나메스 큐브 해법연구소"},
1038
                                          {"kr","snT8xxMb0E0","크레이지 333 수성 2/3","듀나메스 큐브 해법연구소"},
1039
                                          {"kr","Pbfm3FZy_3k","크레이지 333 수성 3/3","듀나메스 큐브 해법연구소"},
1040
                                          {"vn","_1Pn2nqDF3A","Crazy Mercury 3x3 Tutorial","VĂN CÔNG TÙNG"},
1041
                                         };
1042
      case VENUS  : return new String[][]{
1043
                                          {"gb","I4f7UngHofc","Crazy 3x3 Plus Venus 1/3","SuperAntoniovivaldi"},
1044
                                          {"gb","p57W1iBXa0k","Crazy 3x3 Plus Venus 2/3","SuperAntoniovivaldi"},
1045
                                          {"gb","IUQcgfgYW3A","Crazy 3x3 Plus Venus 3/3","SuperAntoniovivaldi"},
1046
                                          {"es","L_o5b6i6iQc","Crazy 3x3 Plus Venus","QBAndo"},
1047
                                          {"ru","e6rFPDlpBoI","Как собрать Crazy Venus","Илья Топор-Гилка"},
1048
                                          {"fr","Ccu2XugYAhw","Solution crazy 3x3x3 Venus 1/6","Laurent Boss"},
1049
                                          {"fr","sz5JjDsBB4c","Solution crazy 3x3x3 Venus 2/6","Laurent Boss"},
1050
                                          {"fr","ap_m3-xY7LU","Solution crazy 3x3x3 Venus 3/6","Laurent Boss"},
1051
                                          {"fr","BkV1dyWIH1Q","Solution crazy 3x3x3 Venus 4/6","Laurent Boss"},
1052
                                          {"fr","spO_rh09h9s","Solution crazy 3x3x3 Venus 5/6","Laurent Boss"},
1053
                                          {"fr","kEmXDJgO0B4","Solution crazy 3x3x3 Venus 6/6","Laurent Boss"},
1054
                                          {"br","i781Mf0Fuag","Resolver Crazy Venus 1/3","Rafael Cinoto"},
1055
                                          {"br","3m0eyKbLaQ4","Resolver Crazy Venus 2/3","Rafael Cinoto"},
1056
                                          {"br","nKamBHo7oxo","Resolver Crazy Venus 3/3","Rafael Cinoto"},
1057
                                          {"kr","hsWfqlOa4_0","크레이지 (Crazy) 333 금성 1/5","듀나메스 큐브 해법연구소"},
1058
                                          {"kr","Z2sJczk29kg","크레이지 (Crazy) 333 금성 2/5","듀나메스 큐브 해법연구소"},
1059
                                          {"kr","8r1la2KEiBo","크레이지 (Crazy) 333 금성 3/5","듀나메스 큐브 해법연구소"},
1060
                                          {"kr","S9IcRa5AQHk","크레이지 (Crazy) 333 금성 4/5","듀나메스 큐브 해법연구소"},
1061
                                          {"kr","fs78ZSlShm0","크레이지 (Crazy) 333 금성 3/5","듀나메스 큐브 해법연구소"},
1062
                                          {"vn","_fG3VIKUwNo","Crazy Venus 3x3 Tutorial","VĂN CÔNG TÙNG"},
1063
                                         };
1064
      case EARTH  : return new String[][]{
1065
                                          {"gb","brNQ6Nl1-Mw","Crazy 3x3 Plus Earth 1/4","SuperAntoniovivaldi"},
1066
                                          {"gb","-3RSoC5OZGc","Crazy 3x3 Plus Earth 2/4","SuperAntoniovivaldi"},
1067
                                          {"gb","ahuXWFLTKRg","Crazy 3x3 Plus Earth 3/4","SuperAntoniovivaldi"},
1068
                                          {"gb","Lwt-7XKesUg","Crazy 3x3 Plus Earth 4/4","SuperAntoniovivaldi"},
1069
                                          {"es","GFHcLpYF620","Crazy 3x3 Plus Tierra","QBAndo"},
1070
                                          {"ru","YmEoI0XI5E4","Как собрать Crazy Earth","Илья Топор-Гилка"},
1071
                                          {"fr","QT4T4JV-L44","Solution crazy 3x3x3 Terre 1/6","Laurent Boss"},
1072
                                          {"fr","8On3fbrG5aA","Solution crazy 3x3x3 Terre 2/6","Laurent Boss"},
1073
                                          {"fr","IPEvUnVumJg","Solution crazy 3x3x3 Terre 3/6","Laurent Boss"},
1074
                                          {"fr","0awyEJmfuMM","Solution crazy 3x3x3 Terre 4/6","Laurent Boss"},
1075
                                          {"fr","xLKGyRXuaGs","Solution crazy 3x3x3 Terre 5/6","Laurent Boss"},
1076
                                          {"fr","CcunFHHhQ7g","Solution crazy 3x3x3 Terre 6/6","Laurent Boss"},
1077
                                          {"kr","4YBV9TnAzlg","크레이지(Crazy) 333 지구 1/5","듀나메스 큐브 해법연구소"},
1078
                                          {"kr","uWbAgUq-IqU","크레이지(Crazy) 333 지구 2/5","듀나메스 큐브 해법연구소"},
1079
                                          {"kr","glZqE9hQXK8","크레이지(Crazy) 333 지구 3/5","듀나메스 큐브 해법연구소"},
1080
                                          {"kr","WF2RGp8E97k","크레이지(Crazy) 333 지구 4/5","듀나메스 큐브 해법연구소"},
1081
                                          {"kr","RC-w26wLtQg","크레이지(Crazy) 333 지구 5/5","듀나메스 큐브 해법연구소"},
1082
                                          {"vn","MsFqHGuWspE","Crazy Earth 3x3 Tutorial","VĂN CÔNG TÙNG"},
1083
                                         };
1084
      case MARS   : return new String[][]{
1085
                                          {"gb","AJC0dZx2T-M","Crazy 3x3 Plus Mars 1/4","SuperAntoniovivaldi"},
1086
                                          {"gb","BcrYXklwEow","Crazy 3x3 Plus Mars 2/4","SuperAntoniovivaldi"},
1087
                                          {"gb","L_Y0qRG8F-0","Crazy 3x3 Plus Mars 3/4","SuperAntoniovivaldi"},
1088
                                          {"gb","PRyeKOV0Pbg","Crazy 3x3 Plus Mars 4/4","SuperAntoniovivaldi"},
1089
                                          {"es","P5NsxqMx9Bo","Crazy 3x3 Plus Marte","QBAndo"},
1090
                                          {"ru","syzb9hOojEs","Как собрать Crazy Mars","Илья Топор-Гилка"},
1091
                                          {"fr","tSqak16XJjw","Solution crazy 3x3x3 Mars 1/6","Laurent Boss"},
1092
                                          {"fr","Dm47WsF8OZg","Solution crazy 3x3x3 Mars 2/6","Laurent Boss"},
1093
                                          {"fr","gl-VL1NAslY","Solution crazy 3x3x3 Mars 3/6","Laurent Boss"},
1094
                                          {"fr","TlgsnVdkNh4","Solution crazy 3x3x3 Mars 4/6","Laurent Boss"},
1095
                                          {"fr","XxVeGY1IYIc","Solution crazy 3x3x3 Mars 5/6","Laurent Boss"},
1096
                                          {"fr","aK9YYEYMsyA","Solution crazy 3x3x3 Mars 6/6","Laurent Boss"},
1097
                                          {"kr","QKu2p9nNxFk","크레이지 333 화성 1/4","듀나메스 큐브 해법연구소"},
1098
                                          {"kr","f5YYqm6PPms","크레이지 333 화성 2a/4","듀나메스 큐브 해법연구소"},
1099
                                          {"kr","nmNxrpvucIg","크레이지 333 화성 2b/4","듀나메스 큐브 해법연구소"},
1100
                                          {"kr","rJLpMPCEc_s","크레이지 333 화성 3/4","듀나메스 큐브 해법연구소"},
1101
                                          {"kr","bBRAfOvUu8M","크레이지 333 화성 4/4","듀나메스 큐브 해법연구소"},
1102
                                          {"vn","lzw0Gfi-dM8","Crazy Mars 3x3 Tutorial","VĂN CÔNG TÙNG"},
1103
                                         };
1104
      case JUPITER: return new String[][]{
1105
                                          {"gb","HMnbVoOPk5E","Crazy 3x3 Plus Jupiter 1/2","SuperAntoniovivaldi"},
1106
                                          {"gb","Nw-LBWVu7yM","Crazy 3x3 Plus Jupiter 2/2","SuperAntoniovivaldi"},
1107
                                          {"es","p2HTOQZNfx4","Crazy 3x3 Plus Jupiter","QBAndo"},
1108
                                          {"ru","PGiYCgJYPAY","Как собрать Crazy Jupiter","RBcuber"},
1109
                                          {"fr","sKi_cXmywVs","Solution crazy 3x3x3 Jupiter 1/3","Laurent Boss"},
1110
                                          {"fr","HYnQCifSzFY","Solution crazy 3x3x3 Jupiter 2/3","Laurent Boss"},
1111
                                          {"fr","DNfV8gnaRXw","Solution crazy 3x3x3 Jupiter 3/3","Laurent Boss"},
1112
                                          {"pl","eJmQ50vcQcU","Crazy 3x3 Jupiter TUTORIAL PL","MrUK"},
1113
                                          {"br","pwYhThiSKLQ","Resolver Crazy Jupiter 1/2","Rafael Cinoto"},
1114
                                          {"br","VhuBtUU866U","Resolver Crazy Jupiter 2/2","Rafael Cinoto"},
1115
                                          {"kr","WQ3ad3DrBwY","크레이지 333 목성 1/2","듀나메스 큐브 해법연구소"},
1116
                                          {"kr","3LLL34HsqUs","크레이지 333 목성 2/2","듀나메스 큐브 해법연구소"},
1117
                                          {"vn","QH4ywmKNGVo","Jupiter Crazy Plus Tutorial","VĂN CÔNG TÙNG"},
1118
                                         };
1119
      case SATURN : return new String[][]{
1120
                                          {"gb","7fPXML8hZ-I","Crazy 3x3 Plus Saturn 1/3","SuperAntoniovivaldi"},
1121
                                          {"gb","ixVVVoxsg4A","Crazy 3x3 Plus Saturn 2/3","SuperAntoniovivaldi"},
1122
                                          {"gb","Dd8ZaGzbvjE","Crazy 3x3 Plus Saturn 3/3","SuperAntoniovivaldi"},
1123
                                          {"es","EyQXl0llt2M","Crazy 3x3 Plus Saturno","QBAndo"},
1124
                                          {"ru","T2uYDHyQZnE","Как собрать Crazy Saturn","Илья Топор-Гилка"},
1125
                                          {"fr","kuSYpTXoXUM","Solution crazy 3x3x3 Saturn 1/6","Laurent Boss"},
1126
                                          {"fr","u1OsRGuBcHA","Solution crazy 3x3x3 Saturn 2/6","Laurent Boss"},
1127
                                          {"fr","ra0MspIkctU","Solution crazy 3x3x3 Saturn 3/6","Laurent Boss"},
1128
                                          {"fr","dm3WBtGdxYA","Solution crazy 3x3x3 Saturn 4/6","Laurent Boss"},
1129
                                          {"fr","jVwPmbYot_U","Solution crazy 3x3x3 Saturn 5/6","Laurent Boss"},
1130
                                          {"fr","raYIoRIZPmc","Solution crazy 3x3x3 Saturn 6/6","Laurent Boss"},
1131
                                          {"br","0oKu1NXiQcY","Resolver Crazy Saturn 1/4","Rafael Cinoto"},
1132
                                          {"br","bRD73Lb1NTw","Resolver Crazy Saturn 2/4","Rafael Cinoto"},
1133
                                          {"br","v9nZrwCyNLs","Resolver Crazy Saturn 3/4","Rafael Cinoto"},
1134
                                          {"br","aipwvc2udbM","Resolver Crazy Saturn 4/4","Rafael Cinoto"},
1135
                                          {"kr","hfogu6lCLvs","크레이지 (Crazy) 333 토성 1/5","듀나메스 큐브 해법연구소"},
1136
                                          {"kr","rKjRzKxXHyA","크레이지 (Crazy) 333 토성 2/5","듀나메스 큐브 해법연구소"},
1137
                                          {"kr","7tKfu5RJCVc","크레이지 (Crazy) 333 토성 3/5","듀나메스 큐브 해법연구소"},
1138
                                          {"kr","L68nVvMhxVc","크레이지 (Crazy) 333 토성 4/5","듀나메스 큐브 해법연구소"},
1139
                                          {"kr","fvOcR9-TQpA","크레이지 (Crazy) 333 토성 5/5","듀나메스 큐브 해법연구소"},
1140
                                          {"vn","jiGMQ9Mn14w","Saturn Crazy Plus Tutorial","VĂN CÔNG TÙNG"},
1141
                                         };
1142
      case URANUS : return new String[][]{
1143
                                          {"gb","wOyVb2TMZlk","Crazy 3x3 Plus Uranus 1/3","SuperAntoniovivaldi"},
1144
                                          {"gb","UbTBBQ-gvk0","Crazy 3x3 Plus Uranus 2/3","SuperAntoniovivaldi"},
1145
                                          {"gb","_7k57cV81BM","Crazy 3x3 Plus Uranus 3/3","SuperAntoniovivaldi"},
1146
                                          {"es","vuPcyvE6EVE","Crazy 3x3 Plus Urano","QBAndo"},
1147
                                          {"ru","tm6sxFSeeBg","Как собрать Crazy Uranus","Илья Топор-Гилка"},
1148
                                          {"fr","i9lU26McP38","Solution crazy 3x3x3 Uranus 1/4","Laurent Boss"},
1149
                                          {"fr","Zr6fTayObJk","Solution crazy 3x3x3 Uranus 2/4","Laurent Boss"},
1150
                                          {"fr","nCmCxrY_QMU","Solution crazy 3x3x3 Uranus 3/4","Laurent Boss"},
1151
                                          {"fr","YNs8IohERKs","Solution crazy 3x3x3 Uranus 4/4","Laurent Boss"},
1152
                                          {"pl","pKPQJoGJtno","Crazy 3x3 Uranus TUTORIAL PL","MrUK"},
1153
                                          {"br","jjcqHXOD9eo","Resolver Crazy Urano 1/2","Rafael Cinoto"},
1154
                                          {"br","1B73Z2XE2ss","Resolver Crazy Urano 2/2","Rafael Cinoto"},
1155
                                          {"kr","_m3S5DiVRMw","크레이지 333 천왕성 1/2","듀나메스 큐브 해법연구소"},
1156
                                          {"kr","z9Wh6FXr0og","크레이지 333 천왕성 2/2","듀나메스 큐브 해법연구소"},
1157
                                          {"vn","bHiQ3YSEb2I","Uranus Crazy Plus Tutorial","VĂN CÔNG TÙNG"},
1158
                                         };
1159
      case NEPTUNE: return new String[][]{
1160
                                          {"gb","1gFmuFpU5-Y","Crazy 3x3 Plus Neptune 1a/4","SuperAntoniovivaldi"},
1161
                                          {"gb","UPRIH0MtmPM","Crazy 3x3 Plus Neptune 1b/4","SuperAntoniovivaldi"},
1162
                                          {"gb","Trqruz1NZ5E","Crazy 3x3 Plus Neptune 2/4","SuperAntoniovivaldi"},
1163
                                          {"gb","1gFmuFpU5-Y","Crazy 3x3 Plus Neptune 3/4","SuperAntoniovivaldi"},
1164
                                          {"gb","Rfa5y8NGqdY","Crazy 3x3 Plus Neptune 4/4","SuperAntoniovivaldi"},
1165
                                          {"es","LOR1cNs4NWM","Crazy 3x3 Plus Neptuno","QBAndo"},
1166
                                          {"ru","qvaRxJJrdi8","Как собрать Crazy Neptune","Илья Топор-Гилка"},
1167
                                          {"kr","6Avdw2zX5XI","크레이지 333 해왕성 1/2","듀나메스 큐브 해법연구소"},
1168
                                          {"kr","YbfWfDDBN9k","크레이지 333 해왕성 2/2","듀나메스 큐브 해법연구소"},
1169
                                          {"vn","hmf1YShJuZg","Neptune Crazy Plus Tutorial","VĂN CÔNG TÙNG"},
1170
                                         };
1171
      }
1172

  
1173
    return null;
1174
    }
1175
}
src/main/java/org/distorted/objectlib/objects/TwistyCrazy3x3.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2022 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 java.io.InputStream;
23

  
24
import org.distorted.library.type.Static3D;
25
import org.distorted.library.type.Static4D;
26
import org.distorted.objectlib.helpers.ObjectFaceShape;
27
import org.distorted.objectlib.helpers.ObjectShape;
28
import org.distorted.objectlib.helpers.ObjectSignature;
29
import org.distorted.objectlib.main.Cubit;
30
import org.distorted.objectlib.main.InitData;
31
import org.distorted.objectlib.main.ObjectType;
32
import org.distorted.objectlib.main.ShapeHexahedron;
33
import org.distorted.objectlib.scrambling.ScrambleState;
34
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
35

  
36
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_HEXAHEDRON;
37
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
38

  
39
///////////////////////////////////////////////////////////////////////////////////////////////////
40

  
41
public class TwistyCrazy3x3 extends ShapeHexahedron
42
{
43
  public static final int CRAZY   = 0x3f;
44
  public static final int MERCURY = 0x2f;
45
  public static final int VENUS   = 0x0f;
46
  public static final int EARTH   = 0x2b;
47
  public static final int MARS    = 0x0b;
48
  public static final int JUPITER = 0x10;
49
  public static final int SATURN  = 0x30;
50
  public static final int URANUS  = 0x14;
51
  public static final int NEPTUNE = 0x16;
52

  
53
  private static final float DIAMETER_RATIO = 0.75f;
54
  private static final float DIFF = 0.6f;
55
  private static final int NUMBER_CORNER_SEGMENTS = 4;
56
  private static final int NUMBER_EDGE_SEGMENTS = 4;
57

  
58
  static final Static3D[] ROT_AXIS = new Static3D[]
59
         {
60
           new Static3D(1,0,0),
61
           new Static3D(0,1,0),
62
           new Static3D(0,0,1)
63
         };
64

  
65
  private ScrambleState[] mStates;
66
  private int[][] mBasicAngle;
67
  private float[][] mCuts;
68
  private float[][] mPositions;
69
  private int[] mQuatIndex;
70
  private float[][] mOffsets;
71

  
72
///////////////////////////////////////////////////////////////////////////////////////////////////
73

  
74
  public TwistyCrazy3x3(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
75
    {
76
    super(data, meshState, iconMode, data.getNumLayers()[0], quat, move, scale, stream);
77
    }
78

  
79
///////////////////////////////////////////////////////////////////////////////////////////////////
80

  
81
  @Override
82
  public void adjustStickerCoords()
83
    {
84
    final float A = 0.3645522f;
85
    final float B = 0.0744520f;
86
    final float C = 0.1823852f;
87
    final float D = 0.3098326f;
88
    final float E = 0.1033291f;
89
    final float F = 0.4044531f;
90
    final float G = 0.4103489f;
91

  
92
    mStickerCoords = new float[][]
93
      {
94
         { A, 0.5f, -0.5f, 0.5f, -0.5f, -A, -B, -A, A, B },
95
         { 0.5f, -C, 0.5f, D, -0.5f, D, -0.5f, -C },
96
         { -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f },
97
         { -0.5f, E, -0.5f, -F, 0.5f, -F, 0.5f, E },
98
         { -G, 0.5f, -G, -G, 0.5f, -G }
99
      };
100
    }
101

  
102
///////////////////////////////////////////////////////////////////////////////////////////////////
103

  
104
  @Override
105
  public int getCubitRotationType(int cubit)
106
    {
107
    int[] numLayers = getNumLayers();
108
    int variant = getCubitVariant(cubit,numLayers);
109

  
110
    switch(variant)
111
      {
112
      case  2: return Cubit.TYPE_DECIDER;
113
      case  3:
114
      case  4: return Cubit.TYPE_FOLLOWER;
115
      default: return Cubit.TYPE_NORMAL;
116
      }
117
    }
118

  
119
///////////////////////////////////////////////////////////////////////////////////////////////////
120

  
121
  @Override
122
  public float[] getCubitRowOffset(int cubitIndex)
123
    {
124
    if( mOffsets==null )
125
      {
126
      float[] tmp = new float[] {0,0,0};
127
      int numCubits = mPositions.length;
128
      mOffsets = new float[numCubits][];
129

  
130
      int param = getInitData().getParam();
131

  
132
      int R = (param>>5)&0x1;
133
      int L = (param>>4)&0x1;
134
      int U = (param>>3)&0x1;
135
      int D = (param>>2)&0x1;
136
      int F = (param>>1)&0x1;
137
      int B = (param   )&0x1;
138

  
139
      for(int i=0; i<numCubits; i++)
140
        {
141
        switch(i)
142
          {
143
          case 20: mOffsets[i] = new float[] {0,0,-DIFF*F}; break;
144
          case 21: mOffsets[i] = new float[] {0,0,+DIFF*B}; break;
145
          case 22: mOffsets[i] = new float[] {0,-DIFF*U,0}; break;
146
          case 23: mOffsets[i] = new float[] {0,+DIFF*D,0}; break;
147
          case 24: mOffsets[i] = new float[] {-DIFF*R,0,0}; break;
148
          case 25: mOffsets[i] = new float[] {+DIFF*L,0,0}; break;
149
          default: mOffsets[i] = tmp;
150
          }
151
        }
152
      }
153

  
154
    return mOffsets[cubitIndex];
155
    }
156

  
157
///////////////////////////////////////////////////////////////////////////////////////////////////
158
// Normal 3x3
159

  
160
  public ScrambleState[] getScrambleStates()
161
    {
162
    if( mStates==null )
163
      {
164
      int[][] m = new int[16][];
165

  
166
      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};
167

  
168
      mStates = new ScrambleState[]
169
          {
170
          new ScrambleState( new int[][] { m[ 1], m[ 2], m[ 3] } ),  //  0 0
171
          new ScrambleState( new int[][] {  null, m[ 4], m[ 5] } ),  //  1 x
172
          new ScrambleState( new int[][] { m[ 6],  null, m[ 7] } ),  //  2 y
173
          new ScrambleState( new int[][] { m[ 8], m[ 9],  null } ),  //  3 z
174
          new ScrambleState( new int[][] { m[10],  null, m[ 7] } ),  //  4 xy
175
          new ScrambleState( new int[][] { m[11], m[ 9],  null } ),  //  5 xz
176
          new ScrambleState( new int[][] {  null, m[12], m[ 5] } ),  //  6 yx
177
          new ScrambleState( new int[][] { m[ 8], m[13],  null } ),  //  7 yz
178
          new ScrambleState( new int[][] {  null, m[ 4], m[14] } ),  //  8 zx
179
          new ScrambleState( new int[][] { m[ 6],  null, m[15] } ),  //  9 zy
180
          new ScrambleState( new int[][] {  null,  null, m[ 5] } ),  // 10 xyx
181
          new ScrambleState( new int[][] {  null, m[ 4],  null } ),  // 11 xzx
182
          new ScrambleState( new int[][] {  null,  null, m[ 7] } ),  // 12 yxy
183
          new ScrambleState( new int[][] { m[ 6],  null,  null } ),  // 13 yzy
184
          new ScrambleState( new int[][] {  null, m[ 9],  null } ),  // 14 zxz
185
          new ScrambleState( new int[][] { m[ 8],  null,  null } ),  // 15 zyz
186
          };
187
      }
188

  
189
    return mStates;
190
    }
191

  
192
///////////////////////////////////////////////////////////////////////////////////////////////////
193

  
194
  public float[][] getCuts(int[] numLayers)
195
    {
196
    if( mCuts==null )
197
      {
198
      float C = 0.5f;
199
      float[] cut = new float[] {-C,+C};
200
      mCuts = new float[][] { cut,cut,cut };
201
      }
202

  
203
    return mCuts;
204
    }
205

  
206
///////////////////////////////////////////////////////////////////////////////////////////////////
207

  
208
  public boolean[][] getLayerRotatable(int[] numLayers)
209
    {
210
    boolean[] tmp = new boolean[] {true,true,true};
211
    return new boolean[][] { tmp,tmp,tmp };
212
    }
213

  
214
///////////////////////////////////////////////////////////////////////////////////////////////////
215

  
216
  public int getTouchControlType()
217
    {
218
    return TC_HEXAHEDRON;
219
    }
220

  
221
///////////////////////////////////////////////////////////////////////////////////////////////////
222

  
223
  public int getTouchControlSplit()
224
    {
225
    return TYPE_NOT_SPLIT;
226
    }
227

  
228
///////////////////////////////////////////////////////////////////////////////////////////////////
229

  
230
  public int[][][] getEnabled()
231
    {
232
    return new int[][][] { {{1,2}},{{1,2}},{{0,2}},{{0,2}},{{0,1}},{{0,1}} };
233
    }
234

  
235
///////////////////////////////////////////////////////////////////////////////////////////////////
236

  
237
  public float[] getDist3D(int[] numLayers)
238
    {
239
    return TouchControlHexahedron.D3D;
240
    }
241

  
242
///////////////////////////////////////////////////////////////////////////////////////////////////
243

  
244
  public Static3D[] getFaceAxis()
245
    {
246
    return TouchControlHexahedron.FACE_AXIS;
247
    }
248

  
249
///////////////////////////////////////////////////////////////////////////////////////////////////
250

  
251
  public float[][] getCubitPositions(int[] numLayers)
252
    {
253
    if( mPositions==null )
254
      {
255
      mPositions = new float[][]
256
         {
257
             { 1.0f, 1.0f, 1.0f},
258
             { 1.0f, 1.0f,-1.0f},
259
             { 1.0f,-1.0f, 1.0f},
260
             { 1.0f,-1.0f,-1.0f},
261
             {-1.0f, 1.0f, 1.0f},
262
             {-1.0f, 1.0f,-1.0f},
263
             {-1.0f,-1.0f, 1.0f},
264
             {-1.0f,-1.0f,-1.0f},
265

  
266
             { 1.0f, 1.0f, 0.0f},
267
             { 1.0f,-1.0f, 0.0f},
268
             { 1.0f, 0.0f, 1.0f},
269
             { 1.0f, 0.0f,-1.0f},
270
             {-1.0f, 1.0f, 0.0f},
271
             {-1.0f,-1.0f, 0.0f},
272
             {-1.0f, 0.0f, 1.0f},
273
             {-1.0f, 0.0f,-1.0f},
274
             { 0.0f, 1.0f, 1.0f},
275
             { 0.0f, 1.0f,-1.0f},
276
             { 0.0f,-1.0f, 1.0f},
277
             { 0.0f,-1.0f,-1.0f},
278

  
279
             { 0.0f, 0.0f, DIFF},
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff