Mission generation

One of the features of the first content update are generated missions.

First we need a randomly generated terrain and stuff.
The following is a simple but surprisingly effective way to do that.

To make thinks easy we don’t generate the isles itself. Instead we use predefined poly templates that are just rotated and positioned like the following:

Now the terrain generation is easy. The nearer a vertex of the terrain to a polygon the higher it is. If it is inside of a polygon it has to be above the water.
Mixing this with a height map created with this approach will create the following result:

The create the grass I defined several heights were they have to be blend in. So for example everything above the height 2 is covered with light grass and everything above height 4 is covered with dark grass.

Now we need trees. To do that a method will iterate over every vertex of the scenery. If the vertex is above the water a random float generator will decide if there’s a tree.
At last we need water and a sky.

Tadaa:

edit: to create smooth islands that don’t have hard edges I smoothed the polygons a little with a bezier curve. The rest is done by the random height map that is multiplied on the island height map.

One problem of this solution is that after the random height map is added to the scene some of the polygons that are used for collision detection will have bad results as there’s no more island where they will detect a collision.

Currently I don’t know how to deal with that. If somebody has an idea feel free to tell me.^^

3 Likes

Just have the random heightmap not take anything above or below the waterline…

That’s awesome @ceiphren

what if you generate a collision mesh from the resulting terrain?

can i see your code?