Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Tweaking Heightmap Generation For Hexagon Grids


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Total_Titillation   Members   -  Reputation: 158

Like
0Likes
Like

Posted 22 December 2012 - 04:20 PM

Currently I'm working on a little project just for a bit of fun. It is a C++, WinAPI application using OpenGL.

I hope it will turn into a RTS Game played on a hexagon grid and when I get the basic game engine done, I have plans to expand it further.
At the moment my application consists of a VBO that holds vertex and heightmap information. The heightmap is generated using a midpoint displacement algorithm (diamond-square).

In order to implement a hexagon grid I went with the idea explained here. It shifts down odd rows of a normal grid to allow relatively easy rendering of hexagons without too many further complications (I hope).

hex_grid4.jpg

Allows for:

hex_grid5.jpg

After a few days it is beginning to come together and I've added mouse picking, which is implemented by rendering each hex in the grid in a unique colour, and then sampling a given mouse position within this FBO to identify the ID of the selected cell (visible in the top right of the screenshot below).

gVXMe.png

In the next stage of my project I would like to look at generating more 'playable' terrains. To me this means that the shape of each hexagon should be more regular than those seen in the image above.
So finally coming to my point, is there:
  • A way of smoothing or adjusting the vertices in my current method that would bring all point of a hexagon onto one plane (coplanar).
  • A better approach to procedural terrain generation that would allow for better control of this sort of thing.
  • A way to represent my vertex information in a different way that allows for this.
To be clear, I am not trying to achieve a flat hex grid with raised edges or platforms (as seen below).

11uBD.jpg

I would like all the geometry to join and lead into the next bit.

I'm hope to achieve something similar to what I have now (relatively nice undulating hills & terrain) but with more controllable plateaus. This gives me the flexibility of cording off areas (unplayable tiles) later on, where I can add higher detail meshes if needed.

Any feedback is welcome, I'm using this as a learning exercise so please - all comments welcome!

Edited by Total_Titillation, 22 December 2012 - 04:22 PM.


Sponsor:

#2 JTippetts   Moderators   -  Reputation: 8598

Like
0Likes
Like

Posted 22 December 2012 - 09:54 PM

You won't be able to do vertical faces like that with a heightmap. If you want vertical faces, you'd be better off just going with simple hex meshes with a top face and a skirt (the vertical faces).



#3 radioteeth   Prime Members   -  Reputation: 1106

Like
0Likes
Like

Posted 22 December 2012 - 11:20 PM

He said that he's *not* trying to produce sides on the hexies.

 

I'm not sure that what you're trying to do is entirely possible - because if you force one hex to be 'flat' so that all its verts are coplanar, then the surrounding hexies which share more than one vertex will have very few options for being on different planes. It seems like somehow it can be done, but the variety of geometry won't be very awesome.

 

I think the best choice would be to make the center vertex of each hex as 'centered' as possible - averaging the surrounding verts to produce its vertical position. But making them literally flat/coplanar would be hard what-with the neighboring hexies connected to it, which the flat rule would have to somehow apply to as well.

 

Very nice work thus far, interesting :)



#4 Total_Titillation   Members   -  Reputation: 158

Like
0Likes
Like

Posted 23 December 2012 - 11:06 AM

Thanks for your suggestions.

 

Could you by any chance, point me in the direction of some material that explains or at least a phrase to search for.

 

Thanks!



#5 JTippetts   Moderators   -  Reputation: 8598

Like
0Likes
Like

Posted 23 December 2012 - 11:59 AM

He said that he's *not* trying to produce sides on the hexies.

 

I'm not sure that what you're trying to do is entirely possible - because if you force one hex to be 'flat' so that all its verts are coplanar, then the surrounding hexies which share more than one vertex will have very few options for being on different planes. It seems like somehow it can be done, but the variety of geometry won't be very awesome.

 

I think the best choice would be to make the center vertex of each hex as 'centered' as possible - averaging the surrounding verts to produce its vertical position. But making them literally flat/coplanar would be hard what-with the neighboring hexies connected to it, which the flat rule would have to somehow apply to as well.

 

Very nice work thus far, interesting smile.png

 

Ah, sorry, I missed that. Typically when someone posts an image, they are showing what they want to do, not what they don't want to do.

 

Still, what I said stands, as you stated. With a heightmap, there are always going to be some slopes, as long as some hexes are raised and some are lowered. The hexes "in between" will be ugly. I still stand with my assertion that the best bet would be to ditch the heightmap and just use straight meshes.

 

Edit: Reading the OP more closely, I'm not sure there really is a way to do what you want. It seems like you don't really have a clear vision of what you want. It might help if you somehow manually constructed a mock-up of what you have in mind, since that might help you to visualize solutions to how to implement it.

 

If you are wanting to have a mix of rolling height-map terrain and cliffs both, then typically this is implemented using a combination of height-map for the rolling terrain, and meshes for the cliffs that are placed on the terrain to cover the "ugly" hexes where hexes slope from high to low.


Edited by JTippetts, 23 December 2012 - 12:03 PM.


#6 Total_Titillation   Members   -  Reputation: 158

Like
0Likes
Like

Posted 23 December 2012 - 12:55 PM

He said that he's *not* trying to produce sides on the hexies.
 
I'm not sure that what you're trying to do is entirely possible - because if you force one hex to be 'flat' so that all its verts are coplanar, then the surrounding hexies which share more than one vertex will have very few options for being on different planes. It seems like somehow it can be done, but the variety of geometry won't be very awesome.
 
I think the best choice would be to make the center vertex of each hex as 'centered' as possible - averaging the surrounding verts to produce its vertical position. But making them literally flat/coplanar would be hard what-with the neighboring hexies connected to it, which the flat rule would have to somehow apply to as well.
 
Very nice work thus far, interesting smile.png

 
Ah, sorry, I missed that. Typically when someone posts an image, they are showing what they want to do, not what they don't want to do.
 
Still, what I said stands, as you stated. With a heightmap, there are always going to be some slopes, as long as some hexes are raised and some are lowered. The hexes "in between" will be ugly. I still stand with my assertion that the best bet would be to ditch the heightmap and just use straight meshes.
 
Edit: Reading the OP more closely, I'm not sure there really is a way to do what you want. It seems like you don't really have a clear vision of what you want. It might help if you somehow manually constructed a mock-up of what you have in mind, since that might help you to visualize solutions to how to implement it.
 
If you are wanting to have a mix of rolling height-map terrain and cliffs both, then typically this is implemented using a combination of height-map for the rolling terrain, and meshes for the cliffs that are placed on the terrain to cover the "ugly" hexes where hexes slope from high to low.

 
 
Thanks, I think you're right.  I'm going to do a bit more reading, turn my application into a more flexible level editor and implement a few different approaches.
 
One thing I have come accross is Spinodal Decomposition on a Hexagonal Lattice. Which looks interesting and I have since found a few papers that explain plenty of interesting procedural techniques, This one in particular.
 






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS