Project

General

Profile

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

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

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2022 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 org.distorted.library.type.Static3D;
23
import org.distorted.library.type.Static4D;
24
import org.distorted.objectlib.helpers.ObjectFaceShape;
25
import org.distorted.objectlib.helpers.ObjectShape;
26
import org.distorted.objectlib.scrambling.ScrambleState;
27
import org.distorted.objectlib.main.ObjectType;
28
import org.distorted.objectlib.main.ShapeHexahedron;
29
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
30

    
31
import java.io.InputStream;
32

    
33
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_CHANGING_SHAPEMOD;
34
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
35

    
36
///////////////////////////////////////////////////////////////////////////////////////////////////
37

    
38
public class TwistyFisher extends ShapeHexahedron
39
{
40
  static final Static3D[] ROT_AXIS = new Static3D[]
41
         {
42
           new Static3D( SQ2/2, 0.0f, SQ2/2),
43
           new Static3D(  0.0f, 1.0f,  0.0f),
44
           new Static3D( SQ2/2, 0.0f,-SQ2/2),
45
         };
46

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

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

    
55
  public TwistyFisher(int[] numL, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
56
    {
57
    super(numL, meshState, iconMode, numL[0], quat, move, scale, stream);
58
    }
59

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

    
62
  @Override
63
  public int getInternalColor()
64
    {
65
    return 0xff333333;
66
    }
67

    
68
///////////////////////////////////////////////////////////////////////////////////////////////////
69
// same as in a 3x3
70

    
71
  public ScrambleState[] getScrambleStates()
72
    {
73
    if( mStates==null )
74
      {
75
      int[][] m = new int[16][];
76

    
77
      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};
78

    
79
      mStates = new ScrambleState[]
80
          {
81
          new ScrambleState( new int[][] { m[ 1], m[ 2], m[ 3] } ),  //  0 0
82
          new ScrambleState( new int[][] {  null, m[ 4], m[ 5] } ),  //  1 x
83
          new ScrambleState( new int[][] { m[ 6],  null, m[ 7] } ),  //  2 y
84
          new ScrambleState( new int[][] { m[ 8], m[ 9],  null } ),  //  3 z
85
          new ScrambleState( new int[][] { m[10],  null, m[ 7] } ),  //  4 xy
86
          new ScrambleState( new int[][] { m[11], m[ 9],  null } ),  //  5 xz
87
          new ScrambleState( new int[][] {  null, m[12], m[ 5] } ),  //  6 yx
88
          new ScrambleState( new int[][] { m[ 8], m[13],  null } ),  //  7 yz
89
          new ScrambleState( new int[][] {  null, m[ 4], m[14] } ),  //  8 zx
90
          new ScrambleState( new int[][] { m[ 6],  null, m[15] } ),  //  9 zy
91
          new ScrambleState( new int[][] {  null,  null, m[ 5] } ),  // 10 xyx
92
          new ScrambleState( new int[][] {  null, m[ 4],  null } ),  // 11 xzx
93
          new ScrambleState( new int[][] {  null,  null, m[ 7] } ),  // 12 yxy
94
          new ScrambleState( new int[][] { m[ 6],  null,  null } ),  // 13 yzy
95
          new ScrambleState( new int[][] {  null, m[ 9],  null } ),  // 14 zxz
96
          new ScrambleState( new int[][] { m[ 8],  null,  null } ),  // 15 zyz
97
          };
98
      }
99

    
100
    return mStates;
101
    }
102

    
103
///////////////////////////////////////////////////////////////////////////////////////////////////
104

    
105
  public float[][] getCuts(int[] numLayers)
106
    {
107
    if( mCuts==null )
108
      {
109
      float C = 0.5f;
110
      float[] cut = new float[] {-C,+C};
111
      mCuts = new float[][] { cut,cut,cut };
112
      }
113

    
114
    return mCuts;
115
    }
116

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

    
119
  public boolean[][] getLayerRotatable(int[] numLayers)
120
    {
121
    boolean[] tmp = new boolean[] {true,true,true};
122
    return new boolean[][] { tmp,tmp,tmp };
123
    }
124

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

    
127
  public int getTouchControlType()
128
    {
129
    return TC_CHANGING_SHAPEMOD;
130
    }
131

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

    
134
  public int getTouchControlSplit()
135
    {
136
    return TYPE_NOT_SPLIT;
137
    }
138

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

    
141
  public int[][][] getEnabled()
142
    {
143
    return null;
144
    }
145

    
146
///////////////////////////////////////////////////////////////////////////////////////////////////
147

    
148
  public float[] getDist3D(int[] numLayers)
149
    {
150
    return TouchControlHexahedron.D3D;
151
    }
152

    
153
///////////////////////////////////////////////////////////////////////////////////////////////////
154

    
155
  public Static3D[] getFaceAxis()
156
    {
157
    return TouchControlHexahedron.FACE_AXIS;
158
    }
159

    
160
///////////////////////////////////////////////////////////////////////////////////////////////////
161

    
162
  public float[][] getCubitPositions(int[] numLayers)
163
    {
164
    if( mCenters==null )
165
      {
166
      mCenters = new float[][]
167
         {
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
             { 0.0f, 0.0f, 1.5f },
173
             { 1.5f, 0.0f, 0.0f },
174
             { 0.0f, 0.0f,-1.5f },
175
             {-1.5f, 0.0f, 0.0f },
176
             { 0.0f,-1.0f, 1.5f },
177
             { 1.5f,-1.0f, 0.0f },
178
             { 0.0f,-1.0f,-1.5f },
179
             {-1.5f,-1.0f, 0.0f },
180

    
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
             {-1.5f, 0.0f, 1.5f },
186
             { 1.5f, 0.0f, 1.5f },
187
             { 1.5f, 0.0f,-1.5f },
188
             {-1.5f, 0.0f,-1.5f },
189
             {-1.5f,-1.0f, 1.5f },
190
             { 1.5f,-1.0f, 1.5f },
191
             { 1.5f,-1.0f,-1.5f },
192
             {-1.5f,-1.0f,-1.5f },
193

    
194
             { 0.0f, 1.0f, 0.0f },
195
             { 0.0f,-1.0f, 0.0f },
196
         };
197
      }
198

    
199
    return mCenters;
200
    }
201

    
202
///////////////////////////////////////////////////////////////////////////////////////////////////
203

    
204
  public Static4D getCubitQuats(int cubit, int[] numLayers)
205
    {
206
    if( mQuatIndex==null )
207
      {
208
      mQuatIndex = new int[] {0,6,5,4,0,6,5,4,0,6,5,4,
209
                              0,6,5,4,0,6,5,4,0,6,5,4,
210
                              0,0 };
211
      }
212

    
213
    return mObjectQuats[mQuatIndex[cubit]];
214
    }
215

    
216
///////////////////////////////////////////////////////////////////////////////////////////////////
217

    
218
  public ObjectShape getObjectShape(int variant)
219
    {
220
    if( variant==0 )
221
      {
222
      final float A = (3-SQ2)/2;
223

    
224
      float[][] vertices =
225
          {
226
              {  -A, 0.5f, 0.0f },
227
              {   A, 0.5f, 0.0f },
228
              {   A,-0.5f, 0.0f },
229
              {  -A,-0.5f, 0.0f },
230
              {0.0f, 0.5f,   -A },
231
              {0.0f,-0.5f,   -A },
232
          };
233

    
234
      int[][] indices =
235
          {
236
             { 3,2,1,0 },
237
             { 0,1,4 },
238
             { 5,2,3 },
239
             { 5,3,0,4 },
240
             { 2,5,4,1 },
241
          };
242

    
243
      return new ObjectShape(vertices, indices);
244
      }
245
    else if( variant==1 )
246
      {
247
      final float A = SQ2/2;
248
      final float B = (3-SQ2)/2;
249

    
250
      float[][] vertices =
251
          {
252
              {0.0f, 0.5f, 0.0f},
253
              {   A, 0.5f, 0.0f},
254
              {1.5f, 0.5f,   -B},
255
              {   B, 0.5f,-1.5f},
256
              {0.0f, 0.5f,   -A},
257
              {0.0f,-0.5f, 0.0f},
258
              {   A,-0.5f, 0.0f},
259
              {1.5f,-0.5f,   -B},
260
              {   B,-0.5f,-1.5f},
261
              {0.0f,-0.5f,   -A},
262
          };
263

    
264
      int[][] indices =
265
          {
266
              {0,1,2,3,4},
267
              {9,8,7,6,5},
268
              {5,6,1,0},
269
              {6,7,2,1},
270
              {7,8,3,2},
271
              {8,9,4,3},
272
              {9,5,0,4}
273
          };
274

    
275
      return new ObjectShape(vertices, indices);
276
      }
277
    else
278
      {
279
      final float A = SQ2/2;
280

    
281
      float[][] vertices =
282
          {
283
             {   -A, 0.5f, 0.0f },
284
             { 0.0f, 0.5f,    A },
285
             { 0.0f,-0.5f,    A },
286
             {   -A,-0.5f, 0.0f },
287
             { 0.0f, 0.5f,   -A },
288
             {    A, 0.5f, 0.0f },
289
             {    A,-0.5f, 0.0f },
290
             { 0.0f,-0.5f,   -A },
291
          };
292

    
293
      int[][] indices =
294
          {
295
             { 3,2,1,0 },
296
             { 0,1,5,4 },
297
             { 7,6,2,3 },
298
             { 2,6,5,1 },
299
             { 6,7,4,5 },
300
             { 7,3,0,4 }
301
          };
302

    
303
      return new ObjectShape(vertices, indices);
304
      }
305
    }
306

    
307
///////////////////////////////////////////////////////////////////////////////////////////////////
308

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

    
348
///////////////////////////////////////////////////////////////////////////////////////////////////
349

    
350
  public int getNumCubitVariants(int[] numLayers)
351
    {
352
    return 3;
353
    }
354

    
355
///////////////////////////////////////////////////////////////////////////////////////////////////
356

    
357
  public int getCubitVariant(int cubit, int[] numLayers)
358
    {
359
    return cubit<12 ? 0 : (cubit<24 ? 1:2);
360
    }
361

    
362
///////////////////////////////////////////////////////////////////////////////////////////////////
363

    
364
  public float getStickerRadius()
365
    {
366
    return 0.13f;
367
    }
368

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

    
371
  public float getStickerStroke()
372
    {
373
    return isInIconMode() ? 0.22f : 0.10f;
374
    }
375

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

    
378
  public float[][] getStickerAngles()
379
    {
380
    return null;
381
    }
382

    
383
///////////////////////////////////////////////////////////////////////////////////////////////////
384
// PUBLIC API
385

    
386
  public Static3D[] getRotationAxis()
387
    {
388
    return ROT_AXIS;
389
    }
390

    
391
///////////////////////////////////////////////////////////////////////////////////////////////////
392

    
393
  public int[][] getBasicAngles()
394
    {
395
    if( mBasicAngle==null )
396
      {
397
      int num = getNumLayers()[0];
398
      int[] tmp = new int[num];
399
      for(int i=0; i<num; i++) tmp[i] = 4;
400
      mBasicAngle = new int[][] { tmp,tmp,tmp };
401
      }
402

    
403
    return mBasicAngle;
404
    }
405

    
406
///////////////////////////////////////////////////////////////////////////////////////////////////
407

    
408
  public String getShortName()
409
    {
410
    return ObjectType.FISH_3.name();
411
    }
412

    
413
///////////////////////////////////////////////////////////////////////////////////////////////////
414

    
415
  public long getSignature()
416
    {
417
    return ObjectType.FISH_3.ordinal();
418
    }
419

    
420
///////////////////////////////////////////////////////////////////////////////////////////////////
421

    
422
  public String getObjectName()
423
    {
424
    return "Fisher Cube";
425
    }
426

    
427
///////////////////////////////////////////////////////////////////////////////////////////////////
428

    
429
  public String getInventor()
430
    {
431
    return "Tony Fisher";
432
    }
433

    
434
///////////////////////////////////////////////////////////////////////////////////////////////////
435

    
436
  public int getYearOfInvention()
437
    {
438
    return 1982;
439
    }
440

    
441
///////////////////////////////////////////////////////////////////////////////////////////////////
442

    
443
  public int getComplexity()
444
    {
445
    return 2;
446
    }
447

    
448
///////////////////////////////////////////////////////////////////////////////////////////////////
449

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