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