Project

General

Profile

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

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

1 23127082 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2022 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6 6133be67 Leszek Koltunski
// 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 23127082 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
9
10
package org.distorted.objectlib.objects;
11
12
import org.distorted.library.type.Static3D;
13
import org.distorted.library.type.Static4D;
14 84a17011 Leszek Koltunski
import org.distorted.objectlib.helpers.FactoryCubit;
15 23127082 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectFaceShape;
16
import org.distorted.objectlib.helpers.ObjectShape;
17 1d581993 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectSignature;
18 84a17011 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectVertexEffects;
19 cf93ea4e Leszek Koltunski
import org.distorted.objectlib.main.InitAssets;
20 2dffaf22 Leszek Koltunski
import org.distorted.objectlib.main.ObjectSignatures;
21 9ba7f3f6 Leszek Koltunski
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator;
22 a8295031 Leszek Koltunski
import org.distorted.objectlib.main.InitData;
23 23127082 Leszek Koltunski
import org.distorted.objectlib.main.ObjectType;
24 b31249d6 Leszek Koltunski
import org.distorted.objectlib.shape.ShapeHexahedron;
25 23127082 Leszek Koltunski
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
26
27
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_CHANGING_SHAPEMOD;
28
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
29
30
///////////////////////////////////////////////////////////////////////////////////////////////////
31
32
public class TwistyFisher extends ShapeHexahedron
33
{
34
  static final Static3D[] ROT_AXIS = new Static3D[]
35
         {
36
           new Static3D( SQ2/2, 0.0f, SQ2/2),
37
           new Static3D(  0.0f, 1.0f,  0.0f),
38
           new Static3D( SQ2/2, 0.0f,-SQ2/2),
39
         };
40
41 9ba7f3f6 Leszek Koltunski
  private int[][] mEdges;
42 beee90ab Leszek Koltunski
  private int[][] mBasicAngle;
43 23127082 Leszek Koltunski
  private float[][] mCuts;
44
  private float[][] mCenters;
45
  private int[] mQuatIndex;
46
47
///////////////////////////////////////////////////////////////////////////////////////////////////
48
49 cf93ea4e Leszek Koltunski
  public TwistyFisher(int meshState, int iconMode, Static4D quat, Static3D move, float scale, InitData data, InitAssets asset)
50 23127082 Leszek Koltunski
    {
51 cf93ea4e Leszek Koltunski
    super(meshState, iconMode, data.getNumLayers()[0], quat, move, scale, data, asset);
52 23127082 Leszek Koltunski
    }
53
54 7ec32155 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
55
56
  @Override
57
  public int getInternalColor()
58
    {
59
    return 0xff333333;
60
    }
61
62 23127082 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
63
64 9ba7f3f6 Leszek Koltunski
  public int[][] getScrambleEdges()
65 23127082 Leszek Koltunski
    {
66 27249eea Leszek Koltunski
    if( mEdges==null ) mEdges = ScrambleEdgeGenerator.getScrambleEdgesCuboid(3,3,3);
67 9ba7f3f6 Leszek Koltunski
    return mEdges;
68 23127082 Leszek Koltunski
    }
69
70
///////////////////////////////////////////////////////////////////////////////////////////////////
71
72
  public float[][] getCuts(int[] numLayers)
73
    {
74
    if( mCuts==null )
75
      {
76
      float C = 0.5f;
77
      float[] cut = new float[] {-C,+C};
78
      mCuts = new float[][] { cut,cut,cut };
79
      }
80
81
    return mCuts;
82
    }
83
84
///////////////////////////////////////////////////////////////////////////////////////////////////
85
86
  public boolean[][] getLayerRotatable(int[] numLayers)
87
    {
88
    boolean[] tmp = new boolean[] {true,true,true};
89
    return new boolean[][] { tmp,tmp,tmp };
90
    }
91
92
///////////////////////////////////////////////////////////////////////////////////////////////////
93
94
  public int getTouchControlType()
95
    {
96
    return TC_CHANGING_SHAPEMOD;
97
    }
98
99
///////////////////////////////////////////////////////////////////////////////////////////////////
100
101
  public int getTouchControlSplit()
102
    {
103
    return TYPE_NOT_SPLIT;
104
    }
105
106
///////////////////////////////////////////////////////////////////////////////////////////////////
107
108
  public int[][][] getEnabled()
109
    {
110
    return null;
111
    }
112
113
///////////////////////////////////////////////////////////////////////////////////////////////////
114
115
  public float[] getDist3D(int[] numLayers)
116
    {
117
    return TouchControlHexahedron.D3D;
118
    }
119
120
///////////////////////////////////////////////////////////////////////////////////////////////////
121
122
  public Static3D[] getFaceAxis()
123
    {
124
    return TouchControlHexahedron.FACE_AXIS;
125
    }
126
127
///////////////////////////////////////////////////////////////////////////////////////////////////
128
129
  public float[][] getCubitPositions(int[] numLayers)
130
    {
131
    if( mCenters==null )
132
      {
133
      mCenters = new float[][]
134
         {
135
             { 0.0f, 1.0f, 1.5f },
136
             { 1.5f, 1.0f, 0.0f },
137
             { 0.0f, 1.0f,-1.5f },
138
             {-1.5f, 1.0f, 0.0f },
139
             { 0.0f, 0.0f, 1.5f },
140
             { 1.5f, 0.0f, 0.0f },
141
             { 0.0f, 0.0f,-1.5f },
142
             {-1.5f, 0.0f, 0.0f },
143
             { 0.0f,-1.0f, 1.5f },
144
             { 1.5f,-1.0f, 0.0f },
145
             { 0.0f,-1.0f,-1.5f },
146
             {-1.5f,-1.0f, 0.0f },
147
148
             {-1.5f, 1.0f, 1.5f },
149
             { 1.5f, 1.0f, 1.5f },
150
             { 1.5f, 1.0f,-1.5f },
151
             {-1.5f, 1.0f,-1.5f },
152
             {-1.5f, 0.0f, 1.5f },
153
             { 1.5f, 0.0f, 1.5f },
154
             { 1.5f, 0.0f,-1.5f },
155
             {-1.5f, 0.0f,-1.5f },
156
             {-1.5f,-1.0f, 1.5f },
157
             { 1.5f,-1.0f, 1.5f },
158
             { 1.5f,-1.0f,-1.5f },
159
             {-1.5f,-1.0f,-1.5f },
160
161
             { 0.0f, 1.0f, 0.0f },
162
             { 0.0f,-1.0f, 0.0f },
163
         };
164
      }
165
166
    return mCenters;
167
    }
168
169
///////////////////////////////////////////////////////////////////////////////////////////////////
170
171
  public Static4D getCubitQuats(int cubit, int[] numLayers)
172
    {
173 e7587264 Leszek Koltunski
    if( mQuatIndex==null )
174
      {
175
      mQuatIndex = new int[] {0,6,5,4,0,6,5,4,0,6,5,4,
176
                              0,6,5,4,0,6,5,4,0,6,5,4,
177
                              0,0 };
178
      }
179
180 23127082 Leszek Koltunski
    return mObjectQuats[mQuatIndex[cubit]];
181
    }
182
183
///////////////////////////////////////////////////////////////////////////////////////////////////
184
185 84a17011 Leszek Koltunski
  private float[][] getVertices(int variant)
186 23127082 Leszek Koltunski
    {
187
    if( variant==0 )
188
      {
189
      final float A = (3-SQ2)/2;
190
191 84a17011 Leszek Koltunski
      return new float[][]
192 23127082 Leszek Koltunski
          {
193
              {  -A, 0.5f, 0.0f },
194
              {   A, 0.5f, 0.0f },
195
              {   A,-0.5f, 0.0f },
196
              {  -A,-0.5f, 0.0f },
197
              {0.0f, 0.5f,   -A },
198
              {0.0f,-0.5f,   -A },
199
          };
200
      }
201
    else if( variant==1 )
202
      {
203
      final float A = SQ2/2;
204
      final float B = (3-SQ2)/2;
205
206 84a17011 Leszek Koltunski
      return new float[][]
207 23127082 Leszek Koltunski
          {
208
              {0.0f, 0.5f, 0.0f},
209
              {   A, 0.5f, 0.0f},
210
              {1.5f, 0.5f,   -B},
211
              {   B, 0.5f,-1.5f},
212
              {0.0f, 0.5f,   -A},
213
              {0.0f,-0.5f, 0.0f},
214
              {   A,-0.5f, 0.0f},
215
              {1.5f,-0.5f,   -B},
216
              {   B,-0.5f,-1.5f},
217
              {0.0f,-0.5f,   -A},
218
          };
219
      }
220
    else
221
      {
222
      final float A = SQ2/2;
223
224 84a17011 Leszek Koltunski
      return new float[][]
225 23127082 Leszek Koltunski
          {
226
             {   -A, 0.5f, 0.0f },
227
             { 0.0f, 0.5f,    A },
228
             { 0.0f,-0.5f,    A },
229
             {   -A,-0.5f, 0.0f },
230
             { 0.0f, 0.5f,   -A },
231
             {    A, 0.5f, 0.0f },
232
             {    A,-0.5f, 0.0f },
233
             { 0.0f,-0.5f,   -A },
234
          };
235 84a17011 Leszek Koltunski
      }
236
    }
237
238
///////////////////////////////////////////////////////////////////////////////////////////////////
239
240
  public ObjectShape getObjectShape(int variant)
241
    {
242
    if( variant==0 )
243
      {
244
      int[][] indices =
245
          {
246
             { 3,2,1,0 },
247
             { 0,1,4 },
248
             { 5,2,3 },
249
             { 5,3,0,4 },
250
             { 2,5,4,1 },
251
          };
252
253
      return new ObjectShape(getVertices(variant), indices);
254
      }
255
    else if( variant==1 )
256
      {
257
      int[][] indices =
258
          {
259
              {0,1,2,3,4},
260
              {9,8,7,6,5},
261
              {5,6,1,0},
262
              {6,7,2,1},
263
              {7,8,3,2},
264
              {8,9,4,3},
265
              {9,5,0,4}
266
          };
267 23127082 Leszek Koltunski
268 84a17011 Leszek Koltunski
      return new ObjectShape(getVertices(variant), indices);
269
      }
270
    else
271
      {
272 23127082 Leszek Koltunski
      int[][] indices =
273
          {
274
             { 3,2,1,0 },
275
             { 0,1,5,4 },
276
             { 7,6,2,3 },
277
             { 2,6,5,1 },
278
             { 6,7,4,5 },
279
             { 7,3,0,4 }
280
          };
281
282 84a17011 Leszek Koltunski
      return new ObjectShape(getVertices(variant), indices);
283 23127082 Leszek Koltunski
      }
284
    }
285
286
///////////////////////////////////////////////////////////////////////////////////////////////////
287
288
  public ObjectFaceShape getObjectFaceShape(int variant)
289
    {
290
    if( variant==0 )
291
      {
292 3bf19410 Leszek Koltunski
      float h1 = isInIconMode() ? 0.001f : 0.025f;
293
      float h2 = isInIconMode() ? 0.001f : 0.020f;
294 84a17011 Leszek Koltunski
      float[][] bands = { {h1,20,0.2f,0.4f,5,1,1}, {h2,20,0.2f,0.4f,5,1,1} };
295
      int[] indices   = { 0,0,0,1,1 };
296
      return new ObjectFaceShape(bands,indices,null);
297
      }
298
    else if( variant==1 )
299
      {
300
      float h1 = isInIconMode() ? 0.001f : 0.025f;
301
      float h2 = isInIconMode() ? 0.001f : 0.020f;
302
      float[][] bands = { {h1,20,0.2f,0.4f,5,1,1}, {h2,20,0.2f,0.4f,5,1,1} };
303
      int[] indices   = { 0,0,0,1,1,1,0 };
304
      return new ObjectFaceShape(bands,indices,null);
305
      }
306
    else
307
      {
308
      float h1 = isInIconMode() ? 0.001f : 0.05f;
309
      float h2 = isInIconMode() ? 0.001f : 0.04f;
310
      float[][] bands = { {h1,35,0.25f,0.7f,5,1,0}, {h2,35,0.25f,0.7f,5,1,0} };
311
      int[] indices   = { 1,0,0,1,1,1 };
312
      return new ObjectFaceShape(bands,indices,null);
313
      }
314
    }
315
316
///////////////////////////////////////////////////////////////////////////////////////////////////
317
318
  public ObjectVertexEffects getVertexEffects(int variant)
319
    {
320
    if( variant==0 )
321
      {
322
      final float A = (3-SQ2)/2;
323 23127082 Leszek Koltunski
      float[][] corners = { {0.04f,0.09f} };
324
      int[] indices     = { 0,0,0,0,-1,-1 };
325
      float[][] centers = { { 0.0f, 0.0f,-A/2 } };
326 84a17011 Leszek Koltunski
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
327 23127082 Leszek Koltunski
      }
328
    else if( variant==1 )
329
      {
330 84a17011 Leszek Koltunski
      final float A = SQ2/2;
331 23127082 Leszek Koltunski
      float[][] corners = { {0.03f,0.09f} };
332
      int[] indices     = { 0,0,-1,-1,0,0,0,-1,-1,0 };
333 84a17011 Leszek Koltunski
      float[][] centers = { { A, 0.0f, -A } };
334
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
335 23127082 Leszek Koltunski
      }
336
    else
337
      {
338
      float[][] corners = { {0.04f,0.12f} };
339
      int[] indices     = { 0,0,0,0,0,0,0,0 };
340
      float[][] centers = { {0.0f, 0.0f, 0.0f } };
341 84a17011 Leszek Koltunski
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
342 23127082 Leszek Koltunski
      }
343
    }
344
345
///////////////////////////////////////////////////////////////////////////////////////////////////
346
347
  public int getNumCubitVariants(int[] numLayers)
348
    {
349
    return 3;
350
    }
351
352
///////////////////////////////////////////////////////////////////////////////////////////////////
353
354
  public int getCubitVariant(int cubit, int[] numLayers)
355
    {
356
    return cubit<12 ? 0 : (cubit<24 ? 1:2);
357
    }
358
359
///////////////////////////////////////////////////////////////////////////////////////////////////
360
361
  public float getStickerRadius()
362
    {
363
    return 0.13f;
364
    }
365
366
///////////////////////////////////////////////////////////////////////////////////////////////////
367
368
  public float getStickerStroke()
369
    {
370 3bf19410 Leszek Koltunski
    return isInIconMode() ? 0.22f : 0.10f;
371 23127082 Leszek Koltunski
    }
372
373
///////////////////////////////////////////////////////////////////////////////////////////////////
374
375
  public float[][] getStickerAngles()
376
    {
377
    return null;
378
    }
379
380
///////////////////////////////////////////////////////////////////////////////////////////////////
381
// PUBLIC API
382
383
  public Static3D[] getRotationAxis()
384
    {
385
    return ROT_AXIS;
386
    }
387
388
///////////////////////////////////////////////////////////////////////////////////////////////////
389
390 beee90ab Leszek Koltunski
  public int[][] getBasicAngles()
391 23127082 Leszek Koltunski
    {
392 beee90ab Leszek Koltunski
    if( mBasicAngle==null )
393
      {
394
      int num = getNumLayers()[0];
395
      int[] tmp = new int[num];
396
      for(int i=0; i<num; i++) tmp[i] = 4;
397
      mBasicAngle = new int[][] { tmp,tmp,tmp };
398
      }
399
400 23127082 Leszek Koltunski
    return mBasicAngle;
401
    }
402
403
///////////////////////////////////////////////////////////////////////////////////////////////////
404
405 5f54927b Leszek Koltunski
  public String getShortName()
406 23127082 Leszek Koltunski
    {
407 5f54927b Leszek Koltunski
    return ObjectType.FISH_3.name();
408
    }
409
410
///////////////////////////////////////////////////////////////////////////////////////////////////
411
412 1d581993 Leszek Koltunski
  public ObjectSignature getSignature()
413 5f54927b Leszek Koltunski
    {
414 2dffaf22 Leszek Koltunski
    return new ObjectSignature(ObjectSignatures.FISH_3);
415 23127082 Leszek Koltunski
    }
416
417
///////////////////////////////////////////////////////////////////////////////////////////////////
418
419
  public String getObjectName()
420
    {
421
    return "Fisher Cube";
422
    }
423
424
///////////////////////////////////////////////////////////////////////////////////////////////////
425
426
  public String getInventor()
427
    {
428
    return "Tony Fisher";
429
    }
430
431
///////////////////////////////////////////////////////////////////////////////////////////////////
432
433
  public int getYearOfInvention()
434
    {
435
    return 1982;
436
    }
437
438
///////////////////////////////////////////////////////////////////////////////////////////////////
439
440
  public int getComplexity()
441
    {
442
    return 2;
443
    }
444 052e0362 Leszek Koltunski
445
///////////////////////////////////////////////////////////////////////////////////////////////////
446
447
  public String[][] getTutorials()
448
    {
449
    return new String[][]{
450
                          {"gb","HhQLhGGcKK0","Solving the Fisher Cube","Junk Cuber"},
451
                          {"es","Ndd0V1gWju0","Como resolver 3x3x3 Fisher Cube","Tutoriales Rubik"},
452
                          {"ru","KfeDuy4n72Q","Как собрать Фишер Куб","Алексей Ярыгин"},
453
                          {"fr","qnnvpFzcZO4","Résolution du Fisher's Cube","asthalis"},
454
                          {"de","aSrF0VxVqck","Fisher Cube Tutorial","Pezcraft"},
455
                          {"pl","vFKujycV3cs","Fisher Cube TUTORIAL PL","MrUk"},
456
                          {"br","S4En0RXDIbs","Como resolver o Fisher Cube","Pedro Filho"},
457
                          {"kr","x9SySGU_iqE","피셔 큐브 맞추는 방법","iamzoone"},
458 a399e91b Leszek Koltunski
                          {"vn","pW3nmZtkfwk","Hướng Dẫn Giải Rubik Fisher","Rubik Cube"},
459 052e0362 Leszek Koltunski
                         };
460
    }
461 23127082 Leszek Koltunski
}