1 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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 |
c9c71c3f
|
Leszek Koltunski
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_HEXAHEDRON;
|
23 |
|
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
|
24 |
29b82486
|
Leszek Koltunski
|
|
25 |
82eb152a
|
Leszek Koltunski
|
import java.io.InputStream;
|
26 |
29b82486
|
Leszek Koltunski
|
|
27 |
|
|
import org.distorted.library.type.Static3D;
|
28 |
|
|
import org.distorted.library.type.Static4D;
|
29 |
386af988
|
Leszek Koltunski
|
import org.distorted.objectlib.main.ShapeHexahedron;
|
30 |
29b82486
|
Leszek Koltunski
|
|
31 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
32 |
|
|
|
33 |
386af988
|
Leszek Koltunski
|
abstract class TwistySquare extends ShapeHexahedron
|
34 |
29b82486
|
Leszek Koltunski
|
{
|
35 |
|
|
static final float COS15 = (SQ6+SQ2)/4;
|
36 |
|
|
static final float SIN15 = (SQ6-SQ2)/4;
|
37 |
|
|
static final float X = 3*(2-SQ3)/2;
|
38 |
|
|
|
39 |
|
|
// The third, artificial axis is for the generic scrambling algorithm.
|
40 |
|
|
// Otherwise it wouldn't be possible to rotate the LO and UP layers
|
41 |
|
|
// consecutively.
|
42 |
|
|
|
43 |
|
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
44 |
|
|
{
|
45 |
|
|
new Static3D(0,+1,0),
|
46 |
|
|
new Static3D(COS15,0,SIN15),
|
47 |
|
|
new Static3D(0,-1,0),
|
48 |
|
|
};
|
49 |
|
|
|
50 |
|
|
private int[] mBasicAngle;
|
51 |
|
|
private float[][] mCuts;
|
52 |
|
|
Static4D[] mQuats;
|
53 |
|
|
|
54 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
55 |
|
|
|
56 |
64c209f5
|
Leszek Koltunski
|
TwistySquare(int[] numL, Static4D quat, Static3D move, float scale, InputStream stream)
|
57 |
29b82486
|
Leszek Koltunski
|
{
|
58 |
64c209f5
|
Leszek Koltunski
|
super(numL, numL[0], quat, move, scale, stream);
|
59 |
29b82486
|
Leszek Koltunski
|
}
|
60 |
|
|
|
61 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
62 |
|
|
|
63 |
|
|
void initializeQuats()
|
64 |
|
|
{
|
65 |
|
|
mQuats = new Static4D[]
|
66 |
|
|
{
|
67 |
|
|
new Static4D( 0.0f, 0.0f, 0.0f, 1.0f ),
|
68 |
|
|
new Static4D( 0.0f, SIN15, 0.0f, COS15 ),
|
69 |
|
|
new Static4D( 0.0f, 0.5f, 0.0f, SQ3/2 ),
|
70 |
|
|
new Static4D( 0.0f, SQ2/2, 0.0f, SQ2/2 ),
|
71 |
|
|
new Static4D( 0.0f, SQ3/2, 0.0f, 0.5f ),
|
72 |
|
|
new Static4D( 0.0f, COS15, 0.0f, SIN15 ),
|
73 |
|
|
new Static4D( 0.0f, 1.0f, 0.0f, 0.0f ),
|
74 |
|
|
new Static4D( 0.0f, COS15, 0.0f,-SIN15 ),
|
75 |
|
|
new Static4D( 0.0f, SQ3/2, 0.0f, -0.5f ),
|
76 |
|
|
new Static4D( 0.0f, SQ2/2, 0.0f,-SQ2/2 ),
|
77 |
|
|
new Static4D( 0.0f, 0.5f, 0.0f,-SQ3/2 ),
|
78 |
|
|
new Static4D( 0.0f, SIN15, 0.0f,-COS15 ),
|
79 |
|
|
|
80 |
|
|
new Static4D( 1.0f, 0.0f, 0.0f, 0.0f ),
|
81 |
|
|
new Static4D( COS15, 0.0f, SIN15, 0.0f ),
|
82 |
|
|
new Static4D( SQ3/2, 0.0f, 0.5f, 0.0f ),
|
83 |
|
|
new Static4D( SQ2/2, 0.0f, SQ2/2, 0.0f ),
|
84 |
|
|
new Static4D( 0.5f, 0.0f, SQ3/2, 0.0f ),
|
85 |
|
|
new Static4D( SIN15, 0.0f, COS15, 0.0f ),
|
86 |
|
|
new Static4D( 0.0f, 0.0f, 1.0f, 0.0f ),
|
87 |
|
|
new Static4D(-SIN15, 0.0f, COS15, 0.0f ),
|
88 |
|
|
new Static4D( -0.5f, 0.0f, SQ3/2, 0.0f ),
|
89 |
|
|
new Static4D(-SQ2/2, 0.0f, SQ2/2, 0.0f ),
|
90 |
|
|
new Static4D(-SQ3/2, 0.0f, 0.5f, 0.0f ),
|
91 |
|
|
new Static4D(-COS15, 0.0f, SIN15, 0.0f )
|
92 |
|
|
};
|
93 |
|
|
}
|
94 |
|
|
|
95 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
96 |
|
|
|
97 |
|
|
void initializeBasicAngle()
|
98 |
|
|
{
|
99 |
|
|
mBasicAngle = new int[] {12,2,12};
|
100 |
|
|
}
|
101 |
|
|
|
102 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
103 |
|
|
|
104 |
1bb09f88
|
Leszek Koltunski
|
public Static4D[] getQuats()
|
105 |
29b82486
|
Leszek Koltunski
|
{
|
106 |
|
|
if( mQuats==null ) initializeQuats();
|
107 |
|
|
return mQuats;
|
108 |
|
|
}
|
109 |
|
|
|
110 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
111 |
|
|
|
112 |
a75ae1ee
|
Leszek Koltunski
|
public int getNumCubitFaces()
|
113 |
29b82486
|
Leszek Koltunski
|
{
|
114 |
|
|
return 6;
|
115 |
|
|
}
|
116 |
|
|
|
117 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
118 |
|
|
|
119 |
7bbfc84f
|
Leszek Koltunski
|
public float[][] getCuts(int[] numLayers)
|
120 |
29b82486
|
Leszek Koltunski
|
{
|
121 |
|
|
if( mCuts==null )
|
122 |
|
|
{
|
123 |
|
|
mCuts = new float[][] { {-0.5f,+0.5f}, {0.0f}, {-0.5f,+0.5f} };
|
124 |
|
|
}
|
125 |
|
|
|
126 |
|
|
return mCuts;
|
127 |
|
|
}
|
128 |
|
|
|
129 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
130 |
|
|
|
131 |
59c20632
|
Leszek Koltunski
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
132 |
29b82486
|
Leszek Koltunski
|
{
|
133 |
59c20632
|
Leszek Koltunski
|
return new boolean[][] { {true,false,true}, {true,true}, {true,false,true} };
|
134 |
29b82486
|
Leszek Koltunski
|
}
|
135 |
|
|
|
136 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
137 |
|
|
|
138 |
11fa413d
|
Leszek Koltunski
|
public int getTouchControlType()
|
139 |
29b82486
|
Leszek Koltunski
|
{
|
140 |
c9c71c3f
|
Leszek Koltunski
|
return TC_HEXAHEDRON;
|
141 |
29b82486
|
Leszek Koltunski
|
}
|
142 |
|
|
|
143 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
144 |
|
|
|
145 |
11fa413d
|
Leszek Koltunski
|
public int getTouchControlSplit()
|
146 |
29b82486
|
Leszek Koltunski
|
{
|
147 |
59c20632
|
Leszek Koltunski
|
return TYPE_NOT_SPLIT;
|
148 |
|
|
}
|
149 |
|
|
|
150 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
151 |
|
|
|
152 |
|
|
public int[][][] getEnabled()
|
153 |
|
|
{
|
154 |
|
|
return new int[][][] { {{0}},{{0}},{{1}},{{1}},{{0,1}},{{0,1}} };
|
155 |
|
|
}
|
156 |
|
|
|
157 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
158 |
|
|
|
159 |
|
|
public float[] getDist3D(int[] numLayers)
|
160 |
|
|
{
|
161 |
|
|
return null;
|
162 |
|
|
}
|
163 |
|
|
|
164 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
165 |
|
|
// PUBLIC API
|
166 |
|
|
|
167 |
|
|
public Static3D[] getRotationAxis()
|
168 |
|
|
{
|
169 |
|
|
return ROT_AXIS;
|
170 |
29b82486
|
Leszek Koltunski
|
}
|
171 |
|
|
|
172 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
173 |
|
|
|
174 |
|
|
public int[] getBasicAngle()
|
175 |
|
|
{
|
176 |
|
|
if( mBasicAngle ==null ) initializeBasicAngle();
|
177 |
|
|
return mBasicAngle;
|
178 |
|
|
}
|
179 |
|
|
}
|