Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyJing.java @ 8b57a8f9

1 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2021 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.TouchControl.TC_TETRAHEDRON;
13
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
14 29b82486 Leszek Koltunski
15
import org.distorted.library.type.Static3D;
16
import org.distorted.library.type.Static4D;
17
18 84a17011 Leszek Koltunski
import org.distorted.objectlib.helpers.FactoryCubit;
19 3ee1d662 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectFaceShape;
20 1d581993 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectSignature;
21 84a17011 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectVertexEffects;
22 cf93ea4e Leszek Koltunski
import org.distorted.objectlib.main.InitAssets;
23 2dffaf22 Leszek Koltunski
import org.distorted.objectlib.main.ObjectSignatures;
24 9ba7f3f6 Leszek Koltunski
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator;
25 a8295031 Leszek Koltunski
import org.distorted.objectlib.main.InitData;
26 c9c71c3f Leszek Koltunski
import org.distorted.objectlib.touchcontrol.TouchControlTetrahedron;
27 8005e762 Leszek Koltunski
import org.distorted.objectlib.main.ObjectType;
28 198c5bf0 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectShape;
29 b31249d6 Leszek Koltunski
import org.distorted.objectlib.shape.ShapeTetrahedron;
30 29b82486 Leszek Koltunski
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32
33 386af988 Leszek Koltunski
public class TwistyJing extends ShapeTetrahedron
34 29b82486 Leszek Koltunski
{
35
  static final Static3D[] ROT_AXIS = new Static3D[]
36
         {
37
           new Static3D(     0,-SQ3/3,-SQ6/3),
38 84a17011 Leszek Koltunski
           new Static3D(     0,-SQ3/3, SQ6/3),
39
           new Static3D( SQ6/3, SQ3/3,     0),
40
           new Static3D(-SQ6/3, SQ3/3,     0),
41 29b82486 Leszek Koltunski
         };
42
43 8b57a8f9 Leszek Koltunski
  public static final float F = 0.48f;  // length of the edge of the corner cubit. Keep<0.5
44
                                        // Assuming the length of the edge of the whole
45
                                        // tetrahedron is 2.0 (ie standard, equal to numLayers)
46 29b82486 Leszek Koltunski
47 9ba7f3f6 Leszek Koltunski
  private int[][] mEdges;
48 beee90ab Leszek Koltunski
  private int[][] mBasicAngle;
49 e7587264 Leszek Koltunski
  private int[] mQuatIndex;
50 29b82486 Leszek Koltunski
  private float[][] mCuts;
51
  private float[][] mCenters;
52
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54
55 cf93ea4e Leszek Koltunski
  public TwistyJing(int meshState, int iconMode, Static4D quat, Static3D move, float scale, InitData data, InitAssets asset)
56 29b82486 Leszek Koltunski
    {
57 cf93ea4e Leszek Koltunski
    super(meshState, iconMode, data.getNumLayers()[0], quat, move, scale, data, asset);
58 29b82486 Leszek Koltunski
    }
59
60 6db8fe2e Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
61
62
  @Override
63
  public float getPillowCoeff()
64
    {
65 8b57a8f9 Leszek Koltunski
    return 1.25f;
66 6db8fe2e Leszek Koltunski
    }
67
68 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
69
70 9ba7f3f6 Leszek Koltunski
  public int[][] getScrambleEdges()
71 29b82486 Leszek Koltunski
    {
72 9ba7f3f6 Leszek Koltunski
    if( mEdges==null ) mEdges = ScrambleEdgeGenerator.getScrambleEdgesSingle(mBasicAngle);
73
    return mEdges;
74 29b82486 Leszek Koltunski
    }
75
76
///////////////////////////////////////////////////////////////////////////////////////////////////
77
78 7bbfc84f Leszek Koltunski
  public float[][] getCuts(int[] numLayers)
79 29b82486 Leszek Koltunski
    {
80
    if( mCuts==null )
81
      {
82
      float[] cut = { (F-0.5f)*(SQ6/3) };
83
      mCuts = new float[][] { cut,cut,cut,cut };
84
      }
85
86
    return mCuts;
87
    }
88
89
///////////////////////////////////////////////////////////////////////////////////////////////////
90
91 59c20632 Leszek Koltunski
  public boolean[][] getLayerRotatable(int[] numLayers)
92 29b82486 Leszek Koltunski
    {
93 9b1fe915 Leszek Koltunski
    boolean[] tmp = {true,true};
94
    return new boolean[][] { tmp,tmp,tmp,tmp };
95 59c20632 Leszek Koltunski
    }
96
97
///////////////////////////////////////////////////////////////////////////////////////////////////
98
99 11fa413d Leszek Koltunski
  public int getTouchControlType()
100 59c20632 Leszek Koltunski
    {
101 c9c71c3f Leszek Koltunski
    return TC_TETRAHEDRON;
102 59c20632 Leszek Koltunski
    }
103
104
///////////////////////////////////////////////////////////////////////////////////////////////////
105
106 11fa413d Leszek Koltunski
  public int getTouchControlSplit()
107 59c20632 Leszek Koltunski
    {
108
    return TYPE_NOT_SPLIT;
109
    }
110
111
///////////////////////////////////////////////////////////////////////////////////////////////////
112
113
  public int[][][] getEnabled()
114
    {
115 1b7ece90 Leszek Koltunski
    return new int[][][] { {{1,2,3}},{{0,2,3}},{{0,1,3}},{{0,1,2}} };
116 59c20632 Leszek Koltunski
    }
117
118
///////////////////////////////////////////////////////////////////////////////////////////////////
119
120
  public float[] getDist3D(int[] numLayers)
121
    {
122 4c9ca251 Leszek Koltunski
    return TouchControlTetrahedron.D3D;
123
    }
124
125
///////////////////////////////////////////////////////////////////////////////////////////////////
126
127
  public Static3D[] getFaceAxis()
128
    {
129
    return TouchControlTetrahedron.FACE_AXIS;
130 29b82486 Leszek Koltunski
    }
131
132 d0e6cf7f Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
133
134
  public float[][] getCubitPositions(int[] numLayers)
135
    {
136
    if( mCenters==null )
137
      {
138
      mCenters = new float[][]
139
         {
140
           { 0.000f, -SQ2/2, 1.000f },
141
           { 0.000f, -SQ2/2,-1.000f },
142
           {-1.000f,  SQ2/2, 0.000f },
143
           { 1.000f,  SQ2/2, 0.000f },
144
145
           { 0.000f, -SQ2/2, 0.000f },
146
           {-0.500f, 0.000f, 0.500f },
147
           { 0.500f, 0.000f, 0.500f },
148
           {-0.500f, 0.000f,-0.500f },
149
           { 0.500f, 0.000f,-0.500f },
150
           { 0.000f,  SQ2/2, 0.000f },
151
152
           { 0.000f,  SQ2/6, 1.0f/3 },
153
           { 0.000f,  SQ2/6,-1.0f/3 },
154
           {-1.0f/3, -SQ2/6, 0.000f },
155
           { 1.0f/3, -SQ2/6, 0.000f },
156
         };
157
      }
158
159
    return mCenters;
160
    }
161
162
///////////////////////////////////////////////////////////////////////////////////////////////////
163
164
  public Static4D getCubitQuats(int cubit, int[] numLayers)
165
    {
166 a4af26c1 Leszek Koltunski
    if( mQuatIndex==null ) mQuatIndex = new int[] {0,10,5,8,
167
                                                   0,5,8,6,7,9,
168
                                                   0,10,7,3};
169 e7587264 Leszek Koltunski
    return mObjectQuats[mQuatIndex[cubit]];
170 d0e6cf7f Leszek Koltunski
    }
171
172 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
173
174 84a17011 Leszek Koltunski
  private float[][] getVertices(int variant)
175 29b82486 Leszek Koltunski
    {
176
    final float X = F/2;
177
    final float Y = F*SQ2/2;
178
    final float Z =-F/2;
179
    final float L = (2.0f-3*F);
180
    final float X2= L/2;
181
    final float Y2= L*SQ2/2;
182
    final float Z2=-L/2;
183
    final float D = F/L;
184
    final float G = 1.0f-F;
185
186
    if( variant==0 )
187
      {
188 84a17011 Leszek Koltunski
      return new float[][]
189 29b82486 Leszek Koltunski
          {
190 57ef6378 Leszek Koltunski
             {   0,   0,   0 },
191 29b82486 Leszek Koltunski
             {   X,   Y,   Z },
192 57ef6378 Leszek Koltunski
             {   0, 2*Y, 2*Z },
193 29b82486 Leszek Koltunski
             {  -X,   Y,   Z },
194 57ef6378 Leszek Koltunski
             {   0,   0,    -F },
195 29b82486 Leszek Koltunski
             {   X,   Y,   Z-F },
196 57ef6378 Leszek Koltunski
             {   0, 2*Y, 2*Z-F },
197 29b82486 Leszek Koltunski
             {  -X,   Y,   Z-F },
198
          };
199
      }
200
    else if( variant==1 )
201
      {
202 84a17011 Leszek Koltunski
      return new float[][]
203 29b82486 Leszek Koltunski
          {
204 57ef6378 Leszek Koltunski
             {   0,   0,     G },
205 29b82486 Leszek Koltunski
             {   X,   Y,   Z+G },
206 57ef6378 Leszek Koltunski
             {   0, 2*Y, 2*Z+G },
207 29b82486 Leszek Koltunski
             {  -X,   Y,   Z+G },
208 57ef6378 Leszek Koltunski
             {   0,   0,    -G },
209 29b82486 Leszek Koltunski
             {   X,   Y,  -Z-G },
210 57ef6378 Leszek Koltunski
             {   0, 2*Y,-2*Z-G },
211 29b82486 Leszek Koltunski
             {  -X,   Y,  -Z-G },
212
          };
213 84a17011 Leszek Koltunski
      }
214
    else
215
      {
216
      return new float[][]
217
          {
218
             {        0,   -2*Y2/3,       -2*Z2/3 },
219
             {       X2,      Y2/3,          Z2/3 },
220
             {      -X2,      Y2/3,          Z2/3 },
221
             {        0,   -2*Y2/3,-2*Z2/3+2*D*Z2 },
222
             {  X2-D*X2, Y2/3-D*Y2,     Z2/3+D*Z2 },
223
             { -X2+D*X2, Y2/3-D*Y2,     Z2/3+D*Z2 },
224
          };
225
      }
226
    }
227
228
///////////////////////////////////////////////////////////////////////////////////////////////////
229
230
  public ObjectShape getObjectShape(int variant)
231
    {
232
    if( variant==0 )
233
      {
234
      int[][] indices =
235
          {
236
             {0,1,2,3},
237
             {1,0,4,5},
238
             {7,4,0,3},
239
             {1,5,6,2},
240
             {7,3,2,6},
241
             {4,7,6,5}
242
          };
243
244
      return new ObjectShape(getVertices(variant), indices);
245
      }
246
    else if( variant==1 )
247
      {
248 4e9f2df5 Leszek Koltunski
      int[][] indices =
249 29b82486 Leszek Koltunski
          {
250
             {0,4,5,1},
251
             {3,7,4,0},
252
             {0,1,2,3},
253
             {4,7,6,5},
254
             {1,5,6,2},
255
             {2,6,7,3}
256
          };
257
258 84a17011 Leszek Koltunski
      return new ObjectShape(getVertices(variant), indices);
259 29b82486 Leszek Koltunski
      }
260
    else
261
      {
262 4e9f2df5 Leszek Koltunski
      int[][] indices =
263 29b82486 Leszek Koltunski
          {
264
             {0,1,2},
265
             {3,5,4},
266
             {0,3,4,1},
267
             {5,3,0,2},
268
             {4,5,2,1}
269
          };
270
271 84a17011 Leszek Koltunski
      return new ObjectShape(getVertices(variant), indices);
272 3ee1d662 Leszek Koltunski
      }
273
    }
274
275
///////////////////////////////////////////////////////////////////////////////////////////////////
276
277
  public ObjectFaceShape getObjectFaceShape(int variant)
278 84a17011 Leszek Koltunski
    {
279
    if( variant==0 )
280
      {
281
      float height = isInIconMode() ? 0.001f : 0.015f;
282
      float[][] bands = { {height,35,0.25f*F,0.5f*F,5,1,1},{0.001f,35,0.25f*F,0.5f*F,5,1,1} };
283
      int[] indices   = { 0,0,0,1,1,1 };
284
      return new ObjectFaceShape(bands,indices,null);
285
      }
286
    else if( variant==1 )
287
      {
288
      float height = isInIconMode() ? 0.001f : 0.015f;
289
      float[][] bands = { {height,35,0.2f*F,0.3f*F,7,0,0},{0.001f,35,0.2f*F,0.3f*F,7,0,0} };
290
      int[] indices   = { 0,0,1,1,1,1 };
291
      return new ObjectFaceShape(bands,indices,null);
292
      }
293
    else
294
      {
295
      final float L = (2.0f-3*F);
296
      float height = isInIconMode() ? 0.001f : 0.020f;
297
      float[][] bands = { {height,35,0.20f*L,0.6f*L,5,1,1}, {0.001f,35,0.05f*L,0.1f*L,5,1,1} };
298
      int[] indices   = { 0,1,1,1,1,1 };
299
      return new ObjectFaceShape(bands,indices,null);
300
      }
301
    }
302
303
///////////////////////////////////////////////////////////////////////////////////////////////////
304
305
  public ObjectVertexEffects getVertexEffects(int variant)
306 3ee1d662 Leszek Koltunski
    {
307
    final float Y = F*SQ2/2;
308
    final float Z =-F/2;
309
310
    if( variant==0 )
311
      {
312 4e9f2df5 Leszek Koltunski
      float[][] corners   = { {0.08f,0.20f*F},{0.07f,0.20f*F} };
313
      int[] cornerIndices = { 0,1,1,-1,1,-1,-1,-1 };
314
      float[][] centers   = { { 0.0f, Y, Z-F/2} };
315
      int[] centerIndices = { 0,0,0,-1,0,-1,-1,-1 };
316 84a17011 Leszek Koltunski
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
317 3ee1d662 Leszek Koltunski
      }
318
    else if( variant==1 )
319
      {
320 4e9f2df5 Leszek Koltunski
      float[][] corners   = { {0.07f,0.20f*F} };
321
      int[] cornerIndices = { 0,0,-1,0,0,0,-1,0 };
322
      float[][] centers   = { { 0, F*SQ2/2, 0 } };
323
      int[] centerIndices = { 0,0,-1,0,0,0,-1,0 };
324 84a17011 Leszek Koltunski
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
325 3ee1d662 Leszek Koltunski
      }
326
    else
327
      {
328 4e9f2df5 Leszek Koltunski
      float[][] corners   = { {0.04f,0.6f*F} };
329
      int[] cornerIndices = { 0,0,0,-1,-1,-1 };
330
      float[][] centers   = { { 0, -2*Y/3, 4*Z/3 } };
331
      int[] centerIndices = { 0,0,0,-1,-1,-1 };
332 84a17011 Leszek Koltunski
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
333 29b82486 Leszek Koltunski
      }
334
    }
335
336
///////////////////////////////////////////////////////////////////////////////////////////////////
337
338 e30c522a Leszek Koltunski
  public int getNumCubitVariants(int[] numLayers)
339 29b82486 Leszek Koltunski
    {
340
    return 3;
341
    }
342
343
///////////////////////////////////////////////////////////////////////////////////////////////////
344
345 e30c522a Leszek Koltunski
  public int getCubitVariant(int cubit, int[] numLayers)
346 29b82486 Leszek Koltunski
    {
347
    return cubit<4 ? 0 : (cubit<10?1:2);
348
    }
349
350 00f4980d Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
351
352 d53fb890 Leszek Koltunski
  public float getStickerRadius()
353 00f4980d Leszek Koltunski
    {
354
    return 0.04f;
355
    }
356
357
///////////////////////////////////////////////////////////////////////////////////////////////////
358
359 d53fb890 Leszek Koltunski
  public float getStickerStroke()
360 00f4980d Leszek Koltunski
    {
361 3bf19410 Leszek Koltunski
    return isInIconMode() ? 0.08f : 0.04f;
362 00f4980d Leszek Koltunski
    }
363
364
///////////////////////////////////////////////////////////////////////////////////////////////////
365
366 d53fb890 Leszek Koltunski
  public float[][] getStickerAngles()
367 00f4980d Leszek Koltunski
    {
368
    return null;
369
    }
370
371 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
372
// PUBLIC API
373
374
  public Static3D[] getRotationAxis()
375
    {
376
    return ROT_AXIS;
377
    }
378
379
///////////////////////////////////////////////////////////////////////////////////////////////////
380
381 beee90ab Leszek Koltunski
  public int[][] getBasicAngles()
382 29b82486 Leszek Koltunski
    {
383 beee90ab Leszek Koltunski
    if( mBasicAngle ==null )
384
      {
385
      int num = getNumLayers()[0];
386
      int[] tmp = new int[num];
387
      for(int i=0; i<num; i++) tmp[i] = 3;
388
      mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
389
      }
390
391 29b82486 Leszek Koltunski
    return mBasicAngle;
392
    }
393
394 61aa85e4 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
395
396 5f54927b Leszek Koltunski
  public String getShortName()
397 61aa85e4 Leszek Koltunski
    {
398 5f54927b Leszek Koltunski
    return ObjectType.JING_2.name();
399
    }
400
401
///////////////////////////////////////////////////////////////////////////////////////////////////
402
403 1d581993 Leszek Koltunski
  public ObjectSignature getSignature()
404 5f54927b Leszek Koltunski
    {
405 2dffaf22 Leszek Koltunski
    return new ObjectSignature(ObjectSignatures.JING_2);
406 61aa85e4 Leszek Koltunski
    }
407
408 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
409
410 e26eb4e7 Leszek Koltunski
  public String getObjectName()
411 29b82486 Leszek Koltunski
    {
412 e26eb4e7 Leszek Koltunski
    return "Jing Pyraminx";
413 29b82486 Leszek Koltunski
    }
414
415
///////////////////////////////////////////////////////////////////////////////////////////////////
416
417 e26eb4e7 Leszek Koltunski
  public String getInventor()
418 29b82486 Leszek Koltunski
    {
419 e26eb4e7 Leszek Koltunski
    return "Tony Fisher";
420 29b82486 Leszek Koltunski
    }
421
422 59c20632 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
423
424 e26eb4e7 Leszek Koltunski
  public int getYearOfInvention()
425 59c20632 Leszek Koltunski
    {
426
    return 1991;
427
    }
428
429 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
430
431 e26eb4e7 Leszek Koltunski
  public int getComplexity()
432 29b82486 Leszek Koltunski
    {
433 b4223a92 Leszek Koltunski
    return 1;
434 29b82486 Leszek Koltunski
    }
435 052e0362 Leszek Koltunski
436
///////////////////////////////////////////////////////////////////////////////////////////////////
437
438
  public String[][] getTutorials()
439
    {
440
    return new String[][]{
441
                          {"gb","0T8Iw6aI2gA","Jing's Pyraminx Tutorial","SuperAntoniovivaldi"},
442
                          {"es","Na27_GUIzqY","Resolver Jing Pyraminx","Cuby"},
443
                          {"ru","rlQXFzjsyAo","Как собрать Jing's pyraminx","Илья Топор-Гилка"},
444
                          {"fr","zC9dGqZRSic","Résolution du Jing's Pyraminx","Asthalis"},
445
                          {"de","6ihN4fdHH6o","Jings Pyraminx - Tutorial","GerCubing"},
446 a399e91b Leszek Koltunski
                          {"pl","nRYoJAy1c_8","Jing's Pyraminx TUTORIAL PL","MrUK"},
447
                          {"vn","yX9KjDpHjws","Tutorial N.50 - Jing's Pyraminx","Duy Thích Rubik"},
448 052e0362 Leszek Koltunski
                         };
449
    }
450 29b82486 Leszek Koltunski
}