Project

General

Profile

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

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

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.helpers.ObjectSignature;
27
import org.distorted.objectlib.main.InitData;
28
import org.distorted.objectlib.scrambling.ScrambleState;
29
import org.distorted.objectlib.main.ObjectType;
30
import org.distorted.objectlib.main.ShapeHexahedron;
31
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
32

    
33
import java.io.InputStream;
34

    
35
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_CHANGING_SHAPEMOD;
36
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
37

    
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39

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

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

    
55
///////////////////////////////////////////////////////////////////////////////////////////////////
56

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

    
62
///////////////////////////////////////////////////////////////////////////////////////////////////
63

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

    
70
///////////////////////////////////////////////////////////////////////////////////////////////////
71
// same as in a 3x3
72

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

    
79
      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};
80

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

    
102
    return mStates;
103
    }
104

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

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

    
116
    return mCuts;
117
    }
118

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

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

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

    
129
  public int getTouchControlType()
130
    {
131
    return TC_CHANGING_SHAPEMOD;
132
    }
133

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

    
136
  public int getTouchControlSplit()
137
    {
138
    return TYPE_NOT_SPLIT;
139
    }
140

    
141
///////////////////////////////////////////////////////////////////////////////////////////////////
142

    
143
  public int[][][] getEnabled()
144
    {
145
    return null;
146
    }
147

    
148
///////////////////////////////////////////////////////////////////////////////////////////////////
149

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

    
155
///////////////////////////////////////////////////////////////////////////////////////////////////
156

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

    
162
///////////////////////////////////////////////////////////////////////////////////////////////////
163

    
164
  public float[][] getCubitPositions(int[] numLayers)
165
    {
166
    if( mCenters==null )
167
      {
168
      mCenters = new float[][]
169
         {
170
             { 0.0f, 1.0f, 1.5f },
171
             { 1.5f, 1.0f, 0.0f },
172
             { 0.0f, 1.0f,-1.5f },
173
             {-1.5f, 1.0f, 0.0f },
174
             { 0.0f, 0.0f, 1.5f },
175
             { 1.5f, 0.0f, 0.0f },
176
             { 0.0f, 0.0f,-1.5f },
177
             {-1.5f, 0.0f, 0.0f },
178
             { 0.0f,-1.0f, 1.5f },
179
             { 1.5f,-1.0f, 0.0f },
180
             { 0.0f,-1.0f,-1.5f },
181
             {-1.5f,-1.0f, 0.0f },
182

    
183
             {-1.5f, 1.0f, 1.5f },
184
             { 1.5f, 1.0f, 1.5f },
185
             { 1.5f, 1.0f,-1.5f },
186
             {-1.5f, 1.0f,-1.5f },
187
             {-1.5f, 0.0f, 1.5f },
188
             { 1.5f, 0.0f, 1.5f },
189
             { 1.5f, 0.0f,-1.5f },
190
             {-1.5f, 0.0f,-1.5f },
191
             {-1.5f,-1.0f, 1.5f },
192
             { 1.5f,-1.0f, 1.5f },
193
             { 1.5f,-1.0f,-1.5f },
194
             {-1.5f,-1.0f,-1.5f },
195

    
196
             { 0.0f, 1.0f, 0.0f },
197
             { 0.0f,-1.0f, 0.0f },
198
         };
199
      }
200

    
201
    return mCenters;
202
    }
203

    
204
///////////////////////////////////////////////////////////////////////////////////////////////////
205

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

    
215
    return mObjectQuats[mQuatIndex[cubit]];
216
    }
217

    
218
///////////////////////////////////////////////////////////////////////////////////////////////////
219

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

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

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

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

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

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

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

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

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

    
305
      return new ObjectShape(vertices, indices);
306
      }
307
    }
308

    
309
///////////////////////////////////////////////////////////////////////////////////////////////////
310

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

    
350
///////////////////////////////////////////////////////////////////////////////////////////////////
351

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

    
357
///////////////////////////////////////////////////////////////////////////////////////////////////
358

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

    
364
///////////////////////////////////////////////////////////////////////////////////////////////////
365

    
366
  public float getStickerRadius()
367
    {
368
    return 0.13f;
369
    }
370

    
371
///////////////////////////////////////////////////////////////////////////////////////////////////
372

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

    
378
///////////////////////////////////////////////////////////////////////////////////////////////////
379

    
380
  public float[][] getStickerAngles()
381
    {
382
    return null;
383
    }
384

    
385
///////////////////////////////////////////////////////////////////////////////////////////////////
386
// PUBLIC API
387

    
388
  public Static3D[] getRotationAxis()
389
    {
390
    return ROT_AXIS;
391
    }
392

    
393
///////////////////////////////////////////////////////////////////////////////////////////////////
394

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

    
405
    return mBasicAngle;
406
    }
407

    
408
///////////////////////////////////////////////////////////////////////////////////////////////////
409

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

    
415
///////////////////////////////////////////////////////////////////////////////////////////////////
416

    
417
  public ObjectSignature getSignature()
418
    {
419
    return new ObjectSignature(ObjectType.FISH_3);
420
    }
421

    
422
///////////////////////////////////////////////////////////////////////////////////////////////////
423

    
424
  public String getObjectName()
425
    {
426
    return "Fisher Cube";
427
    }
428

    
429
///////////////////////////////////////////////////////////////////////////////////////////////////
430

    
431
  public String getInventor()
432
    {
433
    return "Tony Fisher";
434
    }
435

    
436
///////////////////////////////////////////////////////////////////////////////////////////////////
437

    
438
  public int getYearOfInvention()
439
    {
440
    return 1982;
441
    }
442

    
443
///////////////////////////////////////////////////////////////////////////////////////////////////
444

    
445
  public int getComplexity()
446
    {
447
    return 2;
448
    }
449

    
450
///////////////////////////////////////////////////////////////////////////////////////////////////
451

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