238 |
238 |
}
|
239 |
239 |
}
|
240 |
240 |
|
241 |
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
242 |
|
|
243 |
|
MeshBase createFacesSkewbCorner()
|
244 |
|
{
|
245 |
|
MeshBase[] meshes = new MeshBase[6];
|
246 |
|
|
247 |
|
float E = 0.5f;
|
248 |
|
float F = SQ2/2;
|
249 |
|
float G = SQ6/16;
|
250 |
|
float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
|
251 |
|
float[] bands0 = computeBands(0.028f,35,E/3,0.7f,7);
|
252 |
|
|
253 |
|
meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
|
254 |
|
meshes[0].setEffectAssociation(0,1,0);
|
255 |
|
meshes[1] = meshes[0].copy(true);
|
256 |
|
meshes[1].setEffectAssociation(0,2,0);
|
257 |
|
meshes[2] = meshes[0].copy(true);
|
258 |
|
meshes[2].setEffectAssociation(0,4,0);
|
259 |
|
|
260 |
|
float[] vertices1 = { -F/2,-2*G, F/2,-2*G, 3*F/8,-G, 1*F/8,G, 0,2*G };
|
261 |
|
float[] bands1 = computeBands(0,0,1,0,3);
|
262 |
|
|
263 |
|
meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
|
264 |
|
meshes[3].setEffectAssociation(0,8,0);
|
265 |
|
meshes[4] = meshes[3].copy(true);
|
266 |
|
meshes[4].setEffectAssociation(0,16,0);
|
267 |
|
meshes[5] = meshes[3].copy(true);
|
268 |
|
meshes[5].setEffectAssociation(0,32,0);
|
269 |
|
|
270 |
|
return new MeshJoined(meshes);
|
271 |
|
}
|
272 |
|
|
273 |
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
274 |
|
|
275 |
|
MeshBase createFacesSkewbFace()
|
276 |
|
{
|
277 |
|
MeshBase[] meshes = new MeshBase[5];
|
278 |
|
|
279 |
|
float E = SQ2/4;
|
280 |
|
float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
|
281 |
|
float[] bands0 = computeBands(0.051f,35,E/2,0.9f,7);
|
282 |
|
|
283 |
|
meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
|
284 |
|
meshes[0].setEffectAssociation(0,1,0);
|
285 |
|
|
286 |
|
float[] vertices1 = { -E,-SQ3*E, -E*0.7f,-SQ3*E, +E*0.7f,-SQ3*E, +E,-SQ3*E, 0,0 };
|
287 |
|
float[] bands1 = computeBands(0,0,1,0,3);
|
288 |
|
|
289 |
|
meshes[1] = new MeshPolygon(vertices1,bands1,0,0);
|
290 |
|
meshes[1].setEffectAssociation(0,2,0);
|
291 |
|
meshes[2] = meshes[1].copy(true);
|
292 |
|
meshes[2].setEffectAssociation(0,4,0);
|
293 |
|
meshes[3] = meshes[1].copy(true);
|
294 |
|
meshes[3].setEffectAssociation(0,8,0);
|
295 |
|
meshes[4] = meshes[1].copy(true);
|
296 |
|
meshes[4].setEffectAssociation(0,16,0);
|
297 |
|
|
298 |
|
return new MeshJoined(meshes);
|
299 |
|
}
|
300 |
|
|
301 |
241 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
302 |
242 |
|
303 |
243 |
MeshBase createFacesHelicopterCorner()
|
... | ... | |
813 |
753 |
|
814 |
754 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
815 |
755 |
// EFFECTS
|
816 |
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
817 |
|
|
818 |
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
819 |
|
|
820 |
|
VertexEffect[] createVertexEffectsSkewbCorner()
|
821 |
|
{
|
822 |
|
float E = 0.5f;
|
823 |
|
|
824 |
|
Static3D axisX = new Static3D(1,0,0);
|
825 |
|
Static3D axisY = new Static3D(0,1,0);
|
826 |
|
Static3D axis0 = new Static3D(-SQ2/2,0,SQ2/2);
|
827 |
|
Static3D axis1 = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
|
828 |
|
Static1D angle1 = new Static1D(+90);
|
829 |
|
Static1D angle2 = new Static1D(-90);
|
830 |
|
Static1D angle3 = new Static1D(-15);
|
831 |
|
Static1D angle4 = new Static1D((float)((180.0f/Math.PI)*Math.acos(SQ3/3)));
|
832 |
|
Static1D angle5 = new Static1D(120);
|
833 |
|
Static1D angle6 = new Static1D(240);
|
834 |
|
Static3D center1= new Static3D(0,0,0);
|
835 |
|
Static3D center2= new Static3D(-0.5f,-0.5f,-0.5f);
|
836 |
|
Static3D move1 = new Static3D(-E/4,-E/4,0);
|
837 |
|
Static3D move2 = new Static3D(-0.5f+SQ2/4,-0.5f+SQ6/8,-0.5f);
|
838 |
|
|
839 |
|
VertexEffect[] effect = new VertexEffect[10];
|
840 |
|
|
841 |
|
effect[0] = new VertexEffectMove(move1);
|
842 |
|
effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
|
843 |
|
effect[2] = new VertexEffectRotate(angle1,axisX,center1);
|
844 |
|
effect[3] = new VertexEffectRotate(angle2,axisY,center1);
|
845 |
|
effect[4] = new VertexEffectMove(move2);
|
846 |
|
effect[5] = new VertexEffectRotate(angle1,axisX,center2);
|
847 |
|
effect[6] = new VertexEffectRotate(angle3,axisY,center2);
|
848 |
|
effect[7] = new VertexEffectRotate(angle4,axis0,center2);
|
849 |
|
effect[8] = new VertexEffectRotate(angle5,axis1,center2);
|
850 |
|
effect[9] = new VertexEffectRotate(angle6,axis1,center2);
|
851 |
|
|
852 |
|
effect[0].setMeshAssociation( 7,-1); // meshes 0,1,2
|
853 |
|
effect[1].setMeshAssociation( 6,-1); // meshes 1,2
|
854 |
|
effect[2].setMeshAssociation( 2,-1); // mesh 1
|
855 |
|
effect[3].setMeshAssociation( 4,-1); // mesh 2
|
856 |
|
effect[4].setMeshAssociation(56,-1); // meshes 3,4,5
|
857 |
|
effect[5].setMeshAssociation(56,-1); // meshes 3,4,5
|
858 |
|
effect[6].setMeshAssociation(56,-1); // meshes 3,4,5
|
859 |
|
effect[7].setMeshAssociation(56,-1); // meshes 3,4,5
|
860 |
|
effect[8].setMeshAssociation(16,-1); // mesh 4
|
861 |
|
effect[9].setMeshAssociation(32,-1); // mesh 5
|
862 |
|
|
863 |
|
return effect;
|
864 |
|
}
|
865 |
|
|
866 |
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
867 |
|
|
868 |
|
VertexEffect[] createVertexEffectsSkewbFace()
|
869 |
|
{
|
870 |
|
Static3D center = new Static3D(0,0,0);
|
871 |
|
Static3D axisX = new Static3D(1,0,0);
|
872 |
|
Static3D axisZ = new Static3D(0,0,1);
|
873 |
|
float angle = -(float)((180.0f/Math.PI)*Math.acos(SQ3/3));
|
874 |
|
|
875 |
|
VertexEffect[] effect = new VertexEffect[6];
|
876 |
|
|
877 |
|
effect[0] = new VertexEffectRotate( new Static1D(angle), axisX, center);
|
878 |
|
effect[1] = new VertexEffectRotate( new Static1D( 135), axisZ, center);
|
879 |
|
effect[2] = new VertexEffectRotate( new Static1D( 45), axisZ, center);
|
880 |
|
effect[3] = new VertexEffectRotate( new Static1D( -45), axisZ, center);
|
881 |
|
effect[4] = new VertexEffectRotate( new Static1D( -135), axisZ, center);
|
882 |
|
effect[5] = new VertexEffectMove( new Static3D(0,0,-0.5f) );
|
883 |
|
|
884 |
|
effect[0].setMeshAssociation(30,-1); // meshes 1,2,3,4
|
885 |
|
effect[1].setMeshAssociation( 2,-1); // mesh 1
|
886 |
|
effect[2].setMeshAssociation( 5,-1); // meshes 0,2
|
887 |
|
effect[3].setMeshAssociation( 8,-1); // mesh 3
|
888 |
|
effect[4].setMeshAssociation(16,-1); // mesh 4
|
889 |
|
effect[5].setMeshAssociation(30,-1); // meshes 1,2,3,4
|
890 |
|
|
891 |
|
return effect;
|
892 |
|
}
|
893 |
|
|
894 |
756 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
895 |
757 |
|
896 |
758 |
VertexEffect[] createVertexEffectsHelicopterCorner()
|
... | ... | |
1468 |
1330 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1469 |
1331 |
|
1470 |
1332 |
|
1471 |
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1472 |
|
// SKEWB
|
1473 |
|
|
1474 |
|
public MeshBase createSkewbCornerMesh()
|
1475 |
|
{
|
1476 |
|
MeshBase mesh = createFacesSkewbCorner();
|
1477 |
|
VertexEffect[] effects = createVertexEffectsSkewbCorner();
|
1478 |
|
for( VertexEffect effect : effects ) mesh.apply(effect);
|
1479 |
|
|
1480 |
|
float E = 0.5f;
|
1481 |
|
Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
|
1482 |
|
|
1483 |
|
Static3D[] verticesType1 = new Static3D[1];
|
1484 |
|
verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
|
1485 |
|
roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
|
1486 |
|
|
1487 |
|
Static3D[] verticesType2 = new Static3D[3];
|
1488 |
|
verticesType2[0] = new Static3D(-E, 0, 0);
|
1489 |
|
verticesType2[1] = new Static3D( 0,-E, 0);
|
1490 |
|
verticesType2[2] = new Static3D( 0, 0,-E);
|
1491 |
|
roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
|
1492 |
|
|
1493 |
|
mesh.mergeEffComponents();
|
1494 |
|
|
1495 |
|
return mesh;
|
1496 |
|
}
|
1497 |
|
|
1498 |
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1499 |
|
|
1500 |
|
public MeshBase createSkewbFaceMesh()
|
1501 |
|
{
|
1502 |
|
MeshBase mesh = createFacesSkewbFace();
|
1503 |
|
VertexEffect[] effects = createVertexEffectsSkewbFace();
|
1504 |
|
for( VertexEffect effect : effects ) mesh.apply(effect);
|
1505 |
|
|
1506 |
|
Static3D roundingCenter = new Static3D(0,0,-0.2f);
|
1507 |
|
float E = SQ2/4;
|
1508 |
|
Static3D[] vertices = new Static3D[4];
|
1509 |
|
vertices[0] = new Static3D(-E*SQ2, 0, 0);
|
1510 |
|
vertices[1] = new Static3D(+E*SQ2, 0, 0);
|
1511 |
|
vertices[2] = new Static3D( 0, -E*SQ2, 0);
|
1512 |
|
vertices[3] = new Static3D( 0, +E*SQ2, 0);
|
1513 |
|
roundCorners(mesh,roundingCenter,vertices,0.06f,0.10f);
|
1514 |
|
|
1515 |
|
mesh.mergeEffComponents();
|
1516 |
|
mesh.addEmptyTexComponent();
|
1517 |
|
|
1518 |
|
return mesh;
|
1519 |
|
}
|
1520 |
|
|
1521 |
1333 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1522 |
1334 |
// Helicopter
|
1523 |
1335 |
|
... | ... | |
2367 |
2179 |
staticVert[0] = new Static3D( (float)vertices[v][0], (float)vertices[v][1], (float)vertices[v][2]);
|
2368 |
2180 |
|
2369 |
2181 |
int cent = centerIndexes[v];
|
2370 |
|
center.set( centers[cent][0], centers[cent][1], centers[cent][2]);
|
2371 |
2182 |
|
2372 |
|
int corn = cornerIndexes[v];
|
2373 |
|
float strength = corners[corn][0];
|
2374 |
|
float radius = corners[corn][1];
|
|
2183 |
if( cent>=0 )
|
|
2184 |
{
|
|
2185 |
center.set( centers[cent][0], centers[cent][1], centers[cent][2]);
|
|
2186 |
|
|
2187 |
int corn = cornerIndexes[v];
|
|
2188 |
float strength = corners[corn][0];
|
|
2189 |
float radius = corners[corn][1];
|
2375 |
2190 |
|
2376 |
|
roundCorners(mesh, center, staticVert, strength, radius);
|
|
2191 |
roundCorners(mesh, center, staticVert, strength, radius);
|
|
2192 |
}
|
2377 |
2193 |
}
|
2378 |
2194 |
}
|
2379 |
2195 |
|
Convert the Skewb.