Project

General

Profile

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

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

1
///////////////////////////////////////////////////////////////////////////////////////////////////
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
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_TETRAHEDRON;
23
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
24

    
25
import java.io.InputStream;
26

    
27
import org.distorted.library.type.Static3D;
28
import org.distorted.library.type.Static4D;
29

    
30
import org.distorted.objectlib.helpers.ObjectFaceShape;
31
import org.distorted.objectlib.helpers.ObjectSignature;
32
import org.distorted.objectlib.touchcontrol.TouchControlTetrahedron;
33
import org.distorted.objectlib.main.ObjectType;
34
import org.distorted.objectlib.helpers.ObjectShape;
35
import org.distorted.objectlib.scrambling.ScrambleState;
36
import org.distorted.objectlib.main.ShapeTetrahedron;
37

    
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39

    
40
public class TwistyJing extends ShapeTetrahedron
41
{
42
  static final Static3D[] ROT_AXIS = new Static3D[]
43
         {
44
           new Static3D(     0,-SQ3/3,-SQ6/3),
45
           new Static3D(     0,-SQ3/3,+SQ6/3),
46
           new Static3D(+SQ6/3,+SQ3/3,     0),
47
           new Static3D(-SQ6/3,+SQ3/3,     0),
48
         };
49

    
50
  static final float F = 0.48f;  // length of the edge of the corner cubit. Keep<0.5
51
                                 // Assuming the length of the edge of the whole
52
                                 // tetrahedron is 2.0 (ie standard, equal to numLayers)
53

    
54
  private ScrambleState[] mStates;
55
  private int[][] mBasicAngle;
56
  private int[] mQuatIndex;
57
  private float[][] mCuts;
58
  private float[][] mCenters;
59

    
60
///////////////////////////////////////////////////////////////////////////////////////////////////
61

    
62
  public TwistyJing(int[] numL, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
63
    {
64
    super(numL, meshState, iconMode, numL[0], quat, move, scale, stream);
65
    }
66

    
67
///////////////////////////////////////////////////////////////////////////////////////////////////
68

    
69
  public ScrambleState[] getScrambleStates()
70
    {
71
    if( mStates==null )
72
      {
73
      int[] tmp = {0,-1,0, 0,1,0, 1,-1,0, 1,1,0 };
74

    
75
      mStates = new ScrambleState[]
76
        {
77
        new ScrambleState( new int[][] {tmp,tmp,tmp,tmp} )
78
        };
79
      }
80

    
81
    return mStates;
82
    }
83

    
84
///////////////////////////////////////////////////////////////////////////////////////////////////
85

    
86
  public float[][] getCuts(int[] numLayers)
87
    {
88
    if( mCuts==null )
89
      {
90
      float[] cut = { (F-0.5f)*(SQ6/3) };
91
      mCuts = new float[][] { cut,cut,cut,cut };
92
      }
93

    
94
    return mCuts;
95
    }
96

    
97
///////////////////////////////////////////////////////////////////////////////////////////////////
98

    
99
  public boolean[][] getLayerRotatable(int[] numLayers)
100
    {
101
    boolean[] tmp = {true,true};
102
    return new boolean[][] { tmp,tmp,tmp,tmp };
103
    }
104

    
105
///////////////////////////////////////////////////////////////////////////////////////////////////
106

    
107
  public int getTouchControlType()
108
    {
109
    return TC_TETRAHEDRON;
110
    }
111

    
112
///////////////////////////////////////////////////////////////////////////////////////////////////
113

    
114
  public int getTouchControlSplit()
115
    {
116
    return TYPE_NOT_SPLIT;
117
    }
118

    
119
///////////////////////////////////////////////////////////////////////////////////////////////////
120

    
121
  public int[][][] getEnabled()
122
    {
123
    return new int[][][] { {{1,2,3}},{{0,2,3}},{{0,1,3}},{{0,1,2}} };
124
    }
125

    
126
///////////////////////////////////////////////////////////////////////////////////////////////////
127

    
128
  public float[] getDist3D(int[] numLayers)
129
    {
130
    return TouchControlTetrahedron.D3D;
131
    }
132

    
133
///////////////////////////////////////////////////////////////////////////////////////////////////
134

    
135
  public Static3D[] getFaceAxis()
136
    {
137
    return TouchControlTetrahedron.FACE_AXIS;
138
    }
139

    
140
///////////////////////////////////////////////////////////////////////////////////////////////////
141

    
142
  public float[][] getCubitPositions(int[] numLayers)
143
    {
144
    if( mCenters==null )
145
      {
146
      mCenters = new float[][]
147
         {
148
           { 0.000f, -SQ2/2, 1.000f },
149
           { 0.000f, -SQ2/2,-1.000f },
150
           {-1.000f,  SQ2/2, 0.000f },
151
           { 1.000f,  SQ2/2, 0.000f },
152

    
153
           { 0.000f, -SQ2/2, 0.000f },
154
           {-0.500f, 0.000f, 0.500f },
155
           { 0.500f, 0.000f, 0.500f },
156
           {-0.500f, 0.000f,-0.500f },
157
           { 0.500f, 0.000f,-0.500f },
158
           { 0.000f,  SQ2/2, 0.000f },
159

    
160
           { 0.000f,  SQ2/6, 1.0f/3 },
161
           { 0.000f,  SQ2/6,-1.0f/3 },
162
           {-1.0f/3, -SQ2/6, 0.000f },
163
           { 1.0f/3, -SQ2/6, 0.000f },
164
         };
165
      }
166

    
167
    return mCenters;
168
    }
169

    
170
///////////////////////////////////////////////////////////////////////////////////////////////////
171

    
172
  public Static4D getCubitQuats(int cubit, int[] numLayers)
173
    {
174
    if( mQuatIndex==null ) mQuatIndex = new int[] {0,10,5,8,
175
                                                   0,5,8,6,7,9,
176
                                                   0,10,7,3};
177
    return mObjectQuats[mQuatIndex[cubit]];
178
    }
179

    
180
///////////////////////////////////////////////////////////////////////////////////////////////////
181

    
182
  public ObjectShape getObjectShape(int variant)
183
    {
184
    final float X = F/2;
185
    final float Y = F*SQ2/2;
186
    final float Z =-F/2;
187
    final float L = (2.0f-3*F);
188
    final float X2= L/2;
189
    final float Y2= L*SQ2/2;
190
    final float Z2=-L/2;
191
    final float D = F/L;
192
    final float G = 1.0f-F;
193

    
194
    if( variant==0 )
195
      {
196
      float[][] vertices =
197
          {
198
             {   0,   0,   0 },
199
             {   X,   Y,   Z },
200
             {   0, 2*Y, 2*Z },
201
             {  -X,   Y,   Z },
202
             {   0,   0,    -F },
203
             {   X,   Y,   Z-F },
204
             {   0, 2*Y, 2*Z-F },
205
             {  -X,   Y,   Z-F },
206
          };
207
      int[][] indices =
208
          {
209
             {0,1,2,3},
210
             {1,0,4,5},
211
             {7,4,0,3},
212
             {1,5,6,2},
213
             {7,3,2,6},
214
             {4,7,6,5}
215
          };
216

    
217
      return new ObjectShape(vertices, indices);
218
      }
219
    else if( variant==1 )
220
      {
221
      float[][] vertices =
222
          {
223
             {   0,   0,     G },
224
             {   X,   Y,   Z+G },
225
             {   0, 2*Y, 2*Z+G },
226
             {  -X,   Y,   Z+G },
227
             {   0,   0,    -G },
228
             {   X,   Y,  -Z-G },
229
             {   0, 2*Y,-2*Z-G },
230
             {  -X,   Y,  -Z-G },
231
          };
232
      int[][] indices =
233
          {
234
             {0,4,5,1},
235
             {3,7,4,0},
236
             {0,1,2,3},
237
             {4,7,6,5},
238
             {1,5,6,2},
239
             {2,6,7,3}
240
          };
241

    
242
      return new ObjectShape(vertices, indices);
243
      }
244
    else
245
      {
246
      float[][] vertices =
247
          {
248
             {        0,   -2*Y2/3,       -2*Z2/3 },
249
             {       X2,      Y2/3,          Z2/3 },
250
             {      -X2,      Y2/3,          Z2/3 },
251
             {        0,   -2*Y2/3,-2*Z2/3+2*D*Z2 },
252
             {  X2-D*X2, Y2/3-D*Y2,     Z2/3+D*Z2 },
253
             { -X2+D*X2, Y2/3-D*Y2,     Z2/3+D*Z2 },
254
          };
255
      int[][] indices =
256
          {
257
             {0,1,2},
258
             {3,5,4},
259
             {0,3,4,1},
260
             {5,3,0,2},
261
             {4,5,2,1}
262
          };
263

    
264
      return new ObjectShape(vertices, indices);
265
      }
266
    }
267

    
268
///////////////////////////////////////////////////////////////////////////////////////////////////
269

    
270
  public ObjectFaceShape getObjectFaceShape(int variant)
271
    {
272
    final float Y = F*SQ2/2;
273
    final float Z =-F/2;
274
    final float L = (2.0f-3*F);
275

    
276
    if( variant==0 )
277
      {
278
      float height = isInIconMode() ? 0.001f : 0.015f;
279
      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} };
280
      int[] bandIndices   = { 0,0,0,1,1,1 };
281
      float[][] corners   = { {0.08f,0.20f*F},{0.07f,0.20f*F} };
282
      int[] cornerIndices = { 0,1,1,-1,1,-1,-1,-1 };
283
      float[][] centers   = { { 0.0f, Y, Z-F/2} };
284
      int[] centerIndices = { 0,0,0,-1,0,-1,-1,-1 };
285
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
286
      }
287
    else if( variant==1 )
288
      {
289
      float height = isInIconMode() ? 0.001f : 0.015f;
290
      float[][] bands     = { {height,35,0.5f*F,F,5,1,1},{0.001f,35,0.5f*F,F,5,1,1} };
291
      int[] bandIndices   = { 0,0,1,1,1,1 };
292
      float[][] corners   = { {0.07f,0.20f*F} };
293
      int[] cornerIndices = { 0,0,-1,0,0,0,-1,0 };
294
      float[][] centers   = { { 0, F*SQ2/2, 0 } };
295
      int[] centerIndices = { 0,0,-1,0,0,0,-1,0 };
296
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
297
      }
298
    else
299
      {
300
      float height = isInIconMode() ? 0.001f : 0.020f;
301
      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} };
302
      int[] bandIndices   = { 0,1,1,1,1,1 };
303
      float[][] corners   = { {0.04f,0.6f*F} };
304
      int[] cornerIndices = { 0,0,0,-1,-1,-1 };
305
      float[][] centers   = { { 0, -2*Y/3, 4*Z/3 } };
306
      int[] centerIndices = { 0,0,0,-1,-1,-1 };
307
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
308
      }
309
    }
310

    
311
///////////////////////////////////////////////////////////////////////////////////////////////////
312

    
313
  public int getNumCubitVariants(int[] numLayers)
314
    {
315
    return 3;
316
    }
317

    
318
///////////////////////////////////////////////////////////////////////////////////////////////////
319

    
320
  public int getCubitVariant(int cubit, int[] numLayers)
321
    {
322
    return cubit<4 ? 0 : (cubit<10?1:2);
323
    }
324

    
325
///////////////////////////////////////////////////////////////////////////////////////////////////
326

    
327
  public float getStickerRadius()
328
    {
329
    return 0.04f;
330
    }
331

    
332
///////////////////////////////////////////////////////////////////////////////////////////////////
333

    
334
  public float getStickerStroke()
335
    {
336
    return isInIconMode() ? 0.08f : 0.04f;
337
    }
338

    
339
///////////////////////////////////////////////////////////////////////////////////////////////////
340

    
341
  public float[][] getStickerAngles()
342
    {
343
    return null;
344
    }
345

    
346
///////////////////////////////////////////////////////////////////////////////////////////////////
347
// PUBLIC API
348

    
349
  public Static3D[] getRotationAxis()
350
    {
351
    return ROT_AXIS;
352
    }
353

    
354
///////////////////////////////////////////////////////////////////////////////////////////////////
355

    
356
  public int[][] getBasicAngles()
357
    {
358
    if( mBasicAngle ==null )
359
      {
360
      int num = getNumLayers()[0];
361
      int[] tmp = new int[num];
362
      for(int i=0; i<num; i++) tmp[i] = 3;
363
      mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
364
      }
365

    
366
    return mBasicAngle;
367
    }
368

    
369
///////////////////////////////////////////////////////////////////////////////////////////////////
370

    
371
  public String getShortName()
372
    {
373
    return ObjectType.JING_2.name();
374
    }
375

    
376
///////////////////////////////////////////////////////////////////////////////////////////////////
377

    
378
  public ObjectSignature getSignature()
379
    {
380
    return new ObjectSignature(ObjectType.JING_2);
381
    }
382

    
383
///////////////////////////////////////////////////////////////////////////////////////////////////
384

    
385
  public String getObjectName()
386
    {
387
    return "Jing Pyraminx";
388
    }
389

    
390
///////////////////////////////////////////////////////////////////////////////////////////////////
391

    
392
  public String getInventor()
393
    {
394
    return "Tony Fisher";
395
    }
396

    
397
///////////////////////////////////////////////////////////////////////////////////////////////////
398

    
399
  public int getYearOfInvention()
400
    {
401
    return 1991;
402
    }
403

    
404
///////////////////////////////////////////////////////////////////////////////////////////////////
405

    
406
  public int getComplexity()
407
    {
408
    return 1;
409
    }
410

    
411
///////////////////////////////////////////////////////////////////////////////////////////////////
412

    
413
  public String[][] getTutorials()
414
    {
415
    return new String[][]{
416
                          {"gb","0T8Iw6aI2gA","Jing's Pyraminx Tutorial","SuperAntoniovivaldi"},
417
                          {"es","Na27_GUIzqY","Resolver Jing Pyraminx","Cuby"},
418
                          {"ru","rlQXFzjsyAo","Как собрать Jing's pyraminx","Илья Топор-Гилка"},
419
                          {"fr","zC9dGqZRSic","Résolution du Jing's Pyraminx","Asthalis"},
420
                          {"de","6ihN4fdHH6o","Jings Pyraminx - Tutorial","GerCubing"},
421
                          {"pl","nRYoJAy1c_8","Jing's Pyraminx TUTORIAL PL","MrUK"},
422
                          {"vn","yX9KjDpHjws","Tutorial N.50 - Jing's Pyraminx","Duy Thích Rubik"},
423
                         };
424
    }
425
}
(18-18/36)