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