Revision da36b97e
Added by Leszek Koltunski almost 5 years ago
| src/main/java/org/distorted/objects/FactoryCubit.java | ||
|---|---|---|
| 38 | 38 |
static final float IVY_D = 0.003f; |
| 39 | 39 |
static final float IVY_C = 0.59f; |
| 40 | 40 |
static final float IVY_M = 0.35f; |
| 41 |
static final float REX_D = 0.003f;
|
|
| 41 |
static final float REX_D = 0.2f;
|
|
| 42 | 42 |
|
| 43 | 43 |
private static final float SQ2 = (float)Math.sqrt(2); |
| 44 | 44 |
private static final float SQ3 = (float)Math.sqrt(3); |
| 45 | 45 |
private static final float SQ6 = (float)Math.sqrt(6); |
| 46 | 46 |
|
| 47 | 47 |
private static final int IVY_N = 8; |
| 48 |
private static final int REX_N = 5; |
|
| 49 | 48 |
private static final Static1D RADIUS = new Static1D(1); |
| 50 | 49 |
private static FactoryCubit mThis; |
| 51 | 50 |
|
| ... | ... | |
| 606 | 605 |
{
|
| 607 | 606 |
MeshBase[] meshes = new MeshBase[2]; |
| 608 | 607 |
|
| 609 |
final float angle = (float)Math.PI/(6*REX_N); |
|
| 610 |
float[] vertices = new float[6*REX_N]; |
|
| 611 |
final float D = 0.5f - REX_D; |
|
| 612 |
final float F = D*SQ2*(SQ3-1); |
|
| 613 |
final float B = 2.5f; |
|
| 614 |
|
|
| 615 |
final float V1x = -F*0.5f; |
|
| 616 |
final float V1y = -F*SQ3/6; |
|
| 617 |
final float V2x = -V1x; |
|
| 618 |
final float V2y = V1y; |
|
| 619 |
final float V3x = 0.0f; |
|
| 620 |
final float V3y = -2*V1y; |
|
| 621 |
|
|
| 622 |
final float C1x = 0.0f; |
|
| 623 |
final float C1y = -F*(1+2*SQ3/3); |
|
| 624 |
final float C2x = B*V1x; |
|
| 625 |
final float C2y = B*V1y; |
|
| 626 |
final float C3x = B*V2x; |
|
| 627 |
final float C3y = B*V2y; |
|
| 628 |
|
|
| 629 |
for(int i=0; i<REX_N; i++) |
|
| 630 |
{
|
|
| 631 |
writeVertex(C1x,C1y,V1x,V1y,-i*angle, vertices, 2*i ); |
|
| 632 |
writeVertex(C2x,C2y,V2x,V2y, i*angle, vertices, 2*i + 2*REX_N); |
|
| 633 |
writeVertex(C3x,C3y,V3x,V3y, i*angle, vertices, 2*i + 4*REX_N); |
|
| 634 |
} |
|
| 608 |
float F = REX_D*SQ2; |
|
| 609 |
float G = (1-REX_D)*SQ2/2; |
|
| 610 |
float H = 0.1f; |
|
| 611 |
float J = +2*G/3 - H*G; |
|
| 612 |
|
|
| 613 |
float[] vertices = { -F/2, -G/3, +F/2, -G/3, H*F/2, J, -H*F/2, J};
|
|
| 635 | 614 |
|
| 636 |
float[] bands0 = computeBands(+0.02f,10,0.5f,0.5f,5);
|
|
| 637 |
float[] bands1 = computeBands(-0.05f,45,0.5f,0.0f,2);
|
|
| 615 |
float[] bands0 = computeBands(+0.016f,10,G/3,0.5f,5);
|
|
| 616 |
float[] bands1 = computeBands(-0.230f,45,G/3,0.0f,2);
|
|
| 638 | 617 |
|
| 639 | 618 |
meshes[0] = new MeshPolygon(vertices,bands0,1,1); |
| 640 | 619 |
meshes[0].setEffectAssociation(0,1,0); |
| ... | ... | |
| 650 | 629 |
{
|
| 651 | 630 |
MeshBase[] meshes = new MeshBase[2]; |
| 652 | 631 |
|
| 653 |
final float angle = (float)Math.PI/(6*REX_N); |
|
| 654 |
float[] vertices = new float[8*REX_N]; |
|
| 655 |
final float D = 0.5f - REX_D; |
|
| 656 |
final float F = D*(SQ3-1); |
|
| 657 |
|
|
| 658 |
final float V1x = 0.0f; |
|
| 659 |
final float V1y = +F; |
|
| 660 |
final float V2x = -F; |
|
| 661 |
final float V2y = 0.0f; |
|
| 662 |
final float V3x = 0.0f; |
|
| 663 |
final float V3y = -F; |
|
| 664 |
final float V4x = +F; |
|
| 665 |
final float V4y = 0.0f; |
|
| 666 |
|
|
| 667 |
final float C1x = +D; |
|
| 668 |
final float C1y = -D; |
|
| 669 |
final float C2x = +D; |
|
| 670 |
final float C2y = +D; |
|
| 671 |
final float C3x = -D; |
|
| 672 |
final float C3y = +D; |
|
| 673 |
final float C4x = -D; |
|
| 674 |
final float C4y = -D; |
|
| 675 |
|
|
| 676 |
for(int i=0; i<REX_N; i++) |
|
| 677 |
{
|
|
| 678 |
writeVertex(C1x,C1y,V1x,V1y, i*angle, vertices, 2*i ); |
|
| 679 |
writeVertex(C2x,C2y,V2x,V2y, i*angle, vertices, 2*i + 2*REX_N); |
|
| 680 |
writeVertex(C3x,C3y,V3x,V3y, i*angle, vertices, 2*i + 4*REX_N); |
|
| 681 |
writeVertex(C4x,C4y,V4x,V4y, i*angle, vertices, 2*i + 6*REX_N); |
|
| 682 |
} |
|
| 632 |
float[] vertices = { -REX_D,0.0f, 0.0f, -REX_D, +REX_D, 0.0f, 0.0f, +REX_D};
|
|
| 683 | 633 |
|
| 684 |
float[] bands0 = computeBands(+0.02f,10,0.5f,0.5f,5);
|
|
| 685 |
float[] bands1 = computeBands(-0.00f,45,0.5f,0.0f,2);
|
|
| 634 |
float[] bands0 = computeBands(0.016f,10,REX_D/2,0.5f,5);
|
|
| 635 |
float[] bands1 = computeBands(0.000f,45,REX_D/2,0.0f,2);
|
|
| 686 | 636 |
|
| 687 | 637 |
meshes[0] = new MeshPolygon(vertices,bands0,0,0); |
| 688 | 638 |
meshes[0].setEffectAssociation(0,1,0); |
| ... | ... | |
| 696 | 646 |
|
| 697 | 647 |
MeshBase createFacesRexEdge() |
| 698 | 648 |
{
|
| 699 |
MeshBase[] meshes = new MeshBase[4]; |
|
| 700 |
|
|
| 701 |
final float angle = (float)Math.PI/(6*REX_N); |
|
| 702 |
float[] vertices = new float[4*REX_N + 6]; |
|
| 703 |
final float H = 1.0f - SQ3/2; |
|
| 704 |
final float D = 0.5f - REX_D; |
|
| 705 |
final float F = 0.5f*(0.5f - D*(SQ3-1)); |
|
| 706 |
|
|
| 707 |
final float V1x = -D; |
|
| 708 |
final float V1y = +D + F - 0.5f; |
|
| 709 |
final float V2x = 0.0f; |
|
| 710 |
final float V2y = -F; |
|
| 711 |
|
|
| 712 |
final float C1x = -D; |
|
| 713 |
final float C1y = -D + F - 0.5f; |
|
| 714 |
final float C2x = +D; |
|
| 715 |
final float C2y = C1y; |
|
| 716 |
|
|
| 717 |
for(int i=0; i<REX_N; i++) |
|
| 718 |
{
|
|
| 719 |
writeVertex(C1x,C1y,V1x,V1y,-i*angle, vertices, 2*i ); |
|
| 720 |
writeVertex(C2x,C2y,V2x,V2y,-i*angle, vertices, 2*i + 2*REX_N); |
|
| 721 |
} |
|
| 722 |
|
|
| 723 |
vertices[4*REX_N ] = +D; |
|
| 724 |
vertices[4*REX_N+1] = +F-REX_D; |
|
| 725 |
vertices[4*REX_N+2] = +D; |
|
| 726 |
vertices[4*REX_N+3] = +F; |
|
| 727 |
vertices[4*REX_N+4] = -D; |
|
| 728 |
vertices[4*REX_N+5] = +F; |
|
| 649 |
MeshBase[] meshes = new MeshPolygon[6]; |
|
| 729 | 650 |
|
| 730 |
float[] bands0 = computeBands(+0.02f, 9,0.5f,0.5f,5); |
|
| 731 |
float[] bands1 = computeBands( 0.00f,45,0.5f,0.0f,2); |
|
| 651 |
float E = 0.5f - REX_D; |
|
| 652 |
float F = 0.5f; |
|
| 653 |
float[] vertices0 = { -F,E/3, 0,-2*E/3, +F,E/3 };
|
|
| 654 |
float[] bands0 = computeBands(0.03f,27,F/3,0.8f,5); |
|
| 732 | 655 |
|
| 733 |
meshes[0] = new MeshPolygon(vertices,bands0,1,2);
|
|
| 656 |
meshes[0] = new MeshPolygon(vertices0, bands0, 2, 3);
|
|
| 734 | 657 |
meshes[0].setEffectAssociation(0,1,0); |
| 735 | 658 |
meshes[1] = meshes[0].copy(true); |
| 736 | 659 |
meshes[1].setEffectAssociation(0,2,0); |
| 737 |
meshes[2] = new MeshPolygon(vertices,bands1,0,0); |
|
| 660 |
|
|
| 661 |
float G = (float)Math.sqrt(E*E+F*F); |
|
| 662 |
float[] vertices1 = { -2*G/3, -E/3, G/3, -E/3, G/3, 2*E/3 };
|
|
| 663 |
float[] bands1 = computeBands(0.00f,45,G/3,0.2f,3); |
|
| 664 |
|
|
| 665 |
meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2); |
|
| 738 | 666 |
meshes[2].setEffectAssociation(0,4,0); |
| 739 | 667 |
meshes[3] = meshes[2].copy(true); |
| 740 | 668 |
meshes[3].setEffectAssociation(0,8,0); |
| 669 |
meshes[4] = meshes[2].copy(true); |
|
| 670 |
meshes[4].setEffectAssociation(0,16,0); |
|
| 671 |
meshes[5] = meshes[2].copy(true); |
|
| 672 |
meshes[5].setEffectAssociation(0,32,0); |
|
| 741 | 673 |
|
| 742 | 674 |
return new MeshJoined(meshes); |
| 743 | 675 |
} |
| ... | ... | |
| 949 | 881 |
effect[0].setMeshAssociation(15,-1); // apply to meshes 0,1,2,3 |
| 950 | 882 |
effect[1].setMeshAssociation( 3,-1); // apply to meshes 0,1 |
| 951 | 883 |
effect[2].setMeshAssociation( 2,-1); // apply to mesh 1 |
| 952 |
effect[3].setMeshAssociation( 2,-1); // apply to mesh 0
|
|
| 884 |
effect[3].setMeshAssociation( 2,-1); // apply to mesh 1
|
|
| 953 | 885 |
effect[4].setMeshAssociation(12,-1); // apply to meshes 2,3 |
| 954 | 886 |
effect[5].setMeshAssociation(12,-1); // apply to meshes 2,3 |
| 955 | 887 |
effect[6].setMeshAssociation( 8,-1); // apply to mesh 3 |
| ... | ... | |
| 1173 | 1105 |
|
| 1174 | 1106 |
VertexEffect[] createVertexEffectsRexEdge() |
| 1175 | 1107 |
{
|
| 1176 |
final float D = 0.5f - REX_D; |
|
| 1177 |
final float F = 0.5f*(0.5f - D*(SQ3-1)); |
|
| 1108 |
float E = 0.5f - REX_D; |
|
| 1109 |
float F = 0.5f; |
|
| 1110 |
float G = (float)Math.sqrt(E*E+F*F); |
|
| 1111 |
float A = (float)((180/Math.PI)*Math.asin(E/G)); |
|
| 1178 | 1112 |
|
| 1179 |
Static3D move = new Static3D(0.0f, -F, 0.0f); |
|
| 1180 |
Static3D center= new Static3D(0.0f, 0.0f, 0.0f); |
|
| 1181 |
Static3D axisX = new Static3D(1.0f, 0.0f, 0.0f); |
|
| 1182 |
Static3D axisY = new Static3D(0.0f, 1.0f, 0.0f); |
|
| 1113 |
Static3D move1 = new Static3D( 0.0f, -E/3, 0.0f); |
|
| 1114 |
Static3D move2 = new Static3D(2*G/3 -F, +E/3, 0.0f); |
|
| 1115 |
|
|
| 1116 |
Static3D center0= new Static3D(0.0f, 0.0f, 0.0f); |
|
| 1117 |
Static3D center1= new Static3D( -F, 0.0f, 0.0f); |
|
| 1118 |
Static3D center2= new Static3D( +F, 0.0f, 0.0f); |
|
| 1119 |
Static3D axisX = new Static3D(1.0f, 0.0f, 0.0f); |
|
| 1120 |
Static3D axisY = new Static3D(0.0f, 1.0f, 0.0f); |
|
| 1121 |
Static3D axisZ = new Static3D(0.0f, 0.0f, 1.0f); |
|
| 1183 | 1122 |
|
| 1184 | 1123 |
Static1D angle180 = new Static1D(180); |
| 1185 | 1124 |
Static1D angle90 = new Static1D( 90); |
| 1125 |
Static1D angle270 = new Static1D(270); |
|
| 1126 |
Static1D angle1 = new Static1D(+A); |
|
| 1127 |
Static1D angle2 = new Static1D(-A); |
|
| 1186 | 1128 |
|
| 1187 |
VertexEffect[] effect = new VertexEffect[3]; |
|
| 1188 |
|
|
| 1189 |
effect[0] = new VertexEffectMove(move); |
|
| 1190 |
effect[1] = new VertexEffectRotate(angle180, axisY, center); |
|
| 1191 |
effect[2] = new VertexEffectRotate(angle90 , axisX, center); |
|
| 1129 |
VertexEffect[] effect = new VertexEffect[12]; |
|
| 1192 | 1130 |
|
| 1193 |
effect[1].setMeshAssociation(10,-1); // meshes 1 & 3 |
|
| 1194 |
effect[2].setMeshAssociation(10,-1); // meshes 1 & 3 |
|
| 1131 |
effect[0] = new VertexEffectMove(move1); |
|
| 1132 |
effect[1] = new VertexEffectMove(move2); |
|
| 1133 |
effect[2] = new VertexEffectRotate( angle90, axisX, center0 ); |
|
| 1134 |
effect[3] = new VertexEffectRotate( angle270, axisX, center0 ); |
|
| 1135 |
effect[4] = new VertexEffectRotate( angle180, axisX, center0 ); |
|
| 1136 |
effect[5] = new VertexEffectRotate( angle180, axisY, center0 ); |
|
| 1137 |
effect[6] = new VertexEffectScale ( new Static3D(-1, 1, 1) ); |
|
| 1138 |
effect[7] = new VertexEffectScale ( new Static3D( 1,-1, 1) ); |
|
| 1139 |
effect[8] = new VertexEffectRotate( angle1, axisY, center1); |
|
| 1140 |
effect[9] = new VertexEffectRotate( angle2, axisY, center2); |
|
| 1141 |
effect[10]= new VertexEffectRotate( angle2, axisZ, center1); |
|
| 1142 |
effect[11]= new VertexEffectRotate( angle1, axisZ, center2); |
|
| 1143 |
|
|
| 1144 |
effect[0].setMeshAssociation( 3,-1); // meshes 0 & 1 |
|
| 1145 |
effect[1].setMeshAssociation(60,-1); // meshes 2,3,4,5 |
|
| 1146 |
effect[2].setMeshAssociation( 2,-1); // meshes 1 |
|
| 1147 |
effect[3].setMeshAssociation(12,-1); // meshes 2,3 |
|
| 1148 |
effect[4].setMeshAssociation(48,-1); // meshes 4,5 |
|
| 1149 |
effect[5].setMeshAssociation(32,-1); // mesh 5 |
|
| 1150 |
effect[6].setMeshAssociation( 8,-1); // apply to mesh 3 |
|
| 1151 |
effect[7].setMeshAssociation( 2,-1); // apply to mesh 1 |
|
| 1152 |
effect[8].setMeshAssociation(16,-1); // apply to mesh 4 |
|
| 1153 |
effect[9].setMeshAssociation(32,-1); // apply to mesh 5 |
|
| 1154 |
effect[10].setMeshAssociation(4,-1); // apply to mesh 2 |
|
| 1155 |
effect[11].setMeshAssociation(8,-1); // apply to mesh 3 |
|
| 1195 | 1156 |
|
| 1196 | 1157 |
return effect; |
| 1197 | 1158 |
} |
| ... | ... | |
| 1514 | 1475 |
VertexEffect[] effects = createVertexEffectsRexCorner(); |
| 1515 | 1476 |
for( VertexEffect effect : effects ) mesh.apply(effect); |
| 1516 | 1477 |
|
| 1517 |
final float F = (0.5f-REX_D)*SQ2*(SQ3-1); |
|
| 1518 |
final float H = F*SQ3/3; |
|
| 1519 |
final float G = H*SQ2/2; |
|
| 1520 |
|
|
| 1521 |
Static3D center = new Static3D(0.0f,0.0f,-H); |
|
| 1478 |
final float G = (1-REX_D)/3; |
|
| 1479 |
Static3D center = new Static3D(0.0f,0.0f,-G*SQ2/2); |
|
| 1522 | 1480 |
Static3D[] vertices = new Static3D[1]; |
| 1523 | 1481 |
vertices[0] = new Static3D(+G,-G,+0.0f); |
| 1524 |
roundCorners(mesh,center,vertices,0.08f,0.10f);
|
|
| 1482 |
roundCorners(mesh,center,vertices,0.10f,0.10f);
|
|
| 1525 | 1483 |
|
| 1526 | 1484 |
mesh.mergeEffComponents(); |
| 1527 | 1485 |
mesh.addEmptyTexComponent(); |
| 1528 | 1486 |
mesh.addEmptyTexComponent(); |
| 1487 |
mesh.addEmptyTexComponent(); |
|
| 1488 |
mesh.addEmptyTexComponent(); |
|
| 1529 | 1489 |
|
| 1530 | 1490 |
return mesh; |
| 1531 | 1491 |
} |
| ... | ... | |
| 1539 | 1499 |
mesh.mergeEffComponents(); |
| 1540 | 1500 |
mesh.addEmptyTexComponent(); |
| 1541 | 1501 |
mesh.addEmptyTexComponent(); |
| 1502 |
mesh.addEmptyTexComponent(); |
|
| 1503 |
mesh.addEmptyTexComponent(); |
|
| 1542 | 1504 |
|
| 1543 | 1505 |
return mesh; |
| 1544 | 1506 |
} |
| src/main/java/org/distorted/objects/FactorySticker.java | ||
|---|---|---|
| 34 | 34 |
class FactorySticker |
| 35 | 35 |
{
|
| 36 | 36 |
private static final float SQ2 = (float)Math.sqrt(2); |
| 37 |
private static final float SQ3 = (float)Math.sqrt(3); |
|
| 38 |
|
|
| 37 |
private static final float REX_X,REX_R,REX_B,REX_A, REX_P, REX_T, REX_C, REX_S; |
|
| 39 | 38 |
private static FactorySticker mThis; |
| 40 | 39 |
|
| 40 |
static |
|
| 41 |
{
|
|
| 42 |
float F = REX_D*SQ2; |
|
| 43 |
float G = (1-REX_D)*SQ2/2; |
|
| 44 |
|
|
| 45 |
REX_X = (0.5f-REX_D*REX_D)/(2*REX_D); |
|
| 46 |
REX_R = (float)Math.sqrt(2*REX_X*REX_X+0.5f); |
|
| 47 |
REX_B = (float) ((180/Math.PI)*(2*Math.asin( Math.sqrt(REX_D*REX_D-REX_D+0.5f) / (2*REX_R) ))); |
|
| 48 |
REX_A = (float) ((180/Math.PI)*Math.acos(REX_X/REX_R)) - 45; |
|
| 49 |
REX_P = 45 + REX_B/2 + REX_A; |
|
| 50 |
REX_T = (float) ( Math.tan( (Math.PI/180)*(45-REX_P/2) ) ); |
|
| 51 |
REX_C = (float)(REX_R/Math.cos((Math.PI/180)*REX_B/2) ); |
|
| 52 |
REX_S = (float)(1/Math.sqrt(1+4*G*G/(F*F))); |
|
| 53 |
} |
|
| 54 |
|
|
| 41 | 55 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 42 | 56 |
|
| 43 | 57 |
private FactorySticker() |
| ... | ... | |
| 246 | 260 |
|
| 247 | 261 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 248 | 262 |
|
| 249 |
void drawRexCornerSticker(Canvas canvas, Paint paint, int left, int top, int color, float stroke, float radius) |
|
| 263 |
void drawRexCornerSticker(Canvas canvas, Paint paint, int left, int top, int color, float stroke, float radius1, float radius2)
|
|
| 250 | 264 |
{
|
| 251 | 265 |
paint.setColor(color); |
| 252 | 266 |
paint.setStyle(Paint.Style.FILL); |
| ... | ... | |
| 256 | 270 |
paint.setStyle(Paint.Style.STROKE); |
| 257 | 271 |
paint.setStrokeWidth(stroke*TEXTURE_HEIGHT); |
| 258 | 272 |
|
| 259 |
float F = (0.5f-REX_D)*SQ2*(SQ3-1); |
|
| 260 |
float H1 = F*(1.0f + 2*SQ3/3); |
|
| 261 |
float H2 = F*(0.5f + SQ3/6); |
|
| 262 |
float D = H2*SQ3; |
|
| 263 |
|
|
| 264 |
float cx1 = left+ TEXTURE_HEIGHT*0.5f; |
|
| 265 |
float cy1 = top + TEXTURE_HEIGHT*(0.5f+H1); |
|
| 266 |
float cx2 = left+ TEXTURE_HEIGHT*(0.5f-D); |
|
| 267 |
float cy2 = top + TEXTURE_HEIGHT*(0.5f+H2); |
|
| 268 |
float cx3 = left+ TEXTURE_HEIGHT*(0.5f+D); |
|
| 269 |
float cy3 = top + TEXTURE_HEIGHT*(0.5f+H2); |
|
| 270 |
|
|
| 271 |
float R1= TEXTURE_HEIGHT*(1-2*REX_D); |
|
| 272 |
|
|
| 273 |
canvas.drawArc( cx1-R1, cy1-R1, cx1+R1, cy1+R1, 255, 30, false ,paint); |
|
| 274 |
canvas.drawArc( cx2-R1, cy2-R1, cx2+R1, cy2+R1, 315, 30, false ,paint); |
|
| 275 |
canvas.drawArc( cx3-R1, cy3-R1, cx3+R1, cy3+R1, 195, 30, false ,paint); |
|
| 276 |
|
|
| 277 |
float cx = left+ TEXTURE_HEIGHT*0.5f; |
|
| 278 |
float cy = top + TEXTURE_HEIGHT*0.5f; |
|
| 279 |
float R2 = radius*TEXTURE_HEIGHT; |
|
| 280 |
float dist = ( (SQ3/3)*F - SQ2*radius )*TEXTURE_HEIGHT; |
|
| 281 |
float dist2= 1.0f*(SQ3/3)*F*TEXTURE_HEIGHT; |
|
| 282 |
float tmp = SQ2*radius*TEXTURE_HEIGHT; |
|
| 283 |
float distX= (SQ3/2)*dist2 - 1.05f*tmp; |
|
| 284 |
float distY= (0.5f )*dist2 - 0.90f*tmp; |
|
| 285 |
|
|
| 286 |
canvas.drawArc( cx -R2, cy-dist -R2, cx +R2, cy-dist +R2, 225, 90, false ,paint); |
|
| 287 |
canvas.drawArc( cx-distX-R2, cy+distY-R2, cx-distX+R2, cy+distY+R2, 75,120, false ,paint); |
|
| 288 |
canvas.drawArc( cx+distX-R2, cy+distY-R2, cx+distX+R2, cy+distY+R2, 345,120, false ,paint); |
|
| 289 |
} |
|
| 273 |
float F = REX_D*SQ2; |
|
| 274 |
float G = (1-REX_D)*SQ2/2; |
|
| 290 | 275 |
|
| 291 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 276 |
float cx1 = left + (0.5f-F/2)*TEXTURE_HEIGHT; |
|
| 277 |
float cx2 = left + (0.5f+F/2)*TEXTURE_HEIGHT; |
|
| 278 |
float cy = top + (0.5f+G/3)*TEXTURE_HEIGHT; |
|
| 292 | 279 |
|
| 293 |
void drawRexFaceSticker(Canvas canvas, Paint paint, int left, int top, int color, float stroke, float radius) |
|
| 294 |
{
|
|
| 295 |
paint.setColor(color); |
|
| 296 |
paint.setStyle(Paint.Style.FILL); |
|
| 297 |
canvas.drawRect(left,top,left+TEXTURE_HEIGHT,top+TEXTURE_HEIGHT,paint); |
|
| 280 |
canvas.drawLine(cx1, cy, cx2, cy, paint); |
|
| 298 | 281 |
|
| 299 |
paint.setColor(COLOR_BLACK); |
|
| 300 |
paint.setStyle(Paint.Style.STROKE); |
|
| 301 |
paint.setStrokeWidth(stroke*TEXTURE_HEIGHT); |
|
| 282 |
float X = REX_C-F/2; |
|
| 283 |
float R1 = TEXTURE_HEIGHT*(REX_R + 0.5f*stroke); |
|
| 284 |
float cx3 = left + (0.5f-X)*TEXTURE_HEIGHT; |
|
| 285 |
float cx4 = left + (0.5f+X)*TEXTURE_HEIGHT; |
|
| 302 | 286 |
|
| 303 |
float cx1 = left+ TEXTURE_HEIGHT*REX_D; |
|
| 304 |
float cy1 = top + TEXTURE_HEIGHT*(1-REX_D); |
|
| 305 |
float cx2 = left+ TEXTURE_HEIGHT*REX_D; |
|
| 306 |
float cy2 = top + TEXTURE_HEIGHT*REX_D; |
|
| 307 |
float cx3 = left+ TEXTURE_HEIGHT*(1-REX_D); |
|
| 308 |
float cy3 = top + TEXTURE_HEIGHT*REX_D; |
|
| 309 |
float cx4 = left+ TEXTURE_HEIGHT*(1-REX_D); |
|
| 310 |
float cy4 = top + TEXTURE_HEIGHT*(1-REX_D); |
|
| 311 |
float R1 = TEXTURE_HEIGHT*(1-2*REX_D); |
|
| 312 |
|
|
| 313 |
canvas.drawArc( cx1-R1, cy1-R1, cx1+R1, cy1+R1, 300, 30, false ,paint); |
|
| 314 |
canvas.drawArc( cx2-R1, cy2-R1, cx2+R1, cy2+R1, 30, 30, false ,paint); |
|
| 315 |
canvas.drawArc( cx3-R1, cy3-R1, cx3+R1, cy3+R1, 120, 30, false ,paint); |
|
| 316 |
canvas.drawArc( cx4-R1, cy4-R1, cx4+R1, cy4+R1, 210, 30, false ,paint); |
|
| 317 |
|
|
| 318 |
float cx = left+ TEXTURE_HEIGHT*0.5f; |
|
| 319 |
float cy = top + TEXTURE_HEIGHT*0.5f; |
|
| 320 |
float R2 = radius*TEXTURE_HEIGHT; |
|
| 321 |
float dist = ( (0.5f-REX_D)*(SQ3-1) - (2*SQ3/3)*radius )*TEXTURE_HEIGHT; |
|
| 322 |
|
|
| 323 |
canvas.drawArc( cx+dist-R2, cy-R2, cx+dist+R2, cy+R2, 330, 60, false ,paint); |
|
| 324 |
canvas.drawArc( cx-R2, cy+dist-R2, cx+R2, cy+dist+R2, 60, 60, false ,paint); |
|
| 325 |
canvas.drawArc( cx-dist-R2, cy-R2, cx-dist+R2, cy+R2, 150, 60, false ,paint); |
|
| 326 |
canvas.drawArc( cx-R2, cy-dist-R2, cx+R2, cy-dist+R2, 240, 60, false ,paint); |
|
| 287 |
canvas.drawArc( cx3-R1, cy-R1, cx3+R1, cy+R1, 360-REX_B/2, REX_B/2, false ,paint); |
|
| 288 |
canvas.drawArc( cx4-R1, cy-R1, cx4+R1, cy+R1, 180 , REX_B/2, false ,paint); |
|
| 289 |
|
|
| 290 |
float cx5 = left + (0.5f+F/2-radius2)*TEXTURE_HEIGHT; |
|
| 291 |
float cx6 = left + (0.5f-F/2+radius2)*TEXTURE_HEIGHT; |
|
| 292 |
float cy1 = top + (0.5f+G/3-radius2)*TEXTURE_HEIGHT;; |
|
| 293 |
float R2 = TEXTURE_HEIGHT*radius2; |
|
| 294 |
|
|
| 295 |
canvas.drawArc( cx5-R2, cy1-R2, cx5+R2, cy1+R2, 0, 90, false ,paint); |
|
| 296 |
canvas.drawArc( cx6-R2, cy1-R2, cx6+R2, cy1+R2, 90, 90, false ,paint); |
|
| 297 |
|
|
| 298 |
float cx7 = left + 0.5f*TEXTURE_HEIGHT; |
|
| 299 |
float cy2 = top + (0.5f-2*G/3 + radius1/REX_S)*TEXTURE_HEIGHT; |
|
| 300 |
float R3 = TEXTURE_HEIGHT*(radius1 + 0.5f*stroke); |
|
| 301 |
canvas.drawArc( cx7-R3, cy2-R3, cx7+R3, cy2+R3, 270-(90-REX_B/2), 180-REX_B, false ,paint); |
|
| 327 | 302 |
} |
| 328 | 303 |
|
| 329 | 304 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 338 | 313 |
paint.setStyle(Paint.Style.STROKE); |
| 339 | 314 |
paint.setStrokeWidth(stroke*TEXTURE_HEIGHT); |
| 340 | 315 |
|
| 341 |
final float D = 0.5f - REX_D; |
|
| 342 |
final float F = 0.5f*(0.5f - D*(SQ3-1)); |
|
| 316 |
final float D = ( 0.5f - (0.5f-REX_D)/3); |
|
| 317 |
float cx1 = left+ TEXTURE_HEIGHT*(0.5f-REX_X); |
|
| 318 |
float cy1 = top + TEXTURE_HEIGHT*(0.5f+REX_X+D); |
|
| 319 |
float cx2 = left+ TEXTURE_HEIGHT*(0.5f+REX_X); |
|
| 320 |
float R1 = TEXTURE_HEIGHT*REX_R; |
|
| 321 |
|
|
| 322 |
canvas.drawArc( cx1-R1, cy1-R1, cx1+R1, cy1+R1, 315-REX_A-REX_B, REX_B, false ,paint); |
|
| 323 |
canvas.drawArc( cx2-R1, cy1-R1, cx2+R1, cy1+R1, 225+REX_A , REX_B, false ,paint); |
|
| 343 | 324 |
|
| 344 |
float cx1 = left+ TEXTURE_HEIGHT*REX_D; |
|
| 345 |
float cy = top + TEXTURE_HEIGHT*(1-REX_D-F+0.5f); |
|
| 346 |
float cx2 = left+ TEXTURE_HEIGHT*(1-REX_D); |
|
| 347 |
float R1 = 1.0f*TEXTURE_HEIGHT*(1-2*REX_D); |
|
| 325 |
float CORR_Y = radius/12; |
|
| 326 |
float CORR_A = 10; |
|
| 327 |
float sin = (float)Math.sin(Math.PI*REX_P/180); |
|
| 328 |
float cx = left + 0.5f*TEXTURE_HEIGHT; |
|
| 329 |
float cy = top + ( 0.5f + 2*(0.5f-REX_D)/3 -CORR_Y -radius/sin )*TEXTURE_HEIGHT; |
|
| 330 |
float R2 = TEXTURE_HEIGHT*radius; |
|
| 348 | 331 |
|
| 349 |
canvas.drawArc( cx1-R1, cy-R1, cx1+R1, cy+R1, 270, 30, false ,paint); |
|
| 350 |
canvas.drawArc( cx2-R1, cy-R1, cx2+R1, cy+R1, 240, 30, false ,paint); |
|
| 332 |
canvas.drawArc( cx-R2, cy-R2, cx+R2, cy+R2, 90-(REX_P-CORR_A), 2*(REX_P-CORR_A), false ,paint); |
|
| 351 | 333 |
|
| 352 |
float cx = left + TEXTURE_HEIGHT*0.5f; |
|
| 353 |
float R2 = radius*TEXTURE_HEIGHT; |
|
| 354 |
cy = top + TEXTURE_HEIGHT*(0.5f+F-(2*SQ3/3)*radius); |
|
| 334 |
float F = 0.1f; |
|
| 335 |
float G = 0.6f; |
|
| 336 |
float R3 = TEXTURE_HEIGHT*radius*G*0.9f; |
|
| 337 |
float X = G*radius/REX_T; |
|
| 338 |
float cx4 = left + X*TEXTURE_HEIGHT; |
|
| 339 |
float cx3 = left + (1-X)*TEXTURE_HEIGHT; |
|
| 340 |
float cy3 = top + (0.5f - (0.5f-REX_D)/3 + G*radius - F*stroke)*TEXTURE_HEIGHT; |
|
| 355 | 341 |
|
| 356 |
canvas.drawArc( cx-R2, cy-R2, cx+R2, cy+R2, 60, 60, false ,paint); |
|
| 342 |
canvas.drawArc( cx3-R3, cy3-R3, cx3+R3, cy3+R3, 270 , 90+REX_P, false ,paint); |
|
| 343 |
canvas.drawArc( cx4-R3, cy3-R3, cx4+R3, cy3+R3, 270-(90+REX_P), 90+REX_P, false ,paint); |
|
| 357 | 344 |
|
| 358 |
cy = top + (0.5f-F)*TEXTURE_HEIGHT;
|
|
| 345 |
float cy5 = top + D*TEXTURE_HEIGHT;
|
|
| 359 | 346 |
|
| 360 |
paint.setStrokeWidth(0.6f*stroke*TEXTURE_HEIGHT);
|
|
| 361 |
canvas.drawLine(left, cy, left+TEXTURE_HEIGHT, cy, paint);
|
|
| 347 |
paint.setStrokeWidth((1-2*F)*stroke*TEXTURE_HEIGHT);
|
|
| 348 |
canvas.drawLine(left, cy5, left+TEXTURE_HEIGHT, cy5, paint);
|
|
| 362 | 349 |
} |
| 363 | 350 |
} |
| src/main/java/org/distorted/objects/TwistyObject.java | ||
|---|---|---|
| 78 | 78 |
private static final float MAX_SIZE_CHANGE = 1.35f; |
| 79 | 79 |
private static final float MIN_SIZE_CHANGE = 0.75f; |
| 80 | 80 |
|
| 81 |
private static final boolean mCreateFromDMesh = true;
|
|
| 81 |
private static final boolean mCreateFromDMesh = false;
|
|
| 82 | 82 |
|
| 83 | 83 |
private static final Static3D CENTER = new Static3D(0,0,0); |
| 84 | 84 |
private static final int POST_ROTATION_MILLISEC = 500; |
| src/main/java/org/distorted/objects/TwistyRex.java | ||
|---|---|---|
| 42 | 42 |
|
| 43 | 43 |
public class TwistyRex extends TwistyObject |
| 44 | 44 |
{
|
| 45 |
private static final int FACES_PER_CUBIT =4;
|
|
| 45 |
private static final int FACES_PER_CUBIT =6;
|
|
| 46 | 46 |
|
| 47 | 47 |
// the four rotation axis of a RubikRex. Must be normalized. |
| 48 | 48 |
static final Static3D[] ROT_AXIS = new Static3D[] |
| ... | ... | |
| 80 | 80 |
|
| 81 | 81 |
private static final int[][] mFaceMap = |
| 82 | 82 |
{
|
| 83 |
{ 0, 18,18,18 },
|
|
| 84 |
{ 0, 18,18,18 },
|
|
| 85 |
{ 0, 18,18,18 },
|
|
| 86 |
{ 0, 18,18,18 },
|
|
| 87 |
{ 1, 18,18,18 },
|
|
| 88 |
{ 1, 18,18,18 },
|
|
| 89 |
{ 1, 18,18,18 },
|
|
| 90 |
{ 1, 18,18,18 },
|
|
| 91 |
{ 2, 18,18,18 },
|
|
| 92 |
{ 2, 18,18,18 },
|
|
| 93 |
{ 2, 18,18,18 },
|
|
| 94 |
{ 2, 18,18,18 },
|
|
| 95 |
{ 3, 18,18,18 },
|
|
| 96 |
{ 3, 18,18,18 },
|
|
| 97 |
{ 3, 18,18,18 },
|
|
| 98 |
{ 3, 18,18,18 },
|
|
| 99 |
{ 4, 18,18,18 },
|
|
| 100 |
{ 4, 18,18,18 },
|
|
| 101 |
{ 4, 18,18,18 },
|
|
| 102 |
{ 4, 18,18,18 },
|
|
| 103 |
{ 5, 18,18,18 },
|
|
| 104 |
{ 5, 18,18,18 },
|
|
| 105 |
{ 5, 18,18,18 },
|
|
| 106 |
{ 5, 18,18,18 },
|
|
| 107 |
|
|
| 108 |
{ 6, 18,18,18 },
|
|
| 109 |
{ 7, 18,18,18 },
|
|
| 110 |
{ 8, 18,18,18 },
|
|
| 111 |
{ 9, 18,18,18 },
|
|
| 112 |
{ 10, 18,18,18 },
|
|
| 113 |
{ 11, 18,18,18 },
|
|
| 114 |
|
|
| 115 |
{ 16,14, 18,18 },
|
|
| 116 |
{ 16,12, 18,18 },
|
|
| 117 |
{ 16,15, 18,18 },
|
|
| 118 |
{ 16,13, 18,18 },
|
|
| 119 |
{ 12,14, 18,18 },
|
|
| 120 |
{ 15,12, 18,18 },
|
|
| 121 |
{ 15,13, 18,18 },
|
|
| 122 |
{ 13,14, 18,18 },
|
|
| 123 |
{ 14,17, 18,18 },
|
|
| 124 |
{ 12,17, 18,18 },
|
|
| 125 |
{ 17,15, 18,18 },
|
|
| 126 |
{ 13,17, 18,18 },
|
|
| 83 |
{ 0, 18,18,18,18,18 },
|
|
| 84 |
{ 0, 18,18,18,18,18 },
|
|
| 85 |
{ 0, 18,18,18,18,18 },
|
|
| 86 |
{ 0, 18,18,18,18,18 },
|
|
| 87 |
{ 1, 18,18,18,18,18 },
|
|
| 88 |
{ 1, 18,18,18,18,18 },
|
|
| 89 |
{ 1, 18,18,18,18,18 },
|
|
| 90 |
{ 1, 18,18,18,18,18 },
|
|
| 91 |
{ 2, 18,18,18,18,18 },
|
|
| 92 |
{ 2, 18,18,18,18,18 },
|
|
| 93 |
{ 2, 18,18,18,18,18 },
|
|
| 94 |
{ 2, 18,18,18,18,18 },
|
|
| 95 |
{ 3, 18,18,18,18,18 },
|
|
| 96 |
{ 3, 18,18,18,18,18 },
|
|
| 97 |
{ 3, 18,18,18,18,18 },
|
|
| 98 |
{ 3, 18,18,18,18,18 },
|
|
| 99 |
{ 4, 18,18,18,18,18 },
|
|
| 100 |
{ 4, 18,18,18,18,18 },
|
|
| 101 |
{ 4, 18,18,18,18,18 },
|
|
| 102 |
{ 4, 18,18,18,18,18 },
|
|
| 103 |
{ 5, 18,18,18,18,18 },
|
|
| 104 |
{ 5, 18,18,18,18,18 },
|
|
| 105 |
{ 5, 18,18,18,18,18 },
|
|
| 106 |
{ 5, 18,18,18,18,18 },
|
|
| 107 |
|
|
| 108 |
{ 6, 18,18,18,18,18 },
|
|
| 109 |
{ 7, 18,18,18,18,18 },
|
|
| 110 |
{ 8, 18,18,18,18,18 },
|
|
| 111 |
{ 9, 18,18,18,18,18 },
|
|
| 112 |
{ 10, 18,18,18,18,18 },
|
|
| 113 |
{ 11, 18,18,18,18,18 },
|
|
| 114 |
|
|
| 115 |
{ 16,14, 18,18,18,18 },
|
|
| 116 |
{ 16,12, 18,18,18,18 },
|
|
| 117 |
{ 16,15, 18,18,18,18 },
|
|
| 118 |
{ 16,13, 18,18,18,18 },
|
|
| 119 |
{ 12,14, 18,18,18,18 },
|
|
| 120 |
{ 15,12, 18,18,18,18 },
|
|
| 121 |
{ 15,13, 18,18,18,18 },
|
|
| 122 |
{ 13,14, 18,18,18,18 },
|
|
| 123 |
{ 14,17, 18,18,18,18 },
|
|
| 124 |
{ 12,17, 18,18,18,18 },
|
|
| 125 |
{ 17,15, 18,18,18,18 },
|
|
| 126 |
{ 13,17, 18,18,18,18 },
|
|
| 127 | 127 |
}; |
| 128 | 128 |
|
| 129 | 129 |
private static MeshBase mCornerMesh, mFaceMesh, mEdgeMesh; |
| ... | ... | |
| 192 | 192 |
Static3D[] getCubitPositions(int numLayers) |
| 193 | 193 |
{
|
| 194 | 194 |
final float DIST = 0.50f; |
| 195 |
final float DIST2= SQ3/6*(1.0f-2*REX_D);
|
|
| 195 |
final float DIST2= (1+2*REX_D)/6;
|
|
| 196 | 196 |
|
| 197 | 197 |
final Static3D[] CENTERS = new Static3D[42]; |
| 198 | 198 |
|
| ... | ... | |
| 245 | 245 |
} |
| 246 | 246 |
|
| 247 | 247 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 248 |
// 1 +90 ( 1, 0, 0) = Static4D(+SQ2/2, 0, 0, SQ2/2); |
|
| 249 |
// 2 -90 ( 1, 0, 0) = Static4D(-SQ2/2, 0, 0, SQ2/2); |
|
| 250 |
// 3 +90 ( 0, 1, 0) = Static4D( 0,+SQ2/2, 0, SQ2/2); |
|
| 251 |
// 4 -90 ( 0, 1, 0) = Static4D( 0,-SQ2/2, 0, SQ2/2); |
|
| 252 |
// 5 +90 ( 0, 0, 1) = Static4D( 0, 0,+SQ2/2, SQ2/2); |
|
| 253 |
// 6 -90 ( 0, 0, 1) = Static4D( 0, 0,-SQ2/2, SQ2/2); |
|
| 254 |
// 7 180 ( 1, 0, 1) = Static4D(+SQ2/2, 0,+SQ2/2, 0); |
|
| 255 |
// 8 180 (-1, 0, 1) = Static4D(-SQ2/2, 0,+SQ2/2, 0); |
|
| 256 |
// 9 180 ( 0, 1, 1) = Static4D( 0,+SQ2/2,+SQ2/2, 0); |
|
| 257 |
//10 180 ( 0,-1, 1) = Static4D( 0,-SQ2/2,+SQ2/2, 0); |
|
| 258 |
//11 180 ( 1, 1, 0) = Static4D(+SQ2/2,+SQ2/2, 0, 0); |
|
| 259 |
//12 180 ( 1,-1, 0) = Static4D(+SQ2/2,-SQ2/2, 0, 0); |
|
| 260 | 248 |
|
| 261 | 249 |
private Static4D getQuat(int cubit) |
| 262 | 250 |
{
|
| ... | ... | |
| 352 | 340 |
{
|
| 353 | 341 |
int COLORS = FACE_COLORS.length; |
| 354 | 342 |
FactorySticker factory = FactorySticker.getInstance(); |
| 355 |
float S1 = 0.05f; |
|
| 356 |
float S2 = 0.04f; |
|
| 357 |
float R1 = 0.12f; |
|
| 358 |
float R2 = 0.06f; |
|
| 343 |
float S1 = 0.050f; |
|
| 344 |
float S2 = 0.051f; |
|
| 345 |
float R1 = 0.07f; |
|
| 346 |
float R2 = 0.02f; |
|
| 347 |
float R3 = 0.06f; |
|
| 348 |
float R4 = 0.04f; |
|
| 359 | 349 |
|
| 360 | 350 |
if( face<COLORS ) |
| 361 | 351 |
{
|
| 362 |
factory.drawRexCornerSticker(canvas, paint, left, top, FACE_COLORS[face%COLORS], S1, R2); |
|
| 352 |
factory.drawRexCornerSticker(canvas, paint, left, top, FACE_COLORS[face%COLORS], S1, R2, R3);
|
|
| 363 | 353 |
} |
| 364 | 354 |
else if( face<2*COLORS ) |
| 365 | 355 |
{
|
| 366 |
factory.drawRexFaceSticker(canvas, paint, left, top, FACE_COLORS[face%COLORS], S1, R1); |
|
| 356 |
float[] vertices = { -REX_D,0.0f, 0.0f, -REX_D, +REX_D, 0.0f, 0.0f, +REX_D};
|
|
| 357 |
factory.drawRoundedPolygon(canvas, paint, left, top, vertices, S1, FACE_COLORS[face%COLORS], R4); |
|
| 367 | 358 |
} |
| 368 | 359 |
else |
| 369 | 360 |
{
|
Also available in: Unified diff
Rex Cube - new mesh, textures and icon.