Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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).

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).

enter image description here

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:

  1. A way of smoothing or adjusting the vertices in my current method that would bring all point of a hexagon onto one plane (coplanar).
  2. A better approach to procedural terrain generation that would allow for better control of this sort of thing.
  3. 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).

here

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!

share|improve this question
add comment

1 Answer

Fundamentally, hexagon height fields have the same issue that rectangles do; it's not really possible to ensure that a hexagon/rectangle will be entirely coplanar without putting some heavy restrictions on the possible shapes of the terrain, and on the editing of the terrain. That is, each time you move a single vertex, that change will "ripple out" across the entire map as each hexagon is "re-planarised", which in turn will move the vertices of its adjoining hexagons, which then necessitates those adjoining hexagons to be re-planarised, and so on.

If your goal is really just to have a coplanar area within the hexagon, then you might consider creating a second hexagon inset within each hexagon, with the inner hexagon having its own unique vertices (which we can therefore freely make coplanar without influencing any neighbors), and with a strip of triangles stitching the inner (planar) hexagon to the exterior (non-planar) hexagon. That would let you keep the free-form height field, while also letting you make an absolutely flat area in the middle of each hexagon, if you should wish to.

share|improve this answer
    
Thanks for your suggestion. Having a quick look, I have since found and example I might take a closer look at. Would you say youtube.com/watch?v=z7I0NleCBlU uses a similar technique to that you described? –  henryprescott Dec 22 '12 at 23:36
    
Yeah, it looks like they're using exactly this approach, just using a thin gap between internal and external hexagons. –  Trevor Powell Dec 22 '12 at 23:48
    
Actually, later in the video it becomes obvious that their hexagons aren't actually flat. –  Trevor Powell Dec 22 '12 at 23:56
    
I think it might be an artist generated map, that doesn't really use a grid system, but textured to emphasise hexagon shapes. Nice effect though! –  henryprescott Dec 23 '12 at 0:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.