Jump to content
  • Advertisement
Bow_vernon

Random terrain generation with fixed elevation

Recommended Posts

Hi folks, a fellow gamedev here.

 

So recently I've been trying to make a business simulation games (similar to Holiday Island or Sim City), and start moving on the vital element of the game: terrain generation and manipulation. The terrain is a simple heightmap with a randomly generated height values (I haven't implemented the random generation part, cause of this issue I'm talking about). Basically, in my game the terrain has to have fixed elevation, so when you compare a terrain vertex to its neighbors, they could either:

  • have similar height
  • have a 0.5m height difference (higher or lower). It must not have more than 0.5m difference.

I need to do that to simplify the terrain manipulation (the game kinda heavily relies on it). I was thinking on simply generate the random height first, and then loop over every vertex to force its offending neighbors to lower/heighten itself accordingly. But alas it just doesn't seem to be the right way. Perhaps any of you ever done similar things in the past? I hope you could give me any advice on this matter. It's been boggling my mind. 

basically this is the game that inspires me.

program188-1.jpg

Share this post


Link to post
Share on other sites
Advertisement

Midpoint displacement, also called the diamond-square algorithm, is trivially modified to handle that type of thing where you have zones with mandatory heights.

There are more complex algorithms out there which produce more pleasing results, but that one is easy to implement, was used in a bunch of older games, and with a bit of tuning can produce exactly the terrain grids you described.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!