Project

General

Profile

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

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

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2021 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_CHANGING_SQUARE;
13
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
14

    
15
import org.distorted.library.type.Static3D;
16
import org.distorted.library.type.Static4D;
17
import org.distorted.objectlib.main.InitAssets;
18
import org.distorted.objectlib.main.InitData;
19
import org.distorted.objectlib.shape.ShapeHexahedron;
20
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
21

    
22
///////////////////////////////////////////////////////////////////////////////////////////////////
23

    
24
abstract class TwistySquare extends ShapeHexahedron
25
{
26
  static final float COS15 = (SQ6+SQ2)/4;
27
  static final float SIN15 = (SQ6-SQ2)/4;
28
  static final float     X = 3*(2-SQ3)/2;
29

    
30
  // The third, artificial axis is for the generic scrambling algorithm.
31
  // Otherwise it wouldn't be possible to rotate the LO and UP layers
32
  // consecutively.
33

    
34
  static final Static3D[] ROT_AXIS = new Static3D[]
35
    {
36
      new Static3D(0,+1,0),
37
      new Static3D(COS15,0,SIN15),
38
      new Static3D(0,-1,0),
39
    };
40

    
41
  private int[][] mBasicAngle;
42
  private float[][] mCuts;
43

    
44
///////////////////////////////////////////////////////////////////////////////////////////////////
45

    
46
  TwistySquare(int meshState, int iconMode, Static4D quat, Static3D move, float scale, InitData data, InitAssets asset)
47
    {
48
    super(meshState, iconMode, data.getNumLayers()[0], quat, move, scale, data, asset);
49
    }
50

    
51
///////////////////////////////////////////////////////////////////////////////////////////////////
52

    
53
  @Override
54
  public int getInternalColor()
55
    {
56
    return 0xff333333;
57
    }
58

    
59
///////////////////////////////////////////////////////////////////////////////////////////////////
60

    
61
  void initializeBasicAngle()
62
    {
63
    mBasicAngle = new int[][] { {12,12,12},{2,2},{12,12,12} };
64
    }
65

    
66
///////////////////////////////////////////////////////////////////////////////////////////////////
67

    
68
  public float[][] getCuts(int[] numLayers)
69
    {
70
    if( mCuts==null ) mCuts = new float[][] { {-0.5f,+0.5f}, {0.0f}, {-0.5f,+0.5f} };
71
    return mCuts;
72
    }
73

    
74
///////////////////////////////////////////////////////////////////////////////////////////////////
75

    
76
  public boolean[][] getLayerRotatable(int[] numLayers)
77
    {
78
    return new boolean[][] { {true,false,true}, {true,true}, {true,false,true} };
79
    }
80

    
81
///////////////////////////////////////////////////////////////////////////////////////////////////
82

    
83
  public int getTouchControlType()
84
    {
85
    return TC_CHANGING_SQUARE;
86
    }
87

    
88
///////////////////////////////////////////////////////////////////////////////////////////////////
89

    
90
  public int getTouchControlSplit()
91
    {
92
    return TYPE_NOT_SPLIT;
93
    }
94

    
95
///////////////////////////////////////////////////////////////////////////////////////////////////
96

    
97
  public int[][][] getEnabled()
98
    {
99
    return null;
100
    }
101

    
102
///////////////////////////////////////////////////////////////////////////////////////////////////
103

    
104
  public float[] getDist3D(int[] numLayers)
105
    {
106
    return TouchControlHexahedron.D3D;
107
    }
108

    
109
///////////////////////////////////////////////////////////////////////////////////////////////////
110

    
111
  public Static3D[] getFaceAxis()
112
    {
113
    return TouchControlHexahedron.FACE_AXIS;
114
    }
115

    
116
///////////////////////////////////////////////////////////////////////////////////////////////////
117
// PUBLIC API
118

    
119
  public Static3D[] getRotationAxis()
120
    {
121
    return ROT_AXIS;
122
    }
123

    
124
///////////////////////////////////////////////////////////////////////////////////////////////////
125

    
126
  public int[][] getBasicAngles()
127
    {
128
    if( mBasicAngle ==null ) initializeBasicAngle();
129
    return mBasicAngle;
130
    }
131
}
(34-34/41)