Project

General

Profile

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

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

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.touchcontrol.TouchControlTetrahedron;
32
import org.distorted.objectlib.main.ObjectType;
33
import org.distorted.objectlib.helpers.ObjectShape;
34
import org.distorted.objectlib.scrambling.ScrambleState;
35
import org.distorted.objectlib.main.ShapeTetrahedron;
36

    
37
///////////////////////////////////////////////////////////////////////////////////////////////////
38

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

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

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

    
59
///////////////////////////////////////////////////////////////////////////////////////////////////
60

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

    
66
///////////////////////////////////////////////////////////////////////////////////////////////////
67

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

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

    
80
    return mStates;
81
    }
82

    
83
///////////////////////////////////////////////////////////////////////////////////////////////////
84

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

    
93
    return mCuts;
94
    }
95

    
96
///////////////////////////////////////////////////////////////////////////////////////////////////
97

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

    
104
///////////////////////////////////////////////////////////////////////////////////////////////////
105

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

    
111
///////////////////////////////////////////////////////////////////////////////////////////////////
112

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

    
118
///////////////////////////////////////////////////////////////////////////////////////////////////
119

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

    
125
///////////////////////////////////////////////////////////////////////////////////////////////////
126

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

    
132
///////////////////////////////////////////////////////////////////////////////////////////////////
133

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

    
139
///////////////////////////////////////////////////////////////////////////////////////////////////
140

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

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

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

    
166
    return mCenters;
167
    }
168

    
169
///////////////////////////////////////////////////////////////////////////////////////////////////
170

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

    
177
///////////////////////////////////////////////////////////////////////////////////////////////////
178

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

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

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

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

    
261
      return new ObjectShape(vertices, indices);
262
      }
263
    }
264

    
265
///////////////////////////////////////////////////////////////////////////////////////////////////
266

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

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

    
308
///////////////////////////////////////////////////////////////////////////////////////////////////
309

    
310
  public int getNumCubitVariants(int[] numLayers)
311
    {
312
    return 3;
313
    }
314

    
315
///////////////////////////////////////////////////////////////////////////////////////////////////
316

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

    
322
///////////////////////////////////////////////////////////////////////////////////////////////////
323

    
324
  public float getStickerRadius()
325
    {
326
    return 0.04f;
327
    }
328

    
329
///////////////////////////////////////////////////////////////////////////////////////////////////
330

    
331
  public float getStickerStroke()
332
    {
333
    return isInIconMode() ? 0.08f : 0.04f;
334
    }
335

    
336
///////////////////////////////////////////////////////////////////////////////////////////////////
337

    
338
  public float[][] getStickerAngles()
339
    {
340
    return null;
341
    }
342

    
343
///////////////////////////////////////////////////////////////////////////////////////////////////
344
// PUBLIC API
345

    
346
  public Static3D[] getRotationAxis()
347
    {
348
    return ROT_AXIS;
349
    }
350

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

    
353
  public int[] getBasicAngles()
354
    {
355
    if( mBasicAngle ==null ) mBasicAngle = new int[] { 3,3,3,3 };
356
    return mBasicAngle;
357
    }
358

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

    
361
  public String getShortName()
362
    {
363
    return ObjectType.JING_2.name();
364
    }
365

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

    
368
  public long getSignature()
369
    {
370
    return ObjectType.JING_2.ordinal();
371
    }
372

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

    
375
  public String getObjectName()
376
    {
377
    return "Jing Pyraminx";
378
    }
379

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

    
382
  public String getInventor()
383
    {
384
    return "Tony Fisher";
385
    }
386

    
387
///////////////////////////////////////////////////////////////////////////////////////////////////
388

    
389
  public int getYearOfInvention()
390
    {
391
    return 1991;
392
    }
393

    
394
///////////////////////////////////////////////////////////////////////////////////////////////////
395

    
396
  public int getComplexity()
397
    {
398
    return 1;
399
    }
400

    
401
///////////////////////////////////////////////////////////////////////////////////////////////////
402

    
403
  public String[][] getTutorials()
404
    {
405
    return new String[][]{
406
                          {"gb","0T8Iw6aI2gA","Jing's Pyraminx Tutorial","SuperAntoniovivaldi"},
407
                          {"es","Na27_GUIzqY","Resolver Jing Pyraminx","Cuby"},
408
                          {"ru","rlQXFzjsyAo","Как собрать Jing's pyraminx","Илья Топор-Гилка"},
409
                          {"fr","zC9dGqZRSic","Résolution du Jing's Pyraminx","Asthalis"},
410
                          {"de","6ihN4fdHH6o","Jings Pyraminx - Tutorial","GerCubing"},
411
                          {"pl","nRYoJAy1c_8","Jing's Pyraminx TUTORIAL PL","MrUK"},
412
                          {"vn","yX9KjDpHjws","Tutorial N.50 - Jing's Pyraminx","Duy Thích Rubik"},
413
                         };
414
    }
415
}
(18-18/35)