Space is full of rocks. Well that is false but to make any Second Anterean War (2aw) battle field interesting - one needs rocks. I need rocks to add strategic as well as just be interesting to look at.
I have though hard about rocks. I have a limited amount of art assets to work with. Making rocks are boring too, so my 3D artists did not make all that good looking ones.
So any art time I use should be put to good use like making awesome ships ( Aff2aw.com ). So I am stuck with doing auto generating rocks - which sound doable.
I want to first focus on the shape of the rock. For its the first thing players would see the shape of the rock must be interesting first. I will discuss my texture findings in another post. Most common way to make a rocks shape is to extruding it from a spheres yet that just does not make rocks that look all that nice. The main reason is that spheres can't have caves and holes. The triangle density is different from the inner parts. This appears to be true if you start for uv-sphere, iso-Sphere or the cube grid sphere.
In the quest for the best rock shape, I went to the next best thing - marching cubes. Marching-Cubes ( En.wikipedia.org ) is an algorithm to convert a 3D math density function into a triangle based 3D model. So basically I come with math function and then wrap it with triangles. Marching cubes allow me to make much more interesting formations.
To bone looking:
I can generate infinite number of those rocks using random noise. After I generate a rock I sort it based on the number of triangles and scale. This gives me group of small, medium and large rocks. I combine the small rocks into rock groups. Then I can place large, medium and small rocks groups on the map.
The rocks generated are efficient in their triangle counts. In computer graphics we need to show the lowest triangle count but still make it look good.
This is how filled rock looks like.
This is a wire frame of the same rock. You can see the 3D grid of the underlying marching cubes algorithm. Marching cubes work by basically walking each cube of space and figuring out which of the 15 unique cube configurations fit it. After that it does some smoothing between the cubes.
How do you think I could improve rock generation? (not music)