Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyKilominx.java @ 8f5116ec

1 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6 6133be67 Leszek Koltunski
// Magic Cube is proprietary software licensed under an EULA which you should have received      //
7
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html        //
8 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
9
10
package org.distorted.objectlib.objects;
11
12 c9c71c3f Leszek Koltunski
import static org.distorted.objectlib.touchcontrol.TouchControlDodecahedron.COS54;
13
import static org.distorted.objectlib.touchcontrol.TouchControlDodecahedron.SIN54;
14 29b82486 Leszek Koltunski
15 ecf3d6e3 Leszek Koltunski
import org.distorted.library.type.Static3D;
16 29b82486 Leszek Koltunski
import org.distorted.library.type.Static4D;
17 aacf5e27 Leszek Koltunski
import org.distorted.library.helpers.QuatHelper;
18 29b82486 Leszek Koltunski
19 84a17011 Leszek Koltunski
import org.distorted.objectlib.helpers.FactoryCubit;
20 3ee1d662 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectFaceShape;
21 ae9d9227 leszek
import org.distorted.objectlib.metadata.Metadata;
22 84a17011 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectVertexEffects;
23 cf93ea4e Leszek Koltunski
import org.distorted.objectlib.main.InitAssets;
24 361fd0de leszek
import org.distorted.objectlib.metadata.ListObjects;
25 198c5bf0 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectShape;
26 29b82486 Leszek Koltunski
27
///////////////////////////////////////////////////////////////////////////////////////////////////
28
29 9ba7f3f6 Leszek Koltunski
public class TwistyKilominx extends TwistyDodecahedron
30 29b82486 Leszek Koltunski
{
31 ae9d9227 leszek
  public TwistyKilominx(int iconMode, Static4D quat, Static3D move, float scale, Metadata meta, InitAssets asset)
32 29b82486 Leszek Koltunski
    {
33 ae9d9227 leszek
    super(iconMode, quat, move, scale, meta, asset);
34 29b82486 Leszek Koltunski
    }
35
36 ed0988c0 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
37
38
  @Override
39 8f5116ec leszek
  protected float[][][] getStickerRadii()
40 ed0988c0 Leszek Koltunski
    {
41
    int[] numLayers = getNumLayers();
42 8f5116ec leszek
    float R = 0.18f;
43
    float L = 0.50f;
44
    float[][] t1 = {{ R,L,R,R }};
45
    float[][] t2 = {{ R,R,R,R }};
46 ed0988c0 Leszek Koltunski
47 8f5116ec leszek
    if( numLayers[0]==3 ) return new float[][][] { t1 };
48
    else                  return new float[][][] { t2,t2,t2,t1 };
49 ed0988c0 Leszek Koltunski
    }
50
51 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
52
53
  private int numCubitsPerCorner(int numLayers)
54
    {
55
    return 3*((numLayers-3)/2)*((numLayers-5)/2) + (numLayers<5 ? 0:1);
56
    }
57
58
///////////////////////////////////////////////////////////////////////////////////////////////////
59
60
  private int numCubitsPerEdge(int numLayers)
61
    {
62
    return numLayers<5 ? 0 : 2*(numLayers-4);
63
    }
64
65
///////////////////////////////////////////////////////////////////////////////////////////////////
66
67 7bbfc84f Leszek Koltunski
  public float[][] getCuts(int[] numLayers)
68 29b82486 Leszek Koltunski
    {
69 a57e6870 Leszek Koltunski
    return genericGetCuts(numLayers[0],0.5f);
70 29b82486 Leszek Koltunski
    }
71
72
///////////////////////////////////////////////////////////////////////////////////////////////////
73
// Fill out mCurrCorner{X,Y,Z} by applying appropriate Quat to mBasicCorner{X,Y,Z}
74
// Appropriate one: QUATS[QUAT_INDICES[corner]].
75
76
  private void computeBasicCornerVectors(int corner)
77
    {
78
    if( mQuatCornerIndices==null ) initializeQuatIndices();
79
    if( mCurrCornerV==null || mBasicCornerV==null ) initializeCornerV();
80
81 89a00832 Leszek Koltunski
    Static4D quat = mObjectQuats[mQuatCornerIndices[corner]];
82 29b82486 Leszek Koltunski
83
    mCurrCornerV[0] = QuatHelper.rotateVectorByQuat(mBasicCornerV[0],quat);
84
    mCurrCornerV[1] = QuatHelper.rotateVectorByQuat(mBasicCornerV[1],quat);
85
    mCurrCornerV[2] = QuatHelper.rotateVectorByQuat(mBasicCornerV[2],quat);
86
    }
87
88
///////////////////////////////////////////////////////////////////////////////////////////////////
89
90
  private float[] computeCorner(int numCubitsPerCorner, int numLayers, int corner, int part)
91
    {
92 22e5106b leszek
    if( mCorners==null ) mCorners = initializeCorners();
93 29b82486 Leszek Koltunski
    if( mCurrCornerV==null || mBasicCornerV==null ) initializeCornerV();
94
95
    float D = numLayers/3.0f;
96
    float[] corn = mCorners[corner];
97
98
    if( part==0 )
99
      {
100
      return new float[] { corn[0]*D, corn[1]*D, corn[2]*D };
101
      }
102
    else
103
      {
104
      float E = D/(0.5f*(numLayers-1));   // ?? maybe 0.5*
105
      int N = (numCubitsPerCorner-1)/3;
106
      int block = (part-1) % N;
107
      int index = (part-1) / N;
108
      Static4D pri = mCurrCornerV[index];
109
      Static4D sec = mCurrCornerV[(index+2)%3];
110
111
      int layers= (numLayers-5)/2;
112
      int multP = (block % layers) + 1;
113
      int multS = (block / layers);
114
115
      return new float[] {
116
                          corn[0]*D + (pri.get0()*multP + sec.get0()*multS)*E,
117
                          corn[1]*D + (pri.get1()*multP + sec.get1()*multS)*E,
118
                          corn[2]*D + (pri.get2()*multP + sec.get2()*multS)*E
119
                         };
120
      }
121
    }
122
123
///////////////////////////////////////////////////////////////////////////////////////////////////
124
125
  private float[] computeCenter(int numLayers, int center, int part)
126
    {
127
    if( mCenterCoords==null ) initializeCenterCoords();
128 22e5106b leszek
    if( mCorners     ==null ) mCorners = initializeCorners();
129 a662c27e leszek
    if( mCenterMap   ==null ) mCenterMap = initializeCenterMap();
130 29b82486 Leszek Koltunski
131
    int corner = mCenterMap[center][part];
132
    float[] cent = mCenterCoords[center];
133
    float[] corn = mCorners[corner];
134
    float D = numLayers/3.0f;
135
    float F = 1.0f - (2.0f*numLayers-6.0f)/(numLayers-1)*COS54*COS54;
136
137
    return new float[]
138
      {
139
        D * ( cent[0] + (corn[0]-cent[0])*F),
140
        D * ( cent[1] + (corn[1]-cent[1])*F),
141
        D * ( cent[2] + (corn[2]-cent[2])*F)
142
      };
143
    }
144
145
///////////////////////////////////////////////////////////////////////////////////////////////////
146
147
  private int computeEdgeType(int cubit, int numCubitsPerCorner, int numCubitsPerEdge)
148
    {
149
    int part = (cubit - NUM_CORNERS*numCubitsPerCorner) % numCubitsPerEdge;
150
    return part - 2*(part/4);
151
    }
152
153
///////////////////////////////////////////////////////////////////////////////////////////////////
154
155
  private float[] computeEdge(int numLayers, int edge, int part)
156
    {
157
    if( mCenterCoords==null ) initializeCenterCoords();
158 22e5106b leszek
    if( mCorners==null ) mCorners = initializeCorners();
159
    if( mEdgeMap==null ) mEdgeMap = initializeEdgeMap();
160 29b82486 Leszek Koltunski
161
    float D = numLayers/3.0f;
162
    float[] c1 = mCorners[ mEdgeMap[edge][0] ];
163
    float[] c2 = mCorners[ mEdgeMap[edge][1] ];
164
165
    int leftRight = 2*(part%2) -1;
166
    part /= 2;
167
168
    if( part==0 )
169
      {
170
      float T = 0.5f + leftRight/(numLayers-1.0f);
171
      float x = D * (T*c1[0]+(1.0f-T)*c2[0]);
172
      float y = D * (T*c1[1]+(1.0f-T)*c2[1]);
173
      float z = D * (T*c1[2]+(1.0f-T)*c2[2]);
174
175
      return new float[] { x, y, z };
176
      }
177
    else
178
      {
179
      int mult = (part+1)/2;
180
      int dir  = (part+1)%2;
181
      float[] center = mCenterCoords[ mEdgeMap[edge][dir+2] ];
182
      float x = 0.5f * D * (c1[0]+c2[0]);
183
      float y = 0.5f * D * (c1[1]+c2[1]);
184
      float z = 0.5f * D * (c1[2]+c2[2]);
185
186
      float vX = D*center[0] - x;
187
      float vY = D*center[1] - y;
188
      float vZ = D*center[2] - z;
189
190
      float T = 0.5f + leftRight*(mult*SIN18 + 1.0f)/(numLayers-1);
191
192
      x = D * (T*c1[0]+(1.0f-T)*c2[0]);
193
      y = D * (T*c1[1]+(1.0f-T)*c2[1]);
194
      z = D * (T*c1[2]+(1.0f-T)*c2[2]);
195
196
      float H = mult*D*COS18/(numLayers-1);
197
      H /= (float)Math.sqrt(vX*vX+vY*vY+vZ*vZ);
198
199
      return new float[] { x + H*vX, y + H*vY, z + H*vZ };
200
      }
201
    }
202
203
///////////////////////////////////////////////////////////////////////////////////////////////////
204
205 7b832206 Leszek Koltunski
  public float[][] getCubitPositions(int[] numLayers)
206 29b82486 Leszek Koltunski
    {
207 22e5106b leszek
    if( mCorners==null ) mCorners = initializeCorners();
208 29b82486 Leszek Koltunski
209 a57e6870 Leszek Koltunski
    int numL = numLayers[0];
210
    if( numL<5 ) return mCorners;
211
212
    int numCubitsPerCorner = numCubitsPerCorner(numL);
213
    int numCubitsPerEdge   = numCubitsPerEdge(numL);
214 29b82486 Leszek Koltunski
    int numCubitsPerCenter = 5;
215
    int numCubits = NUM_CORNERS*numCubitsPerCorner + NUM_EDGES*numCubitsPerEdge + NUM_CENTERS*numCubitsPerCenter;
216
    int index=0;
217
218 9659b849 leszek
    final float[][] positions = new float[numCubits][];
219 29b82486 Leszek Koltunski
220
    for(int corner=0; corner<NUM_CORNERS; corner++)
221
      {
222
      computeBasicCornerVectors(corner);
223
224
      for(int part=0; part<numCubitsPerCorner; part++, index++)
225
        {
226 9659b849 leszek
        positions[index] = computeCorner(numCubitsPerCorner,numL,corner,part);
227 29b82486 Leszek Koltunski
        }
228
      }
229
230
    for(int edge=0; edge<NUM_EDGES; edge++)
231
      {
232
      for(int part=0; part<numCubitsPerEdge; part++, index++)
233
        {
234 9659b849 leszek
        positions[index] = computeEdge(numL, edge, part );
235 29b82486 Leszek Koltunski
        }
236
      }
237
238
    for(int center=0; center<NUM_CENTERS; center++)
239
      {
240
      for(int part=0; part<numCubitsPerCenter; part++, index++)
241
        {
242 9659b849 leszek
        positions[index] = computeCenter(numL,center, part);
243 29b82486 Leszek Koltunski
        }
244
      }
245
246 9659b849 leszek
    return positions;
247 29b82486 Leszek Koltunski
    }
248
249 d0e6cf7f Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
250
251
  public Static4D getCubitQuats(int cubit, int[] numLayers)
252
    {
253
    int numL = numLayers[0];
254
    int numCubitsPerCorner = numCubitsPerCorner(numL);
255
    int numCubitsPerEdge   = numCubitsPerEdge(numL);
256 89a00832 Leszek Koltunski
    int q = getQuat(cubit,numCubitsPerCorner,numCubitsPerEdge);
257
    return mObjectQuats[q];
258 d0e6cf7f Leszek Koltunski
    }
259
260 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
261
262
  private int getQuat(int cubit, int numCubitsPerCorner, int numCubitsPerEdge)
263
    {
264
    if( mQuatCornerIndices==null || mQuatEdgeIndices==null ) initializeQuatIndices();
265 a662c27e leszek
    if( mCenterMap==null ) mCenterMap = initializeCenterMap();
266 29b82486 Leszek Koltunski
267
    if( cubit < NUM_CORNERS*numCubitsPerCorner )
268
      {
269
      int corner = cubit/numCubitsPerCorner;
270
      return mQuatCornerIndices[corner];
271
      }
272
273
    if( cubit < NUM_CORNERS*numCubitsPerCorner + NUM_EDGES*numCubitsPerEdge )
274
      {
275
      int edge = (cubit-NUM_CORNERS*numCubitsPerCorner)/numCubitsPerEdge;
276
      return mQuatEdgeIndices[edge];
277
      }
278
279
    if( numCubitsPerCorner==0 )
280
      {
281
      return mQuatCornerIndices[cubit];
282
      }
283
    else
284
      {
285
      cubit -= (NUM_CORNERS*numCubitsPerCorner + NUM_EDGES*numCubitsPerEdge);
286
      int numCubitsPerCenter = 5;
287
      int face = cubit/numCubitsPerCenter;
288
      int index= cubit%numCubitsPerCenter;
289
      int center=mCenterMap[face][index];
290
      return mQuatCornerIndices[center];
291
      }
292
    }
293
294
///////////////////////////////////////////////////////////////////////////////////////////////////
295
296 84a17011 Leszek Koltunski
  private float[][] getVertices(int variant)
297 29b82486 Leszek Koltunski
    {
298 e30c522a Leszek Koltunski
    int[] numLayers = getNumLayers();
299 29b82486 Leszek Koltunski
    int numVariants = getNumCubitVariants(numLayers);
300 e30c522a Leszek Koltunski
    int numL        = numLayers[0];
301 66de0d91 Leszek Koltunski
    boolean small   = numL<=3;
302 29b82486 Leszek Koltunski
303 66de0d91 Leszek Koltunski
    if( variant==0 && !small )
304 29b82486 Leszek Koltunski
      {
305 a57e6870 Leszek Koltunski
      float width = numL/(numL-1.0f);
306 57ef6378 Leszek Koltunski
      float X = width*COS18*SIN_HALFD;
307
      float Y = width*SIN18;
308
      float Z = width*COS18*COS_HALFD;
309 29b82486 Leszek Koltunski
310 84a17011 Leszek Koltunski
      return new float[][]
311 29b82486 Leszek Koltunski
        {
312 57ef6378 Leszek Koltunski
            {   0,   0      ,   0 },
313 29b82486 Leszek Koltunski
            {   X,   Y      ,  -Z },
314 57ef6378 Leszek Koltunski
            {   0, 2*Y      ,-2*Z },
315 29b82486 Leszek Koltunski
            {  -X,   Y      ,  -Z },
316 57ef6378 Leszek Koltunski
            {   0,   0-width,   0 },
317 29b82486 Leszek Koltunski
            {   X,   Y-width,  -Z },
318 57ef6378 Leszek Koltunski
            {   0, 2*Y-width,-2*Z },
319 29b82486 Leszek Koltunski
            {  -X,   Y-width,  -Z },
320
        };
321
      }
322 84a17011 Leszek Koltunski
    else if( variant<numVariants-1 )
323 29b82486 Leszek Koltunski
      {
324 e30c522a Leszek Koltunski
      int type = variant-1;
325 a57e6870 Leszek Koltunski
      float tmpVal= numL/(numL-1.0f);
326 29b82486 Leszek Koltunski
      float height= tmpVal*COS18;
327
      float width = tmpVal + (type/2)*tmpVal*SIN18;
328
      boolean left = (type%2)==0;
329
330 57ef6378 Leszek Koltunski
      float X = height*SIN_HALFD;
331
      float Y = height*SIN18/COS18;
332
      float Z = height*COS_HALFD;
333 29b82486 Leszek Koltunski
334 4e9f2df5 Leszek Koltunski
      float[][] vertices =
335 29b82486 Leszek Koltunski
        {
336 57ef6378 Leszek Koltunski
            {   0,   0   ,   0 },
337 29b82486 Leszek Koltunski
            {   X,   Y   ,  -Z },
338 57ef6378 Leszek Koltunski
            {   0, 2*Y   ,-2*Z },
339 29b82486 Leszek Koltunski
            {  -X,   Y   ,  -Z },
340 57ef6378 Leszek Koltunski
            {   0, -width,   0 },
341 29b82486 Leszek Koltunski
            {   X, -width,  -Z },
342 57ef6378 Leszek Koltunski
            {   0, -width,-2*Z },
343 29b82486 Leszek Koltunski
            {  -X, -width,  -Z },
344
        };
345
346
      if( !left )
347
        {
348 84a17011 Leszek Koltunski
        int len = vertices.length;
349 29b82486 Leszek Koltunski
        for(int i=0; i<len; i++) vertices[i][1] = -vertices[i][1];
350
        }
351 84a17011 Leszek Koltunski
      return vertices;
352 29b82486 Leszek Koltunski
      }
353
    else
354
      {
355 a57e6870 Leszek Koltunski
      float width = (1+0.5f*(numL-3)*SIN18)*numL/(numL-1);
356 57ef6378 Leszek Koltunski
      float X = width*COS18*SIN_HALFD;
357
      float Y = width*SIN18;
358
      float Z = width*COS18*COS_HALFD;
359
      float H = width*(SIN54/COS54);
360
      float H3= H/COS_HALFD;
361
      float X3= H*SIN_HALFD;
362
      float Z3= H*COS_HALFD;
363
      float C = 1/(COS54*(float)Math.sqrt(2-2*SIN18));
364 29b82486 Leszek Koltunski
365 84a17011 Leszek Koltunski
      return new float[][]
366 29b82486 Leszek Koltunski
        {
367 57ef6378 Leszek Koltunski
            {   0,   0  ,     0 },
368 29b82486 Leszek Koltunski
            {   X,   Y  ,    -Z },
369 57ef6378 Leszek Koltunski
            {   0,C*2*Y ,-2*C*Z },
370 29b82486 Leszek Koltunski
            {  -X,   Y  ,    -Z },
371 57ef6378 Leszek Koltunski
            {   0,-width,     0 },
372 29b82486 Leszek Koltunski
            {  X3,-width,   -Z3 },
373 57ef6378 Leszek Koltunski
            {   0,-width,   -H3 },
374 29b82486 Leszek Koltunski
            { -X3,-width,   -Z3 }
375
        };
376 84a17011 Leszek Koltunski
      }
377
    }
378
379
///////////////////////////////////////////////////////////////////////////////////////////////////
380
381
  public ObjectShape getObjectShape(int variant)
382
    {
383
    int[] numLayers = getNumLayers();
384
    int numVariants = getNumCubitVariants(numLayers);
385
    int numL        = numLayers[0];
386
387 2a495bdb leszek
    int[][] indices =
388 84a17011 Leszek Koltunski
      {
389 2a495bdb leszek
       {4,5,1,0},
390
       {7,4,0,3},
391
       {0,1,2,3},
392
       {7,6,5,4},
393
       {2,1,5,6},
394
       {3,2,6,7}
395
      };
396 84a17011 Leszek Koltunski
397 2a495bdb leszek
    if( (variant!=0 || numL<=3) && (variant<numVariants-1) && (variant%2)!=1 )
398 84a17011 Leszek Koltunski
      {
399 2a495bdb leszek
      int tmp, len = indices.length;
400 84a17011 Leszek Koltunski
401 2a495bdb leszek
      for(int i=0; i<len; i++)
402 84a17011 Leszek Koltunski
        {
403 2a495bdb leszek
        tmp = indices[i][0];
404
        indices[i][0] = indices[i][3];
405
        indices[i][3] = tmp;
406
        tmp = indices[i][1];
407
        indices[i][1] = indices[i][2];
408
        indices[i][2] = tmp;
409 84a17011 Leszek Koltunski
        }
410
      }
411 29b82486 Leszek Koltunski
412 2a495bdb leszek
    return new ObjectShape(getVertices(variant), indices);
413 3ee1d662 Leszek Koltunski
    }
414
415
///////////////////////////////////////////////////////////////////////////////////////////////////
416
417
  public ObjectFaceShape getObjectFaceShape(int variant)
418
    {
419
    int[] numLayers = getNumLayers();
420
    int numVariants = getNumCubitVariants(numLayers);
421
    int numL        = numLayers[0];
422
    boolean small   = numL<=3;
423 347f6cc1 Leszek Koltunski
    int angle = 25;
424
    float R = 0.7f;
425
    float S = 0.5f;
426 3ee1d662 Leszek Koltunski
427
    if( variant==0 && !small )
428
      {
429 3bf19410 Leszek Koltunski
      float h1 = isInIconMode() ? 0.001f : 0.04f;
430 347f6cc1 Leszek Koltunski
      float[][] bands = { {h1,angle,R,S,3,0,0}, {0.001f,angle,R,S,2,0,0} };
431 84a17011 Leszek Koltunski
      int[] indices   = { 0,0,0,1,1,1};
432
      return new ObjectFaceShape(bands,indices,null);
433 3ee1d662 Leszek Koltunski
      }
434
    if( variant<numVariants-1 )
435
      {
436
      int E  = small ? 1 : 0;
437
      int N0 = small ? 4 : 3;
438
      int N1 = small ? 3 : 2;
439 3bf19410 Leszek Koltunski
      float h1 = isInIconMode() ? 0.001f : 0.04f;
440 29b82486 Leszek Koltunski
441 347f6cc1 Leszek Koltunski
      float[][] bands = { {h1,angle,R,S,N0,E,E}, {0.001f,angle,R,S,N1,0,0} };
442 84a17011 Leszek Koltunski
      int[] indices   = { 0,0,1,1,1,1};
443 3ee1d662 Leszek Koltunski
444 84a17011 Leszek Koltunski
      return new ObjectFaceShape(bands,indices,null);
445 3ee1d662 Leszek Koltunski
      }
446
    else
447
      {
448
      int N = small ? 4 : 3;
449
      int E = small ? 1 : 0;
450 3bf19410 Leszek Koltunski
      float h1 = isInIconMode() ? 0.001f : 0.04f;
451
      float h2 = isInIconMode() ? 0.001f : 0.01f;
452 29b82486 Leszek Koltunski
453 347f6cc1 Leszek Koltunski
      float[][] bands = { {h1,angle,R,S,N,E,E},{h2,angle,R,S,N,E,E} };
454 84a17011 Leszek Koltunski
      int[] indices   = { 0,0,0,1,1,1};
455
456
      return new ObjectFaceShape(bands,indices,null);
457
      }
458
    }
459
460
///////////////////////////////////////////////////////////////////////////////////////////////////
461
462
  public ObjectVertexEffects getVertexEffects(int variant)
463
    {
464
    int[] numLayers = getNumLayers();
465
    int numVariants = getNumCubitVariants(numLayers);
466
    int numL        = numLayers[0];
467
    boolean small   = numL<=3;
468 29b82486 Leszek Koltunski
469 84a17011 Leszek Koltunski
    if( variant==0 && !small )
470
      {
471
      float A = (2*SQ3/3)*SIN54;
472
      float B = 0.4f;
473 ba8dbe0e Leszek Koltunski
      float[][] corners = { {0.06f,0.15f} };
474 84a17011 Leszek Koltunski
      int[] indices = { 0,-1,-1,-1,-1,-1,-1,-1 };
475
      float[][] centers = { {0.0f, -(float)Math.sqrt(1-A*A)*B,-A*B} };
476
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
477
      }
478
    if( variant<numVariants-1 )
479
      {
480
      int type = variant-1;
481
      float tmpVal= numL/(numL-1.0f);
482
      float height= tmpVal*COS18;
483
      float width = tmpVal + (type/2)*tmpVal*SIN18;
484
      float Z = height*COS_HALFD;
485 ba8dbe0e Leszek Koltunski
      float[][] corners = { {0.02f,0.15f} };
486 84a17011 Leszek Koltunski
      int[] indices = { 0,-1,-1,-1, 0,-1,-1,-1 };
487
      float[][] centers = { {0.0f, -width/2, -2*Z} };
488
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
489
      }
490
    else
491
      {
492
      float A = (2*SQ3/3)*SIN54;
493
      float B = 0.4f;
494 ba8dbe0e Leszek Koltunski
      float[][] corners = { {0.10f,0.30f},{0.05f,0.15f} };
495
      int[] cornerIndices = { 0, 1,-1, 1, 1,-1,-1,-1 };
496 84a17011 Leszek Koltunski
      float[][] centers = { {0.0f, -(float)Math.sqrt(1-A*A)*B,-A*B} };
497 ba8dbe0e Leszek Koltunski
      int[] centerIndices = { 0, 0,-1, 0, 0,-1,-1,-1 };
498
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
499 29b82486 Leszek Koltunski
      }
500
    }
501
502
///////////////////////////////////////////////////////////////////////////////////////////////////
503
504 e30c522a Leszek Koltunski
  public int getNumCubitVariants(int[] numLayers)
505 29b82486 Leszek Koltunski
    {
506 a57e6870 Leszek Koltunski
    switch(numLayers[0])
507 61aa85e4 Leszek Koltunski
      {
508
      case 3: return 1;
509
      case 5: return 4;
510
      }
511 29b82486 Leszek Koltunski
512 61aa85e4 Leszek Koltunski
    return 1;
513 29b82486 Leszek Koltunski
    }
514
515
///////////////////////////////////////////////////////////////////////////////////////////////////
516
517 e30c522a Leszek Koltunski
  public int getCubitVariant(int cubit, int[] numLayers)
518 29b82486 Leszek Koltunski
    {
519 a57e6870 Leszek Koltunski
    int numL = numLayers[0];
520
    int numCubitsPerCorner = numCubitsPerCorner(numL);
521 29b82486 Leszek Koltunski
522
    if( cubit<NUM_CORNERS*numCubitsPerCorner ) return 0;
523
524 a57e6870 Leszek Koltunski
    int numCubitsPerEdge = numCubitsPerEdge(numL);
525 29b82486 Leszek Koltunski
526
    if( cubit<NUM_CORNERS*numCubitsPerCorner + NUM_EDGES*numCubitsPerEdge )
527
      {
528
      int type = computeEdgeType(cubit,numCubitsPerCorner,numCubitsPerEdge);
529
      return type+1;
530
      }
531
532 61aa85e4 Leszek Koltunski
    return getNumCubitVariants(numLayers)-1;
533 29b82486 Leszek Koltunski
    }
534
535 3d766df3 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
536 8f5116ec leszek
// we override getStickerRadii() anyway
537 3d766df3 Leszek Koltunski
538 d53fb890 Leszek Koltunski
  public float getStickerRadius()
539 3d766df3 Leszek Koltunski
    {
540 8f5116ec leszek
    return 0.0f;
541 3d766df3 Leszek Koltunski
    }
542
543
///////////////////////////////////////////////////////////////////////////////////////////////////
544 a75ae1ee Leszek Koltunski
545 d53fb890 Leszek Koltunski
  public float getStickerStroke()
546 3d766df3 Leszek Koltunski
    {
547
    float stroke = 0.25f;
548
549 3bf19410 Leszek Koltunski
    if( isInIconMode() )
550 a75ae1ee Leszek Koltunski
      {
551 3d766df3 Leszek Koltunski
      int[] numLayers = getNumLayers();
552
      if( numLayers[0]>3 ) stroke*=1.5f;
553 29b82486 Leszek Koltunski
      }
554 3d766df3 Leszek Koltunski
555
    return stroke;
556 29b82486 Leszek Koltunski
    }
557
558 00f4980d Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
559
560 ebe8c08e leszek
  public float[][][] getStickerAngles()
561 00f4980d Leszek Koltunski
    {
562
    return null;
563
    }
564
565 61aa85e4 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
566
567 5f54927b Leszek Koltunski
  public String getShortName()
568 61aa85e4 Leszek Koltunski
    {
569 5f54927b Leszek Koltunski
    switch(getNumLayers()[0])
570
      {
571 361fd0de leszek
      case 3: return ListObjects.KILO_3.name();
572
      case 5: return ListObjects.KILO_5.name();
573 5f54927b Leszek Koltunski
      }
574
575 361fd0de leszek
    return ListObjects.KILO_3.name();
576 5f54927b Leszek Koltunski
    }
577
578 052e0362 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
579
580
  public String[][] getTutorials()
581
    {
582
    int[] numLayers = getNumLayers();
583
584
    switch(numLayers[0])
585
      {
586
      case 3: return new String[][] {
587
                          {"gb","grgGgUSxiQg","How to Solve the Kilominx","Z3"},
588
                          {"es","g6WMYjkCLok","Resolver Kilominx","Cuby"},
589
                          {"ru","gjaknjuZXPs","Киломинкс как собрать","CUBES WORLD"},
590
                          {"fr","F7z6LztN-7A","Résoudre le Kilominx","Twins Cuber"},
591
                          {"de","fcmJdpLfZwk","Megaminx 2x2 lösen","JamesKnopf"},
592
                          {"pl","tdWh8f8qpq4","Kilominx TUTORIAL PL","MrUK"},
593
                          {"kr","8-X4GhQnE5I","2X2 킬로밍크스 TUTORIAL","큐브놀이터"},
594 a399e91b Leszek Koltunski
                          {"vn","eW7RLayPPmA","Tutorial N.11 - Kilominx","Duy Thích Rubik"},
595 2318a72a leszek
                          {"tw","iDueAHkim4g","二階五魔方進階解法","不正常魔術方塊研究中心"},
596 052e0362 Leszek Koltunski
                         };
597
      case 5: return new String[][] {
598
                          {"gb","VAnzC2SYVc4","How To Solve A Master Kilominx","Grizz Media"},
599
                          {"es","ozINTg-61Fs","Tutorial Master Kilominx","RubikArt"},
600
                          {"ru","0aemQayCZRc","Как собрать Мастер Киломинкс ч.1","Артем Мартиросов"},
601
                          {"ru","ohOUFTx-oQI","Как собрать Мастер Киломинкс ч.2","Артем Мартиросов"},
602
                          {"ru","YRXRdT2jCn8","Как собрать Мастер Киломинкс ч.3","Артем Мартиросов"},
603
                          {"fr","usMiWt44aqo","Résolution du Master Kilominx","Asthalis"},
604
                          {"pl","rdln0IG86_s","Master Kilominx TUTORIAL PL","MrUK"},
605
                          {"br","0nmaZf2-44M","Como resolver o Master Kilominx 1/3","Rafael Cinoto"},
606
                          {"br","SkR6RybAKHc","Como resolver o Master Kilominx 2/3","Rafael Cinoto"},
607
                          {"br","5C7J7Cb4a7Q","Como resolver o Master Kilominx 3/3","Rafael Cinoto"},
608
                          {"kr","dvy-GxCjm5c","마스터 킬로밍크스 배우기 1","vincentcube"},
609
                          {"kr","Jm0B12vNxsE","마스터 킬로밍크스 배우기 2","vincentcube"},
610
                          {"kr","H1I18FVpr6g","마스터 킬로밍크스 배우기 3","vincentcube"},
611 2318a72a leszek
                          {"tw","nVrtIVu_avo","四階五魔方 教學","不正常魔術方塊研究中心"},
612 052e0362 Leszek Koltunski
                         };
613
      }
614
    return null;
615
    }
616 29b82486 Leszek Koltunski
}