Project

General

Profile

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

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

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 97a75106 leszek
import org.distorted.objectlib.signature.ObjectSignature;
18 84a17011 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectVertexEffects;
19 cf93ea4e Leszek Koltunski
import org.distorted.objectlib.main.InitAssets;
20 97a75106 leszek
import org.distorted.objectlib.signature.ObjectConstants;
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 1fda81c4 leszek
  public TwistyFisher(int iconMode, Static4D quat, Static3D move, float scale, InitData data, InitAssets asset)
50 23127082 Leszek Koltunski
    {
51 1fda81c4 leszek
    super(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 347f6cc1 Leszek Koltunski
    int angle = 25;
291
    float R = 0.7f;
292
    float S = 0.5f;
293
294 23127082 Leszek Koltunski
    if( variant==0 )
295
      {
296 3bf19410 Leszek Koltunski
      float h1 = isInIconMode() ? 0.001f : 0.025f;
297
      float h2 = isInIconMode() ? 0.001f : 0.020f;
298 347f6cc1 Leszek Koltunski
      float[][] bands = { {h1,angle,R,S,5,1,0}, {h2,angle,R,S,5,1,0} };
299 84a17011 Leszek Koltunski
      int[] indices   = { 0,0,0,1,1 };
300
      return new ObjectFaceShape(bands,indices,null);
301
      }
302
    else if( variant==1 )
303
      {
304
      float h1 = isInIconMode() ? 0.001f : 0.025f;
305
      float h2 = isInIconMode() ? 0.001f : 0.020f;
306 347f6cc1 Leszek Koltunski
      float[][] bands = { {h1,angle,R,S,5,1,0}, {h2,angle,R,S,5,1,0} };
307 84a17011 Leszek Koltunski
      int[] indices   = { 0,0,0,1,1,1,0 };
308
      return new ObjectFaceShape(bands,indices,null);
309
      }
310
    else
311
      {
312
      float h1 = isInIconMode() ? 0.001f : 0.05f;
313
      float h2 = isInIconMode() ? 0.001f : 0.04f;
314 347f6cc1 Leszek Koltunski
      float[][] bands = { {h1,angle,R,S,5,1,0}, {h2,angle,R,S,5,1,0} };
315 84a17011 Leszek Koltunski
      int[] indices   = { 1,0,0,1,1,1 };
316
      return new ObjectFaceShape(bands,indices,null);
317
      }
318
    }
319
320
///////////////////////////////////////////////////////////////////////////////////////////////////
321
322
  public ObjectVertexEffects getVertexEffects(int variant)
323
    {
324
    if( variant==0 )
325
      {
326
      final float A = (3-SQ2)/2;
327 23127082 Leszek Koltunski
      float[][] corners = { {0.04f,0.09f} };
328
      int[] indices     = { 0,0,0,0,-1,-1 };
329
      float[][] centers = { { 0.0f, 0.0f,-A/2 } };
330 84a17011 Leszek Koltunski
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
331 23127082 Leszek Koltunski
      }
332
    else if( variant==1 )
333
      {
334 84a17011 Leszek Koltunski
      final float A = SQ2/2;
335 23127082 Leszek Koltunski
      float[][] corners = { {0.03f,0.09f} };
336
      int[] indices     = { 0,0,-1,-1,0,0,0,-1,-1,0 };
337 84a17011 Leszek Koltunski
      float[][] centers = { { A, 0.0f, -A } };
338
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
339 23127082 Leszek Koltunski
      }
340
    else
341
      {
342
      float[][] corners = { {0.04f,0.12f} };
343
      int[] indices     = { 0,0,0,0,0,0,0,0 };
344
      float[][] centers = { {0.0f, 0.0f, 0.0f } };
345 84a17011 Leszek Koltunski
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
346 23127082 Leszek Koltunski
      }
347
    }
348
349
///////////////////////////////////////////////////////////////////////////////////////////////////
350
351
  public int getNumCubitVariants(int[] numLayers)
352
    {
353
    return 3;
354
    }
355
356
///////////////////////////////////////////////////////////////////////////////////////////////////
357
358
  public int getCubitVariant(int cubit, int[] numLayers)
359
    {
360
    return cubit<12 ? 0 : (cubit<24 ? 1:2);
361
    }
362
363
///////////////////////////////////////////////////////////////////////////////////////////////////
364
365
  public float getStickerRadius()
366
    {
367
    return 0.13f;
368
    }
369
370
///////////////////////////////////////////////////////////////////////////////////////////////////
371
372
  public float getStickerStroke()
373
    {
374 3bf19410 Leszek Koltunski
    return isInIconMode() ? 0.22f : 0.10f;
375 23127082 Leszek Koltunski
    }
376
377
///////////////////////////////////////////////////////////////////////////////////////////////////
378
379 ebe8c08e leszek
  public float[][][] getStickerAngles()
380 23127082 Leszek Koltunski
    {
381
    return null;
382
    }
383
384
///////////////////////////////////////////////////////////////////////////////////////////////////
385
// PUBLIC API
386
387
  public Static3D[] getRotationAxis()
388
    {
389
    return ROT_AXIS;
390
    }
391
392
///////////////////////////////////////////////////////////////////////////////////////////////////
393
394 beee90ab Leszek Koltunski
  public int[][] getBasicAngles()
395 23127082 Leszek Koltunski
    {
396 beee90ab Leszek Koltunski
    if( mBasicAngle==null )
397
      {
398
      int num = getNumLayers()[0];
399
      int[] tmp = new int[num];
400
      for(int i=0; i<num; i++) tmp[i] = 4;
401
      mBasicAngle = new int[][] { tmp,tmp,tmp };
402
      }
403
404 23127082 Leszek Koltunski
    return mBasicAngle;
405
    }
406
407
///////////////////////////////////////////////////////////////////////////////////////////////////
408
409 5f54927b Leszek Koltunski
  public String getShortName()
410 23127082 Leszek Koltunski
    {
411 5f54927b Leszek Koltunski
    return ObjectType.FISH_3.name();
412
    }
413
414
///////////////////////////////////////////////////////////////////////////////////////////////////
415
416 1d581993 Leszek Koltunski
  public ObjectSignature getSignature()
417 5f54927b Leszek Koltunski
    {
418 97a75106 leszek
    return new ObjectSignature(ObjectConstants.FISH_3);
419 23127082 Leszek Koltunski
    }
420
421
///////////////////////////////////////////////////////////////////////////////////////////////////
422
423
  public String getObjectName()
424
    {
425
    return "Fisher Cube";
426
    }
427
428
///////////////////////////////////////////////////////////////////////////////////////////////////
429
430
  public String getInventor()
431
    {
432
    return "Tony Fisher";
433
    }
434
435
///////////////////////////////////////////////////////////////////////////////////////////////////
436
437
  public int getYearOfInvention()
438
    {
439
    return 1982;
440
    }
441
442
///////////////////////////////////////////////////////////////////////////////////////////////////
443
444
  public int getComplexity()
445
    {
446
    return 2;
447
    }
448 052e0362 Leszek Koltunski
449
///////////////////////////////////////////////////////////////////////////////////////////////////
450
451
  public String[][] getTutorials()
452
    {
453
    return new String[][]{
454
                          {"gb","HhQLhGGcKK0","Solving the Fisher Cube","Junk Cuber"},
455
                          {"es","Ndd0V1gWju0","Como resolver 3x3x3 Fisher Cube","Tutoriales Rubik"},
456
                          {"ru","KfeDuy4n72Q","Как собрать Фишер Куб","Алексей Ярыгин"},
457
                          {"fr","qnnvpFzcZO4","Résolution du Fisher's Cube","asthalis"},
458
                          {"de","aSrF0VxVqck","Fisher Cube Tutorial","Pezcraft"},
459
                          {"pl","vFKujycV3cs","Fisher Cube TUTORIAL PL","MrUk"},
460
                          {"br","S4En0RXDIbs","Como resolver o Fisher Cube","Pedro Filho"},
461
                          {"kr","x9SySGU_iqE","피셔 큐브 맞추는 방법","iamzoone"},
462 a399e91b Leszek Koltunski
                          {"vn","pW3nmZtkfwk","Hướng Dẫn Giải Rubik Fisher","Rubik Cube"},
463 2318a72a leszek
                          {"tw","pAgUEf3ut88","異形魔術方塊復原教學","1hrBLD"},
464 052e0362 Leszek Koltunski
                         };
465
    }
466 23127082 Leszek Koltunski
}