Marching cubes algorithm + gravitational attraction
Read more here