Jump to content
  • Advertisement
Sign in to follow this  
brandonman

Diamond Square

This topic is 3921 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've done on and off atempts at fractal terrain and just CAN'T get it. I understand the concept, just can't implement it, especially figuring out how to move on to another iteration. Could someone give me some basic code or an example to build off? I just cant get it, even after at least a few months researching it. I'm sure it's something really simple I just don't see, but please help. Thanks! -Regards, Brandonman

Share this post


Link to post
Share on other sites
Advertisement
Well there are numerous approaches to fractal terrain that you can take... One can make a true fractal noise (eg perlin) to generate a terrain directly or iterate an initial mesh to produce a terrain. A Fractal noise can produce an infinite terrain whereas an iteration produces a finite one. The easiest iteration I have used is as follows:
1. Pick a point at random on the terrain you're generating
2. Make a random vector
3. For each terrain node, dot product the random vector with the vector from the randomly chosen point to that node.
3.a If it's positive, raise that node by some set ammount
3.b otherwise lower that node by a set amount
4. Goto 1 until you are happy with the terrain
5. Possibly normalise, smooth, apply curves, contrast, offset etc as a post process.

This is very simple mathematically and can also be programmed efficiently. The size of terrain required and efficiency of the algorithms (your implementation of this vs fractal noise) determine how large your required terrain should be before the fractal noise becomes a better option. Neither are that complex and I'm sure you can find information about both with a bit of searching.
Good luck,

Dan

Share this post


Link to post
Share on other sites
Now that I'm thinking, random terain wouldn't be very useful in a fps/rpg game... Be impossible to have cities. So, how can I do heightmaps? I understand you load the pixels into a 2d array, but how?

Share this post


Link to post
Share on other sites
You can have cities, you just need to apply a "flatening" algorithm to the heightfield after the noise is finished. Build up your city building by building, "flatening" the ground along the way to build the foundations. The foundations only need to be level individually, there's nothing stopping you from building a city on a huge slope. Then you could have sloping streets, too, which open up interesting possibilities for FPS especially (use height advantage to throw your grenade effectively further than your opponents).

Of course, this is a whole level of complexity you might not want to wrestle with if you're having problems with the basic noise terrain.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!