Project

General

Profile

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

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

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 java.io.InputStream;
16

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

    
23
///////////////////////////////////////////////////////////////////////////////////////////////////
24

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

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

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

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

    
45
///////////////////////////////////////////////////////////////////////////////////////////////////
46

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

    
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53

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

    
60
///////////////////////////////////////////////////////////////////////////////////////////////////
61

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

    
67
///////////////////////////////////////////////////////////////////////////////////////////////////
68

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

    
75
///////////////////////////////////////////////////////////////////////////////////////////////////
76

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

    
82
///////////////////////////////////////////////////////////////////////////////////////////////////
83

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

    
89
///////////////////////////////////////////////////////////////////////////////////////////////////
90

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

    
96
///////////////////////////////////////////////////////////////////////////////////////////////////
97

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

    
103
///////////////////////////////////////////////////////////////////////////////////////////////////
104

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

    
110
///////////////////////////////////////////////////////////////////////////////////////////////////
111

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

    
117
///////////////////////////////////////////////////////////////////////////////////////////////////
118
// PUBLIC API
119

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

    
125
///////////////////////////////////////////////////////////////////////////////////////////////////
126

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