Project

General

Profile

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

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

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