123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|513|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> On Topic -> Hill Algorithm?!

Fri, 05 Feb 2010, 12:38
The V Man
Afternoon all,

I've been trying to suss out a Hill Algorithm to use for some dynamic terrain.
The idea is that after a number of passes (50 or 200 or so) the hills all blend together and you get some very organic looking terrain, which would be perfect for what I'm doing.

Example here (Circle Based Hills section:
https://www.eecs.tufts.edu/~jlowel01/

Unfortunatly the best tutorial I've found was located here:
www.robot-frog.com/3d/hills/
But it's long offline. The Internet Archive can pull up the pages from mid-2005(ish) though if anyone's interested. It's a great article, though the source code (www.robot-frog.com/3d/hills/HillTerrain.zip) can't be found anywhere on the internet sadly.

So anyway, I'm generating a mesh and have done some random height mapping on it with a 2D array, and that's fine, but I can't figure out how to apply the hill algorithm.

For what it's worth, I'm using Cobra. Working pretty well so far too

Any thoughts?


-=-=-
----------
-V
Fri, 05 Feb 2010, 15:08
Jayenkai
I've not done a whole lot of 3D stuff, but when I did attempt hill stuff I did it on a plain 2D surface as a heightmap, then just loaded that in. Seemed a whole lot easier than trying to mess around with a mesh, plus you can do all your neat smoothing and things whilst it's a bunch of pixels.
Other than that, I'm no expert at this stuff!!

-=-=-
''Load, Next List!''
Fri, 05 Feb 2010, 19:40
The V Man
That's more or less what I'm driving at - the Array is 2D and it stores the height values at each point in the terrain - the trick is using a point in the array and drawing the parabolic shape - not sure how I can approach that just yet. Especially since they can overlap and pile up, for a better effect.

-=-=-
----------
-V
Sat, 06 Feb 2010, 17:39
mindstorm8191
Why don't you try a basic blur algorithm? For each pixel, simply look at each of the surrounding pixels, average their value and apply it to the pixel you're working on. You may want to do this to a new array, instead of the one you're reading.

Not ure if it'll give you what you're after, but its a thought.

-=-=-
Vesuvius web game
Sat, 06 Feb 2010, 20:40
The V Man
Well, trouble with that is I'm not working with pixels in an image - I'll output what I generate to a bitmap for use as a heightmap, but right now all the array values are at 0.

-=-=-
----------
-V
Sat, 06 Feb 2010, 21:41
mindstorm8191
Well, you should remmber, an image is really only a set of arrays, a 2D array for red, for green and for blue. A classic blur routine works on 2D array data, like what you're after. But instead of blurring for each color component, you only have to deal with one array.

This is, of course, assuming you already have some form of height data to play with.

-=-=-
Vesuvius web game
Sun, 07 Feb 2010, 05:59
The V Man
That's where I'm at now - I need to calculate the parabolic height values given a mid-point and radius. I've got a formula, it's the implementation that's got me stuck.

-=-=-
----------
-V
Thu, 11 Feb 2010, 08:15
Erebel55
How's this coming along V Man?
Thu, 11 Feb 2010, 19:53
The V Man
Actually I've made great strides - I've got a hill generating and looking good in wireframe - I just need to add a few checks so I'm only modifying the areas that are affected and not the whole map - right now it takes whatever the last hill was and is setting everything else to 0.

Should have that sorted tomorrow though, and then I'm moving into doing an isolated landmass - then a few more. I'm mulling over the idea of making landmasses into cells that can be drawn in less detail or hidden altogether depending on your distance from them. I'd like to use Cobra's built in terrains, but Graham himself has said that they're very limited in the manipulations you can do to them (and I plan to add rivers and caves and whatnot).

I may decide to go another way though and dump the heightmap to a series of bitmaps, then run the rivers on a separate map (referencing the first), erode the riverbeds and apply the heightmap with the terrain command - then it's pretty much done.

Until I decide to do caves....


-=-=-
----------
-V
Fri, 12 Feb 2010, 13:35
The V Man
Well more progress. Got the check in to have multiple hills - also managed to get things normalizing (if I choose to use that, I may not since it drastically reduces the height of the hills - it'll be perfect for low lands and rolling fields though).

So far the problem is with hills that overlap. Need to figure a way to get the position of the vertex I'm about to modify before changing it as right now hills are getting cut in half if one overlaps another. VertexZ isn't being much help right the moment though...

-=-=-
----------
-V
Tue, 16 Feb 2010, 13:44
The V Man
Well huzzah. Some tinkering has solved the issue.
I also managed to get normalizing and smoothing to function correctly as well. Still tinkering with values to get different types of environments (rolling lowlands, craggy highlands and gentle, subtle plains).

All good so far. Also wrote an exporter to text file so I can view values (and save anything I really like!) - need to write the importer (which will be stupid easy now) so I can reload stuff.

Up next? Well, that would be telling...

-=-=-
----------
-V