1 |
ece1b58d
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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.objects;
|
21 |
|
|
|
22 |
588ace55
|
Leszek Koltunski
|
import static org.distorted.objectlib.Movement.TYPE_NOT_SPLIT;
|
23 |
967c1d17
|
Leszek Koltunski
|
|
24 |
ece1b58d
|
Leszek Koltunski
|
import android.content.res.Resources;
|
25 |
|
|
|
26 |
588ace55
|
Leszek Koltunski
|
import org.distorted.objectlib.ObjectShape;
|
27 |
|
|
import org.distorted.objectlib.ObjectSticker;
|
28 |
|
|
import org.distorted.objectlib.ScrambleState;
|
29 |
ece1b58d
|
Leszek Koltunski
|
import org.distorted.library.main.DistortedEffects;
|
30 |
|
|
import org.distorted.library.main.DistortedTexture;
|
31 |
|
|
import org.distorted.library.mesh.MeshSquare;
|
32 |
|
|
import org.distorted.library.type.Static3D;
|
33 |
|
|
import org.distorted.library.type.Static4D;
|
34 |
6fd4a72c
|
Leszek Koltunski
|
import org.distorted.main.R;
|
35 |
588ace55
|
Leszek Koltunski
|
import org.distorted.objectlib.Movement;
|
36 |
|
|
import org.distorted.objectlib.Movement8;
|
37 |
|
|
import org.distorted.objectlib.ObjectList;
|
38 |
|
|
import org.distorted.objectlib.Twisty8;
|
39 |
ece1b58d
|
Leszek Koltunski
|
|
40 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
41 |
|
|
|
42 |
efa81f0c
|
Leszek Koltunski
|
public class TwistyDiamond extends Twisty8
|
43 |
ece1b58d
|
Leszek Koltunski
|
{
|
44 |
|
|
// the four rotation axis of a Diamond. Must be normalized.
|
45 |
|
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
46 |
|
|
{
|
47 |
|
|
new Static3D(+SQ6/3,+SQ3/3, 0),
|
48 |
|
|
new Static3D(-SQ6/3,+SQ3/3, 0),
|
49 |
cc99cf91
|
Leszek Koltunski
|
new Static3D( 0,-SQ3/3,-SQ6/3),
|
50 |
|
|
new Static3D( 0,-SQ3/3,+SQ6/3)
|
51 |
ece1b58d
|
Leszek Koltunski
|
};
|
52 |
|
|
|
53 |
967c1d17
|
Leszek Koltunski
|
private static final int[][][] ENABLED = new int[][][]
|
54 |
|
|
{
|
55 |
|
|
{{1,2,3}},{{1,2,3}},{{0,2,3}},{{0,2,3}},{{0,1,3}},{{0,1,3}},{{0,1,2}},{{0,1,2}}
|
56 |
|
|
};
|
57 |
|
|
|
58 |
91792184
|
Leszek Koltunski
|
private ScrambleState[] mStates;
|
59 |
aec5cc91
|
Leszek Koltunski
|
private int[] mBasicAngle;
|
60 |
|
|
private int[] mFaceMap;
|
61 |
ef018c1b
|
Leszek Koltunski
|
private float[][] mCuts;
|
62 |
|
|
private boolean[][] mLayerRotatable;
|
63 |
aec5cc91
|
Leszek Koltunski
|
private Static4D[] mQuats;
|
64 |
|
|
private int[] mTetraToFaceMap;
|
65 |
|
|
private ObjectSticker[] mStickers;
|
66 |
e9a87113
|
Leszek Koltunski
|
private Movement mMovement;
|
67 |
486b3417
|
Leszek Koltunski
|
|
68 |
ece1b58d
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
69 |
|
|
|
70 |
bdbbb4c5
|
Leszek Koltunski
|
public TwistyDiamond(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
|
71 |
|
|
DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
|
72 |
ece1b58d
|
Leszek Koltunski
|
{
|
73 |
db875721
|
Leszek Koltunski
|
super(size, size, quat, texture, mesh, effects, moves, ObjectList.DIAM, res, scrWidth);
|
74 |
91792184
|
Leszek Koltunski
|
}
|
75 |
486b3417
|
Leszek Koltunski
|
|
76 |
91792184
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
77 |
486b3417
|
Leszek Koltunski
|
|
78 |
bdbbb4c5
|
Leszek Koltunski
|
protected ScrambleState[] getScrambleStates()
|
79 |
91792184
|
Leszek Koltunski
|
{
|
80 |
|
|
if( mStates==null )
|
81 |
486b3417
|
Leszek Koltunski
|
{
|
82 |
91792184
|
Leszek Koltunski
|
int size = getNumLayers();
|
83 |
|
|
int[] tmp = new int[3*2*size];
|
84 |
|
|
|
85 |
|
|
for(int i=0; i<2*size; i++)
|
86 |
|
|
{
|
87 |
|
|
tmp[3*i ] = (i<size) ? i:i-size;
|
88 |
|
|
tmp[3*i+1] = (i%2==0) ? -1:1;
|
89 |
|
|
tmp[3*i+2] = 0;
|
90 |
|
|
}
|
91 |
|
|
|
92 |
|
|
mStates = new ScrambleState[]
|
93 |
|
|
{
|
94 |
|
|
new ScrambleState( new int[][] {tmp,tmp,tmp,tmp} )
|
95 |
|
|
};
|
96 |
486b3417
|
Leszek Koltunski
|
}
|
97 |
|
|
|
98 |
91792184
|
Leszek Koltunski
|
return mStates;
|
99 |
ece1b58d
|
Leszek Koltunski
|
}
|
100 |
|
|
|
101 |
aec5cc91
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
102 |
|
|
|
103 |
|
|
private void initializeQuats()
|
104 |
|
|
{
|
105 |
|
|
mQuats = new Static4D[]
|
106 |
|
|
{
|
107 |
|
|
new Static4D( 0.0f, 0.0f, 0.0f, 1.0f ),
|
108 |
|
|
new Static4D( 0.0f, 1.0f, 0.0f, 0.0f ),
|
109 |
|
|
new Static4D(+SQ2/2, 0.0f, -SQ2/2, 0.0f ),
|
110 |
|
|
new Static4D(-SQ2/2, 0.0f, -SQ2/2, 0.0f ),
|
111 |
|
|
|
112 |
|
|
new Static4D(+SQ2/2, 0.5f, 0.0f, 0.5f ),
|
113 |
|
|
new Static4D(-SQ2/2, 0.5f, 0.0f, 0.5f ),
|
114 |
|
|
new Static4D( 0.0f, 0.5f, +SQ2/2, 0.5f ),
|
115 |
|
|
new Static4D( 0.0f, 0.5f, -SQ2/2, 0.5f ),
|
116 |
|
|
new Static4D(+SQ2/2, 0.5f, 0.0f, -0.5f ),
|
117 |
|
|
new Static4D(-SQ2/2, 0.5f, 0.0f, -0.5f ),
|
118 |
|
|
new Static4D( 0.0f, 0.5f, +SQ2/2, -0.5f ),
|
119 |
|
|
new Static4D( 0.0f, 0.5f, -SQ2/2, -0.5f )
|
120 |
|
|
};
|
121 |
|
|
}
|
122 |
|
|
|
123 |
a480ee80
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
124 |
|
|
|
125 |
bdbbb4c5
|
Leszek Koltunski
|
protected int[] getSolvedQuats(int cubit, int numLayers)
|
126 |
a480ee80
|
Leszek Koltunski
|
{
|
127 |
aec5cc91
|
Leszek Koltunski
|
if( mQuats==null ) initializeQuats();
|
128 |
|
|
if( mFaceMap==null ) mFaceMap = new int[] {4,0,6,2,7,3,5,1};
|
129 |
a480ee80
|
Leszek Koltunski
|
int status = retCubitSolvedStatus(cubit,numLayers);
|
130 |
967c1d17
|
Leszek Koltunski
|
return status<0 ? null : buildSolvedQuats(Movement8.FACE_AXIS[mFaceMap[status]],mQuats);
|
131 |
a480ee80
|
Leszek Koltunski
|
}
|
132 |
|
|
|
133 |
ece1b58d
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
134 |
|
|
|
135 |
bdbbb4c5
|
Leszek Koltunski
|
protected Static4D[] getQuats()
|
136 |
ece1b58d
|
Leszek Koltunski
|
{
|
137 |
aec5cc91
|
Leszek Koltunski
|
if( mQuats==null ) initializeQuats();
|
138 |
|
|
return mQuats;
|
139 |
ece1b58d
|
Leszek Koltunski
|
}
|
140 |
|
|
|
141 |
169219a7
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
142 |
|
|
|
143 |
bdbbb4c5
|
Leszek Koltunski
|
protected int getSolvedFunctionIndex()
|
144 |
169219a7
|
Leszek Koltunski
|
{
|
145 |
|
|
return 0;
|
146 |
|
|
}
|
147 |
|
|
|
148 |
ece1b58d
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
149 |
|
|
|
150 |
bdbbb4c5
|
Leszek Koltunski
|
protected int getNumStickerTypes(int numLayers)
|
151 |
ece1b58d
|
Leszek Koltunski
|
{
|
152 |
aec5cc91
|
Leszek Koltunski
|
return 1;
|
153 |
ece1b58d
|
Leszek Koltunski
|
}
|
154 |
|
|
|
155 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
156 |
|
|
|
157 |
bdbbb4c5
|
Leszek Koltunski
|
protected float[][] getCuts(int numLayers)
|
158 |
ece1b58d
|
Leszek Koltunski
|
{
|
159 |
ef018c1b
|
Leszek Koltunski
|
if( numLayers<2 ) return null;
|
160 |
|
|
|
161 |
|
|
if( mCuts==null )
|
162 |
680f921e
|
Leszek Koltunski
|
{
|
163 |
ef018c1b
|
Leszek Koltunski
|
mCuts = new float[4][numLayers-1];
|
164 |
|
|
float cut = (SQ6/6)*(2-numLayers);
|
165 |
680f921e
|
Leszek Koltunski
|
|
166 |
|
|
for(int i=0; i<numLayers-1; i++)
|
167 |
|
|
{
|
168 |
ef018c1b
|
Leszek Koltunski
|
mCuts[0][i] = cut;
|
169 |
|
|
mCuts[1][i] = cut;
|
170 |
|
|
mCuts[2][i] = cut;
|
171 |
|
|
mCuts[3][i] = cut;
|
172 |
|
|
cut += SQ6/3;
|
173 |
680f921e
|
Leszek Koltunski
|
}
|
174 |
ef018c1b
|
Leszek Koltunski
|
}
|
175 |
|
|
|
176 |
|
|
return mCuts;
|
177 |
|
|
}
|
178 |
680f921e
|
Leszek Koltunski
|
|
179 |
ef018c1b
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
180 |
|
|
|
181 |
|
|
private void getLayerRotatable(int numLayers)
|
182 |
|
|
{
|
183 |
|
|
if( mLayerRotatable==null )
|
184 |
|
|
{
|
185 |
|
|
int numAxis = ROT_AXIS.length;
|
186 |
|
|
boolean[] tmp = new boolean[numLayers];
|
187 |
|
|
for(int i=0; i<numLayers; i++) tmp[i] = true;
|
188 |
|
|
mLayerRotatable = new boolean[numAxis][];
|
189 |
|
|
for(int i=0; i<numAxis; i++) mLayerRotatable[i] = tmp;
|
190 |
680f921e
|
Leszek Koltunski
|
}
|
191 |
ece1b58d
|
Leszek Koltunski
|
}
|
192 |
|
|
|
193 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
194 |
|
|
|
195 |
bdbbb4c5
|
Leszek Koltunski
|
protected int getNumCubitFaces()
|
196 |
ece1b58d
|
Leszek Koltunski
|
{
|
197 |
efa81f0c
|
Leszek Koltunski
|
return 8;
|
198 |
ece1b58d
|
Leszek Koltunski
|
}
|
199 |
|
|
|
200 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
201 |
|
|
|
202 |
680f921e
|
Leszek Koltunski
|
private int getNumOctahedrons(int layers)
|
203 |
|
|
{
|
204 |
|
|
return layers==1 ? 1 : 4*(layers-1)*(layers-1) + 2;
|
205 |
|
|
}
|
206 |
|
|
|
207 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
208 |
|
|
|
209 |
|
|
private int getNumTetrahedrons(int layers)
|
210 |
|
|
{
|
211 |
|
|
return 4*layers*(layers-1);
|
212 |
|
|
}
|
213 |
|
|
|
214 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
215 |
|
|
|
216 |
31cd7256
|
Leszek Koltunski
|
private int createOctaPositions(float[][] centers, int index, int layers, float height)
|
217 |
680f921e
|
Leszek Koltunski
|
{
|
218 |
5da517d3
|
Leszek Koltunski
|
float x = (layers-1)*0.5f;
|
219 |
|
|
float z = (layers+1)*0.5f;
|
220 |
680f921e
|
Leszek Koltunski
|
|
221 |
|
|
for(int i=0; i<layers; i++, index++)
|
222 |
|
|
{
|
223 |
5da517d3
|
Leszek Koltunski
|
z -= 1;
|
224 |
680f921e
|
Leszek Koltunski
|
centers[index][0] = x;
|
225 |
|
|
centers[index][1] = height;
|
226 |
|
|
centers[index][2] = z;
|
227 |
|
|
}
|
228 |
|
|
|
229 |
|
|
for(int i=0; i<layers-1; i++, index++)
|
230 |
|
|
{
|
231 |
5da517d3
|
Leszek Koltunski
|
x -= 1;
|
232 |
680f921e
|
Leszek Koltunski
|
centers[index][0] = x;
|
233 |
|
|
centers[index][1] = height;
|
234 |
|
|
centers[index][2] = z;
|
235 |
|
|
}
|
236 |
|
|
|
237 |
|
|
for(int i=0; i<layers-1; i++, index++)
|
238 |
|
|
{
|
239 |
5da517d3
|
Leszek Koltunski
|
z += 1;
|
240 |
680f921e
|
Leszek Koltunski
|
centers[index][0] = x;
|
241 |
|
|
centers[index][1] = height;
|
242 |
|
|
centers[index][2] = z;
|
243 |
|
|
}
|
244 |
|
|
|
245 |
|
|
for(int i=0; i<layers-2; i++, index++)
|
246 |
|
|
{
|
247 |
5da517d3
|
Leszek Koltunski
|
x += 1;
|
248 |
680f921e
|
Leszek Koltunski
|
centers[index][0] = x;
|
249 |
|
|
centers[index][1] = height;
|
250 |
|
|
centers[index][2] = z;
|
251 |
|
|
}
|
252 |
|
|
|
253 |
|
|
return index;
|
254 |
|
|
}
|
255 |
|
|
|
256 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
257 |
|
|
|
258 |
31cd7256
|
Leszek Koltunski
|
private int createTetraPositions(float[][] centers, int index, int layers, float height)
|
259 |
ece1b58d
|
Leszek Koltunski
|
{
|
260 |
5da517d3
|
Leszek Koltunski
|
float x = (layers-1)*0.5f;
|
261 |
|
|
float z = layers*0.5f;
|
262 |
680f921e
|
Leszek Koltunski
|
|
263 |
|
|
for(int i=0; i<layers-1; i++, index++)
|
264 |
|
|
{
|
265 |
5da517d3
|
Leszek Koltunski
|
z -= 1;
|
266 |
680f921e
|
Leszek Koltunski
|
centers[index][0] = x;
|
267 |
|
|
centers[index][1] = height;
|
268 |
|
|
centers[index][2] = z;
|
269 |
|
|
}
|
270 |
|
|
|
271 |
5da517d3
|
Leszek Koltunski
|
x += 0.5f;
|
272 |
|
|
z -= 0.5f;
|
273 |
680f921e
|
Leszek Koltunski
|
|
274 |
|
|
for(int i=0; i<layers-1; i++, index++)
|
275 |
|
|
{
|
276 |
5da517d3
|
Leszek Koltunski
|
x -= 1;
|
277 |
680f921e
|
Leszek Koltunski
|
centers[index][0] = x;
|
278 |
|
|
centers[index][1] = height;
|
279 |
|
|
centers[index][2] = z;
|
280 |
|
|
}
|
281 |
|
|
|
282 |
5da517d3
|
Leszek Koltunski
|
x -= 0.5f;
|
283 |
|
|
z -= 0.5f;
|
284 |
680f921e
|
Leszek Koltunski
|
|
285 |
|
|
for(int i=0; i<layers-1; i++, index++)
|
286 |
|
|
{
|
287 |
5da517d3
|
Leszek Koltunski
|
z += 1;
|
288 |
680f921e
|
Leszek Koltunski
|
centers[index][0] = x;
|
289 |
|
|
centers[index][1] = height;
|
290 |
|
|
centers[index][2] = z;
|
291 |
|
|
}
|
292 |
|
|
|
293 |
5da517d3
|
Leszek Koltunski
|
x -= 0.5f;
|
294 |
|
|
z += 0.5f;
|
295 |
680f921e
|
Leszek Koltunski
|
|
296 |
|
|
for(int i=0; i<layers-1; i++, index++)
|
297 |
|
|
{
|
298 |
5da517d3
|
Leszek Koltunski
|
x += 1;
|
299 |
680f921e
|
Leszek Koltunski
|
centers[index][0] = x;
|
300 |
|
|
centers[index][1] = height;
|
301 |
|
|
centers[index][2] = z;
|
302 |
|
|
}
|
303 |
|
|
|
304 |
|
|
return index;
|
305 |
|
|
}
|
306 |
|
|
|
307 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
308 |
|
|
|
309 |
bdbbb4c5
|
Leszek Koltunski
|
protected float[][] getCubitPositions(int layers)
|
310 |
680f921e
|
Leszek Koltunski
|
{
|
311 |
|
|
int numO = getNumOctahedrons(layers);
|
312 |
|
|
int numT = getNumTetrahedrons(layers);
|
313 |
|
|
int index = 0;
|
314 |
|
|
float height = 0.0f;
|
315 |
|
|
|
316 |
|
|
float[][] CENTERS = new float[numO+numT][3];
|
317 |
|
|
|
318 |
31cd7256
|
Leszek Koltunski
|
index = createOctaPositions(CENTERS,index,layers,height);
|
319 |
680f921e
|
Leszek Koltunski
|
|
320 |
|
|
for(int i=layers-1; i>0; i--)
|
321 |
|
|
{
|
322 |
5da517d3
|
Leszek Koltunski
|
height += SQ2/2;
|
323 |
31cd7256
|
Leszek Koltunski
|
index = createOctaPositions(CENTERS,index,i,+height);
|
324 |
|
|
index = createOctaPositions(CENTERS,index,i,-height);
|
325 |
680f921e
|
Leszek Koltunski
|
}
|
326 |
|
|
|
327 |
5da517d3
|
Leszek Koltunski
|
height = SQ2/4;
|
328 |
680f921e
|
Leszek Koltunski
|
|
329 |
|
|
for(int i=layers; i>1; i--)
|
330 |
|
|
{
|
331 |
31cd7256
|
Leszek Koltunski
|
index = createTetraPositions(CENTERS,index,i,+height);
|
332 |
|
|
index = createTetraPositions(CENTERS,index,i,-height);
|
333 |
5da517d3
|
Leszek Koltunski
|
height += SQ2/2;
|
334 |
680f921e
|
Leszek Koltunski
|
}
|
335 |
|
|
|
336 |
ece1b58d
|
Leszek Koltunski
|
return CENTERS;
|
337 |
|
|
}
|
338 |
|
|
|
339 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
340 |
|
|
|
341 |
680f921e
|
Leszek Koltunski
|
private int retFaceTetraBelongsTo(int tetra, int numLayers)
|
342 |
ece1b58d
|
Leszek Koltunski
|
{
|
343 |
aec5cc91
|
Leszek Koltunski
|
if( mTetraToFaceMap==null ) mTetraToFaceMap = new int[] {1,2,3,0,5,6,7,4};
|
344 |
|
|
|
345 |
68b5f9c5
|
Leszek Koltunski
|
for(int i=numLayers-1; i>0; i--)
|
346 |
ece1b58d
|
Leszek Koltunski
|
{
|
347 |
68b5f9c5
|
Leszek Koltunski
|
if( tetra < 8*i ) return mTetraToFaceMap[tetra/i];
|
348 |
|
|
tetra -= 8*i;
|
349 |
680f921e
|
Leszek Koltunski
|
}
|
350 |
68b5f9c5
|
Leszek Koltunski
|
|
351 |
|
|
return -1;
|
352 |
680f921e
|
Leszek Koltunski
|
}
|
353 |
|
|
|
354 |
f10a88a8
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
355 |
|
|
|
356 |
bdbbb4c5
|
Leszek Koltunski
|
protected ObjectShape getObjectShape(int cubit, int numLayers)
|
357 |
f10a88a8
|
Leszek Koltunski
|
{
|
358 |
|
|
int variant = getCubitVariant(cubit,numLayers);
|
359 |
f56b53cb
|
Leszek Koltunski
|
int N = numLayers>3 ? 5:6;
|
360 |
7d11f930
|
Leszek Koltunski
|
int E = numLayers>2 ? (numLayers>3 ? 0:1):2;
|
361 |
ece1b58d
|
Leszek Koltunski
|
|
362 |
f10a88a8
|
Leszek Koltunski
|
if( variant==0 )
|
363 |
ece1b58d
|
Leszek Koltunski
|
{
|
364 |
aec5cc91
|
Leszek Koltunski
|
double[][] vertices = new double[][]
|
365 |
|
|
{
|
366 |
|
|
{ 0.5, 0.0, 0.5},
|
367 |
|
|
{ 0.5, 0.0,-0.5},
|
368 |
|
|
{-0.5, 0.0,-0.5},
|
369 |
|
|
{-0.5, 0.0, 0.5},
|
370 |
|
|
{ 0.0, SQ2/2, 0.0},
|
371 |
|
|
{ 0.0,-SQ2/2, 0.0}
|
372 |
|
|
};
|
373 |
|
|
|
374 |
|
|
int[][] vert_indices = new int[][]
|
375 |
|
|
{
|
376 |
|
|
{3,0,4},
|
377 |
|
|
{0,1,4},
|
378 |
|
|
{1,2,4},
|
379 |
|
|
{2,3,4},
|
380 |
|
|
{5,0,3},
|
381 |
|
|
{5,1,0},
|
382 |
|
|
{5,2,1},
|
383 |
|
|
{5,3,2}
|
384 |
|
|
};
|
385 |
|
|
|
386 |
f10a88a8
|
Leszek Koltunski
|
float[][] bands = new float[][] { {0.05f,35,0.5f,0.8f,N,E,E} };
|
387 |
|
|
int[] bandIndices = new int[] { 0,0,0,0,0,0,0,0 };
|
388 |
|
|
float[][] corners = new float[][] { {0.04f,0.20f} };
|
389 |
|
|
int[] cornerIndices = new int[] { 0,0,0,0,0,0 };
|
390 |
|
|
float[][] centers = new float[][] { {0.0f, 0.0f, 0.0f} };
|
391 |
|
|
int[] centerIndices = new int[] { 0,0,0,0,0,0 };
|
392 |
aec5cc91
|
Leszek Koltunski
|
return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
393 |
ece1b58d
|
Leszek Koltunski
|
}
|
394 |
|
|
else
|
395 |
|
|
{
|
396 |
aec5cc91
|
Leszek Koltunski
|
double[][] vertices = new double[][] { {-0.5, SQ2/4, 0.0}, { 0.5, SQ2/4, 0.0}, { 0.0,-SQ2/4, 0.5}, { 0.0,-SQ2/4,-0.5} };
|
397 |
|
|
int[][] vert_indices = new int[][] { {2,1,0}, {2,3,1}, {3,2,0}, {3,0,1} };
|
398 |
f10a88a8
|
Leszek Koltunski
|
float[][] bands = new float[][] { {0.05f,35,0.5f,0.8f,N,E,E} };
|
399 |
|
|
int[] bandIndices = new int[] { 0,0,0,0 };
|
400 |
|
|
float[][] corners = new float[][] { {0.08f,0.15f} };
|
401 |
|
|
int[] cornerIndices = new int[] { 0,0,0,0 };
|
402 |
|
|
float[][] centers = new float[][] { {0.0f, 0.0f, 0.0f} };
|
403 |
|
|
int[] centerIndices = new int[] { 0,0,0,0 };
|
404 |
aec5cc91
|
Leszek Koltunski
|
return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
405 |
f10a88a8
|
Leszek Koltunski
|
}
|
406 |
|
|
}
|
407 |
|
|
|
408 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
409 |
|
|
|
410 |
bdbbb4c5
|
Leszek Koltunski
|
protected Static4D getQuat(int cubit, int numLayers)
|
411 |
f10a88a8
|
Leszek Koltunski
|
{
|
412 |
aec5cc91
|
Leszek Koltunski
|
if( mQuats==null ) initializeQuats();
|
413 |
3e605536
|
Leszek Koltunski
|
int numO = getNumOctahedrons(numLayers);
|
414 |
f10a88a8
|
Leszek Koltunski
|
|
415 |
aec5cc91
|
Leszek Koltunski
|
if( cubit<numO ) return mQuats[0];
|
416 |
f10a88a8
|
Leszek Koltunski
|
|
417 |
3e605536
|
Leszek Koltunski
|
switch( retFaceTetraBelongsTo(cubit-numO, numLayers) )
|
418 |
f10a88a8
|
Leszek Koltunski
|
{
|
419 |
aec5cc91
|
Leszek Koltunski
|
case 0: return mQuats[0]; // unit quat
|
420 |
3e605536
|
Leszek Koltunski
|
case 1: return new Static4D(0,-SQ2/2,0,SQ2/2); // 90 along Y
|
421 |
aec5cc91
|
Leszek Koltunski
|
case 2: return mQuats[1]; // 180 along Y
|
422 |
3e605536
|
Leszek Koltunski
|
case 3: return new Static4D(0,+SQ2/2,0,SQ2/2); // 90 along
|
423 |
|
|
case 4: return new Static4D(0, 0,1, 0); // 180 along Z
|
424 |
|
|
case 5: return new Static4D(SQ2/2, 0,SQ2/2,0); //
|
425 |
|
|
case 6: return new Static4D( 1,0,0, 0); // 180 along X
|
426 |
|
|
case 7: return new Static4D(-SQ2/2,0,SQ2/2,0); //
|
427 |
ece1b58d
|
Leszek Koltunski
|
}
|
428 |
|
|
|
429 |
3e605536
|
Leszek Koltunski
|
return null;
|
430 |
|
|
}
|
431 |
|
|
|
432 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
433 |
ece1b58d
|
Leszek Koltunski
|
|
434 |
bdbbb4c5
|
Leszek Koltunski
|
protected int getNumCubitVariants(int numLayers)
|
435 |
3e605536
|
Leszek Koltunski
|
{
|
436 |
|
|
return 2;
|
437 |
|
|
}
|
438 |
|
|
|
439 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
440 |
|
|
|
441 |
bdbbb4c5
|
Leszek Koltunski
|
protected int getCubitVariant(int cubit, int numLayers)
|
442 |
3e605536
|
Leszek Koltunski
|
{
|
443 |
|
|
return cubit<getNumOctahedrons(numLayers) ? 0 : 1;
|
444 |
ece1b58d
|
Leszek Koltunski
|
}
|
445 |
|
|
|
446 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
447 |
|
|
|
448 |
bdbbb4c5
|
Leszek Koltunski
|
protected int getFaceColor(int cubit, int cubitface, int size)
|
449 |
ece1b58d
|
Leszek Koltunski
|
{
|
450 |
2ef489e2
|
Leszek Koltunski
|
int numO = getNumOctahedrons(size);
|
451 |
680f921e
|
Leszek Koltunski
|
|
452 |
|
|
if( cubit<numO )
|
453 |
|
|
{
|
454 |
2ef489e2
|
Leszek Koltunski
|
int axis = 0;
|
455 |
|
|
int layer= 1;
|
456 |
|
|
|
457 |
|
|
switch(cubitface)
|
458 |
|
|
{
|
459 |
|
|
case 0: axis = 2; layer = 1; break;
|
460 |
|
|
case 1: axis = 0; layer = (1<<(size-1)); break;
|
461 |
|
|
case 2: axis = 3; layer = 1; break;
|
462 |
|
|
case 3: axis = 1; layer = (1<<(size-1)); break;
|
463 |
|
|
case 4: axis = 3; layer = (1<<(size-1)); break;
|
464 |
|
|
case 5: axis = 1; layer = 1; break;
|
465 |
|
|
case 6: axis = 2; layer = (1<<(size-1)); break;
|
466 |
|
|
case 7: axis = 0; layer = 1; break;
|
467 |
|
|
}
|
468 |
|
|
|
469 |
bdbbb4c5
|
Leszek Koltunski
|
return CUBITS[cubit].getRotRow(axis) == layer ? cubitface : NUM_TEXTURES;
|
470 |
680f921e
|
Leszek Koltunski
|
}
|
471 |
|
|
else
|
472 |
|
|
{
|
473 |
a4962b9c
|
Leszek Koltunski
|
return cubitface>0 ? NUM_TEXTURES : retFaceTetraBelongsTo(cubit-numO, size);
|
474 |
680f921e
|
Leszek Koltunski
|
}
|
475 |
ece1b58d
|
Leszek Koltunski
|
}
|
476 |
|
|
|
477 |
9c06394a
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
478 |
76c2bd07
|
Leszek Koltunski
|
|
479 |
bdbbb4c5
|
Leszek Koltunski
|
protected ObjectSticker retSticker(int face)
|
480 |
9c06394a
|
Leszek Koltunski
|
{
|
481 |
aec5cc91
|
Leszek Koltunski
|
if( mStickers==null )
|
482 |
|
|
{
|
483 |
|
|
float[][] STICKERS = new float[][] { { -0.4330127f, -0.25f, 0.4330127f, -0.25f, 0.0f, 0.5f } };
|
484 |
|
|
float radius = 0.06f;
|
485 |
|
|
float stroke = 0.07f;
|
486 |
|
|
float[] radii = new float[] {radius,radius,radius};
|
487 |
|
|
mStickers = new ObjectSticker[STICKERS.length];
|
488 |
|
|
mStickers[0] = new ObjectSticker(STICKERS[0],null,radii,stroke);
|
489 |
|
|
}
|
490 |
|
|
|
491 |
abf36986
|
Leszek Koltunski
|
return mStickers[face/NUM_FACE_COLORS];
|
492 |
ece1b58d
|
Leszek Koltunski
|
}
|
493 |
|
|
|
494 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
495 |
e1dc3366
|
Leszek Koltunski
|
// PUBLIC API
|
496 |
ece1b58d
|
Leszek Koltunski
|
|
497 |
e1dc3366
|
Leszek Koltunski
|
public Static3D[] getRotationAxis()
|
498 |
|
|
{
|
499 |
|
|
return ROT_AXIS;
|
500 |
|
|
}
|
501 |
|
|
|
502 |
e9a87113
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
503 |
|
|
|
504 |
|
|
public Movement getMovement()
|
505 |
|
|
{
|
506 |
ef018c1b
|
Leszek Koltunski
|
if( mMovement==null )
|
507 |
|
|
{
|
508 |
|
|
int numLayers = getNumLayers();
|
509 |
|
|
if( mCuts==null ) getCuts(numLayers);
|
510 |
|
|
getLayerRotatable(numLayers);
|
511 |
7ee89540
|
Leszek Koltunski
|
mMovement = new Movement8(ROT_AXIS,mCuts,mLayerRotatable,numLayers,TYPE_NOT_SPLIT,ENABLED);
|
512 |
ef018c1b
|
Leszek Koltunski
|
}
|
513 |
e9a87113
|
Leszek Koltunski
|
return mMovement;
|
514 |
|
|
}
|
515 |
|
|
|
516 |
e1dc3366
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
517 |
|
|
|
518 |
|
|
public int[] getBasicAngle()
|
519 |
|
|
{
|
520 |
aec5cc91
|
Leszek Koltunski
|
if( mBasicAngle ==null ) mBasicAngle = new int[] { 3,3,3,3 };
|
521 |
|
|
return mBasicAngle;
|
522 |
e1dc3366
|
Leszek Koltunski
|
}
|
523 |
|
|
|
524 |
6fd4a72c
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
525 |
|
|
|
526 |
|
|
public int getObjectName(int numLayers)
|
527 |
|
|
{
|
528 |
2ef489e2
|
Leszek Koltunski
|
switch(numLayers)
|
529 |
|
|
{
|
530 |
|
|
case 2: return R.string.diam2;
|
531 |
|
|
case 3: return R.string.diam3;
|
532 |
2adf1263
|
Leszek Koltunski
|
case 4: return R.string.diam4;
|
533 |
2ef489e2
|
Leszek Koltunski
|
}
|
534 |
|
|
|
535 |
|
|
return 0;
|
536 |
6fd4a72c
|
Leszek Koltunski
|
}
|
537 |
|
|
|
538 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
539 |
|
|
|
540 |
|
|
public int getInventor(int numLayers)
|
541 |
|
|
{
|
542 |
2ef489e2
|
Leszek Koltunski
|
switch(numLayers)
|
543 |
|
|
{
|
544 |
|
|
case 2: return R.string.diam2_inventor;
|
545 |
|
|
case 3: return R.string.diam3_inventor;
|
546 |
2adf1263
|
Leszek Koltunski
|
case 4: return R.string.diam4_inventor;
|
547 |
2ef489e2
|
Leszek Koltunski
|
}
|
548 |
|
|
|
549 |
|
|
return 0;
|
550 |
6fd4a72c
|
Leszek Koltunski
|
}
|
551 |
|
|
|
552 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
553 |
|
|
|
554 |
|
|
public int getComplexity(int numLayers)
|
555 |
|
|
{
|
556 |
2ef489e2
|
Leszek Koltunski
|
switch(numLayers)
|
557 |
|
|
{
|
558 |
2adf1263
|
Leszek Koltunski
|
case 2: return 4;
|
559 |
|
|
case 3: return 6;
|
560 |
|
|
case 4: return 8;
|
561 |
2ef489e2
|
Leszek Koltunski
|
}
|
562 |
|
|
|
563 |
|
|
return 0;
|
564 |
6fd4a72c
|
Leszek Koltunski
|
}
|
565 |
ece1b58d
|
Leszek Koltunski
|
}
|