1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2020 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_HEXAHEDRON;
|
23
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_SPLIT_CORNER;
|
24
|
|
25
|
import java.io.InputStream;
|
26
|
|
27
|
import org.distorted.library.type.Static3D;
|
28
|
import org.distorted.library.type.Static4D;
|
29
|
|
30
|
import org.distorted.objectlib.helpers.ObjectFaceShape;
|
31
|
import org.distorted.objectlib.helpers.ObjectShape;
|
32
|
import org.distorted.objectlib.scrambling.ScrambleState;
|
33
|
import org.distorted.objectlib.main.ShapeHexahedron;
|
34
|
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
|
35
|
|
36
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
37
|
|
38
|
abstract class TwistyDino extends ShapeHexahedron
|
39
|
{
|
40
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
41
|
{
|
42
|
new Static3D(+SQ3/3,+SQ3/3,+SQ3/3),
|
43
|
new Static3D(+SQ3/3,+SQ3/3,-SQ3/3),
|
44
|
new Static3D(+SQ3/3,-SQ3/3,+SQ3/3),
|
45
|
new Static3D(+SQ3/3,-SQ3/3,-SQ3/3)
|
46
|
};
|
47
|
|
48
|
private int[][] mBasicAngle;
|
49
|
private float[][] mCuts;
|
50
|
private float[][] mCenters;
|
51
|
ScrambleState[] mStates;
|
52
|
private int[] mQuatIndex;
|
53
|
|
54
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
55
|
|
56
|
TwistyDino(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
|
public float[][] getCuts(int[] numLayers)
|
64
|
{
|
65
|
if( mCuts==null )
|
66
|
{
|
67
|
float[] cut = new float[] { -SQ3/3, +SQ3/3 };
|
68
|
mCuts = new float[][] { cut,cut,cut,cut };
|
69
|
}
|
70
|
|
71
|
return mCuts;
|
72
|
}
|
73
|
|
74
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
75
|
|
76
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
77
|
{
|
78
|
int numAxis = ROT_AXIS.length;
|
79
|
boolean[] tmp = new boolean[] {true,false,true};
|
80
|
boolean[][] layerRotatable = new boolean[numAxis][];
|
81
|
for(int i=0; i<numAxis; i++) layerRotatable[i] = tmp;
|
82
|
|
83
|
return layerRotatable;
|
84
|
}
|
85
|
|
86
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
87
|
|
88
|
public int getTouchControlType()
|
89
|
{
|
90
|
return TC_HEXAHEDRON;
|
91
|
}
|
92
|
|
93
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
94
|
|
95
|
public int getTouchControlSplit()
|
96
|
{
|
97
|
return TYPE_SPLIT_CORNER;
|
98
|
}
|
99
|
|
100
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
101
|
|
102
|
public int[][][] getEnabled()
|
103
|
{
|
104
|
return new int[][][]
|
105
|
{
|
106
|
{{0,1},{3,1},{2,3},{0,2}},
|
107
|
{{2,3},{3,1},{0,1},{0,2}},
|
108
|
{{1,2},{0,1},{0,3},{2,3}},
|
109
|
{{1,2},{2,3},{0,3},{0,1}},
|
110
|
{{0,3},{0,2},{1,2},{1,3}},
|
111
|
{{1,2},{0,2},{0,3},{1,3}},
|
112
|
};
|
113
|
}
|
114
|
|
115
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
116
|
|
117
|
public float[] getDist3D(int[] numLayers)
|
118
|
{
|
119
|
return TouchControlHexahedron.D3D;
|
120
|
}
|
121
|
|
122
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
123
|
|
124
|
public Static3D[] getFaceAxis()
|
125
|
{
|
126
|
return TouchControlHexahedron.FACE_AXIS;
|
127
|
}
|
128
|
|
129
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
130
|
|
131
|
public float[][] getCubitPositions(int[] numLayers)
|
132
|
{
|
133
|
if( mCenters ==null )
|
134
|
{
|
135
|
mCenters = new float[][]
|
136
|
{
|
137
|
{ 0.0f, 1.5f, 1.5f },
|
138
|
{ 1.5f, 0.0f, 1.5f },
|
139
|
{ 0.0f,-1.5f, 1.5f },
|
140
|
{-1.5f, 0.0f, 1.5f },
|
141
|
{ 1.5f, 1.5f, 0.0f },
|
142
|
{ 1.5f,-1.5f, 0.0f },
|
143
|
{-1.5f,-1.5f, 0.0f },
|
144
|
{-1.5f, 1.5f, 0.0f },
|
145
|
{ 0.0f, 1.5f,-1.5f },
|
146
|
{ 1.5f, 0.0f,-1.5f },
|
147
|
{ 0.0f,-1.5f,-1.5f },
|
148
|
{-1.5f, 0.0f,-1.5f }
|
149
|
};
|
150
|
}
|
151
|
|
152
|
return mCenters;
|
153
|
}
|
154
|
|
155
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
156
|
|
157
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
158
|
{
|
159
|
if( mQuatIndex==null ) mQuatIndex = new int[] { 0,2,10,8,1,4,6,7,11,5,9,3 };
|
160
|
return mObjectQuats[mQuatIndex[cubit]];
|
161
|
}
|
162
|
|
163
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
164
|
|
165
|
public ObjectShape getObjectShape(int variant)
|
166
|
{
|
167
|
float[][] vertices= { {-1.5f, 0.0f, 0.0f},{ 1.5f, 0.0f, 0.0f},{ 0.0f,-1.5f, 0.0f},{ 0.0f, 0.0f,-1.5f} };
|
168
|
int[][] indices = { {2,1,0},{3,0,1},{2,3,1},{3,2,0} };
|
169
|
return new ObjectShape(vertices, indices);
|
170
|
}
|
171
|
|
172
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
173
|
|
174
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
175
|
{
|
176
|
float h1 = isInIconMode() ? 0.001f : 0.035f;
|
177
|
float h2 = isInIconMode() ? 0.001f : 0.010f;
|
178
|
float[][] bands = { {h1,30,0.16f,0.8f,6,2,2}, {h2,30,0.16f,0.2f,6,2,2} };
|
179
|
int[] bandIndices = { 0,0,1,1 };
|
180
|
float[][] corners = { {0.07f,0.40f}, {0.05f,0.30f} };
|
181
|
int[] cornerIndices = { 0,0,1,1 };
|
182
|
float[][] centers = { {0.0f, -0.75f, -0.75f} };
|
183
|
int[] centerIndices = { 0,0,0,0 };
|
184
|
return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices, null);
|
185
|
}
|
186
|
|
187
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
188
|
|
189
|
public int getNumCubitVariants(int[] numLayers)
|
190
|
{
|
191
|
return 1;
|
192
|
}
|
193
|
|
194
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
195
|
|
196
|
public int getCubitVariant(int cubit, int[] numLayers)
|
197
|
{
|
198
|
return 0;
|
199
|
}
|
200
|
|
201
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
202
|
|
203
|
public float getStickerRadius()
|
204
|
{
|
205
|
return 0.09f;
|
206
|
}
|
207
|
|
208
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
209
|
|
210
|
public float getStickerStroke()
|
211
|
{
|
212
|
return isInIconMode() ? 0.22f : 0.15f;
|
213
|
}
|
214
|
|
215
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
216
|
|
217
|
public float[][] getStickerAngles()
|
218
|
{
|
219
|
return null;
|
220
|
}
|
221
|
|
222
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
223
|
// PUBLIC API
|
224
|
|
225
|
public Static3D[] getRotationAxis()
|
226
|
{
|
227
|
return ROT_AXIS;
|
228
|
}
|
229
|
|
230
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
231
|
|
232
|
public int[][] getBasicAngles()
|
233
|
{
|
234
|
if( mBasicAngle==null )
|
235
|
{
|
236
|
int num = getNumLayers()[0];
|
237
|
int[] tmp = new int[num];
|
238
|
for(int i=0; i<num; i++) tmp[i] = 3;
|
239
|
mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
|
240
|
}
|
241
|
|
242
|
return mBasicAngle;
|
243
|
}
|
244
|
|
245
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
246
|
|
247
|
public int getComplexity()
|
248
|
{
|
249
|
return 0;
|
250
|
}
|
251
|
}
|