Revision da36b97e
Added by Leszek Koltunski about 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 |
} |
Also available in: Unified diff
Rex Cube - new mesh, textures and icon.