Project

General

Profile

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

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

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