Project

General

Profile

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

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

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