Project

General

Profile

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

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

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
    int I0 =0; int I1 =6; int I2 =5; int I3 =4;
207
    if( mQuatIndex==null ) mQuatIndex = new int[] {I0,I1,I2,I3,I0,I1,I2,I3,I0,I1,I2,I3, I0,I1,I2,I3,I0,I1,I2,I3,I0,I1,I2,I3, 0,0 };
208
    return mObjectQuats[mQuatIndex[cubit]];
209
    }
210

    
211
///////////////////////////////////////////////////////////////////////////////////////////////////
212

    
213
  public ObjectShape getObjectShape(int variant)
214
    {
215
    if( variant==0 )
216
      {
217
      final float A = (3-SQ2)/2;
218

    
219
      float[][] vertices =
220
          {
221
              {  -A, 0.5f, 0.0f },
222
              {   A, 0.5f, 0.0f },
223
              {   A,-0.5f, 0.0f },
224
              {  -A,-0.5f, 0.0f },
225
              {0.0f, 0.5f,   -A },
226
              {0.0f,-0.5f,   -A },
227
          };
228

    
229
      int[][] indices =
230
          {
231
             { 3,2,1,0 },
232
             { 0,1,4 },
233
             { 5,2,3 },
234
             { 5,3,0,4 },
235
             { 2,5,4,1 },
236
          };
237

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

    
245
      float[][] vertices =
246
          {
247
              {0.0f, 0.5f, 0.0f},
248
              {   A, 0.5f, 0.0f},
249
              {1.5f, 0.5f,   -B},
250
              {   B, 0.5f,-1.5f},
251
              {0.0f, 0.5f,   -A},
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
          };
258

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

    
270
      return new ObjectShape(vertices, indices);
271
      }
272
    else
273
      {
274
      final float A = SQ2/2;
275

    
276
      float[][] vertices =
277
          {
278
             {   -A, 0.5f, 0.0f },
279
             { 0.0f, 0.5f,    A },
280
             { 0.0f,-0.5f,    A },
281
             {   -A,-0.5f, 0.0f },
282
             { 0.0f, 0.5f,   -A },
283
             {    A, 0.5f, 0.0f },
284
             {    A,-0.5f, 0.0f },
285
             { 0.0f,-0.5f,   -A },
286
          };
287

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

    
298
      return new ObjectShape(vertices, indices);
299
      }
300
    }
301

    
302
///////////////////////////////////////////////////////////////////////////////////////////////////
303

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

    
343
///////////////////////////////////////////////////////////////////////////////////////////////////
344

    
345
  public int getNumCubitVariants(int[] numLayers)
346
    {
347
    return 3;
348
    }
349

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

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

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

    
359
  public float getStickerRadius()
360
    {
361
    return 0.13f;
362
    }
363

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

    
366
  public float getStickerStroke()
367
    {
368
    return isInIconMode() ? 0.22f : 0.10f;
369
    }
370

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

    
373
  public float[][] getStickerAngles()
374
    {
375
    return null;
376
    }
377

    
378
///////////////////////////////////////////////////////////////////////////////////////////////////
379
// PUBLIC API
380

    
381
  public Static3D[] getRotationAxis()
382
    {
383
    return ROT_AXIS;
384
    }
385

    
386
///////////////////////////////////////////////////////////////////////////////////////////////////
387

    
388
  public int[] getBasicAngles()
389
    {
390
    if( mBasicAngle ==null ) mBasicAngle = new int[] { 4,4,4 };
391
    return mBasicAngle;
392
    }
393

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

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

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

    
403
  public long getSignature()
404
    {
405
    return ObjectType.FISH_3.ordinal();
406
    }
407

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

    
410
  public String getObjectName()
411
    {
412
    return "Fisher Cube";
413
    }
414

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

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

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

    
424
  public int getYearOfInvention()
425
    {
426
    return 1982;
427
    }
428

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

    
431
  public int getComplexity()
432
    {
433
    return 2;
434
    }
435

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

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