Revision a57e6870
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objectlib/objects/TwistySkewb.java | ||
---|---|---|
72 | 72 |
|
73 | 73 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
74 | 74 |
|
75 |
public TwistySkewb(int size, Static4D quat, Static3D move, DistortedTexture texture,
|
|
75 |
public TwistySkewb(int[] numL, Static4D quat, Static3D move, DistortedTexture texture,
|
|
76 | 76 |
MeshSquare mesh, DistortedEffects effects, Resources res, int scrWidth) |
77 | 77 |
{ |
78 |
super(size, 2*size-2, quat, move, texture, mesh, effects, res, scrWidth);
|
|
78 |
super(numL, 2*numL[0]-2, quat, move, texture, mesh, effects, res, scrWidth);
|
|
79 | 79 |
} |
80 | 80 |
|
81 | 81 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
84 | 84 |
{ |
85 | 85 |
if( mStates==null ) |
86 | 86 |
{ |
87 |
int size = getNumLayers(); |
|
88 |
int[] tmp = {0,-1,0, 0,1,0, size-1,-1,0, size-1,1,0 }; |
|
87 |
int[] numLayers = getNumLayers(); |
|
88 |
int numL = numLayers[0]; |
|
89 |
|
|
90 |
int[] tmp = {0,-1,0, 0,1,0, numL-1,-1,0, numL-1,1,0 }; |
|
89 | 91 |
|
90 | 92 |
mStates = new ScrambleState[] |
91 | 93 |
{ |
... | ... | |
98 | 100 |
|
99 | 101 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
100 | 102 |
|
101 |
protected int getResource(int numLayers) |
|
103 |
protected int getResource(int[] numLayers)
|
|
102 | 104 |
{ |
103 |
switch(numLayers) |
|
105 |
switch(numLayers[0])
|
|
104 | 106 |
{ |
105 | 107 |
case 2: return R.raw.skew2; |
106 | 108 |
case 3: return R.raw.skew3; |
... | ... | |
133 | 135 |
|
134 | 136 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
135 | 137 |
|
136 |
protected int[] getSolvedQuats(int cubit, int numLayers) |
|
138 |
protected int[] getSolvedQuats(int cubit, int[] numLayers)
|
|
137 | 139 |
{ |
138 | 140 |
if( mQuats==null ) initializeQuats(); |
139 | 141 |
int status = retCubitSolvedStatus(cubit,numLayers); |
... | ... | |
149 | 151 |
|
150 | 152 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
151 | 153 |
|
152 |
private int getNumEdges(int layers)
|
|
154 |
private int getNumEdges(int numLayers)
|
|
153 | 155 |
{ |
154 |
return (layers-2)*12;
|
|
156 |
return (numLayers-2)*12;
|
|
155 | 157 |
} |
156 | 158 |
|
157 | 159 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
158 | 160 |
|
159 |
private int getNumCentersPerFace(int layers)
|
|
161 |
private int getNumCentersPerFace(int numLayers)
|
|
160 | 162 |
{ |
161 |
return ((layers-2)*(layers-2) + (layers-1)*(layers-1));
|
|
163 |
return ((numLayers-2)*(numLayers-2) + (numLayers-1)*(numLayers-1));
|
|
162 | 164 |
} |
163 | 165 |
|
164 | 166 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
178 | 180 |
|
179 | 181 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
180 | 182 |
|
181 |
protected int getNumStickerTypes(int numLayers) |
|
183 |
protected int getNumStickerTypes(int[] numLayers)
|
|
182 | 184 |
{ |
183 | 185 |
return 3; |
184 | 186 |
} |
185 | 187 |
|
186 | 188 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
187 | 189 |
|
188 |
protected float[][] getCuts(int numLayers) |
|
190 |
protected float[][] getCuts(int[] numLayers)
|
|
189 | 191 |
{ |
190 | 192 |
if( mCuts==null ) |
191 | 193 |
{ |
192 |
float[] c = numLayers==2 ? (new float[] {0.0f}) : (new float[] {-SQ3/6,+SQ3/6}); |
|
194 |
float[] c = numLayers[0]==2 ? (new float[] {0.0f}) : (new float[] {-SQ3/6,+SQ3/6});
|
|
193 | 195 |
mCuts = new float[][] {c,c,c,c}; |
194 | 196 |
} |
195 | 197 |
|
... | ... | |
198 | 200 |
|
199 | 201 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
200 | 202 |
|
201 |
private void getLayerRotatable(int numLayers) |
|
203 |
private void getLayerRotatable(int[] numLayers)
|
|
202 | 204 |
{ |
203 | 205 |
if( mLayerRotatable==null ) |
204 | 206 |
{ |
205 | 207 |
int numAxis = ROT_AXIS.length; |
206 |
boolean[] tmp = numLayers==2 ? (new boolean[] {true,true}) : (new boolean[] {true,false,true}); |
|
208 |
boolean[] tmp = numLayers[0]==2 ? (new boolean[] {true,true}) : (new boolean[] {true,false,true});
|
|
207 | 209 |
mLayerRotatable = new boolean[numAxis][]; |
208 | 210 |
for(int i=0; i<numAxis; i++) mLayerRotatable[i] = tmp; |
209 | 211 |
} |
... | ... | |
218 | 220 |
|
219 | 221 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
220 | 222 |
|
221 |
protected float[][] getCubitPositions(int numLayers) |
|
223 |
protected float[][] getCubitPositions(int[] numLayers)
|
|
222 | 224 |
{ |
223 |
final float DIST_CORNER = numLayers-1; |
|
224 |
final float DIST_EDGE = numLayers-1; |
|
225 |
final float DIST_CENTER = numLayers-1; |
|
225 |
int numL = numLayers[0]; |
|
226 |
final float DIST_CORNER = numL-1; |
|
227 |
final float DIST_EDGE = numL-1; |
|
228 |
final float DIST_CENTER = numL-1; |
|
226 | 229 |
|
227 | 230 |
final int numCorners = getNumCorners(); |
228 |
final int numEdges = getNumEdges(numLayers);
|
|
229 |
final int numCenters = 6*getNumCentersPerFace(numLayers);
|
|
231 |
final int numEdges = getNumEdges(numL); |
|
232 |
final int numCenters = 6*getNumCentersPerFace(numL); |
|
230 | 233 |
|
231 | 234 |
final float[][] CENTERS = new float[numCorners+numEdges+numCenters][]; |
232 | 235 |
|
... | ... | |
263 | 266 |
|
264 | 267 |
for (float[] edges : edgeTable) |
265 | 268 |
{ |
266 |
float c = 3-numLayers;
|
|
269 |
float c = 3-numL; |
|
267 | 270 |
|
268 |
for (int j=0; j<numLayers-2; j++, c+=2, index++)
|
|
271 |
for (int j=0; j<numL-2; j++, c+=2, index++) |
|
269 | 272 |
{ |
270 | 273 |
CENTERS[index] = new float[] { edges[0]==0 ? c : edges[0] , |
271 | 274 |
edges[1]==0 ? c : edges[1] , |
... | ... | |
292 | 295 |
|
293 | 296 |
for( float[] centers : centerTable ) |
294 | 297 |
{ |
295 |
x = 2-numLayers;
|
|
298 |
x = 2-numL; |
|
296 | 299 |
|
297 |
for(int i=0; i<numLayers-1; i++, x+=2)
|
|
300 |
for(int i=0; i<numL-1; i++, x+=2) |
|
298 | 301 |
{ |
299 |
y = 2-numLayers;
|
|
302 |
y = 2-numL; |
|
300 | 303 |
|
301 |
for(int j=0; j<numLayers-1; j++, y+=2, index++)
|
|
304 |
for(int j=0; j<numL-1; j++, y+=2, index++) |
|
302 | 305 |
{ |
303 | 306 |
if( centers[0]==Y ) cen0 = y; |
304 | 307 |
else if( centers[0]==X ) cen0 = x; |
... | ... | |
316 | 319 |
} |
317 | 320 |
} |
318 | 321 |
|
319 |
x = 3-numLayers;
|
|
322 |
x = 3-numL; |
|
320 | 323 |
|
321 |
for(int i=0; i<numLayers-2; i++, x+=2)
|
|
324 |
for(int i=0; i<numL-2; i++, x+=2) |
|
322 | 325 |
{ |
323 |
y = 3-numLayers;
|
|
326 |
y = 3-numL; |
|
324 | 327 |
|
325 |
for(int j=0; j<numLayers-2; j++, y+=2, index++)
|
|
328 |
for(int j=0; j<numL-2; j++, y+=2, index++) |
|
326 | 329 |
{ |
327 | 330 |
if( centers[0]==Y ) cen0 = y; |
328 | 331 |
else if( centers[0]==X ) cen0 = x; |
... | ... | |
346 | 349 |
|
347 | 350 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
348 | 351 |
|
349 |
protected Static4D getQuat(int cubit, int numLayers) |
|
352 |
protected Static4D getQuat(int cubit, int[] numLayers)
|
|
350 | 353 |
{ |
351 | 354 |
if( mQuats==null ) initializeQuats(); |
355 |
|
|
356 |
int numL = numLayers[0]; |
|
352 | 357 |
int numCorners = getNumCorners(); |
353 |
int numEdges = getNumEdges(numLayers);
|
|
358 |
int numEdges = getNumEdges(numL); |
|
354 | 359 |
|
355 | 360 |
if( cubit<numCorners ) |
356 | 361 |
{ |
... | ... | |
368 | 373 |
} |
369 | 374 |
else if( cubit<numCorners+numEdges ) |
370 | 375 |
{ |
371 |
int edge = (cubit-numCorners)/(numLayers-2);
|
|
376 |
int edge = (cubit-numCorners)/(numL-2); |
|
372 | 377 |
|
373 | 378 |
switch(edge) |
374 | 379 |
{ |
... | ... | |
388 | 393 |
} |
389 | 394 |
else |
390 | 395 |
{ |
391 |
int center = (cubit-numCorners-numEdges)/getNumCentersPerFace(numLayers);
|
|
396 |
int center = (cubit-numCorners-numEdges)/getNumCentersPerFace(numL); |
|
392 | 397 |
|
393 | 398 |
switch(center) |
394 | 399 |
{ |
... | ... | |
406 | 411 |
|
407 | 412 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
408 | 413 |
|
409 |
protected ObjectShape getObjectShape(int cubit, int numLayers) |
|
414 |
protected ObjectShape getObjectShape(int cubit, int[] numLayers)
|
|
410 | 415 |
{ |
416 |
int numL = numLayers[0]; |
|
411 | 417 |
int variant = getCubitVariant(cubit,numLayers); |
412 | 418 |
|
413 | 419 |
if( variant==0 ) |
414 | 420 |
{ |
415 | 421 |
double[][] vertices = new double[][] { {-1,0,0},{0,-1,0},{0,0,-1},{-1,-1,-1},{0,0,0} }; |
416 | 422 |
int[][] vert_indices = new int[][] { {0,1,4},{2,0,4},{1,2,4},{3,1,0},{3,2,1},{3,0,2} }; |
417 |
int N = numLayers==2 ? 7:5;
|
|
418 |
int E1= numLayers==2 ? 3:2;
|
|
419 |
int E2= numLayers==2 ? 5:3;
|
|
423 |
int N = numL==2 ? 7:5; |
|
424 |
int E1= numL==2 ? 3:2; |
|
425 |
int E2= numL==2 ? 5:3; |
|
420 | 426 |
float[][] bands = new float[][] { {0.020f,35,0.16f,0.7f,N,E1,E1}, {0.000f, 0,1.00f,0.0f,3,1,E2} }; |
421 | 427 |
int[] bandIndices = new int[] { 0,0,0,1,1,1 }; |
422 | 428 |
float[][] corners = new float[][] { {0.05f,0.25f}, {0.05f,0.20f} }; |
... | ... | |
429 | 435 |
{ |
430 | 436 |
double[][] vertices = new double[][] { {-1,0,0},{1,0,0},{0,-1,0},{0,0,-1} }; |
431 | 437 |
int[][] vert_indices = new int[][] { {2,1,0},{3,0,1},{2,3,1},{3,2,0} }; |
432 |
int N = numLayers==2 ? 7:5;
|
|
433 |
int E = numLayers==2 ? 5:2;
|
|
438 |
int N = numL==2 ? 7:5; |
|
439 |
int E = numL==2 ? 5:2; |
|
434 | 440 |
float[][] bands = new float[][] { {0.035f,30,0.16f,0.8f,N,2,E}, {0.020f,45,0.16f,0.2f,3,1,2} }; |
435 | 441 |
int[] bandIndices = new int[] { 0,0,1,1 }; |
436 | 442 |
float[][] corners = new float[][] { {0.07f,0.20f}, {0.02f,0.30f} }; |
... | ... | |
443 | 449 |
{ |
444 | 450 |
double[][] vertices = new double[][] { {-1,0,0},{0,-1,0},{1,0,0},{0,1,0},{0,0,-1} }; |
445 | 451 |
int[][] vert_indices = new int[][] { {0,1,2,3},{4,1,0},{4,2,1},{4,3,2},{4,0,3} }; |
446 |
int N = numLayers==2 ? 7:6;
|
|
447 |
int E = numLayers==2 ? 3:1;
|
|
452 |
int N = numL==2 ? 7:6; |
|
453 |
int E = numL==2 ? 3:1; |
|
448 | 454 |
float[][] bands = new float[][] { {0.04f,35,SQ2/8,0.9f,N,E,E}, {0.000f,0,1,0.0f,3,0,0} }; |
449 | 455 |
int[] bandIndices = new int[] { 0,1,1,1,1 }; |
450 | 456 |
float[][] corners = new float[][] { {0.06f,0.15f} }; |
... | ... | |
457 | 463 |
|
458 | 464 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
459 | 465 |
|
460 |
protected int getNumCubitVariants(int numLayers) |
|
466 |
protected int getNumCubitVariants(int[] numLayers)
|
|
461 | 467 |
{ |
462 | 468 |
return 3; |
463 | 469 |
} |
464 | 470 |
|
465 | 471 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
466 | 472 |
|
467 |
protected int getCubitVariant(int cubit, int numLayers) |
|
473 |
protected int getCubitVariant(int cubit, int[] numLayers)
|
|
468 | 474 |
{ |
469 | 475 |
int numCorners = getNumCorners(); |
470 | 476 |
if( cubit<numCorners ) return 0; |
471 |
int numEdges = getNumEdges(numLayers); |
|
477 |
int numEdges = getNumEdges(numLayers[0]);
|
|
472 | 478 |
return cubit<numCorners+numEdges ? 1:2; |
473 | 479 |
} |
474 | 480 |
|
475 | 481 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
476 | 482 |
|
477 |
protected int getFaceColor(int cubit, int cubitface, int numLayers) |
|
483 |
protected int getFaceColor(int cubit, int cubitface, int[] numLayers)
|
|
478 | 484 |
{ |
479 | 485 |
if( mCornerMap==null || mEdgeMap==null || mCenterMap==null ) |
480 | 486 |
{ |
... | ... | |
517 | 523 |
}; |
518 | 524 |
} |
519 | 525 |
|
526 |
int numL = numLayers[0]; |
|
520 | 527 |
int numCorners = getNumCorners(); |
521 |
int numEdges = getNumEdges(numLayers);
|
|
528 |
int numEdges = getNumEdges(numL); |
|
522 | 529 |
|
523 | 530 |
if( cubit<numCorners ) |
524 | 531 |
{ |
... | ... | |
526 | 533 |
} |
527 | 534 |
else if( cubit<numCorners+numEdges ) |
528 | 535 |
{ |
529 |
int edge = (cubit-numCorners)/(numLayers-2);
|
|
536 |
int edge = (cubit-numCorners)/(numL-2); |
|
530 | 537 |
return mEdgeMap[edge][cubitface]; |
531 | 538 |
} |
532 | 539 |
else |
533 | 540 |
{ |
534 |
int center = (cubit-numCorners-numEdges)/getNumCentersPerFace(numLayers);
|
|
541 |
int center = (cubit-numCorners-numEdges)/getNumCentersPerFace(numL); |
|
535 | 542 |
return mCenterMap[center][cubitface]; |
536 | 543 |
} |
537 | 544 |
} |
... | ... | |
556 | 563 |
|
557 | 564 |
if( ObjectControl.isInIconMode() ) |
558 | 565 |
{ |
559 |
float mult = getNumLayers()==2 ? 2.0f : 2.7f; |
|
566 |
int[] numLayers = getNumLayers(); |
|
567 |
float mult = numLayers[0]==2 ? 2.0f : 2.7f; |
|
560 | 568 |
strokes[0]*=mult; |
561 | 569 |
strokes[1]*=mult; |
562 | 570 |
strokes[2]*=mult; |
... | ... | |
588 | 596 |
{ |
589 | 597 |
if( mMovement==null ) |
590 | 598 |
{ |
591 |
int numLayers = getNumLayers(); |
|
599 |
int[] numLayers = getNumLayers();
|
|
592 | 600 |
if( mCuts==null ) getCuts(numLayers); |
593 | 601 |
getLayerRotatable(numLayers); |
594 |
mMovement = new Movement6(ROT_AXIS,mCuts,mLayerRotatable,2*numLayers-2,TYPE_SPLIT_CORNER,ENABLED); |
|
602 |
mMovement = new Movement6(ROT_AXIS,mCuts,mLayerRotatable,2*numLayers[0]-2,TYPE_SPLIT_CORNER,ENABLED);
|
|
595 | 603 |
} |
596 | 604 |
return mMovement; |
597 | 605 |
} |
... | ... | |
606 | 614 |
|
607 | 615 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
608 | 616 |
|
609 |
public ObjectType intGetObjectType(int numLayers) |
|
617 |
public ObjectType intGetObjectType(int[] numLayers)
|
|
610 | 618 |
{ |
611 |
switch(numLayers) |
|
619 |
switch(numLayers[0])
|
|
612 | 620 |
{ |
613 | 621 |
case 2: return ObjectType.SKEW_2; |
614 | 622 |
case 3: return ObjectType.SKEW_3; |
... | ... | |
619 | 627 |
|
620 | 628 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
621 | 629 |
|
622 |
public int getObjectName(int numLayers) |
|
630 |
public int getObjectName(int[] numLayers)
|
|
623 | 631 |
{ |
624 |
switch(numLayers) |
|
632 |
switch(numLayers[0])
|
|
625 | 633 |
{ |
626 | 634 |
case 2: return R.string.skew2; |
627 | 635 |
case 3: return R.string.skew3; |
... | ... | |
631 | 639 |
|
632 | 640 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
633 | 641 |
|
634 |
public int getInventor(int numLayers) |
|
642 |
public int getInventor(int[] numLayers)
|
|
635 | 643 |
{ |
636 |
switch(numLayers) |
|
644 |
switch(numLayers[0])
|
|
637 | 645 |
{ |
638 | 646 |
case 2: return R.string.skew2_inventor; |
639 | 647 |
case 3: return R.string.skew3_inventor; |
... | ... | |
643 | 651 |
|
644 | 652 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
645 | 653 |
|
646 |
public int getComplexity(int numLayers) |
|
654 |
public int getComplexity(int[] numLayers)
|
|
647 | 655 |
{ |
648 |
switch(numLayers) |
|
656 |
switch(numLayers[0])
|
|
649 | 657 |
{ |
650 | 658 |
case 2: return 4; |
651 | 659 |
case 3: return 8; |
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!