Revision f8031218
Added by Leszek Koltunski over 3 years ago
src/main/java/org/distorted/objects/TwistyKilominx.java | ||
---|---|---|
37 | 37 |
|
38 | 38 |
public class TwistyKilominx extends TwistyMinx |
39 | 39 |
{ |
40 |
private static MeshBase[] mCenterMeshes, mCornerMeshes; |
|
41 |
private static MeshBase[][] mEdgeMeshes; |
|
40 |
private static MeshBase[][] mMeshes; |
|
42 | 41 |
|
43 | 42 |
private static final int[] mCenterFaceMap = new int[] |
44 | 43 |
{ |
... | ... | |
65 | 64 |
{ -0.3249197f, -0.39442718f, 0.3249197f, -0.39442718f, 0.3249197f, 0.5f, -0.3249197f, 0.2888544f } |
66 | 65 |
}; |
67 | 66 |
|
68 |
private static final int mNumCornerEdgeVariants; |
|
69 |
|
|
70 | 67 |
static |
71 | 68 |
{ |
72 | 69 |
final float C = 1.14f; // make the 'center' sticker artificially larger, so that we paint |
73 | 70 |
// over the area in the center of the face. |
74 | 71 |
|
75 |
int[] sizes = ObjectList.KILO.getSizes(); |
|
76 |
int variants = sizes.length; |
|
77 |
mNumCornerEdgeVariants = sizes[0]==3 ? variants-1 : variants; |
|
78 |
|
|
79 | 72 |
STICKERS[0][0] *= C; |
80 | 73 |
STICKERS[0][1] *= C; |
81 | 74 |
STICKERS[0][2] *= C; |
... | ... | |
377 | 370 |
double H = width*(SIN54/COS54); |
378 | 371 |
double H3= H/COS_HALFD; |
379 | 372 |
double X3= H*SIN_HALFD; |
380 |
double Z3= H*COS_HALFD;;
|
|
373 |
double Z3= H*COS_HALFD; |
|
381 | 374 |
double C = 1/(COS54*Math.sqrt(2-2*SIN18)); |
382 | 375 |
|
383 | 376 |
double[][] vertices = new double[][] |
... | ... | |
512 | 505 |
int indexCornerEdge = (numLayers-lowestSize)/2 - (lowestSize==3 ? 1:0); |
513 | 506 |
MeshBase mesh; |
514 | 507 |
|
515 |
if( mNumCornerEdgeVariants>0 ) |
|
516 |
{ |
|
517 |
if( mCornerMeshes==null ) mCornerMeshes = new MeshBase[mNumCornerEdgeVariants]; |
|
518 |
if( mEdgeMeshes ==null ) mEdgeMeshes = new MeshBase[mNumCornerEdgeVariants][highestSize-3]; |
|
519 |
} |
|
520 |
|
|
521 |
if( mCenterMeshes==null ) mCenterMeshes = new MeshBase[variants]; |
|
508 |
if( mMeshes==null ) mMeshes = new MeshBase[variants][highestSize-1]; |
|
522 | 509 |
|
523 | 510 |
if( cubit < NUM_CORNERS*numCubitsPerCorner ) |
524 | 511 |
{ |
525 |
if( mCornerMeshes[indexCornerEdge]==null )
|
|
512 |
if( mMeshes[indexCornerEdge][0]==null )
|
|
526 | 513 |
{ |
527 | 514 |
float width = (numLayers/3.0f)/(numLayers-1); |
528 |
mCornerMeshes[indexCornerEdge] = createCornerMesh(numLayers,width);
|
|
515 |
mMeshes[indexCornerEdge][0] = createCornerMesh(numLayers,width);
|
|
529 | 516 |
} |
530 |
mesh = mCornerMeshes[indexCornerEdge].copy(true);
|
|
517 |
mesh = mMeshes[indexCornerEdge][0].copy(true);
|
|
531 | 518 |
} |
532 | 519 |
else if( cubit<NUM_CORNERS*numCubitsPerCorner + NUM_EDGES*numCubitsPerEdge ) |
533 | 520 |
{ |
534 | 521 |
int type = computeEdgeType(cubit,numCubitsPerCorner,numCubitsPerEdge); // left-top, right-top, left-second, right-second, left-third... |
535 | 522 |
|
536 |
if( mEdgeMeshes[indexCornerEdge][type]==null )
|
|
523 |
if( mMeshes[indexCornerEdge][1+type]==null )
|
|
537 | 524 |
{ |
538 | 525 |
float tmp = (numLayers/3.0f)/(numLayers-1); |
539 | 526 |
float height= tmp*COS18; |
540 | 527 |
float width = tmp + (type/2)*tmp*SIN18; |
541 | 528 |
|
542 |
mEdgeMeshes[indexCornerEdge][type] = createEdgeMesh(numLayers,width,height, (type%2)==0 );
|
|
529 |
mMeshes[indexCornerEdge][1+type] = createEdgeMesh(numLayers,width,height, (type%2)==0 );
|
|
543 | 530 |
} |
544 | 531 |
|
545 |
mesh = mEdgeMeshes[indexCornerEdge][type].copy(true);
|
|
532 |
mesh = mMeshes[indexCornerEdge][1+type].copy(true);
|
|
546 | 533 |
} |
547 | 534 |
else |
548 | 535 |
{ |
549 | 536 |
int indexCenter = (numLayers-3)/2; |
550 | 537 |
|
551 |
if( mCenterMeshes[indexCenter]==null )
|
|
538 |
if( mMeshes[indexCenter][highestSize-2]==null )
|
|
552 | 539 |
{ |
553 | 540 |
float width = (1+0.5f*(numLayers-3)*SIN18)*(numLayers/3.0f)/(numLayers-1); |
554 |
mCenterMeshes[indexCenter] = createCenterMesh(width);
|
|
541 |
mMeshes[indexCenter][highestSize-2] = createCenterMesh(width);
|
|
555 | 542 |
} |
556 | 543 |
|
557 |
mesh = mCenterMeshes[indexCenter].copy(true);
|
|
544 |
mesh = mMeshes[indexCenter][highestSize-2].copy(true);
|
|
558 | 545 |
} |
559 | 546 |
|
560 | 547 |
Static4D q = QUATS[getQuat(cubit,numCubitsPerCorner,numCubitsPerEdge)]; |
Also available in: Unified diff
Make the Kilominx cubit creation a bit more standard.