Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyTins.java @ 3290a98d

1 5d7bb479 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// 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
///////////////////////////////////////////////////////////////////////////////////////////////////
9
10
package org.distorted.objectlib.objects;
11
12
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_HEXAHEDRON;
13
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_SPLIT_CORNER;
14
15
import org.distorted.library.type.Static3D;
16
import org.distorted.library.type.Static4D;
17
import org.distorted.objectlib.helpers.FactoryCubit;
18
import org.distorted.objectlib.helpers.ObjectFaceShape;
19
import org.distorted.objectlib.helpers.ObjectShape;
20
import org.distorted.objectlib.helpers.ObjectSignature;
21
import org.distorted.objectlib.helpers.ObjectVertexEffects;
22
import org.distorted.objectlib.main.InitAssets;
23
import org.distorted.objectlib.main.InitData;
24
import org.distorted.objectlib.main.ObjectSignatures;
25
import org.distorted.objectlib.main.ObjectType;
26
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator;
27
import org.distorted.objectlib.shape.ShapeHexahedron;
28
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
29
30
///////////////////////////////////////////////////////////////////////////////////////////////////
31
32
public class TwistyTins extends ShapeHexahedron
33
{
34
  static final Static3D[] ROT_AXIS = new Static3D[]
35
         {
36
           new Static3D( SQ3/3, SQ3/3, SQ3/3),
37
           new Static3D( SQ3/3, SQ3/3,-SQ3/3),
38
           new Static3D( SQ3/3,-SQ3/3, SQ3/3),
39
           new Static3D( SQ3/3,-SQ3/3,-SQ3/3)
40
         };
41
42
  private int[][] mEdges;
43
  private int[][] mBasicAngle;
44
  private float[][] mCuts;
45
  private float[][] mPosition;
46
  private int[] mQuatIndex;
47 acf2a9e1 Leszek Koltunski
  private boolean[][] mRotatable;
48 5d7bb479 Leszek Koltunski
49
///////////////////////////////////////////////////////////////////////////////////////////////////
50
51
  public TwistyTins(int meshState, int iconMode, Static4D quat, Static3D move, float scale, InitData data, InitAssets asset)
52
    {
53
    super(meshState, iconMode, 4, quat, move, scale, data, asset);
54
    }
55
56
///////////////////////////////////////////////////////////////////////////////////////////////////
57
58
  public int[][] getScrambleEdges()
59
    {
60 acf2a9e1 Leszek Koltunski
    if( mEdges==null )
61
      {
62
      setUpRotatable();
63
      mEdges = ScrambleEdgeGenerator.getScrambleEdgesSingle(mBasicAngle, mRotatable);
64
      }
65
66 5d7bb479 Leszek Koltunski
    return mEdges;
67
    }
68
69 acf2a9e1 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
70
71
  @Override
72
  public int[][] getScrambleAlgorithms()
73
    {
74
    setUpRotatable();
75
    return ScrambleEdgeGenerator.getScramblingAlgorithms(mBasicAngle, mRotatable);
76
    }
77
78 a70b1e96 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
79
80
  @Override
81
  public float[][] returnRotationFactor()
82
    {
83
    float C1 = 1.7f;
84
    float C2 = 2.5f;
85
    float[] f = new float[] { C2,C1,C1,C1,C2 };
86
    return new float[][] { f,f,f,f };
87
    }
88
89 5d7bb479 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
90
91
  public float[][] getCuts(int[] numLayers)
92
    {
93
    if( mCuts==null )
94
      {
95
      float C1 = -4*SQ3/3;
96
      float C2 = -2*SQ3/3;
97
      float C3 =  2*SQ3/3;
98
      float C4 =    SQ3+0.01f;
99
100
      float[] cut1 = new float[] { C1, C2, C3, C4 };
101
      float[] cut2 = new float[] {-C4,-C3,-C2,-C1 };
102
103
      mCuts = new float[][] { cut1,cut2,cut2,cut1 };
104
      }
105
106
    return mCuts;
107
    }
108
109 acf2a9e1 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
110
111
  private void setUpRotatable()
112
    {
113
    if( mRotatable==null )
114
      {
115
      boolean[] tmp = new boolean[] {true,true,false,true,true};
116
      mRotatable = new boolean[][] { tmp,tmp,tmp,tmp };
117
      }
118
    }
119
120 5d7bb479 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
121
122
  public boolean[][] getLayerRotatable(int[] numLayers)
123
    {
124 acf2a9e1 Leszek Koltunski
    setUpRotatable();
125
    return mRotatable;
126 5d7bb479 Leszek Koltunski
    }
127
128
///////////////////////////////////////////////////////////////////////////////////////////////////
129
130
  public int getTouchControlType()
131
    {
132
    return TC_HEXAHEDRON;
133
    }
134
135
///////////////////////////////////////////////////////////////////////////////////////////////////
136
137
  public int getTouchControlSplit()
138
    {
139
    return TYPE_SPLIT_CORNER;
140
    }
141
142
///////////////////////////////////////////////////////////////////////////////////////////////////
143
144
  public int[][][] getEnabled()
145
    {
146
    return new int[][][]
147
      {
148
          {{0,1},{3,1},{2,3},{0,2}},
149
          {{2,3},{3,1},{0,1},{0,2}},
150
          {{1,2},{0,1},{0,3},{2,3}},
151
          {{1,2},{2,3},{0,3},{0,1}},
152
          {{0,3},{0,2},{1,2},{1,3}},
153
          {{1,2},{0,2},{0,3},{1,3}},
154
      };
155
    }
156
157
///////////////////////////////////////////////////////////////////////////////////////////////////
158
159
  public float[] getDist3D(int[] numLayers)
160
    {
161
    return TouchControlHexahedron.D3D;
162
    }
163
164
///////////////////////////////////////////////////////////////////////////////////////////////////
165
166
  public Static3D[] getFaceAxis()
167
    {
168
    return TouchControlHexahedron.FACE_AXIS;
169
    }
170
171
///////////////////////////////////////////////////////////////////////////////////////////////////
172
// corner cubes, corner 'dino' , edges, centers.
173
174
  public float[][] getCubitPositions(int[] numLayers)
175
    {
176
    if( mPosition==null )
177
      {
178
      float C1 = 1.5f;
179
      float C2 = 1.0f;
180
      float C3 = 2.0f;
181
      float C4 = 0.5f;
182
      float C5 = 0.25f;
183
      float C6 = 0.75f;
184
185
      mPosition = new float[][]
186
         {
187
             { C1, C1, C1},
188
             {-C1, C1,-C1},
189
             { C1,-C1,-C1},
190
             {-C1,-C1, C1},
191
192
             {-C2, C3, C3},
193
             {-C3, C2, C3},
194
             {-C3, C3, C2},
195
             { C2, C3,-C3},
196
             { C3, C2,-C3},
197
             { C3, C3,-C2},
198
             { C2,-C3, C3},
199
             { C3,-C2, C3},
200
             { C3,-C3, C2},
201
             {-C2,-C3,-C3},
202
             {-C3,-C2,-C3},
203
             {-C3,-C3,-C2},
204
205
             { C4, C3, C3},
206
             { C3, C4, C3},
207
             {-C4,-C3, C3},
208
             {-C3,-C4, C3},
209
             { C3, C3, C4},
210
             { C3,-C3,-C4},
211
             {-C3,-C3, C4},
212
             {-C3, C3,-C4},
213
             {-C4, C3,-C3},
214
             { C3,-C4,-C3},
215
             { C4,-C3,-C3},
216
             {-C3, C4,-C3},
217
218
             {-C5, C6, C3}, // F
219
             { C5,-C6, C3},
220
             { C5, C6,-C3}, // B
221
             {-C5,-C6,-C3},
222 b3c8eeda Leszek Koltunski
             { C3, C5,-C6}, // R
223 5d7bb479 Leszek Koltunski
             { C3,-C5, C6},
224 b3c8eeda Leszek Koltunski
             {-C3,-C5,-C6}, // L
225 5d7bb479 Leszek Koltunski
             {-C3, C5, C6},
226 b3c8eeda Leszek Koltunski
             {-C6, C3, C5}, // T
227 5d7bb479 Leszek Koltunski
             { C6, C3,-C5},
228 b3c8eeda Leszek Koltunski
             {-C6,-C3,-C5}, // D
229 5d7bb479 Leszek Koltunski
             { C6,-C3, C5},
230 b3c8eeda Leszek Koltunski
231
             { C6,-C5, C3},
232
             {-C6, C5, C3},
233
             {-C6,-C5,-C3},
234
             { C6, C5,-C3},
235
             { C3,-C6, C5},
236
             { C3, C6,-C5},
237
             {-C3, C6, C5},
238
             {-C3,-C6,-C5},
239
             { C5, C3,-C6},
240
             {-C5, C3, C6},
241
             { C5,-C3, C6},
242 5d7bb479 Leszek Koltunski
             {-C5,-C3,-C6},
243
         };
244
      }
245
246
    return mPosition;
247
    }
248
249
///////////////////////////////////////////////////////////////////////////////////////////////////
250
251
  public Static4D getCubitQuats(int cubit, int[] numLayers)
252
    {
253
    if( mQuatIndex==null ) mQuatIndex = new int[] { 0, 3, 4, 6,
254
                                                    0, 8, 7,11, 5, 1,10, 2, 4, 9, 3, 6,
255
                                                    0, 2,10, 8, 1, 4, 6, 7,11, 5, 9, 3,
256 b3c8eeda Leszek Koltunski
                                                    0,10,11, 9, 5, 2, 3, 8, 7, 1, 6, 4,
257
                                                    0,10,11, 9, 5, 2, 3, 8, 7, 1, 6, 4,
258 5d7bb479 Leszek Koltunski
                                                  };
259
    return mObjectQuats[mQuatIndex[cubit]];
260
    }
261
262
///////////////////////////////////////////////////////////////////////////////////////////////////
263
264
  private float[][] getVertices(int variant)
265
    {
266
    if( variant==0 )
267
      {
268
      return new float[][]
269
          {
270
             { 0.0f, 0.0f, 0.0f },
271
             {-0.5f, 0.5f, 0.5f },
272
             {-0.5f,-0.5f, 0.5f },
273
             { 0.5f, 0.5f, 0.5f },
274
             { 0.5f,-0.5f, 0.5f },
275
             { 0.5f, 0.5f,-0.5f },
276
             { 0.5f,-0.5f,-0.5f },
277
             {-0.5f, 0.5f,-0.5f },
278
          };
279
      }
280
    else if( variant==1 )
281
      {
282
      return new float[][]
283
          {
284
             {-1.0f, 0.0f, 0.0f},
285
             { 1.0f, 0.0f, 0.0f},
286
             { 0.0f,-1.0f, 0.0f},
287
             { 0.0f, 0.0f,-1.0f}
288
          };
289
      }
290
    else if( variant==2 )
291
      {
292
      return new float[][]
293
          {
294
             {-0.5f, 0.0f, 0.0f},
295
             { 0.5f, 0.0f, 0.0f},
296
             { 0.5f,-1.0f, 0.0f},
297
             { 0.0f,-1.5f, 0.0f},
298
             {-1.0f,-0.5f, 0.0f},
299
             {-1.0f, 0.0f,-0.5f},
300
             { 0.0f, 0.0f,-1.5f},
301
             { 0.5f, 0.0f,-1.0f}
302
          };
303
      }
304 b3c8eeda Leszek Koltunski
    else if( variant==3 )
305
      {
306
      return new float[][]
307
          {
308
             {-0.25f, 0.75f, 0.00f},
309
             { 0.75f,-0.25f, 0.00f},
310
             { 0.25f,-0.75f, 0.00f},
311
             {-0.75f, 0.25f, 0.00f},
312
             {-0.25f, 1.00f,-0.25f},
313
             { 0.75f, 0.50f,-0.75f},
314
             { 0.25f, 0.25f,-1.00f},
315
             {-0.75f, 0.75f,-0.50f}
316
          };
317
      }
318 5d7bb479 Leszek Koltunski
    else
319
      {
320
      return new float[][]
321
          {
322 b3c8eeda Leszek Koltunski
             {-0.25f, 0.75f, 0.00f},
323
             { 0.75f,-0.25f, 0.00f},
324
             { 0.25f,-0.75f, 0.00f},
325
             {-0.75f, 0.25f, 0.00f},
326
             { 0.50f, 0.75f,-0.75f},
327
             { 1.00f,-0.25f,-0.25f},
328
             { 0.75f,-0.75f,-0.50f},
329
             { 0.25f, 0.25f,-1.00f}
330 5d7bb479 Leszek Koltunski
          };
331
      }
332
    }
333
334
///////////////////////////////////////////////////////////////////////////////////////////////////
335
336
  public ObjectShape getObjectShape(int variant)
337
    {
338
    if( variant==0 )
339
      {
340
      int[][] indices =
341
          {
342
             { 2,4,3,1 },
343
             { 1,3,5,7 },
344
             { 4,6,5,3 },
345
             { 0,4,2 },
346
             { 0,7,5 },
347
             { 0,6,4 },
348
             { 0,1,7 },
349
             { 0,2,1 },
350
             { 0,5,6 }
351
          };
352
353
      return new ObjectShape(getVertices(variant), indices);
354
      }
355
    else if( variant==1 )
356
      {
357
      int[][] indices =
358
          {
359
             {2,1,0},
360
             {3,0,1},
361
             {2,3,1},
362
             {3,2,0}
363
          };
364
365
      return new ObjectShape(getVertices(variant), indices);
366
      }
367
    else if( variant==2 )
368
      {
369
      int[][] indices =
370
          {
371
             {4,3,2,1,0},
372
             {0,1,7,6,5},
373
             {1,2,7},
374
             {2,3,6,7},
375
             {3,4,5,6},
376 a2c64ac3 Leszek Koltunski
             {0,5,4}
377 5d7bb479 Leszek Koltunski
          };
378
379
      return new ObjectShape(getVertices(variant), indices);
380
      }
381
    else
382
      {
383
      int[][] indices =
384
          {
385
             {3,2,1,0},
386 b3c8eeda Leszek Koltunski
             {6,5,1,2},
387
             {5,4,0,1},
388
             {4,7,3,0},
389
             {7,6,2,3},
390
             {4,5,6,7}
391 5d7bb479 Leszek Koltunski
          };
392
393
      return new ObjectShape(getVertices(variant), indices);
394
      }
395
    }
396
397
///////////////////////////////////////////////////////////////////////////////////////////////////
398
399
  public ObjectFaceShape getObjectFaceShape(int variant)
400
    {
401
    if( variant==0 )
402
      {
403
      float h1 = isInIconMode() ? 0.001f : 0.06f;
404
      float h2 = isInIconMode() ? 0.001f : 0.01f;
405
      float[][] bands = { {h1,35,0.5f,0.7f,5,1,0}, {h2,35,0.2f,0.4f,5,1,0} };
406
      int[] indices   = { 0,0,0,1,1,1,1,1,1 };
407
      return new ObjectFaceShape(bands,indices,null);
408
      }
409
    else if( variant==1 )
410
      {
411
      float h1 = isInIconMode() ? 0.001f : 0.035f;
412
      float h2 = isInIconMode() ? 0.001f : 0.010f;
413
      float[][] bands  = { {h1,30,0.16f,0.8f,5,0,0}, {h2,30,0.16f,0.2f,5,0,0} };
414
      int[] bandIndices= { 0,0,1,1 };
415
      return new ObjectFaceShape(bands,bandIndices,null);
416
      }
417
    else if( variant==2 )
418
      {
419
      float h1 = isInIconMode() ? 0.001f : 0.035f;
420
      float h2 = isInIconMode() ? 0.001f : 0.010f;
421
      float[][] bands  = { {h1,30,0.16f,0.8f,5,1,0}, {h2,30,0.16f,0.2f,5,0,0} };
422
      int[] bandIndices= { 0,0,1,1,1,1 };
423
      return new ObjectFaceShape(bands,bandIndices,null);
424
      }
425
    else
426
      {
427 a2c64ac3 Leszek Koltunski
      float h1 = isInIconMode() ? 0.001f : 0.040f;
428 b3c8eeda Leszek Koltunski
      float h2 = isInIconMode() ? 0.001f : 0.002f;
429 a2c64ac3 Leszek Koltunski
      float[][] bands  = { {h1,30,0.3f,0.5f,5,0,0}, {h2,30,0.1f,0.2f,3,0,0} };
430 b3c8eeda Leszek Koltunski
      int[] bandIndices= { 0,1,1,1,1,1,1,1 };
431 5d7bb479 Leszek Koltunski
      return new ObjectFaceShape(bands,bandIndices,null);
432
      }
433
    }
434
435
///////////////////////////////////////////////////////////////////////////////////////////////////
436
437
  public ObjectVertexEffects getVertexEffects(int variant)
438
    {
439
    if( variant==0 )
440
      {
441
      float[][] corners = { {0.06f,0.12f} };
442
      int[] indices     = { -1,0,-1,0,0,0,-1,-1 };
443
      float[][] centers = { { 0.0f, 0.0f, 0.0f} };
444
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
445
      }
446
    else if( variant==1 )
447
      {
448 a2c64ac3 Leszek Koltunski
      float[][] corners   = { {0.05f,0.30f}, {0.05f,0.20f} };
449 5d7bb479 Leszek Koltunski
      int[] cornerIndices = { 0,0,1,1 };
450
      float[][] centers   = { {0.0f, -0.75f, -0.75f} };
451
      int[] centerIndices = { 0,0,0,0 };
452
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
453
      }
454
    else if( variant==2 )
455
      {
456 a2c64ac3 Leszek Koltunski
      float[][] corners   = { {0.05f,0.20f}, {0.05f,0.15f} };
457 5d7bb479 Leszek Koltunski
      int[] cornerIndices = { 0,0,1,1,1,1,1,1 };
458
      float[][] centers   = { {0.0f, -0.5f, -0.5f} };
459
      int[] centerIndices = { 0,0,0,0,0,0,0,0 };
460
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
461
      }
462
    else
463
      {
464
      return null;
465
      }
466
    }
467
468
///////////////////////////////////////////////////////////////////////////////////////////////////
469
470
  public int getNumCubitVariants(int[] numLayers)
471
    {
472 b3c8eeda Leszek Koltunski
    return 5;
473 5d7bb479 Leszek Koltunski
    }
474
475
///////////////////////////////////////////////////////////////////////////////////////////////////
476
477
  public int getCubitVariant(int cubit, int[] numLayers)
478
    {
479 b3c8eeda Leszek Koltunski
    return cubit<4 ? 0: (cubit<16 ? 1: (cubit<28 ? 2: (cubit<40 ? 3:4)));
480 5d7bb479 Leszek Koltunski
    }
481
482
///////////////////////////////////////////////////////////////////////////////////////////////////
483
484
  public float getStickerRadius()
485
    {
486
    return 0.09f;
487
    }
488
489
///////////////////////////////////////////////////////////////////////////////////////////////////
490
491
  public float getStickerStroke()
492
    {
493 031d098f Leszek Koltunski
    return isInIconMode() ? 0.24f : 0.10f;
494 5d7bb479 Leszek Koltunski
    }
495
496
///////////////////////////////////////////////////////////////////////////////////////////////////
497
498 ebe8c08e leszek
  public float[][][] getStickerAngles()
499 5d7bb479 Leszek Koltunski
    {
500
    return null;
501
    }
502
503
///////////////////////////////////////////////////////////////////////////////////////////////////
504
// PUBLIC API
505
506
  public Static3D[] getRotationAxis()
507
    {
508
    return ROT_AXIS;
509
    }
510
511
///////////////////////////////////////////////////////////////////////////////////////////////////
512
513
  public int[][] getBasicAngles()
514
    {
515
    if( mBasicAngle ==null )
516
      {
517
      int[] tmp = {3,3,3,3,3};
518
      mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
519
      }
520
521
    return mBasicAngle;
522
    }
523
524
///////////////////////////////////////////////////////////////////////////////////////////////////
525
526
  public String getShortName()
527
    {
528
    return ObjectType.TINS_5.name();
529
    }
530
531
///////////////////////////////////////////////////////////////////////////////////////////////////
532
533
  public ObjectSignature getSignature()
534
    {
535
    return new ObjectSignature(ObjectSignatures.TINS_5);
536
    }
537
538
///////////////////////////////////////////////////////////////////////////////////////////////////
539
540
  public String getObjectName()
541
    {
542
    return "Tins Cube";
543
    }
544
545
///////////////////////////////////////////////////////////////////////////////////////////////////
546
547
  public String getInventor()
548
    {
549
    return "조현준";
550
    }
551
552
///////////////////////////////////////////////////////////////////////////////////////////////////
553
554
  public int getYearOfInvention()
555
    {
556
    return 2021;
557
    }
558
559
///////////////////////////////////////////////////////////////////////////////////////////////////
560
561
  public int getComplexity()
562
    {
563
    return 2;
564
    }
565
566
///////////////////////////////////////////////////////////////////////////////////////////////////
567
568
  public String[][] getTutorials()
569
    {
570
    return null;
571
    }
572
}