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.ShapeHexahedron;
|
30
|
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
|
31
|
|
32
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
33
|
|
34
|
abstract class TwistySquare extends ShapeHexahedron
|
35
|
{
|
36
|
static final float COS15 = (SQ6+SQ2)/4;
|
37
|
static final float SIN15 = (SQ6-SQ2)/4;
|
38
|
static final float X = 3*(2-SQ3)/2;
|
39
|
|
40
|
// The third, artificial axis is for the generic scrambling algorithm.
|
41
|
// Otherwise it wouldn't be possible to rotate the LO and UP layers
|
42
|
// consecutively.
|
43
|
|
44
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
45
|
{
|
46
|
new Static3D(0,+1,0),
|
47
|
new Static3D(COS15,0,SIN15),
|
48
|
new Static3D(0,-1,0),
|
49
|
};
|
50
|
|
51
|
private int[][] mBasicAngle;
|
52
|
private float[][] mCuts;
|
53
|
|
54
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
55
|
|
56
|
TwistySquare(int[] numL, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
|
57
|
{
|
58
|
super(numL, meshState, iconMode, numL[0], quat, move, scale, stream);
|
59
|
}
|
60
|
|
61
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
62
|
|
63
|
@Override
|
64
|
public int getInternalColor()
|
65
|
{
|
66
|
return 0xff333333;
|
67
|
}
|
68
|
|
69
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
70
|
|
71
|
void initializeBasicAngle()
|
72
|
{
|
73
|
mBasicAngle = new int[][] { {12,12,12},{2,2},{12,12,12} };
|
74
|
}
|
75
|
|
76
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
77
|
|
78
|
public float[][] getCuts(int[] numLayers)
|
79
|
{
|
80
|
if( mCuts==null ) mCuts = new float[][] { {-0.5f,+0.5f}, {0.0f}, {-0.5f,+0.5f} };
|
81
|
return mCuts;
|
82
|
}
|
83
|
|
84
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
85
|
|
86
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
87
|
{
|
88
|
return new boolean[][] { {true,false,true}, {true,true}, {true,false,true} };
|
89
|
}
|
90
|
|
91
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
92
|
|
93
|
public int getTouchControlType()
|
94
|
{
|
95
|
return TC_CHANGING_SQUARE;
|
96
|
}
|
97
|
|
98
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
99
|
|
100
|
public int getTouchControlSplit()
|
101
|
{
|
102
|
return TYPE_NOT_SPLIT;
|
103
|
}
|
104
|
|
105
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
106
|
|
107
|
public int[][][] getEnabled()
|
108
|
{
|
109
|
return null;
|
110
|
}
|
111
|
|
112
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
113
|
|
114
|
public float[] getDist3D(int[] numLayers)
|
115
|
{
|
116
|
return TouchControlHexahedron.D3D;
|
117
|
}
|
118
|
|
119
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
120
|
|
121
|
public Static3D[] getFaceAxis()
|
122
|
{
|
123
|
return TouchControlHexahedron.FACE_AXIS;
|
124
|
}
|
125
|
|
126
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
127
|
// PUBLIC API
|
128
|
|
129
|
public Static3D[] getRotationAxis()
|
130
|
{
|
131
|
return ROT_AXIS;
|
132
|
}
|
133
|
|
134
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
135
|
|
136
|
public int[][] getBasicAngles()
|
137
|
{
|
138
|
if( mBasicAngle ==null ) initializeBasicAngle();
|
139
|
return mBasicAngle;
|
140
|
}
|
141
|
}
|