1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2021 Leszek Koltunski //
|
3
|
// //
|
4
|
// This file is part of Magic Cube. //
|
5
|
// //
|
6
|
// Magic Cube is free software: you can redistribute it and/or modify //
|
7
|
// it under the terms of the GNU General Public License as published by //
|
8
|
// the Free Software Foundation, either version 2 of the License, or //
|
9
|
// (at your option) any later version. //
|
10
|
// //
|
11
|
// Magic Cube is distributed in the hope that it will be useful, //
|
12
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
13
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
14
|
// GNU General Public License for more details. //
|
15
|
// //
|
16
|
// You should have received a copy of the GNU General Public License //
|
17
|
// along with Magic Cube. If not, see <http://www.gnu.org/licenses/>. //
|
18
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19
|
|
20
|
package org.distorted.objectlib.objects;
|
21
|
|
22
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_CHANGING_SQUARE;
|
23
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
|
24
|
|
25
|
import java.io.InputStream;
|
26
|
|
27
|
import org.distorted.library.type.Static3D;
|
28
|
import org.distorted.library.type.Static4D;
|
29
|
import org.distorted.objectlib.main.InitData;
|
30
|
import org.distorted.objectlib.main.ShapeHexahedron;
|
31
|
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
|
32
|
|
33
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
34
|
|
35
|
abstract class TwistySquare extends ShapeHexahedron
|
36
|
{
|
37
|
static final float COS15 = (SQ6+SQ2)/4;
|
38
|
static final float SIN15 = (SQ6-SQ2)/4;
|
39
|
static final float X = 3*(2-SQ3)/2;
|
40
|
|
41
|
// The third, artificial axis is for the generic scrambling algorithm.
|
42
|
// Otherwise it wouldn't be possible to rotate the LO and UP layers
|
43
|
// consecutively.
|
44
|
|
45
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
46
|
{
|
47
|
new Static3D(0,+1,0),
|
48
|
new Static3D(COS15,0,SIN15),
|
49
|
new Static3D(0,-1,0),
|
50
|
};
|
51
|
|
52
|
private int[][] mBasicAngle;
|
53
|
private float[][] mCuts;
|
54
|
|
55
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
56
|
|
57
|
TwistySquare(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
|
58
|
{
|
59
|
super(data, meshState, iconMode, data.getNumLayers()[0], quat, move, scale, stream);
|
60
|
}
|
61
|
|
62
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
63
|
|
64
|
@Override
|
65
|
public int getInternalColor()
|
66
|
{
|
67
|
return 0xff333333;
|
68
|
}
|
69
|
|
70
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
71
|
|
72
|
void initializeBasicAngle()
|
73
|
{
|
74
|
mBasicAngle = new int[][] { {12,12,12},{2,2},{12,12,12} };
|
75
|
}
|
76
|
|
77
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
78
|
|
79
|
public float[][] getCuts(int[] numLayers)
|
80
|
{
|
81
|
if( mCuts==null ) mCuts = new float[][] { {-0.5f,+0.5f}, {0.0f}, {-0.5f,+0.5f} };
|
82
|
return mCuts;
|
83
|
}
|
84
|
|
85
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
86
|
|
87
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
88
|
{
|
89
|
return new boolean[][] { {true,false,true}, {true,true}, {true,false,true} };
|
90
|
}
|
91
|
|
92
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
93
|
|
94
|
public int getTouchControlType()
|
95
|
{
|
96
|
return TC_CHANGING_SQUARE;
|
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
|
// PUBLIC API
|
129
|
|
130
|
public Static3D[] getRotationAxis()
|
131
|
{
|
132
|
return ROT_AXIS;
|
133
|
}
|
134
|
|
135
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
136
|
|
137
|
public int[][] getBasicAngles()
|
138
|
{
|
139
|
if( mBasicAngle ==null ) initializeBasicAngle();
|
140
|
return mBasicAngle;
|
141
|
}
|
142
|
}
|