Revision a57e6870
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objectlib/objects/TwistyPyraminx.java | ||
---|---|---|
66 | 66 |
|
67 | 67 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
68 | 68 |
|
69 |
public TwistyPyraminx(int size, Static4D quat, Static3D move, DistortedTexture texture,
|
|
69 |
public TwistyPyraminx(int[] numL, Static4D quat, Static3D move, DistortedTexture texture,
|
|
70 | 70 |
MeshSquare mesh, DistortedEffects effects, Resources res, int scrWidth) |
71 | 71 |
{ |
72 |
super(size, size, quat, move, texture, mesh, effects, res, scrWidth);
|
|
72 |
super(numL, numL[0], quat, move, texture, mesh, effects, res, scrWidth);
|
|
73 | 73 |
} |
74 | 74 |
|
75 | 75 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
78 | 78 |
{ |
79 | 79 |
if( mStates==null ) |
80 | 80 |
{ |
81 |
int numLayers = getNumLayers(); |
|
82 |
initializeScrambleStates(numLayers); |
|
81 |
int[] numLayers = getNumLayers();
|
|
82 |
initializeScrambleStates(numLayers[0]);
|
|
83 | 83 |
} |
84 | 84 |
|
85 | 85 |
return mStates; |
... | ... | |
87 | 87 |
|
88 | 88 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
89 | 89 |
|
90 |
protected int getResource(int numLayers) |
|
90 |
protected int getResource(int[] numLayers)
|
|
91 | 91 |
{ |
92 |
switch(numLayers) |
|
92 |
switch(numLayers[0])
|
|
93 | 93 |
{ |
94 | 94 |
case 3: return R.raw.pyra3; |
95 | 95 |
case 4: return R.raw.pyra4; |
... | ... | |
158 | 158 |
|
159 | 159 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
160 | 160 |
|
161 |
protected int[] getSolvedQuats(int cubit, int numLayers) |
|
161 |
protected int[] getSolvedQuats(int cubit, int[] numLayers)
|
|
162 | 162 |
{ |
163 | 163 |
if( mQuats==null ) initializeQuats(); |
164 | 164 |
int status = retCubitSolvedStatus(cubit,numLayers); |
... | ... | |
205 | 205 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
206 | 206 |
// there are (n^3-n)/6 octahedrons and ((n+1)^3 - (n+1))/6 tetrahedrons |
207 | 207 |
|
208 |
protected float[][] getCubitPositions(int size)
|
|
208 |
protected float[][] getCubitPositions(int[] numLayers)
|
|
209 | 209 |
{ |
210 |
int numOcta = (size-1)*size*(size+1)/6; |
|
211 |
int numTetra= size*(size+1)*(size+2)/6; |
|
210 |
int numL = numLayers[0]; |
|
211 |
int numOcta = (numL-1)*numL*(numL+1)/6; |
|
212 |
int numTetra= numL*(numL+1)*(numL+2)/6; |
|
212 | 213 |
float[][] ret = new float[numOcta+numTetra][]; |
213 | 214 |
|
214 |
addTetrahedralLattice(size-1, 0,ret);
|
|
215 |
addTetrahedralLattice(size ,numOcta,ret);
|
|
215 |
addTetrahedralLattice(numL-1, 0,ret);
|
|
216 |
addTetrahedralLattice(numL ,numOcta,ret);
|
|
216 | 217 |
|
217 | 218 |
return ret; |
218 | 219 |
} |
... | ... | |
234 | 235 |
|
235 | 236 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
236 | 237 |
|
237 |
protected int getNumStickerTypes(int numLayers) |
|
238 |
protected int getNumStickerTypes(int[] numLayers)
|
|
238 | 239 |
{ |
239 | 240 |
return 1; |
240 | 241 |
} |
241 | 242 |
|
242 | 243 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
243 | 244 |
|
244 |
protected float[][] getCuts(int numLayers) |
|
245 |
protected float[][] getCuts(int[] numLayers)
|
|
245 | 246 |
{ |
246 | 247 |
if( mCuts==null ) |
247 | 248 |
{ |
248 |
mCuts = new float[4][numLayers-1]; |
|
249 |
int numL = numLayers[0]; |
|
250 |
mCuts = new float[4][numL-1]; |
|
249 | 251 |
|
250 |
for(int i=0; i<numLayers-1; i++)
|
|
252 |
for(int i=0; i<numL-1; i++) |
|
251 | 253 |
{ |
252 |
float cut = (1.0f+i-numLayers/4.0f)*(SQ6/3);
|
|
254 |
float cut = (1.0f+i-numL/4.0f)*(SQ6/3); |
|
253 | 255 |
mCuts[0][i] = cut; |
254 | 256 |
mCuts[1][i] = cut; |
255 | 257 |
mCuts[2][i] = cut; |
... | ... | |
262 | 264 |
|
263 | 265 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
264 | 266 |
|
265 |
private void getLayerRotatable(int numLayers) |
|
267 |
private void getLayerRotatable(int[] numLayers)
|
|
266 | 268 |
{ |
267 | 269 |
if( mLayerRotatable==null ) |
268 | 270 |
{ |
269 | 271 |
int numAxis = ROT_AXIS.length; |
270 |
boolean[] tmp = new boolean[numLayers]; |
|
271 |
for(int i=0; i<numLayers; i++) tmp[i] = true; |
|
272 | 272 |
mLayerRotatable = new boolean[numAxis][]; |
273 |
for(int i=0; i<numAxis; i++) mLayerRotatable[i] = tmp; |
|
273 |
|
|
274 |
for(int i=0; i<numAxis; i++) |
|
275 |
{ |
|
276 |
mLayerRotatable[i] = new boolean[numLayers[i]]; |
|
277 |
for(int j=0; j<numLayers[i]; j++) mLayerRotatable[i][j] = true; |
|
278 |
} |
|
274 | 279 |
} |
275 | 280 |
} |
276 | 281 |
|
... | ... | |
297 | 302 |
|
298 | 303 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
299 | 304 |
|
300 |
protected int getFaceColor(int cubit, int cubitface, int size)
|
|
305 |
protected int getFaceColor(int cubit, int cubitface, int[] numLayers)
|
|
301 | 306 |
{ |
302 |
if( cubit< (size-1)*size*(size+1)/6 ) |
|
307 |
int numL = numLayers[0]; |
|
308 |
|
|
309 |
if( cubit< (numL-1)*numL*(numL+1)/6 ) |
|
303 | 310 |
{ |
304 | 311 |
switch( cubitface ) |
305 | 312 |
{ |
... | ... | |
318 | 325 |
|
319 | 326 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
320 | 327 |
|
321 |
protected ObjectShape getObjectShape(int cubit, int numLayers) |
|
328 |
protected ObjectShape getObjectShape(int cubit, int[] numLayers)
|
|
322 | 329 |
{ |
330 |
int numL = numLayers[0]; |
|
323 | 331 |
int variant = getCubitVariant(cubit,numLayers); |
324 | 332 |
|
325 | 333 |
if( variant==0 ) |
326 | 334 |
{ |
327 | 335 |
double[][] vertices = new double[][] { { 0.5,0.0,0.5},{ 0.5,0.0,-0.5},{-0.5,0.0,-0.5},{-0.5,0.0,0.5},{ 0.0,SQ2/2,0.0},{ 0.0,-SQ2/2,0.0} }; |
328 | 336 |
int[][] vert_indices = new int[][] { {3,0,4},{0,1,4},{1,2,4},{2,3,4},{5,0,3},{5,1,0},{5,2,1},{5,3,2} }; |
329 |
int N = numLayers==3? 6 : 5;
|
|
330 |
int E = numLayers==3? 2 : 1;
|
|
337 |
int N = numL==3? 6 : 5; |
|
338 |
int E = numL==3? 2 : 1; |
|
331 | 339 |
float[][] bands = new float[][] { {0.05f,35,0.5f,0.8f,N,E,E} }; |
332 | 340 |
int[] bandIndices = new int[] { 0,0,0,0,0,0,0,0 }; |
333 | 341 |
float[][] corners = new float[][] { {0.04f,0.20f} }; |
... | ... | |
340 | 348 |
{ |
341 | 349 |
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} }; |
342 | 350 |
int[][] vert_indices = new int[][] { {2,1,0},{3,0,1},{3,2,0},{2,3,1} }; |
343 |
int N = numLayers==3? 6 : 5;
|
|
344 |
int E = numLayers==3? 2 : 1;
|
|
351 |
int N = numL==3? 6 : 5; |
|
352 |
int E = numL==3? 2 : 1; |
|
345 | 353 |
float[][] bands = new float[][] { {0.05f,35,0.5f,0.8f,N,E,E} }; |
346 | 354 |
int[] bandIndices = new int[] { 0,0,0,0 }; |
347 | 355 |
float[][] corners = new float[][] { {0.06f,0.15f} }; |
... | ... | |
354 | 362 |
|
355 | 363 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
356 | 364 |
|
357 |
protected Static4D getQuat(int cubit, int numLayers) |
|
365 |
protected Static4D getQuat(int cubit, int[] numLayers)
|
|
358 | 366 |
{ |
359 | 367 |
if( mQuats==null ) initializeQuats(); |
360 | 368 |
return mQuats[0]; |
... | ... | |
362 | 370 |
|
363 | 371 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
364 | 372 |
|
365 |
protected int getNumCubitVariants(int numLayers) |
|
373 |
protected int getNumCubitVariants(int[] numLayers)
|
|
366 | 374 |
{ |
367 | 375 |
return 2; |
368 | 376 |
} |
369 | 377 |
|
370 | 378 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
371 | 379 |
|
372 |
protected int getCubitVariant(int cubit, int numLayers) |
|
380 |
protected int getCubitVariant(int cubit, int[] numLayers)
|
|
373 | 381 |
{ |
374 |
return cubit<getNumOctahedrons(numLayers) ? 0:1; |
|
382 |
return cubit<getNumOctahedrons(numLayers[0]) ? 0:1;
|
|
375 | 383 |
} |
376 | 384 |
|
377 | 385 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
389 | 397 |
|
390 | 398 |
if( ObjectControl.isInIconMode() ) |
391 | 399 |
{ |
392 |
switch(getNumLayers()) |
|
400 |
int[] numLayers = getNumLayers(); |
|
401 |
|
|
402 |
switch(numLayers[0]) |
|
393 | 403 |
{ |
394 | 404 |
case 2: stroke*=1.0f; break; |
395 | 405 |
case 3: stroke*=1.4f; break; |
... | ... | |
418 | 428 |
{ |
419 | 429 |
if( mMovement==null ) |
420 | 430 |
{ |
421 |
int numLayers = getNumLayers(); |
|
431 |
int[] numLayers = getNumLayers();
|
|
422 | 432 |
if( mCuts==null ) getCuts(numLayers); |
423 | 433 |
getLayerRotatable(numLayers); |
424 |
mMovement = new Movement4(ROT_AXIS,mCuts,mLayerRotatable,numLayers,TYPE_NOT_SPLIT,ENABLED); |
|
434 |
mMovement = new Movement4(ROT_AXIS,mCuts,mLayerRotatable,numLayers[0],TYPE_NOT_SPLIT,ENABLED);
|
|
425 | 435 |
} |
426 | 436 |
return mMovement; |
427 | 437 |
} |
... | ... | |
436 | 446 |
|
437 | 447 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
438 | 448 |
|
439 |
public ObjectType intGetObjectType(int numLayers) |
|
449 |
public ObjectType intGetObjectType(int[] numLayers)
|
|
440 | 450 |
{ |
441 |
switch(numLayers) |
|
451 |
switch(numLayers[0])
|
|
442 | 452 |
{ |
443 | 453 |
case 3: return ObjectType.PYRA_3; |
444 | 454 |
case 4: return ObjectType.PYRA_4; |
... | ... | |
450 | 460 |
|
451 | 461 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
452 | 462 |
|
453 |
public int getObjectName(int numLayers) |
|
463 |
public int getObjectName(int[] numLayers)
|
|
454 | 464 |
{ |
455 |
switch(numLayers) |
|
465 |
switch(numLayers[0])
|
|
456 | 466 |
{ |
457 | 467 |
case 3: return R.string.pyra3; |
458 | 468 |
case 4: return R.string.pyra4; |
... | ... | |
463 | 473 |
|
464 | 474 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
465 | 475 |
|
466 |
public int getInventor(int numLayers) |
|
476 |
public int getInventor(int[] numLayers)
|
|
467 | 477 |
{ |
468 |
switch(numLayers) |
|
478 |
switch(numLayers[0])
|
|
469 | 479 |
{ |
470 | 480 |
case 3: return R.string.pyra3_inventor; |
471 | 481 |
case 4: return R.string.pyra4_inventor; |
... | ... | |
476 | 486 |
|
477 | 487 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
478 | 488 |
|
479 |
public int getComplexity(int numLayers) |
|
489 |
public int getComplexity(int[] numLayers)
|
|
480 | 490 |
{ |
481 |
switch(numLayers) |
|
491 |
switch(numLayers[0])
|
|
482 | 492 |
{ |
483 | 493 |
case 3: return 4; |
484 | 494 |
case 4: return 6; |
Also available in: Unified diff
make numLayers into an int[] (preparation for Cuboids)
Caution: because of previous changes to cubit order in cube, the Solver is broken!