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