Project

General

Profile

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

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

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.ObjectSignatures;
25
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator;
26
import org.distorted.objectlib.main.InitData;
27
import org.distorted.objectlib.touchcontrol.TouchControlTetrahedron;
28
import org.distorted.objectlib.main.ObjectType;
29
import org.distorted.objectlib.helpers.ObjectShape;
30
import org.distorted.objectlib.shape.ShapeTetrahedron;
31

    
32
///////////////////////////////////////////////////////////////////////////////////////////////////
33

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

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

    
48
  private int[][] mEdges;
49
  private int[][] mBasicAngle;
50
  private int[] mQuatIndex;
51
  private float[][] mCuts;
52
  private float[][] mCenters;
53

    
54
///////////////////////////////////////////////////////////////////////////////////////////////////
55

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

    
61
///////////////////////////////////////////////////////////////////////////////////////////////////
62

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

    
69
///////////////////////////////////////////////////////////////////////////////////////////////////
70

    
71
  public int[][] getScrambleEdges()
72
    {
73
    if( mEdges==null ) mEdges = ScrambleEdgeGenerator.getScrambleEdgesSingle(mBasicAngle);
74
    return mEdges;
75
    }
76

    
77
///////////////////////////////////////////////////////////////////////////////////////////////////
78

    
79
  public float[][] getCuts(int[] numLayers)
80
    {
81
    if( mCuts==null )
82
      {
83
      float[] cut = { (F-0.5f)*(SQ6/3) };
84
      mCuts = new float[][] { cut,cut,cut,cut };
85
      }
86

    
87
    return mCuts;
88
    }
89

    
90
///////////////////////////////////////////////////////////////////////////////////////////////////
91

    
92
  public boolean[][] getLayerRotatable(int[] numLayers)
93
    {
94
    boolean[] tmp = {true,true};
95
    return new boolean[][] { tmp,tmp,tmp,tmp };
96
    }
97

    
98
///////////////////////////////////////////////////////////////////////////////////////////////////
99

    
100
  public int getTouchControlType()
101
    {
102
    return TC_TETRAHEDRON;
103
    }
104

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

    
107
  public int getTouchControlSplit()
108
    {
109
    return TYPE_NOT_SPLIT;
110
    }
111

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

    
114
  public int[][][] getEnabled()
115
    {
116
    return new int[][][] { {{1,2,3}},{{0,2,3}},{{0,1,3}},{{0,1,2}} };
117
    }
118

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

    
121
  public float[] getDist3D(int[] numLayers)
122
    {
123
    return TouchControlTetrahedron.D3D;
124
    }
125

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

    
128
  public Static3D[] getFaceAxis()
129
    {
130
    return TouchControlTetrahedron.FACE_AXIS;
131
    }
132

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

    
135
  public float[][] getCubitPositions(int[] numLayers)
136
    {
137
    if( mCenters==null )
138
      {
139
      mCenters = new float[][]
140
         {
141
           { 0.000f, -SQ2/2, 1.000f },
142
           { 0.000f, -SQ2/2,-1.000f },
143
           {-1.000f,  SQ2/2, 0.000f },
144
           { 1.000f,  SQ2/2, 0.000f },
145

    
146
           { 0.000f, -SQ2/2, 0.000f },
147
           {-0.500f, 0.000f, 0.500f },
148
           { 0.500f, 0.000f, 0.500f },
149
           {-0.500f, 0.000f,-0.500f },
150
           { 0.500f, 0.000f,-0.500f },
151
           { 0.000f,  SQ2/2, 0.000f },
152

    
153
           { 0.000f,  SQ2/6, 1.0f/3 },
154
           { 0.000f,  SQ2/6,-1.0f/3 },
155
           {-1.0f/3, -SQ2/6, 0.000f },
156
           { 1.0f/3, -SQ2/6, 0.000f },
157
         };
158
      }
159

    
160
    return mCenters;
161
    }
162

    
163
///////////////////////////////////////////////////////////////////////////////////////////////////
164

    
165
  public Static4D getCubitQuats(int cubit, int[] numLayers)
166
    {
167
    if( mQuatIndex==null ) mQuatIndex = new int[] {0,10,5,8,
168
                                                   0,5,8,6,7,9,
169
                                                   0,10,7,3};
170
    return mObjectQuats[mQuatIndex[cubit]];
171
    }
172

    
173
///////////////////////////////////////////////////////////////////////////////////////////////////
174

    
175
  private float[][] getVertices(int variant)
176
    {
177
    final float X = F/2;
178
    final float Y = F*SQ2/2;
179
    final float Z =-F/2;
180
    final float L = (2.0f-3*F);
181
    final float X2= L/2;
182
    final float Y2= L*SQ2/2;
183
    final float Z2=-L/2;
184
    final float D = F/L;
185
    final float G = 1.0f-F;
186

    
187
    if( variant==0 )
188
      {
189
      return new float[][]
190
          {
191
             {   0,   0,   0 },
192
             {   X,   Y,   Z },
193
             {   0, 2*Y, 2*Z },
194
             {  -X,   Y,   Z },
195
             {   0,   0,    -F },
196
             {   X,   Y,   Z-F },
197
             {   0, 2*Y, 2*Z-F },
198
             {  -X,   Y,   Z-F },
199
          };
200
      }
201
    else if( variant==1 )
202
      {
203
      return new float[][]
204
          {
205
             {   0,   0,     G },
206
             {   X,   Y,   Z+G },
207
             {   0, 2*Y, 2*Z+G },
208
             {  -X,   Y,   Z+G },
209
             {   0,   0,    -G },
210
             {   X,   Y,  -Z-G },
211
             {   0, 2*Y,-2*Z-G },
212
             {  -X,   Y,  -Z-G },
213
          };
214
      }
215
    else
216
      {
217
      return new float[][]
218
          {
219
             {        0,   -2*Y2/3,       -2*Z2/3 },
220
             {       X2,      Y2/3,          Z2/3 },
221
             {      -X2,      Y2/3,          Z2/3 },
222
             {        0,   -2*Y2/3,-2*Z2/3+2*D*Z2 },
223
             {  X2-D*X2, Y2/3-D*Y2,     Z2/3+D*Z2 },
224
             { -X2+D*X2, Y2/3-D*Y2,     Z2/3+D*Z2 },
225
          };
226
      }
227
    }
228

    
229
///////////////////////////////////////////////////////////////////////////////////////////////////
230

    
231
  public ObjectShape getObjectShape(int variant)
232
    {
233
    if( variant==0 )
234
      {
235
      int[][] indices =
236
          {
237
             {0,1,2,3},
238
             {1,0,4,5},
239
             {7,4,0,3},
240
             {1,5,6,2},
241
             {7,3,2,6},
242
             {4,7,6,5}
243
          };
244

    
245
      return new ObjectShape(getVertices(variant), indices);
246
      }
247
    else if( variant==1 )
248
      {
249
      int[][] indices =
250
          {
251
             {0,4,5,1},
252
             {3,7,4,0},
253
             {0,1,2,3},
254
             {4,7,6,5},
255
             {1,5,6,2},
256
             {2,6,7,3}
257
          };
258

    
259
      return new ObjectShape(getVertices(variant), indices);
260
      }
261
    else
262
      {
263
      int[][] indices =
264
          {
265
             {0,1,2},
266
             {3,5,4},
267
             {0,3,4,1},
268
             {5,3,0,2},
269
             {4,5,2,1}
270
          };
271

    
272
      return new ObjectShape(getVertices(variant), indices);
273
      }
274
    }
275

    
276
///////////////////////////////////////////////////////////////////////////////////////////////////
277

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

    
304
///////////////////////////////////////////////////////////////////////////////////////////////////
305

    
306
  public ObjectVertexEffects getVertexEffects(int variant)
307
    {
308
    final float Y = F*SQ2/2;
309
    final float Z =-F/2;
310

    
311
    if( variant==0 )
312
      {
313
      float[][] corners   = { {0.08f,0.20f*F},{0.07f,0.20f*F} };
314
      int[] cornerIndices = { 0,1,1,-1,1,-1,-1,-1 };
315
      float[][] centers   = { { 0.0f, Y, Z-F/2} };
316
      int[] centerIndices = { 0,0,0,-1,0,-1,-1,-1 };
317
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
318
      }
319
    else if( variant==1 )
320
      {
321
      float[][] corners   = { {0.07f,0.20f*F} };
322
      int[] cornerIndices = { 0,0,-1,0,0,0,-1,0 };
323
      float[][] centers   = { { 0, F*SQ2/2, 0 } };
324
      int[] centerIndices = { 0,0,-1,0,0,0,-1,0 };
325
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
326
      }
327
    else
328
      {
329
      float[][] corners   = { {0.04f,0.6f*F} };
330
      int[] cornerIndices = { 0,0,0,-1,-1,-1 };
331
      float[][] centers   = { { 0, -2*Y/3, 4*Z/3 } };
332
      int[] centerIndices = { 0,0,0,-1,-1,-1 };
333
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
334
      }
335
    }
336

    
337
///////////////////////////////////////////////////////////////////////////////////////////////////
338

    
339
  public int getNumCubitVariants(int[] numLayers)
340
    {
341
    return 3;
342
    }
343

    
344
///////////////////////////////////////////////////////////////////////////////////////////////////
345

    
346
  public int getCubitVariant(int cubit, int[] numLayers)
347
    {
348
    return cubit<4 ? 0 : (cubit<10?1:2);
349
    }
350

    
351
///////////////////////////////////////////////////////////////////////////////////////////////////
352

    
353
  public float getStickerRadius()
354
    {
355
    return 0.04f;
356
    }
357

    
358
///////////////////////////////////////////////////////////////////////////////////////////////////
359

    
360
  public float getStickerStroke()
361
    {
362
    return isInIconMode() ? 0.08f : 0.04f;
363
    }
364

    
365
///////////////////////////////////////////////////////////////////////////////////////////////////
366

    
367
  public float[][] getStickerAngles()
368
    {
369
    return null;
370
    }
371

    
372
///////////////////////////////////////////////////////////////////////////////////////////////////
373
// PUBLIC API
374

    
375
  public Static3D[] getRotationAxis()
376
    {
377
    return ROT_AXIS;
378
    }
379

    
380
///////////////////////////////////////////////////////////////////////////////////////////////////
381

    
382
  public int[][] getBasicAngles()
383
    {
384
    if( mBasicAngle ==null )
385
      {
386
      int num = getNumLayers()[0];
387
      int[] tmp = new int[num];
388
      for(int i=0; i<num; i++) tmp[i] = 3;
389
      mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
390
      }
391

    
392
    return mBasicAngle;
393
    }
394

    
395
///////////////////////////////////////////////////////////////////////////////////////////////////
396

    
397
  public String getShortName()
398
    {
399
    return ObjectType.JING_2.name();
400
    }
401

    
402
///////////////////////////////////////////////////////////////////////////////////////////////////
403

    
404
  public ObjectSignature getSignature()
405
    {
406
    return new ObjectSignature(ObjectSignatures.JING_2);
407
    }
408

    
409
///////////////////////////////////////////////////////////////////////////////////////////////////
410

    
411
  public String getObjectName()
412
    {
413
    return "Jing Pyraminx";
414
    }
415

    
416
///////////////////////////////////////////////////////////////////////////////////////////////////
417

    
418
  public String getInventor()
419
    {
420
    return "Tony Fisher";
421
    }
422

    
423
///////////////////////////////////////////////////////////////////////////////////////////////////
424

    
425
  public int getYearOfInvention()
426
    {
427
    return 1991;
428
    }
429

    
430
///////////////////////////////////////////////////////////////////////////////////////////////////
431

    
432
  public int getComplexity()
433
    {
434
    return 1;
435
    }
436

    
437
///////////////////////////////////////////////////////////////////////////////////////////////////
438

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