Revision f7936f2f
Added by Leszek Koltunski almost 5 years ago
| src/main/java/org/distorted/examples/meshfile/FactoryCubit.java | ||
|---|---|---|
| 43 | 43 |
private static final int IVY_N = 8; |
| 44 | 44 |
private static final float IVY_C = 0.59f; |
| 45 | 45 |
private static final float IVY_M = 0.35f; |
| 46 |
private static final float REX_D = 0.03f;
|
|
| 46 |
private static final float REX_D = 0.2f;
|
|
| 47 | 47 |
private static final int REX_N = 5; |
| 48 | 48 |
|
| 49 | 49 |
private static final Static1D RADIUS = new Static1D(1); |
| ... | ... | |
| 697 | 697 |
|
| 698 | 698 |
MeshBase createFacesRexEdge() |
| 699 | 699 |
{
|
| 700 |
MeshBase[] meshes = new MeshBase[1]; |
|
| 701 |
|
|
| 702 |
final float angle = (float)Math.PI/(6*REX_N); |
|
| 703 |
float[] vertices = new float[4*REX_N + 6]; |
|
| 704 |
final float H = 1.0f - SQ3/2; |
|
| 705 |
final float D = 0.5f - REX_D; |
|
| 706 |
final float F = 0.5f*H; |
|
| 707 |
|
|
| 708 |
final float V1x = -D; |
|
| 709 |
final float V1y = +D + F - 0.5f; |
|
| 710 |
final float V2x = 0.0f; |
|
| 711 |
final float V2y = -F; |
|
| 712 |
|
|
| 713 |
final float C1x = -D; |
|
| 714 |
final float C1y = -D + F - 0.5f; |
|
| 715 |
final float C2x = +D; |
|
| 716 |
final float C2y = C1y; |
|
| 717 |
|
|
| 718 |
for(int i=0; i<REX_N; i++) |
|
| 719 |
{
|
|
| 720 |
writeVertex(C1x,C1y,V1x,V1y,-i*angle, vertices, 2*i ); |
|
| 721 |
writeVertex(C2x,C2y,V2x,V2y,-i*angle, vertices, 2*i + 2*REX_N); |
|
| 722 |
} |
|
| 723 |
|
|
| 724 |
vertices[4*REX_N ] = +D; |
|
| 725 |
vertices[4*REX_N+1] = +F-REX_D; |
|
| 726 |
vertices[4*REX_N+2] = +D; |
|
| 727 |
vertices[4*REX_N+3] = +F; |
|
| 728 |
vertices[4*REX_N+4] = -D; |
|
| 729 |
vertices[4*REX_N+5] = +F; |
|
| 700 |
MeshBase[] meshes = new MeshPolygon[6]; |
|
| 730 | 701 |
|
| 731 |
/* |
|
| 732 |
vertices[0] = V1x; |
|
| 733 |
vertices[1] = V1y; |
|
| 734 |
vertices[2] = V2x; |
|
| 735 |
vertices[3] = V2y; |
|
| 736 |
vertices[4] = +D; |
|
| 737 |
vertices[5] = +F-REX_D; |
|
| 738 |
vertices[6] = +D; |
|
| 739 |
vertices[7] = +F; |
|
| 740 |
vertices[8] = -D; |
|
| 741 |
vertices[9] = +F; |
|
| 742 |
*/ |
|
| 743 |
float[] bands0 = computeBands(+0.02f, 9,0.5f,0.5f,5); |
|
| 744 |
float[] bands1 = computeBands( 0.00f,45,0.5f,0.0f,2); |
|
| 702 |
float E = 0.5f - REX_D; |
|
| 703 |
float F = 0.5f; |
|
| 704 |
float[] vertices0 = { -F,E/3, 0,-2*E/3, +F,E/3 };
|
|
| 705 |
float[] bands0 = computeBands(0.03f,27,F/3,0.8f,5); |
|
| 745 | 706 |
|
| 746 |
meshes[0] = new MeshPolygon(vertices,bands0,1,2);
|
|
| 707 |
meshes[0] = new MeshPolygon(vertices0, bands0, 2, 3);
|
|
| 747 | 708 |
meshes[0].setEffectAssociation(0,1,0); |
| 748 |
/* |
|
| 749 | 709 |
meshes[1] = meshes[0].copy(true); |
| 750 | 710 |
meshes[1].setEffectAssociation(0,2,0); |
| 751 |
meshes[2] = new MeshPolygon(vertices,bands1,0,0); |
|
| 711 |
|
|
| 712 |
float G = (float)Math.sqrt(E*E+F*F); |
|
| 713 |
float[] vertices1 = { -2*G/3, -E/3, G/3, -E/3, G/3, 2*E/3 };
|
|
| 714 |
float[] bands1 = computeBands(0.00f,45,G/3,0.2f,3); |
|
| 715 |
|
|
| 716 |
meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2); |
|
| 752 | 717 |
meshes[2].setEffectAssociation(0,4,0); |
| 753 | 718 |
meshes[3] = meshes[2].copy(true); |
| 754 | 719 |
meshes[3].setEffectAssociation(0,8,0); |
| 755 |
*/ |
|
| 720 |
meshes[4] = meshes[2].copy(true); |
|
| 721 |
meshes[4].setEffectAssociation(0,16,0); |
|
| 722 |
meshes[5] = meshes[2].copy(true); |
|
| 723 |
meshes[5].setEffectAssociation(0,32,0); |
|
| 724 |
|
|
| 756 | 725 |
return new MeshJoined(meshes); |
| 757 | 726 |
} |
| 758 | 727 |
|
| ... | ... | |
| 1187 | 1156 |
|
| 1188 | 1157 |
VertexEffect[] createVertexEffectsRexEdge() |
| 1189 | 1158 |
{
|
| 1190 |
final float H = 1.0f - SQ3/2; |
|
| 1191 |
final float D = 0.5f - REX_D; |
|
| 1192 |
final float F = H*D; |
|
| 1159 |
float E = 0.5f - REX_D; |
|
| 1160 |
float F = 0.5f; |
|
| 1161 |
float G = (float)Math.sqrt(E*E+F*F); |
|
| 1162 |
float A = (float)((180/Math.PI)*Math.asin(E/G)); |
|
| 1193 | 1163 |
|
| 1194 |
Static3D move = new Static3D(0.0f, -F, 0.0f); |
|
| 1195 |
Static3D center= new Static3D(0.0f, 0.0f, 0.0f); |
|
| 1196 |
Static3D axisX = new Static3D(1.0f, 0.0f, 0.0f); |
|
| 1197 |
Static3D axisY = new Static3D(0.0f, 1.0f, 0.0f); |
|
| 1164 |
Static3D move1 = new Static3D( 0.0f, -E/3, 0.0f); |
|
| 1165 |
Static3D move2 = new Static3D(2*G/3 -F, +E/3, 0.0f); |
|
| 1166 |
|
|
| 1167 |
Static3D center0= new Static3D(0.0f, 0.0f, 0.0f); |
|
| 1168 |
Static3D center1= new Static3D( -F, 0.0f, 0.0f); |
|
| 1169 |
Static3D center2= new Static3D( +F, 0.0f, 0.0f); |
|
| 1170 |
Static3D axisX = new Static3D(1.0f, 0.0f, 0.0f); |
|
| 1171 |
Static3D axisY = new Static3D(0.0f, 1.0f, 0.0f); |
|
| 1172 |
Static3D axisZ = new Static3D(0.0f, 0.0f, 1.0f); |
|
| 1198 | 1173 |
|
| 1199 | 1174 |
Static1D angle180 = new Static1D(180); |
| 1200 | 1175 |
Static1D angle90 = new Static1D( 90); |
| 1176 |
Static1D angle270 = new Static1D(270); |
|
| 1177 |
Static1D angle1 = new Static1D(+A); |
|
| 1178 |
Static1D angle2 = new Static1D(-A); |
|
| 1201 | 1179 |
|
| 1202 |
VertexEffect[] effect = new VertexEffect[3]; |
|
| 1203 |
|
|
| 1204 |
effect[0] = new VertexEffectMove(move); |
|
| 1205 |
effect[1] = new VertexEffectRotate(angle180, axisY, center); |
|
| 1206 |
effect[2] = new VertexEffectRotate(angle90 , axisX, center); |
|
| 1180 |
VertexEffect[] effect = new VertexEffect[12]; |
|
| 1207 | 1181 |
|
| 1208 |
effect[1].setMeshAssociation(10,-1); // meshes 1 & 3 |
|
| 1209 |
effect[2].setMeshAssociation(10,-1); // meshes 1 & 3 |
|
| 1182 |
effect[0] = new VertexEffectMove(move1); |
|
| 1183 |
effect[1] = new VertexEffectMove(move2); |
|
| 1184 |
effect[2] = new VertexEffectRotate( angle90, axisX, center0 ); |
|
| 1185 |
effect[3] = new VertexEffectRotate( angle270, axisX, center0 ); |
|
| 1186 |
effect[4] = new VertexEffectRotate( angle180, axisX, center0 ); |
|
| 1187 |
effect[5] = new VertexEffectRotate( angle180, axisY, center0 ); |
|
| 1188 |
effect[6] = new VertexEffectScale ( new Static3D(-1, 1, 1) ); |
|
| 1189 |
effect[7] = new VertexEffectScale ( new Static3D( 1,-1, 1) ); |
|
| 1190 |
effect[8] = new VertexEffectRotate( angle1, axisY, center1); |
|
| 1191 |
effect[9] = new VertexEffectRotate( angle2, axisY, center2); |
|
| 1192 |
effect[10]= new VertexEffectRotate( angle2, axisZ, center1); |
|
| 1193 |
effect[11]= new VertexEffectRotate( angle1, axisZ, center2); |
|
| 1194 |
|
|
| 1195 |
effect[0].setMeshAssociation( 3,-1); // meshes 0 & 1 |
|
| 1196 |
effect[1].setMeshAssociation(60,-1); // meshes 2,3,4,5 |
|
| 1197 |
effect[2].setMeshAssociation( 2,-1); // meshes 1 |
|
| 1198 |
effect[3].setMeshAssociation(12,-1); // meshes 2,3 |
|
| 1199 |
effect[4].setMeshAssociation(48,-1); // meshes 4,5 |
|
| 1200 |
effect[5].setMeshAssociation(32,-1); // mesh 5 |
|
| 1201 |
effect[6].setMeshAssociation( 8,-1); // apply to mesh 3 |
|
| 1202 |
effect[7].setMeshAssociation( 2,-1); // apply to mesh 1 |
|
| 1203 |
effect[8].setMeshAssociation(16,-1); // apply to mesh 4 |
|
| 1204 |
effect[9].setMeshAssociation(32,-1); // apply to mesh 5 |
|
| 1205 |
effect[10].setMeshAssociation(4,-1); // apply to mesh 2 |
|
| 1206 |
effect[11].setMeshAssociation(8,-1); // apply to mesh 3 |
|
| 1210 | 1207 |
|
| 1211 | 1208 |
return effect; |
| 1212 | 1209 |
} |
| ... | ... | |
| 1561 | 1558 |
MeshBase mesh = createFacesRexEdge(); |
| 1562 | 1559 |
VertexEffect[] effects = createVertexEffectsRexEdge(); |
| 1563 | 1560 |
for( VertexEffect effect : effects ) mesh.apply(effect); |
| 1564 |
|
|
| 1561 |
/* |
|
| 1565 | 1562 |
Static3D center = new Static3D(0.0f,-0.5f,-0.5f); |
| 1566 | 1563 |
Static3D[] vertices = new Static3D[2]; |
| 1567 | 1564 |
vertices[0] = new Static3D(+0.5f,+0.0f,+0.0f); |
| ... | ... | |
| 1569 | 1566 |
roundCorners(mesh,center,vertices,0.03f,0.10f); |
| 1570 | 1567 |
|
| 1571 | 1568 |
mesh.mergeEffComponents(); |
| 1572 |
|
|
| 1569 |
*/ |
|
| 1573 | 1570 |
return mesh; |
| 1574 | 1571 |
} |
| 1575 | 1572 |
} |
Also available in: Unified diff
Rex Cube - new mesh, textures and icon.