Project

General

Profile

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

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

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2021 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// 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
///////////////////////////////////////////////////////////////////////////////////////////////////
9

    
10
package org.distorted.objectlib.objects;
11

    
12
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_TETRAHEDRON;
13
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
14

    
15
import java.io.InputStream;
16

    
17
import org.distorted.library.type.Static3D;
18
import org.distorted.library.type.Static4D;
19

    
20
import org.distorted.objectlib.helpers.FactoryCubit;
21
import org.distorted.objectlib.helpers.ObjectFaceShape;
22
import org.distorted.objectlib.helpers.ObjectSignature;
23
import org.distorted.objectlib.helpers.ObjectVertexEffects;
24
import org.distorted.objectlib.main.InitData;
25
import org.distorted.objectlib.touchcontrol.TouchControlTetrahedron;
26
import org.distorted.objectlib.main.ObjectType;
27
import org.distorted.objectlib.helpers.ObjectShape;
28
import org.distorted.objectlib.scrambling.ScrambleState;
29
import org.distorted.objectlib.shape.ShapeTetrahedron;
30

    
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32

    
33
public class TwistyJing extends ShapeTetrahedron
34
{
35
  static final Static3D[] ROT_AXIS = new Static3D[]
36
         {
37
           new Static3D(     0,-SQ3/3,-SQ6/3),
38
           new Static3D(     0,-SQ3/3, SQ6/3),
39
           new Static3D( SQ6/3, SQ3/3,     0),
40
           new Static3D(-SQ6/3, SQ3/3,     0),
41
         };
42

    
43
  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

    
47
  private ScrambleState[] mStates;
48
  private int[][] mBasicAngle;
49
  private int[] mQuatIndex;
50
  private float[][] mCuts;
51
  private float[][] mCenters;
52

    
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54

    
55
  public TwistyJing(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
56
    {
57
    super(data, meshState, iconMode, data.getNumLayers()[0], quat, move, scale, stream);
58
    }
59

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

    
62
  @Override
63
  public float getPillowCoeff()
64
    {
65
    return 1.5f;
66
    }
67

    
68
///////////////////////////////////////////////////////////////////////////////////////////////////
69

    
70
  public ScrambleState[] getScrambleStates()
71
    {
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
  public float[][] getCuts(int[] numLayers)
88
    {
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
  public boolean[][] getLayerRotatable(int[] numLayers)
101
    {
102
    boolean[] tmp = {true,true};
103
    return new boolean[][] { tmp,tmp,tmp,tmp };
104
    }
105

    
106
///////////////////////////////////////////////////////////////////////////////////////////////////
107

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

    
113
///////////////////////////////////////////////////////////////////////////////////////////////////
114

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

    
120
///////////////////////////////////////////////////////////////////////////////////////////////////
121

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

    
127
///////////////////////////////////////////////////////////////////////////////////////////////////
128

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

    
134
///////////////////////////////////////////////////////////////////////////////////////////////////
135

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

    
141
///////////////////////////////////////////////////////////////////////////////////////////////////
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
    if( mQuatIndex==null ) mQuatIndex = new int[] {0,10,5,8,
176
                                                   0,5,8,6,7,9,
177
                                                   0,10,7,3};
178
    return mObjectQuats[mQuatIndex[cubit]];
179
    }
180

    
181
///////////////////////////////////////////////////////////////////////////////////////////////////
182

    
183
  private float[][] getVertices(int variant)
184
    {
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
      return new float[][]
198
          {
199
             {   0,   0,   0 },
200
             {   X,   Y,   Z },
201
             {   0, 2*Y, 2*Z },
202
             {  -X,   Y,   Z },
203
             {   0,   0,    -F },
204
             {   X,   Y,   Z-F },
205
             {   0, 2*Y, 2*Z-F },
206
             {  -X,   Y,   Z-F },
207
          };
208
      }
209
    else if( variant==1 )
210
      {
211
      return new float[][]
212
          {
213
             {   0,   0,     G },
214
             {   X,   Y,   Z+G },
215
             {   0, 2*Y, 2*Z+G },
216
             {  -X,   Y,   Z+G },
217
             {   0,   0,    -G },
218
             {   X,   Y,  -Z-G },
219
             {   0, 2*Y,-2*Z-G },
220
             {  -X,   Y,  -Z-G },
221
          };
222
      }
223
    else
224
      {
225
      return new float[][]
226
          {
227
             {        0,   -2*Y2/3,       -2*Z2/3 },
228
             {       X2,      Y2/3,          Z2/3 },
229
             {      -X2,      Y2/3,          Z2/3 },
230
             {        0,   -2*Y2/3,-2*Z2/3+2*D*Z2 },
231
             {  X2-D*X2, Y2/3-D*Y2,     Z2/3+D*Z2 },
232
             { -X2+D*X2, Y2/3-D*Y2,     Z2/3+D*Z2 },
233
          };
234
      }
235
    }
236

    
237
///////////////////////////////////////////////////////////////////////////////////////////////////
238

    
239
  public ObjectShape getObjectShape(int variant)
240
    {
241
    if( variant==0 )
242
      {
243
      int[][] indices =
244
          {
245
             {0,1,2,3},
246
             {1,0,4,5},
247
             {7,4,0,3},
248
             {1,5,6,2},
249
             {7,3,2,6},
250
             {4,7,6,5}
251
          };
252

    
253
      return new ObjectShape(getVertices(variant), indices);
254
      }
255
    else if( variant==1 )
256
      {
257
      int[][] indices =
258
          {
259
             {0,4,5,1},
260
             {3,7,4,0},
261
             {0,1,2,3},
262
             {4,7,6,5},
263
             {1,5,6,2},
264
             {2,6,7,3}
265
          };
266

    
267
      return new ObjectShape(getVertices(variant), indices);
268
      }
269
    else
270
      {
271
      int[][] indices =
272
          {
273
             {0,1,2},
274
             {3,5,4},
275
             {0,3,4,1},
276
             {5,3,0,2},
277
             {4,5,2,1}
278
          };
279

    
280
      return new ObjectShape(getVertices(variant), indices);
281
      }
282
    }
283

    
284
///////////////////////////////////////////////////////////////////////////////////////////////////
285

    
286
  public ObjectFaceShape getObjectFaceShape(int variant)
287
    {
288
    if( variant==0 )
289
      {
290
      float height = isInIconMode() ? 0.001f : 0.015f;
291
      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} };
292
      int[] indices   = { 0,0,0,1,1,1 };
293
      return new ObjectFaceShape(bands,indices,null);
294
      }
295
    else if( variant==1 )
296
      {
297
      float height = isInIconMode() ? 0.001f : 0.015f;
298
      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} };
299
      int[] indices   = { 0,0,1,1,1,1 };
300
      return new ObjectFaceShape(bands,indices,null);
301
      }
302
    else
303
      {
304
      final float L = (2.0f-3*F);
305
      float height = isInIconMode() ? 0.001f : 0.020f;
306
      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} };
307
      int[] indices   = { 0,1,1,1,1,1 };
308
      return new ObjectFaceShape(bands,indices,null);
309
      }
310
    }
311

    
312
///////////////////////////////////////////////////////////////////////////////////////////////////
313

    
314
  public ObjectVertexEffects getVertexEffects(int variant)
315
    {
316
    final float Y = F*SQ2/2;
317
    final float Z =-F/2;
318

    
319
    if( variant==0 )
320
      {
321
      float[][] corners   = { {0.08f,0.20f*F},{0.07f,0.20f*F} };
322
      int[] cornerIndices = { 0,1,1,-1,1,-1,-1,-1 };
323
      float[][] centers   = { { 0.0f, Y, Z-F/2} };
324
      int[] centerIndices = { 0,0,0,-1,0,-1,-1,-1 };
325
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
326
      }
327
    else if( variant==1 )
328
      {
329
      float[][] corners   = { {0.07f,0.20f*F} };
330
      int[] cornerIndices = { 0,0,-1,0,0,0,-1,0 };
331
      float[][] centers   = { { 0, F*SQ2/2, 0 } };
332
      int[] centerIndices = { 0,0,-1,0,0,0,-1,0 };
333
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
334
      }
335
    else
336
      {
337
      float[][] corners   = { {0.04f,0.6f*F} };
338
      int[] cornerIndices = { 0,0,0,-1,-1,-1 };
339
      float[][] centers   = { { 0, -2*Y/3, 4*Z/3 } };
340
      int[] centerIndices = { 0,0,0,-1,-1,-1 };
341
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
342
      }
343
    }
344

    
345
///////////////////////////////////////////////////////////////////////////////////////////////////
346

    
347
  public int getNumCubitVariants(int[] numLayers)
348
    {
349
    return 3;
350
    }
351

    
352
///////////////////////////////////////////////////////////////////////////////////////////////////
353

    
354
  public int getCubitVariant(int cubit, int[] numLayers)
355
    {
356
    return cubit<4 ? 0 : (cubit<10?1:2);
357
    }
358

    
359
///////////////////////////////////////////////////////////////////////////////////////////////////
360

    
361
  public float getStickerRadius()
362
    {
363
    return 0.04f;
364
    }
365

    
366
///////////////////////////////////////////////////////////////////////////////////////////////////
367

    
368
  public float getStickerStroke()
369
    {
370
    return isInIconMode() ? 0.08f : 0.04f;
371
    }
372

    
373
///////////////////////////////////////////////////////////////////////////////////////////////////
374

    
375
  public float[][] getStickerAngles()
376
    {
377
    return null;
378
    }
379

    
380
///////////////////////////////////////////////////////////////////////////////////////////////////
381
// PUBLIC API
382

    
383
  public Static3D[] getRotationAxis()
384
    {
385
    return ROT_AXIS;
386
    }
387

    
388
///////////////////////////////////////////////////////////////////////////////////////////////////
389

    
390
  public int[][] getBasicAngles()
391
    {
392
    if( mBasicAngle ==null )
393
      {
394
      int num = getNumLayers()[0];
395
      int[] tmp = new int[num];
396
      for(int i=0; i<num; i++) tmp[i] = 3;
397
      mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
398
      }
399

    
400
    return mBasicAngle;
401
    }
402

    
403
///////////////////////////////////////////////////////////////////////////////////////////////////
404

    
405
  public String getShortName()
406
    {
407
    return ObjectType.JING_2.name();
408
    }
409

    
410
///////////////////////////////////////////////////////////////////////////////////////////////////
411

    
412
  public ObjectSignature getSignature()
413
    {
414
    return new ObjectSignature(ObjectType.JING_2);
415
    }
416

    
417
///////////////////////////////////////////////////////////////////////////////////////////////////
418

    
419
  public String getObjectName()
420
    {
421
    return "Jing Pyraminx";
422
    }
423

    
424
///////////////////////////////////////////////////////////////////////////////////////////////////
425

    
426
  public String getInventor()
427
    {
428
    return "Tony Fisher";
429
    }
430

    
431
///////////////////////////////////////////////////////////////////////////////////////////////////
432

    
433
  public int getYearOfInvention()
434
    {
435
    return 1991;
436
    }
437

    
438
///////////////////////////////////////////////////////////////////////////////////////////////////
439

    
440
  public int getComplexity()
441
    {
442
    return 1;
443
    }
444

    
445
///////////////////////////////////////////////////////////////////////////////////////////////////
446

    
447
  public String[][] getTutorials()
448
    {
449
    return new String[][]{
450
                          {"gb","0T8Iw6aI2gA","Jing's Pyraminx Tutorial","SuperAntoniovivaldi"},
451
                          {"es","Na27_GUIzqY","Resolver Jing Pyraminx","Cuby"},
452
                          {"ru","rlQXFzjsyAo","Как собрать Jing's pyraminx","Илья Топор-Гилка"},
453
                          {"fr","zC9dGqZRSic","Résolution du Jing's Pyraminx","Asthalis"},
454
                          {"de","6ihN4fdHH6o","Jings Pyraminx - Tutorial","GerCubing"},
455
                          {"pl","nRYoJAy1c_8","Jing's Pyraminx TUTORIAL PL","MrUK"},
456
                          {"vn","yX9KjDpHjws","Tutorial N.50 - Jing's Pyraminx","Duy Thích Rubik"},
457
                         };
458
    }
459
}
(15-15/39)