Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyFisher.java @ 5d09301e

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2022 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 org.distorted.library.type.Static3D;
13
import org.distorted.library.type.Static4D;
14
import org.distorted.objectlib.helpers.ObjectFaceShape;
15
import org.distorted.objectlib.helpers.ObjectShape;
16
import org.distorted.objectlib.helpers.ObjectSignature;
17
import org.distorted.objectlib.main.InitData;
18
import org.distorted.objectlib.scrambling.ScrambleState;
19
import org.distorted.objectlib.main.ObjectType;
20
import org.distorted.objectlib.main.ShapeHexahedron;
21
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
22

    
23
import java.io.InputStream;
24

    
25
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_CHANGING_SHAPEMOD;
26
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
27

    
28
///////////////////////////////////////////////////////////////////////////////////////////////////
29

    
30
public class TwistyFisher extends ShapeHexahedron
31
{
32
  static final Static3D[] ROT_AXIS = new Static3D[]
33
         {
34
           new Static3D( SQ2/2, 0.0f, SQ2/2),
35
           new Static3D(  0.0f, 1.0f,  0.0f),
36
           new Static3D( SQ2/2, 0.0f,-SQ2/2),
37
         };
38

    
39
  private ScrambleState[] mStates;
40
  private int[][] mBasicAngle;
41
  private float[][] mCuts;
42
  private float[][] mCenters;
43
  private int[] mQuatIndex;
44

    
45
///////////////////////////////////////////////////////////////////////////////////////////////////
46

    
47
  public TwistyFisher(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
48
    {
49
    super(data, meshState, iconMode, data.getNumLayers()[0], quat, move, scale, stream);
50
    }
51

    
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53

    
54
  @Override
55
  public int getInternalColor()
56
    {
57
    return 0xff333333;
58
    }
59

    
60
///////////////////////////////////////////////////////////////////////////////////////////////////
61
// same as in a 3x3
62

    
63
  public ScrambleState[] getScrambleStates()
64
    {
65
    if( mStates==null )
66
      {
67
      int[][] m = new int[16][];
68

    
69
      for(int i=0; i<16; i++) m[i] = new int[] { 0,-1,i,0,1,i,0,2,i, 1,-1,i,1,1,i,1,2,i, 2,-1,i,2,1,i,2,2,i};
70

    
71
      mStates = new ScrambleState[]
72
          {
73
          new ScrambleState( new int[][] { m[ 1], m[ 2], m[ 3] } ),  //  0 0
74
          new ScrambleState( new int[][] {  null, m[ 4], m[ 5] } ),  //  1 x
75
          new ScrambleState( new int[][] { m[ 6],  null, m[ 7] } ),  //  2 y
76
          new ScrambleState( new int[][] { m[ 8], m[ 9],  null } ),  //  3 z
77
          new ScrambleState( new int[][] { m[10],  null, m[ 7] } ),  //  4 xy
78
          new ScrambleState( new int[][] { m[11], m[ 9],  null } ),  //  5 xz
79
          new ScrambleState( new int[][] {  null, m[12], m[ 5] } ),  //  6 yx
80
          new ScrambleState( new int[][] { m[ 8], m[13],  null } ),  //  7 yz
81
          new ScrambleState( new int[][] {  null, m[ 4], m[14] } ),  //  8 zx
82
          new ScrambleState( new int[][] { m[ 6],  null, m[15] } ),  //  9 zy
83
          new ScrambleState( new int[][] {  null,  null, m[ 5] } ),  // 10 xyx
84
          new ScrambleState( new int[][] {  null, m[ 4],  null } ),  // 11 xzx
85
          new ScrambleState( new int[][] {  null,  null, m[ 7] } ),  // 12 yxy
86
          new ScrambleState( new int[][] { m[ 6],  null,  null } ),  // 13 yzy
87
          new ScrambleState( new int[][] {  null, m[ 9],  null } ),  // 14 zxz
88
          new ScrambleState( new int[][] { m[ 8],  null,  null } ),  // 15 zyz
89
          };
90
      }
91

    
92
    return mStates;
93
    }
94

    
95
///////////////////////////////////////////////////////////////////////////////////////////////////
96

    
97
  public float[][] getCuts(int[] numLayers)
98
    {
99
    if( mCuts==null )
100
      {
101
      float C = 0.5f;
102
      float[] cut = new float[] {-C,+C};
103
      mCuts = new float[][] { cut,cut,cut };
104
      }
105

    
106
    return mCuts;
107
    }
108

    
109
///////////////////////////////////////////////////////////////////////////////////////////////////
110

    
111
  public boolean[][] getLayerRotatable(int[] numLayers)
112
    {
113
    boolean[] tmp = new boolean[] {true,true,true};
114
    return new boolean[][] { tmp,tmp,tmp };
115
    }
116

    
117
///////////////////////////////////////////////////////////////////////////////////////////////////
118

    
119
  public int getTouchControlType()
120
    {
121
    return TC_CHANGING_SHAPEMOD;
122
    }
123

    
124
///////////////////////////////////////////////////////////////////////////////////////////////////
125

    
126
  public int getTouchControlSplit()
127
    {
128
    return TYPE_NOT_SPLIT;
129
    }
130

    
131
///////////////////////////////////////////////////////////////////////////////////////////////////
132

    
133
  public int[][][] getEnabled()
134
    {
135
    return null;
136
    }
137

    
138
///////////////////////////////////////////////////////////////////////////////////////////////////
139

    
140
  public float[] getDist3D(int[] numLayers)
141
    {
142
    return TouchControlHexahedron.D3D;
143
    }
144

    
145
///////////////////////////////////////////////////////////////////////////////////////////////////
146

    
147
  public Static3D[] getFaceAxis()
148
    {
149
    return TouchControlHexahedron.FACE_AXIS;
150
    }
151

    
152
///////////////////////////////////////////////////////////////////////////////////////////////////
153

    
154
  public float[][] getCubitPositions(int[] numLayers)
155
    {
156
    if( mCenters==null )
157
      {
158
      mCenters = new float[][]
159
         {
160
             { 0.0f, 1.0f, 1.5f },
161
             { 1.5f, 1.0f, 0.0f },
162
             { 0.0f, 1.0f,-1.5f },
163
             {-1.5f, 1.0f, 0.0f },
164
             { 0.0f, 0.0f, 1.5f },
165
             { 1.5f, 0.0f, 0.0f },
166
             { 0.0f, 0.0f,-1.5f },
167
             {-1.5f, 0.0f, 0.0f },
168
             { 0.0f,-1.0f, 1.5f },
169
             { 1.5f,-1.0f, 0.0f },
170
             { 0.0f,-1.0f,-1.5f },
171
             {-1.5f,-1.0f, 0.0f },
172

    
173
             {-1.5f, 1.0f, 1.5f },
174
             { 1.5f, 1.0f, 1.5f },
175
             { 1.5f, 1.0f,-1.5f },
176
             {-1.5f, 1.0f,-1.5f },
177
             {-1.5f, 0.0f, 1.5f },
178
             { 1.5f, 0.0f, 1.5f },
179
             { 1.5f, 0.0f,-1.5f },
180
             {-1.5f, 0.0f,-1.5f },
181
             {-1.5f,-1.0f, 1.5f },
182
             { 1.5f,-1.0f, 1.5f },
183
             { 1.5f,-1.0f,-1.5f },
184
             {-1.5f,-1.0f,-1.5f },
185

    
186
             { 0.0f, 1.0f, 0.0f },
187
             { 0.0f,-1.0f, 0.0f },
188
         };
189
      }
190

    
191
    return mCenters;
192
    }
193

    
194
///////////////////////////////////////////////////////////////////////////////////////////////////
195

    
196
  public Static4D getCubitQuats(int cubit, int[] numLayers)
197
    {
198
    if( mQuatIndex==null )
199
      {
200
      mQuatIndex = new int[] {0,6,5,4,0,6,5,4,0,6,5,4,
201
                              0,6,5,4,0,6,5,4,0,6,5,4,
202
                              0,0 };
203
      }
204

    
205
    return mObjectQuats[mQuatIndex[cubit]];
206
    }
207

    
208
///////////////////////////////////////////////////////////////////////////////////////////////////
209

    
210
  public ObjectShape getObjectShape(int variant)
211
    {
212
    if( variant==0 )
213
      {
214
      final float A = (3-SQ2)/2;
215

    
216
      float[][] vertices =
217
          {
218
              {  -A, 0.5f, 0.0f },
219
              {   A, 0.5f, 0.0f },
220
              {   A,-0.5f, 0.0f },
221
              {  -A,-0.5f, 0.0f },
222
              {0.0f, 0.5f,   -A },
223
              {0.0f,-0.5f,   -A },
224
          };
225

    
226
      int[][] indices =
227
          {
228
             { 3,2,1,0 },
229
             { 0,1,4 },
230
             { 5,2,3 },
231
             { 5,3,0,4 },
232
             { 2,5,4,1 },
233
          };
234

    
235
      return new ObjectShape(vertices, indices);
236
      }
237
    else if( variant==1 )
238
      {
239
      final float A = SQ2/2;
240
      final float B = (3-SQ2)/2;
241

    
242
      float[][] vertices =
243
          {
244
              {0.0f, 0.5f, 0.0f},
245
              {   A, 0.5f, 0.0f},
246
              {1.5f, 0.5f,   -B},
247
              {   B, 0.5f,-1.5f},
248
              {0.0f, 0.5f,   -A},
249
              {0.0f,-0.5f, 0.0f},
250
              {   A,-0.5f, 0.0f},
251
              {1.5f,-0.5f,   -B},
252
              {   B,-0.5f,-1.5f},
253
              {0.0f,-0.5f,   -A},
254
          };
255

    
256
      int[][] indices =
257
          {
258
              {0,1,2,3,4},
259
              {9,8,7,6,5},
260
              {5,6,1,0},
261
              {6,7,2,1},
262
              {7,8,3,2},
263
              {8,9,4,3},
264
              {9,5,0,4}
265
          };
266

    
267
      return new ObjectShape(vertices, indices);
268
      }
269
    else
270
      {
271
      final float A = SQ2/2;
272

    
273
      float[][] vertices =
274
          {
275
             {   -A, 0.5f, 0.0f },
276
             { 0.0f, 0.5f,    A },
277
             { 0.0f,-0.5f,    A },
278
             {   -A,-0.5f, 0.0f },
279
             { 0.0f, 0.5f,   -A },
280
             {    A, 0.5f, 0.0f },
281
             {    A,-0.5f, 0.0f },
282
             { 0.0f,-0.5f,   -A },
283
          };
284

    
285
      int[][] indices =
286
          {
287
             { 3,2,1,0 },
288
             { 0,1,5,4 },
289
             { 7,6,2,3 },
290
             { 2,6,5,1 },
291
             { 6,7,4,5 },
292
             { 7,3,0,4 }
293
          };
294

    
295
      return new ObjectShape(vertices, indices);
296
      }
297
    }
298

    
299
///////////////////////////////////////////////////////////////////////////////////////////////////
300

    
301
  public ObjectFaceShape getObjectFaceShape(int variant)
302
    {
303
    if( variant==0 )
304
      {
305
      final float A = (3-SQ2)/2;
306
      float h1 = isInIconMode() ? 0.001f : 0.025f;
307
      float h2 = isInIconMode() ? 0.001f : 0.020f;
308
      float[][] bands   = { {h1,20,0.2f,0.4f,5,1,1}, {h2,20,0.2f,0.4f,5,1,1} };
309
      int[] bandIndices = { 0,0,0,1,1 };
310
      float[][] corners = { {0.04f,0.09f} };
311
      int[] indices     = { 0,0,0,0,-1,-1 };
312
      float[][] centers = { { 0.0f, 0.0f,-A/2 } };
313
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
314
      }
315
    else if( variant==1 )
316
      {
317
      final float B = SQ2/2;
318
      float h1 = isInIconMode() ? 0.001f : 0.025f;
319
      float h2 = isInIconMode() ? 0.001f : 0.020f;
320
      float[][] bands   = { {h1,20,0.2f,0.4f,5,1,1}, {h2,20,0.2f,0.4f,5,1,1} };
321
      int[] bandIndices = { 0,0,0,1,1,1,0 };
322
      float[][] corners = { {0.03f,0.09f} };
323
      int[] indices     = { 0,0,-1,-1,0,0,0,-1,-1,0 };
324
      float[][] centers = { { B, 0.0f, -B } };
325
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
326
      }
327
    else
328
      {
329
      float h1 = isInIconMode() ? 0.001f : 0.05f;
330
      float h2 = isInIconMode() ? 0.001f : 0.04f;
331
      float[][] bands   = { {h1,35,0.25f,0.7f,5,1,0}, {h2,35,0.25f,0.7f,5,1,0} };
332
      int[] bandIndices = { 1,0,0,1,1,1 };
333
      float[][] corners = { {0.04f,0.12f} };
334
      int[] indices     = { 0,0,0,0,0,0,0,0 };
335
      float[][] centers = { {0.0f, 0.0f, 0.0f } };
336
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
337
      }
338
    }
339

    
340
///////////////////////////////////////////////////////////////////////////////////////////////////
341

    
342
  public int getNumCubitVariants(int[] numLayers)
343
    {
344
    return 3;
345
    }
346

    
347
///////////////////////////////////////////////////////////////////////////////////////////////////
348

    
349
  public int getCubitVariant(int cubit, int[] numLayers)
350
    {
351
    return cubit<12 ? 0 : (cubit<24 ? 1:2);
352
    }
353

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

    
356
  public float getStickerRadius()
357
    {
358
    return 0.13f;
359
    }
360

    
361
///////////////////////////////////////////////////////////////////////////////////////////////////
362

    
363
  public float getStickerStroke()
364
    {
365
    return isInIconMode() ? 0.22f : 0.10f;
366
    }
367

    
368
///////////////////////////////////////////////////////////////////////////////////////////////////
369

    
370
  public float[][] getStickerAngles()
371
    {
372
    return null;
373
    }
374

    
375
///////////////////////////////////////////////////////////////////////////////////////////////////
376
// PUBLIC API
377

    
378
  public Static3D[] getRotationAxis()
379
    {
380
    return ROT_AXIS;
381
    }
382

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

    
385
  public int[][] getBasicAngles()
386
    {
387
    if( mBasicAngle==null )
388
      {
389
      int num = getNumLayers()[0];
390
      int[] tmp = new int[num];
391
      for(int i=0; i<num; i++) tmp[i] = 4;
392
      mBasicAngle = new int[][] { tmp,tmp,tmp };
393
      }
394

    
395
    return mBasicAngle;
396
    }
397

    
398
///////////////////////////////////////////////////////////////////////////////////////////////////
399

    
400
  public String getShortName()
401
    {
402
    return ObjectType.FISH_3.name();
403
    }
404

    
405
///////////////////////////////////////////////////////////////////////////////////////////////////
406

    
407
  public ObjectSignature getSignature()
408
    {
409
    return new ObjectSignature(ObjectType.FISH_3);
410
    }
411

    
412
///////////////////////////////////////////////////////////////////////////////////////////////////
413

    
414
  public String getObjectName()
415
    {
416
    return "Fisher Cube";
417
    }
418

    
419
///////////////////////////////////////////////////////////////////////////////////////////////////
420

    
421
  public String getInventor()
422
    {
423
    return "Tony Fisher";
424
    }
425

    
426
///////////////////////////////////////////////////////////////////////////////////////////////////
427

    
428
  public int getYearOfInvention()
429
    {
430
    return 1982;
431
    }
432

    
433
///////////////////////////////////////////////////////////////////////////////////////////////////
434

    
435
  public int getComplexity()
436
    {
437
    return 2;
438
    }
439

    
440
///////////////////////////////////////////////////////////////////////////////////////////////////
441

    
442
  public String[][] getTutorials()
443
    {
444
    return new String[][]{
445
                          {"gb","HhQLhGGcKK0","Solving the Fisher Cube","Junk Cuber"},
446
                          {"es","Ndd0V1gWju0","Como resolver 3x3x3 Fisher Cube","Tutoriales Rubik"},
447
                          {"ru","KfeDuy4n72Q","Как собрать Фишер Куб","Алексей Ярыгин"},
448
                          {"fr","qnnvpFzcZO4","Résolution du Fisher's Cube","asthalis"},
449
                          {"de","aSrF0VxVqck","Fisher Cube Tutorial","Pezcraft"},
450
                          {"pl","vFKujycV3cs","Fisher Cube TUTORIAL PL","MrUk"},
451
                          {"br","S4En0RXDIbs","Como resolver o Fisher Cube","Pedro Filho"},
452
                          {"kr","x9SySGU_iqE","피셔 큐브 맞추는 방법","iamzoone"},
453
                          {"vn","pW3nmZtkfwk","Hướng Dẫn Giải Rubik Fisher","Rubik Cube"},
454
                         };
455
    }
456
}
(12-12/36)