Project

General

Profile

« Previous | Next » 

Revision d31c5b24

Added by Leszek Koltunski over 3 years ago

First attempt at a Circle 2x2 - but this is implemented wrong. The smallInner pieces next to the FLD corner should never move relative to the corner.

View differences:

src/main/java/org/distorted/objectlib/main/ObjectSignatures.java
74 74
  public static final int PENT_2 = ObjectType.PENT_2.ordinal();
75 75
  public static final int MIXU_3 = ObjectType.MIXU_3.ordinal();
76 76
  public static final int MIXP_3 = ObjectType.MIXP_3.ordinal();
77
  public static final int CRA1_2 = ObjectType.CRA1_2.ordinal();
77 78
  public static final int CRA1_3 = ObjectType.CRA1_3.ordinal();
78 79
  public static final int CRA2_3 = ObjectType.CRA2_3.ordinal();
79 80
  public static final int CRA3_3 = ObjectType.CRA3_3.ordinal();
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_2 ( TwistyCrazy2x2.class      , 16, R.drawable.cra1_3, true, new InitData(new int[] {2,2,2}, TwistyCrazy2x2.CIRCLE )),
82 83
  CRA1_3 ( TwistyCrazy3x3.class      , 22, R.drawable.cra1_3, true, new InitData(new int[] {3,3,3}, TwistyCrazy3x3.CRAZY  )),
83 84
  CRA2_3 ( TwistyCrazy3x3.class      , 22, R.drawable.cra1_3, true, new InitData(new int[] {3,3,3}, TwistyCrazy3x3.MERCURY)),
84 85
  CRA3_3 ( TwistyCrazy3x3.class      , 22, R.drawable.cra1_3, true, new InitData(new int[] {3,3,3}, TwistyCrazy3x3.VENUS  )),
......
176 177
  public static TwistyObject create(int ordinal, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream meshStream)
177 178
    {
178 179
    /*
179
    if( ordinal==CRA2_3.ordinal() )
180
    if( ordinal==CRA1_2.ordinal() )
180 181
      {
181
      InitData data = CRA2_3.mInitData;
182
      return new TwistyCrazy(data,meshState,iconMode,quat,move,scale,meshStream);
182
      InitData data = CRA1_2.mInitData;
183
      return new TwistyCrazy2x2(data,meshState,iconMode,quat,move,scale,meshStream);
183 184
      }
184 185
    */
185 186
    Class<? extends TwistyObject> clazz = objects[ordinal].mClass;
src/main/java/org/distorted/objectlib/main/TwistyObject.java
198 198
    mObjectQuats = getQuats();
199 199
    mNumQuats = mObjectQuats.length;
200 200
    mOrigPos = getCubitPositions(mNumLayers);
201
    mRowOffsets = new float[getNumFaces()][3];
201
    mRowOffsets = createInitRowOffsets();
202 202
    mTmp = new float[4];
203 203

  
204 204
    int numAxis = mAxis.length;
......
1929 1929
    return 0;
1930 1930
    }
1931 1931

  
1932
///////////////////////////////////////////////////////////////////////////////////////////////////
1933

  
1934
  public float[][] createInitRowOffsets()
1935
    {
1936
    return new float[getNumFaces()][3];
1937
    }
1938

  
1932 1939
///////////////////////////////////////////////////////////////////////////////////////////////////
1933 1940

  
1934 1941
  public TouchControl getTouchControl()
src/main/java/org/distorted/objectlib/objects/TwistyCrazy2x2.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 TwistyCrazy2x2 extends ShapeHexahedron
42
{
43
  public static final int CIRCLE = 0x29;
44

  
45
  private static final float DIAMETER_RATIO = 0.60f;
46
  private static final float DIFF = 0.3f;
47
  private static final int NUMBER_CORNER_SEGMENTS = 4;
48

  
49
  static final Static3D[] ROT_AXIS = new Static3D[]
50
         {
51
           new Static3D(1,0,0),
52
           new Static3D(0,1,0),
53
           new Static3D(0,0,1)
54
         };
55

  
56
  private ScrambleState[] mStates;
57
  private int[][] mBasicAngle;
58
  private float[][] mCuts;
59
  private float[][] mPositions;
60
  private int[] mQuatIndex;
61
  private float[][] mOffsets;
62

  
63
///////////////////////////////////////////////////////////////////////////////////////////////////
64

  
65
  public TwistyCrazy2x2(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
66
    {
67
    super(data, meshState, iconMode, data.getNumLayers()[0], quat, move, scale, stream);
68
    }
69

  
70
///////////////////////////////////////////////////////////////////////////////////////////////////
71

  
72
  @Override
73
  public void adjustStickerCoords()
74
    {
75
    final float A = 0.50000f;
76
    final float B = 0.45424f;
77
    final float C = 0.11830f;
78

  
79
    mStickerCoords = new float[][]
80
      {
81
        {  B, A,-A, A,-A,-B,-C,-B, B, C },
82
        { -A, A,-A,-A, A,-A }
83
      };
84
    }
85

  
86
///////////////////////////////////////////////////////////////////////////////////////////////////
87

  
88
  @Override
89
  public int getCubitRotationType(int cubit)
90
    {
91
    return cubit<8 ? Cubit.TYPE_NORMAL : Cubit.TYPE_FOLLOWER;
92
    }
93

  
94
///////////////////////////////////////////////////////////////////////////////////////////////////
95

  
96
  @Override
97
  public float[][] createInitRowOffsets()
98
    {
99
    if( mOffsets==null )
100
      {
101
      int param = getInitData().getParam();
102

  
103
      int R = (param>>5)&0x1;
104
      int L = (param>>4)&0x1;
105
      int U = (param>>3)&0x1;
106
      int D = (param>>2)&0x1;
107
      int F = (param>>1)&0x1;
108
      int B = (param   )&0x1;
109

  
110
      float OFF = 1.5f*DIFF;
111

  
112
      mOffsets = new float[][] { {-OFF*R,0,0},{+OFF*L,0,0},{0,-OFF*U,0},{0,+OFF*D,0},{0,0,-OFF*F},{0,0,+OFF*B} };
113
      }
114

  
115
    return mOffsets;
116
    }
117

  
118
///////////////////////////////////////////////////////////////////////////////////////////////////
119
// Normal 2x2
120

  
121
  public ScrambleState[] getScrambleStates()
122
    {
123
    if( mStates==null )
124
      {
125
      int[] m = new int[] { 0,-1,0,0,1,0,0,2,0, 1,-1,0,1,1,0,1,2,0 };
126

  
127
      mStates = new ScrambleState[]
128
          {
129
          new ScrambleState( new int[][] { m,m,m } )
130
          };
131
      }
132

  
133
    return mStates;
134
    }
135

  
136
///////////////////////////////////////////////////////////////////////////////////////////////////
137

  
138
  public float[][] getCuts(int[] numLayers)
139
    {
140
    if( mCuts==null )
141
      {
142
      float[] cut = new float[] {0};
143
      mCuts = new float[][] { cut,cut,cut };
144
      }
145

  
146
    return mCuts;
147
    }
148

  
149
///////////////////////////////////////////////////////////////////////////////////////////////////
150

  
151
  public boolean[][] getLayerRotatable(int[] numLayers)
152
    {
153
    boolean[] tmp = new boolean[] {true,true};
154
    return new boolean[][] { tmp,tmp,tmp };
155
    }
156

  
157
///////////////////////////////////////////////////////////////////////////////////////////////////
158

  
159
  public int getTouchControlType()
160
    {
161
    return TC_HEXAHEDRON;
162
    }
163

  
164
///////////////////////////////////////////////////////////////////////////////////////////////////
165

  
166
  public int getTouchControlSplit()
167
    {
168
    return TYPE_NOT_SPLIT;
169
    }
170

  
171
///////////////////////////////////////////////////////////////////////////////////////////////////
172

  
173
  public int[][][] getEnabled()
174
    {
175
    return new int[][][] { {{1,2}},{{1,2}},{{0,2}},{{0,2}},{{0,1}},{{0,1}} };
176
    }
177

  
178
///////////////////////////////////////////////////////////////////////////////////////////////////
179

  
180
  public float[] getDist3D(int[] numLayers)
181
    {
182
    return TouchControlHexahedron.D3D;
183
    }
184

  
185
///////////////////////////////////////////////////////////////////////////////////////////////////
186

  
187
  public Static3D[] getFaceAxis()
188
    {
189
    return TouchControlHexahedron.FACE_AXIS;
190
    }
191

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

  
194
  public float[][] getCubitPositions(int[] numLayers)
195
    {
196
    if( mPositions==null )
197
      {
198
      mPositions = new float[][]
199
         {
200
             { 0.5f, 0.5f, 0.5f},
201
             { 0.5f, 0.5f,-0.5f},
202
             { 0.5f,-0.5f, 0.5f},
203
             { 0.5f,-0.5f,-0.5f},
204
             {-0.5f, 0.5f, 0.5f},
205
             {-0.5f, 0.5f,-0.5f},
206
             {-0.5f,-0.5f, 0.5f},
207
             {-0.5f,-0.5f,-0.5f},
208

  
209
             { 0.5f, 0.5f, DIFF},
210
             { 0.5f, 0.5f,-DIFF},
211
             { 0.5f,-0.5f, DIFF},
212
             { 0.5f,-0.5f,-DIFF},
213
             {-0.5f, 0.5f, DIFF},
214
             {-0.5f, 0.5f,-DIFF},
215
             {-0.5f,-0.5f, DIFF},
216
             {-0.5f,-0.5f,-DIFF},
217
             { 0.5f, DIFF, 0.5f},
218
             { 0.5f,-DIFF, 0.5f},
219
             { 0.5f, DIFF,-0.5f},
220
             { 0.5f,-DIFF,-0.5f},
221
             {-0.5f, DIFF, 0.5f},
222
             {-0.5f,-DIFF, 0.5f},
223
             {-0.5f, DIFF,-0.5f},
224
             {-0.5f,-DIFF,-0.5f},
225
             { DIFF, 0.5f, 0.5f},
226
             {-DIFF, 0.5f, 0.5f},
227
             { DIFF, 0.5f,-0.5f},
228
             {-DIFF, 0.5f,-0.5f},
229
             { DIFF,-0.5f, 0.5f},
230
             {-DIFF,-0.5f, 0.5f},
231
             { DIFF,-0.5f,-0.5f},
232
             {-DIFF,-0.5f,-0.5f},
233
         };
234
      }
235

  
236
    return mPositions;
237
    }
238

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

  
241
  public Static4D getCubitQuats(int cubit, int[] numLayers)
242
    {
243
    if( mQuatIndex==null ) mQuatIndex = new int[] { 0,1,17,22,4,5,8,19,
244
                                                    0,18,7,2, 9,5,8,19, 13,3,1,22, 14,23,15,11, 21,4,6,10, 17,20,12,16 };
245
    return mObjectQuats[mQuatIndex[cubit]];
246
    }
247

  
248
///////////////////////////////////////////////////////////////////////////////////////////////////
249

  
250
  private ObjectShape getCornerShape()
251
    {
252
    final float INIT_ALPHA = 0.0f;
253
    final float STEP_CORNER= (float)((Math.PI/2)/NUMBER_CORNER_SEGMENTS);
254
    final int SINGLE_ARC = NUMBER_CORNER_SEGMENTS+1;
255
    final int SINGLE_INNER_ARC = (NUMBER_CORNER_SEGMENTS+1)/2;
256
    final int NUM_VERTICES = 4 + 3*SINGLE_ARC + 1 + 3*SINGLE_INNER_ARC;
257
    float[][] tmp = new float[SINGLE_ARC][2];
258

  
259
    for(int i=0; i<SINGLE_ARC; i++)
260
      {
261
      float alpha = INIT_ALPHA + i*STEP_CORNER;
262
      tmp[i][0] = (float)(DIAMETER_RATIO*Math.sin(alpha) - 0.5f);
263
      tmp[i][1] = (float)(DIAMETER_RATIO*Math.cos(alpha) - 0.5f);
264
      }
265

  
266
    float[][] vertices = new float[NUM_VERTICES][];
267

  
268
    vertices[0] = new float[] { +0.5f, +0.5f, +0.5f };
269
    vertices[1] = new float[] { -0.5f, +0.5f, +0.5f };
270
    vertices[2] = new float[] { +0.5f, -0.5f, +0.5f };
271
    vertices[3] = new float[] { +0.5f, +0.5f, -0.5f };
272

  
273
    for(int i=0; i<SINGLE_ARC; i++)
274
      {
275
      float s = tmp[i][0];
276
      float c = tmp[i][1];
277

  
278
      vertices[4             +i] = new float[] {0.5f,+s,+c};
279
      vertices[4+  SINGLE_ARC+i] = new float[] {+c,0.5f,+s};
280
      vertices[4+2*SINGLE_ARC+i] = new float[] {+s,+c,0.5f};
281
      }
282

  
283
    final float EXTRA = (NUMBER_CORNER_SEGMENTS%2)==0 ? 1.0f : (float)Math.cos((Math.PI/2)/(2*NUMBER_CORNER_SEGMENTS));
284
    final float LEN   = DIAMETER_RATIO*EXTRA;
285
    final float M     = (float)(LEN*Math.sin(Math.PI/4) - 0.5f);
286
    vertices[4+3*SINGLE_ARC] = new float[] {M,M,M};
287

  
288
    for(int i=0; i<SINGLE_INNER_ARC; i++)
289
      {
290
      float s = tmp[i][0];
291
      float c = tmp[i][1];
292

  
293
      vertices[4+3*SINGLE_ARC+1                   +i] = new float[] {s,c,c};
294
      vertices[4+3*SINGLE_ARC+1+  SINGLE_INNER_ARC+i] = new float[] {c,s,c};
295
      vertices[4+3*SINGLE_ARC+1+2*SINGLE_INNER_ARC+i] = new float[] {c,c,s};
296
      }
297

  
298
    final int NUM_FACES = 6 + 3*NUMBER_CORNER_SEGMENTS;
299
    final int NUM_VERTS = 4 +   NUMBER_CORNER_SEGMENTS;
300

  
301
    int[][] indices = new int[NUM_FACES][];
302

  
303
    indices[0] = new int[NUM_VERTS];
304
    indices[1] = new int[NUM_VERTS];
305
    indices[2] = new int[NUM_VERTS];
306

  
307
    indices[0][0] = 3;
308
    indices[0][1] = 0;
309
    indices[0][2] = 2;
310
    indices[1][0] = 1;
311
    indices[1][1] = 0;
312
    indices[1][2] = 3;
313
    indices[2][0] = 2;
314
    indices[2][1] = 0;
315
    indices[2][2] = 1;
316

  
317
    for(int i=0; i<SINGLE_ARC; i++)
318
      {
319
      indices[0][3+i] = 4+i;
320
      indices[1][3+i] = 4+i+  SINGLE_ARC;
321
      indices[2][3+i] = 4+i+2*SINGLE_ARC;
322
      }
323

  
324
    indices[3] = new int[] { 1, 4+2*SINGLE_ARC-1, 4+3*SINGLE_ARC+1                   , 4+2*SINGLE_ARC};
325
    indices[4] = new int[] { 2, 4+3*SINGLE_ARC-1, 4+3*SINGLE_ARC+1+  SINGLE_INNER_ARC, 4             };
326
    indices[5] = new int[] { 3, 4+  SINGLE_ARC-1, 4+3*SINGLE_ARC+1+2*SINGLE_INNER_ARC, 4+  SINGLE_ARC};
327

  
328
    int start,i0,i1,i2,i3;
329
    int MID = (NUMBER_CORNER_SEGMENTS)/2;
330
    int MID2= (NUMBER_CORNER_SEGMENTS+1)/2;
331

  
332
    if( (NUMBER_CORNER_SEGMENTS%2) == 0 )
333
      {
334
      start = 12;
335
      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};
336
      indices[ 7] = new int[] { 4+3*SINGLE_ARC, 4+3*SINGLE_ARC+1+MID-1,  4+SINGLE_ARC+MID+1, 4+SINGLE_ARC+MID};
337
      indices[ 8] = new int[] { 4+3*SINGLE_ARC, 4+3*SINGLE_ARC+1+2*SINGLE_INNER_ARC+MID-1, 4+MID+1, 4+MID };
338
      indices[ 9] = new int[] { 4+3*SINGLE_ARC, 4+MID, 4+MID-1, 4+3*SINGLE_ARC+1+SINGLE_INNER_ARC+MID-1 };
339
      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 };
340
      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 };
341
      }
342
    else
343
      {
344
      start = 9;
345
      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};
346
      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};
347
      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};
348
      }
349

  
350
    for(int j=0; j<MID2-1; j++)
351
      {
352
      i0 = 4+3*SINGLE_ARC+1+2*SINGLE_INNER_ARC+j;
353
      i1 = 4+3*SINGLE_ARC+1+2*SINGLE_INNER_ARC+j+1;
354
      i2 = 4+SINGLE_ARC+j+1;
355
      i3 = 4+SINGLE_ARC+j;
356

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

  
359
      i0 = 4+3*SINGLE_ARC+1+2*SINGLE_INNER_ARC+j+1;
360
      i1 = 4+3*SINGLE_ARC+1+2*SINGLE_INNER_ARC+j;
361
      i2 = 4+(SINGLE_ARC-1)-j;
362
      i3 = 4+(SINGLE_ARC-1)-(j+1);
363

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

  
366
      i0 = 4+3*SINGLE_ARC+1+j;
367
      i1 = 4+3*SINGLE_ARC+1+j+1;
368
      i2 = 4+2*SINGLE_ARC+j+1;
369
      i3 = 4+2*SINGLE_ARC+j;
370

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

  
373
      i0 = 4+3*SINGLE_ARC+1+j+1;
374
      i1 = 4+3*SINGLE_ARC+1+j;
375
      i2 = 4+(2*SINGLE_ARC-1)-j;
376
      i3 = 4+(2*SINGLE_ARC-1)-(j+1);
377

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

  
380
      i0 = 4+3*SINGLE_ARC+1+SINGLE_INNER_ARC+j;
381
      i1 = 4+3*SINGLE_ARC+1+SINGLE_INNER_ARC+j+1;
382
      i2 = 4+j+1;
383
      i3 = 4+j;
384

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

  
387
      i0 = 4+3*SINGLE_ARC+1+SINGLE_INNER_ARC+j+1;
388
      i1 = 4+3*SINGLE_ARC+1+SINGLE_INNER_ARC+j;
389
      i2 = 4+(3*SINGLE_ARC-1)-j;
390
      i3 = 4+(3*SINGLE_ARC-1)-(j+1);
391

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

  
395
    return new ObjectShape(vertices,indices);
396
    }
397

  
398
///////////////////////////////////////////////////////////////////////////////////////////////////
399

  
400
  private ObjectShape getSmallCircleShape(float D)
401
    {
402
    final float H = DIAMETER_RATIO-0.5f;
403
    final float INIT_ALPHA = 0;
404
    final float STEP_CORNER= (float)((Math.PI/2)/NUMBER_CORNER_SEGMENTS);
405
    final int NUM_VERTICES = 6 + 2*(NUMBER_CORNER_SEGMENTS-1);
406
    float[][] vertices = new float[NUM_VERTICES][];
407

  
408
    vertices[0] = new float[] {-0.5f,    H, 0.5f+D};
409
    vertices[1] = new float[] {    H,-0.5f, 0.5f+D};
410
    vertices[2] = new float[] {-0.5f,-0.5f, 0.5f+D};
411
    vertices[3] = new float[] {-0.5f,    H,-0.5f+D};
412
    vertices[4] = new float[] {    H,-0.5f,-0.5f+D};
413
    vertices[5] = new float[] {-0.5f,-0.5f,-0.5f+D};
414

  
415
    for(int i=0; i<NUMBER_CORNER_SEGMENTS-1; i++)
416
      {
417
      float alpha = INIT_ALPHA + (i+1)*STEP_CORNER;
418
      float A = (float)(DIAMETER_RATIO*Math.sin(alpha) - 0.5f);
419
      float B = (float)(DIAMETER_RATIO*Math.cos(alpha) - 0.5f);
420

  
421
      vertices[6                       +i] = new float[] {A,B, 0.5f+D};
422
      vertices[5+NUMBER_CORNER_SEGMENTS+i] = new float[] {A,B,-0.5f+D};
423
      }
424

  
425
    final int NUM_FACES = 4 + NUMBER_CORNER_SEGMENTS;
426
    int[][] indices = new int[NUM_FACES][];
427

  
428
    int NUMV = 2+NUMBER_CORNER_SEGMENTS;
429
    indices[0] = new int[NUMV];
430
    indices[0][0] = 0;
431
    indices[0][1] = 2;
432
    indices[0][2] = 1;
433
    for(int i=3; i<NUMV; i++) indices[0][i] = 5+(NUMBER_CORNER_SEGMENTS-1)-(i-3);
434

  
435
    indices[1] = new int[NUMV];
436
    indices[1][0] = 4;
437
    indices[1][1] = 5;
438
    indices[1][2] = 3;
439
    for(int i=3; i<NUMV; i++) indices[1][i] = 5+NUMBER_CORNER_SEGMENTS+(i-3);
440

  
441
    indices[2] = new int[] {0,3,5,2};
442
    indices[3] = new int[] {1,2,5,4};
443

  
444
    indices[4] = new int[] {5+NUMBER_CORNER_SEGMENTS,3,0,6};
445
    indices[5] = new int[] {1,4,5+2*(NUMBER_CORNER_SEGMENTS-1),5+(NUMBER_CORNER_SEGMENTS-1)};
446

  
447
    for(int i=0; i<NUMBER_CORNER_SEGMENTS-2; i++)
448
      {
449
      int i0 = 6+i;
450
      int i1 = 7+i;
451
      int i2 = 6+NUMBER_CORNER_SEGMENTS+i;
452
      int i3 = 5+NUMBER_CORNER_SEGMENTS+i;
453

  
454
      indices[6+i] = new int[] {i0,i1,i2,i3};
455
      }
456

  
457
    return new ObjectShape(vertices,indices);
458
    }
459

  
460
///////////////////////////////////////////////////////////////////////////////////////////////////
461

  
462
  public ObjectShape getObjectShape(int variant)
463
    {
464
    switch(variant)
465
      {
466
      case 0: return getCornerShape();
467
      case 1: return getSmallCircleShape(0.52f-DIFF);
468
      }
469

  
470
    return null;
471
    }
472

  
473
///////////////////////////////////////////////////////////////////////////////////////////////////
474

  
475
  public ObjectFaceShape getObjectFaceShape(int variant)
476
    {
477
    if( variant==0 )
478
      {
479
      float h1 = isInIconMode() ? 0.001f : 0.04f;
480
      float h2 = 0.001f;
481
      float[][] bands   = { {h1,45,0.3f,0.7f,5,0,0}, {h2,5,0.3f,0.2f,5,0,0} };
482
      final int NUM_BANDS = 6+3*NUMBER_CORNER_SEGMENTS;
483
      int[] bandIndices = new int[NUM_BANDS];
484
      bandIndices[0] = bandIndices[1] = bandIndices[2] = 0;
485
      for(int i=3; i<NUM_BANDS; i++) bandIndices[i] = 1;
486
      float[][] corners = { {0.02f,0.09f} };
487
      float[][] centers = { { 0.0f, 0.0f, 0.0f } };
488
      final int SINGLE_ARC = NUMBER_CORNER_SEGMENTS+1;
489
      final int SINGLE_INNER_ARC = (NUMBER_CORNER_SEGMENTS+1)/2;
490
      final int NUM_VERTICES = 4 + 3*SINGLE_ARC + 1 + 3*SINGLE_INNER_ARC;
491
      int[] indices = new int[NUM_VERTICES];
492
      indices[0] = indices[1] = indices[2] = indices[3] = 0;
493
      for(int i=4; i<NUM_VERTICES; i++) indices[i] = -1;
494
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
495
      }
496
    else
497
      {
498
      float h1 = isInIconMode() ? 0.001f : 0.02f;
499
      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} };
500
      final int NUM_BANDS = 4 + NUMBER_CORNER_SEGMENTS;
501
      int[] bandIndices = new int[NUM_BANDS];
502
      bandIndices[0] = 0;
503
      bandIndices[1] = 2;
504
      bandIndices[2] = bandIndices[3] = 1;
505
      for(int i=4; i<NUM_BANDS; i++) bandIndices[i] = 2;
506
      float[][] corners = { {0.02f,0.09f} };
507
      float[][] centers = { { 0.0f, 0.0f, 1.0f } };
508
      final int NUM_VERTICES = 6 + 2*(NUMBER_CORNER_SEGMENTS-1);
509
      int[] indices = new int[NUM_VERTICES];
510
      for(int i=0; i<NUM_VERTICES; i++) indices[i] = -1;
511
      indices[0] = indices[1] = indices[2] = 0;
512
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
513
      }
514
    }
515

  
516
///////////////////////////////////////////////////////////////////////////////////////////////////
517

  
518
  public int getNumCubitVariants(int[] numLayers)
519
    {
520
    return 2;
521
    }
522

  
523
///////////////////////////////////////////////////////////////////////////////////////////////////
524

  
525
  public int getCubitVariant(int cubit, int[] numLayers)
526
    {
527
    return cubit<8 ? 0:1;
528
    }
529

  
530
///////////////////////////////////////////////////////////////////////////////////////////////////
531

  
532
  public float getStickerRadius()
533
    {
534
    return 0.07f;
535
    }
536

  
537
///////////////////////////////////////////////////////////////////////////////////////////////////
538

  
539
  public float getStickerStroke()
540
    {
541
    return isInIconMode() ? 0.22f : 0.12f;
542
    }
543

  
544
///////////////////////////////////////////////////////////////////////////////////////////////////
545

  
546
  public float[][] getStickerAngles()
547
    {
548
    float D = (float)(Math.PI/4);
549
    return new float[][] { { 0,0,0,-D,0 },{ 0,0,D } };
550
    }
551

  
552
///////////////////////////////////////////////////////////////////////////////////////////////////
553
// PUBLIC API
554

  
555
  public Static3D[] getRotationAxis()
556
    {
557
    return ROT_AXIS;
558
    }
559

  
560
///////////////////////////////////////////////////////////////////////////////////////////////////
561

  
562
  public int[][] getBasicAngles()
563
    {
564
    if( mBasicAngle==null )
565
      {
566
      int[] tmp = new int[] {4,4,4};
567
      mBasicAngle = new int[][] { tmp,tmp,tmp };
568
      }
569

  
570
    return mBasicAngle;
571
    }
572

  
573
///////////////////////////////////////////////////////////////////////////////////////////////////
574

  
575
  public String getShortName()
576
    {
577
    return ObjectType.CRA1_2.name();
578
    }
579

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

  
582
  public ObjectSignature getSignature()
583
    {
584
    return new ObjectSignature(ObjectType.CRA1_2);
585
    }
586

  
587
///////////////////////////////////////////////////////////////////////////////////////////////////
588

  
589
  public String getObjectName()
590
    {
591
    return "Circle 2x2";
592
    }
593

  
594
///////////////////////////////////////////////////////////////////////////////////////////////////
595

  
596
  public String getInventor()
597
    {
598
    return "Aleh Hladzilin";
599
    }
600

  
601
///////////////////////////////////////////////////////////////////////////////////////////////////
602

  
603
  public int getYearOfInvention()
604
    {
605
    return 2007;
606
    }
607

  
608
///////////////////////////////////////////////////////////////////////////////////////////////////
609

  
610
  public int getComplexity()
611
    {
612
    return 2;
613
    }
614

  
615
///////////////////////////////////////////////////////////////////////////////////////////////////
616

  
617
  public String[][] getTutorials()
618
    {
619
     return new String[][] {
620
                            {"gb","7xUE8ond_Mg","Crazy 3x3x3 Cube Tutorial","SuperAntoniovivaldi"},
621
                            {"vn","N_AWJjHzqk0","Circle Crazy 3x3 Tutorial","VĂN CÔNG TÙNG"},
622
                           };
623
    }
624
}

Also available in: Unified diff