Revision 8655f3fe
Added by Leszek Koltunski over 3 years ago
src/main/java/org/distorted/objects/TwistySkewb.java | ||
---|---|---|
22 | 22 |
import android.content.res.Resources; |
23 | 23 |
|
24 | 24 |
import org.distorted.helpers.FactoryCubit; |
25 |
import org.distorted.helpers.ObjectShape; |
|
25 | 26 |
import org.distorted.helpers.ObjectSticker; |
26 | 27 |
import org.distorted.library.effect.MatrixEffectQuaternion; |
27 | 28 |
import org.distorted.library.main.DistortedEffects; |
... | ... | |
465 | 466 |
|
466 | 467 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
467 | 468 |
|
468 |
MeshBase createCubitMesh(int cubit, int numLayers)
|
|
469 |
ObjectShape getObjectShape(int cubit, int numLayers)
|
|
469 | 470 |
{ |
470 |
if( mMeshes==null ) |
|
471 |
{ |
|
472 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
473 |
factory.clear(); |
|
474 |
mMeshes = new MeshBase[3]; |
|
475 |
} |
|
476 |
|
|
477 |
MeshBase mesh; |
|
471 |
int variant = getCubitVariant(cubit,numLayers); |
|
478 | 472 |
|
479 |
int numCorners = getNumCorners(); |
|
480 |
int numEdges = getNumEdges(numLayers); |
|
481 |
|
|
482 |
if( cubit<numCorners ) |
|
473 |
if( variant==0 ) |
|
483 | 474 |
{ |
484 |
if( mMeshes[0]==null ) |
|
485 |
{ |
|
486 |
float[][] bands= new float[][] |
|
475 |
int N = numLayers==2 ? 7:5; |
|
476 |
int E1= numLayers==2 ? 3:2; |
|
477 |
int E2= numLayers==2 ? 5:3; |
|
478 |
float[][] bands= new float[][] |
|
487 | 479 |
{ |
488 |
{0.028f,35,0.16f,0.7f,7,3,3},
|
|
489 |
{0.000f, 0,1.00f,0.0f,3,1,5}
|
|
480 |
{0.028f,35,0.16f,0.7f,N,E1,E1},
|
|
481 |
{0.000f, 0,1.00f,0.0f,3, 1,E2}
|
|
490 | 482 |
}; |
491 |
int[] bandIndexes = new int[] { 0,0,0,1,1,1 }; |
|
492 |
float[][] corners = new float[][] { {0.08f,0.15f}, {0.08f,0.20f} }; |
|
493 |
int[] cornerIndexes = new int[] { 1,1,1,0,0 }; |
|
494 |
float[][] centers = new float[][] { {-0.25f, -0.25f, -0.25f} }; |
|
495 |
int[] centerIndexes = new int[] { 0,0,0,-1,0 }; |
|
496 |
|
|
497 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
498 |
factory.createNewFaceTransform(VERTICES_CORNER,VERT_INDEXES_CORNER); |
|
499 |
mMeshes[0] = factory.createRoundedSolid(VERTICES_CORNER, VERT_INDEXES_CORNER, |
|
500 |
bands, bandIndexes, |
|
501 |
corners, cornerIndexes, |
|
502 |
centers, centerIndexes, |
|
503 |
getNumCubitFaces(), null ); |
|
504 |
} |
|
505 |
mesh = mMeshes[0].copy(true); |
|
483 |
int[] bandIndices = new int[] { 0,0,0,1,1,1 }; |
|
484 |
float[][] corners = new float[][] { {0.08f,0.15f}, {0.08f,0.20f} }; |
|
485 |
int[] cornerIndices = new int[] { 1,1,1,0,0 }; |
|
486 |
float[][] centers = new float[][] { {-0.25f, -0.25f, -0.25f} }; |
|
487 |
int[] centerIndices = new int[] { 0,0,0,-1,0 }; |
|
488 |
|
|
489 |
return new ObjectShape(VERTICES_CORNER,VERT_INDEXES_CORNER,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null); |
|
506 | 490 |
} |
507 |
else if( cubit<numCorners+numEdges )
|
|
491 |
else if( variant==1 )
|
|
508 | 492 |
{ |
509 |
if( mMeshes[1]==null )
|
|
510 |
{
|
|
511 |
float[][] bands= new float[][]
|
|
493 |
int N = numLayers==2 ? 7:5;
|
|
494 |
int E = numLayers==2 ? 5:2;
|
|
495 |
float[][] bands= new float[][] |
|
512 | 496 |
{ |
513 |
{0.035f,30,0.16f,0.8f,7,2,5},
|
|
497 |
{0.035f,30,0.16f,0.8f,N,2,E},
|
|
514 | 498 |
{0.020f,45,0.16f,0.2f,3,1,2} |
515 | 499 |
}; |
516 |
int[] bandIndexes = new int[] { 0,0,1,1 }; |
|
517 |
float[][] corners = new float[][] { {0.07f,0.20f}, {0.02f,0.30f} }; |
|
518 |
int[] cornerIndexes = new int[] { 0,0,1,1 }; |
|
519 |
float[][] centers = new float[][] { {0.0f, -0.25f, -0.25f} }; |
|
520 |
int[] centerIndexes = new int[] { 0,0,0,0 }; |
|
521 |
|
|
522 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
523 |
factory.createNewFaceTransform(VERTICES_EDGE,VERT_INDEXES_EDGE); |
|
524 |
mMeshes[1] = factory.createRoundedSolid(VERTICES_EDGE, VERT_INDEXES_EDGE, |
|
525 |
bands, bandIndexes, |
|
526 |
corners, cornerIndexes, |
|
527 |
centers, centerIndexes, |
|
528 |
getNumCubitFaces(), null ); |
|
529 |
} |
|
530 |
mesh = mMeshes[1].copy(true); |
|
500 |
int[] bandIndices = new int[] { 0,0,1,1 }; |
|
501 |
float[][] corners = new float[][] { {0.07f,0.20f}, {0.02f,0.30f} }; |
|
502 |
int[] cornerIndices = new int[] { 0,0,1,1 }; |
|
503 |
float[][] centers = new float[][] { {0.0f, -0.25f, -0.25f} }; |
|
504 |
int[] centerIndices = new int[] { 0,0,0,0 }; |
|
505 |
|
|
506 |
return new ObjectShape(VERTICES_EDGE,VERT_INDEXES_EDGE,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null); |
|
531 | 507 |
} |
532 | 508 |
else |
533 | 509 |
{ |
534 |
if( mMeshes[2]==null )
|
|
535 |
{
|
|
536 |
float[][] bands= new float[][]
|
|
510 |
int N = numLayers==2 ? 7:6;
|
|
511 |
int E = numLayers==2 ? 3:1;
|
|
512 |
float[][] bands= new float[][] |
|
537 | 513 |
{ |
538 |
{0.051f,35,SQ2/8,0.9f, 7,3,3},
|
|
514 |
{0.051f,35,SQ2/8,0.9f, N,E,E},
|
|
539 | 515 |
{0.000f, 0, 1,0.0f, 3,0,0} |
540 | 516 |
}; |
541 |
int[] bandIndexes = new int[] { 0,1,1,1,1 }; |
|
542 |
float[][] corners = new float[][] { {0.06f,0.10f} }; |
|
543 |
int[] cornerIndexes = new int[] { 0,0,0,0,0 }; |
|
544 |
float[][] centers = new float[][] { {0,0,-0.2f} }; |
|
545 |
int[] centerIndexes = new int[] { 0,0,0,0,-1 }; |
|
546 |
|
|
547 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
548 |
factory.createNewFaceTransform(VERTICES_FACE,VERT_INDEXES_FACE); |
|
549 |
mMeshes[2] = factory.createRoundedSolid(VERTICES_FACE, VERT_INDEXES_FACE, |
|
550 |
bands, bandIndexes, |
|
551 |
corners, cornerIndexes, |
|
552 |
centers, centerIndexes, |
|
553 |
getNumCubitFaces(), null ); |
|
554 |
} |
|
555 |
mesh = mMeshes[2].copy(true); |
|
517 |
int[] bandIndices = new int[] { 0,1,1,1,1 }; |
|
518 |
float[][] corners = new float[][] { {0.06f,0.10f} }; |
|
519 |
int[] cornerIndices = new int[] { 0,0,0,0,0 }; |
|
520 |
float[][] centers = new float[][] { {0,0,-0.2f} }; |
|
521 |
int[] centerIndices = new int[] { 0,0,0,0,-1 }; |
|
522 |
|
|
523 |
return new ObjectShape(VERTICES_FACE,VERT_INDEXES_FACE,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null); |
|
524 |
} |
|
525 |
} |
|
526 |
|
|
527 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
528 |
|
|
529 |
private int getNumCubitVariants(int numLayers) |
|
530 |
{ |
|
531 |
return 3; |
|
532 |
} |
|
533 |
|
|
534 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
535 |
|
|
536 |
int getCubitVariant(int cubit, int numLayers) |
|
537 |
{ |
|
538 |
int numCorners = getNumCorners(); |
|
539 |
if( cubit<numCorners ) return 0; |
|
540 |
int numEdges = getNumEdges(numLayers); |
|
541 |
return cubit<numCorners+numEdges ? 1:2; |
|
542 |
} |
|
543 |
|
|
544 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
545 |
|
|
546 |
MeshBase createCubitMesh(int cubit, int numLayers) |
|
547 |
{ |
|
548 |
int variant = getCubitVariant(cubit,numLayers); |
|
549 |
|
|
550 |
if( mMeshes==null ) |
|
551 |
{ |
|
552 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
553 |
factory.clear(); |
|
554 |
mMeshes = new MeshBase[getNumCubitVariants(numLayers)]; |
|
555 |
} |
|
556 |
|
|
557 |
if( mMeshes[variant]==null ) |
|
558 |
{ |
|
559 |
ObjectShape shape = getObjectShape(cubit,numLayers); |
|
560 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
561 |
factory.createNewFaceTransform(shape); |
|
562 |
mMeshes[variant] = factory.createRoundedSolid(shape); |
|
556 | 563 |
} |
557 | 564 |
|
565 |
MeshBase mesh = mMeshes[variant].copy(true); |
|
558 | 566 |
MatrixEffectQuaternion quat = new MatrixEffectQuaternion( getQuat(cubit,numLayers), new Static3D(0,0,0) ); |
559 | 567 |
mesh.apply(quat,0xffffffff,0); |
560 | 568 |
|
Also available in: Unified diff
Convert Skewb to the new scheme. New smaller mesh for the Master Skewb.