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