New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for hexagonal maps #1

Closed
bjorn opened this Issue Apr 12, 2011 · 27 comments

Comments

Projects
None yet
@bjorn
Owner

bjorn commented Apr 12, 2011

Hopefully using a generic tile-shifting map renderer that could also be used for that kind of isometric maps.

This issue replaces the following issue from the old issue tracker:
http://sourceforge.net/apps/mantisbt/tiled/view.php?id=32

@maq777

This comment has been minimized.

Show comment
Hide comment
@maq777

maq777 Jun 5, 2011

I've made a very basic impl. of a hexagonal renderer. Basic stuff works. Please have a look at it: https://github.com/maq777/tiled and tell me what issues/fixes have the highest priority for an possible inclusion on upstream.

maq777 commented Jun 5, 2011

I've made a very basic impl. of a hexagonal renderer. Basic stuff works. Please have a look at it: https://github.com/maq777/tiled and tell me what issues/fixes have the highest priority for an possible inclusion on upstream.

@LearnCocos2D

This comment has been minimized.

Show comment
Hide comment
@LearnCocos2D

LearnCocos2D Jul 27, 2013

Hex maps have my vote. If I remember correctly hex maps were working some time back (around Tiled 0.5/0.6), at least there was an option for creating them.

Hex maps have my vote. If I remember correctly hex maps were working some time back (around Tiled 0.5/0.6), at least there was an option for creating them.

@bjorn

This comment has been minimized.

Show comment
Hide comment
@bjorn

bjorn Jul 27, 2013

Owner

@LearnCocos2D Hex maps have never worked in Tiled Qt, but there was experimental support for them in the Java version of Tiled.

The reason I've never merged @maq777 patch is mostly because I didn't like the implementation of the rendering, which I think is too inefficient. Of course, I expected to get around to doing a faster renderer sooner rather than later, but this hasn't been the case so far.

Owner

bjorn commented Jul 27, 2013

@LearnCocos2D Hex maps have never worked in Tiled Qt, but there was experimental support for them in the Java version of Tiled.

The reason I've never merged @maq777 patch is mostly because I didn't like the implementation of the rendering, which I think is too inefficient. Of course, I expected to get around to doing a faster renderer sooner rather than later, but this hasn't been the case so far.

@LearnCocos2D

This comment has been minimized.

Show comment
Hide comment
@LearnCocos2D

LearnCocos2D Jul 27, 2013

As long as it works editing hex maps would be great, even if it may be slow or inefficient. You can always optimize or rewrite it at a later time if it's not fundamentally broken or incomplete (ie no select, no tilesets - I have no idea what the hex renderer does and doesn't do).

As long as it works editing hex maps would be great, even if it may be slow or inefficient. You can always optimize or rewrite it at a later time if it's not fundamentally broken or incomplete (ie no select, no tilesets - I have no idea what the hex renderer does and doesn't do).

@maq777

This comment has been minimized.

Show comment
Hide comment
@maq777

maq777 Jul 30, 2013

@LearnCocos2D @bjorn F.Y.I. The impementation I provide is broken. Yes, it needs optimizations. But most of all it needs bug fixes. And the only feasible way to fix the selection problems is a completely new algorithm. I studied and found a new algorithm - unfortunately I didn't have the time to implement it (and now the theory is long forgotten).

maq777 commented Jul 30, 2013

@LearnCocos2D @bjorn F.Y.I. The impementation I provide is broken. Yes, it needs optimizations. But most of all it needs bug fixes. And the only feasible way to fix the selection problems is a completely new algorithm. I studied and found a new algorithm - unfortunately I didn't have the time to implement it (and now the theory is long forgotten).

@bjorn

This comment has been minimized.

Show comment
Hide comment
@bjorn

bjorn Jul 30, 2013

Owner

@maq777 No worries, we're all looking for more time. Yet, maybe @LearnCocos2D is right that it would be better to have an implementation that is not fundamentally broken rather than no implementation at all. On the other hand I've added an incomplete staggered renderer which, even though it's optimized, does not support object layers because I hadn't figured out a good way of handling those yet, and that confuses people... :-/

In any case, my approach would be to tweak the current staggered renderer to also work for hexagonal, since the rendering method is very similar. However, a solution will still need to be found for the object layers. I think the objects should use pixel coordinates for these types of maps and just ignore the projection (since the projection is irregular anyway).

Owner

bjorn commented Jul 30, 2013

@maq777 No worries, we're all looking for more time. Yet, maybe @LearnCocos2D is right that it would be better to have an implementation that is not fundamentally broken rather than no implementation at all. On the other hand I've added an incomplete staggered renderer which, even though it's optimized, does not support object layers because I hadn't figured out a good way of handling those yet, and that confuses people... :-/

In any case, my approach would be to tweak the current staggered renderer to also work for hexagonal, since the rendering method is very similar. However, a solution will still need to be found for the object layers. I think the objects should use pixel coordinates for these types of maps and just ignore the projection (since the projection is irregular anyway).

@nalmeth

This comment has been minimized.

Show comment
Hide comment
@nalmeth

nalmeth Jul 31, 2013

I would love to have Tiled support hexes. Many other applications I've looked into that support them are old and/or terrible. Please make this feature a priority. Thanks for your work so far.

nalmeth commented Jul 31, 2013

I would love to have Tiled support hexes. Many other applications I've looked into that support them are old and/or terrible. Please make this feature a priority. Thanks for your work so far.

@Goutte

This comment has been minimized.

Show comment
Hide comment
@Goutte

Goutte Aug 2, 2013

I love that this is the first issue !
This is something that would make me find a use for tiled ! (i got no time to pitch in right now, though)

In case some of you don't know about this yet, here's the new reference for hexagonal tiling : http://www.redblobgames.com/grids/hexagons/

The barycentric coordinates system is the way to go !

Goutte commented Aug 2, 2013

I love that this is the first issue !
This is something that would make me find a use for tiled ! (i got no time to pitch in right now, though)

In case some of you don't know about this yet, here's the new reference for hexagonal tiling : http://www.redblobgames.com/grids/hexagons/

The barycentric coordinates system is the way to go !

@bjorn

This comment has been minimized.

Show comment
Hide comment
@bjorn

bjorn Aug 4, 2013

Owner

@Goutte Thanks a lot for linking that article, it's very useful! However, the article does not mention a "barycentric coordinates sytem". Is it mentioned under a different name? The article actually recommends its "axial coordinates", which seem to make sense to me.

However, if any such alternative coordinate systems are to be supported it needs to be done in addition to supporting the "offset" coordinates, since that is the system supported by the old Tiled Java and is what cocos2d-iphone supports.

Owner

bjorn commented Aug 4, 2013

@Goutte Thanks a lot for linking that article, it's very useful! However, the article does not mention a "barycentric coordinates sytem". Is it mentioned under a different name? The article actually recommends its "axial coordinates", which seem to make sense to me.

However, if any such alternative coordinate systems are to be supported it needs to be done in addition to supporting the "offset" coordinates, since that is the system supported by the old Tiled Java and is what cocos2d-iphone supports.

@Goutte

This comment has been minimized.

Show comment
Hide comment
@Goutte

Goutte Aug 5, 2013

Axial coordinates is just another name for barycentric coordinates, AFAIK.
Offset coordinates are really painful to work with in hex grids, trust me. Should be fairly easy to convert from axial to offset once the hard calculus is done, though.

Goutte commented Aug 5, 2013

Axial coordinates is just another name for barycentric coordinates, AFAIK.
Offset coordinates are really painful to work with in hex grids, trust me. Should be fairly easy to convert from axial to offset once the hard calculus is done, though.

@bjorn

This comment has been minimized.

Show comment
Hide comment
@bjorn

bjorn Aug 5, 2013

Owner

Well, I know offset coordinates and am familiar with the issues it causes with the editing tools in Tiled. However, as I said this mode needs to be supported for backwards compatibility. Of course it would be nice to support axial coordinates as well, and it looks like this system will work better with the existing tools. Though, I'm sure it will also need changes to things like line and circle drawing and of course the terrain tool, in order to work perfectly.

Owner

bjorn commented Aug 5, 2013

Well, I know offset coordinates and am familiar with the issues it causes with the editing tools in Tiled. However, as I said this mode needs to be supported for backwards compatibility. Of course it would be nice to support axial coordinates as well, and it looks like this system will work better with the existing tools. Though, I'm sure it will also need changes to things like line and circle drawing and of course the terrain tool, in order to work perfectly.

@bjorn

This comment has been minimized.

Show comment
Hide comment
@bjorn

bjorn Oct 31, 2013

Owner

For reference here are the forks I'm aware of that merged @maq777 hexagonal renderer with more recent versions of Tiled:

@evant took that version and merged Tiled 0.6, 0.7, 0.8 and 0.9 into it:

https://github.com/evant/tiled/branches/hex

And here's another version by @chedburgh that rebased the commits on top of a more recent version of Tiled:

https://github.com/chedburgh/tiled/commits/master

Owner

bjorn commented Oct 31, 2013

For reference here are the forks I'm aware of that merged @maq777 hexagonal renderer with more recent versions of Tiled:

@evant took that version and merged Tiled 0.6, 0.7, 0.8 and 0.9 into it:

https://github.com/evant/tiled/branches/hex

And here's another version by @chedburgh that rebased the commits on top of a more recent version of Tiled:

https://github.com/chedburgh/tiled/commits/master

@go3k

This comment has been minimized.

Show comment
Hide comment
@go3k

go3k Nov 6, 2013

I find a alternative way to build a hexagonal map using tiled map editor without any changes, my own practice is:

  1. My hexagon tile size is 128 * 64
  2. New map, set the tile size to 32 * 32
  3. New tileset, set the tile size to 128 * 64
  4. That's all, “This tile editor is wonderful!”

map screen shoot:
tilemap

I create a test repo, hextiletest

go3k commented Nov 6, 2013

I find a alternative way to build a hexagonal map using tiled map editor without any changes, my own practice is:

  1. My hexagon tile size is 128 * 64
  2. New map, set the tile size to 32 * 32
  3. New tileset, set the tile size to 128 * 64
  4. That's all, “This tile editor is wonderful!”

map screen shoot:
tilemap

I create a test repo, hextiletest

@bjorn

This comment has been minimized.

Show comment
Hide comment
@bjorn

bjorn Nov 6, 2013

Owner

@go3k Ah, that's creative!

Owner

bjorn commented Nov 6, 2013

@go3k Ah, that's creative!

@cristaloleg

This comment has been minimized.

Show comment
Hide comment
@cristaloleg

cristaloleg Nov 10, 2013

@go3k looks cool, but this is hack. i think users needs real support for hextiles

@go3k looks cool, but this is hack. i think users needs real support for hextiles

@Mungoid

This comment has been minimized.

Show comment
Hide comment
@Mungoid

Mungoid Nov 20, 2013

@Goutte - Thats a fantastic link! I originally wanted to use tiled for my map but i just decided to roll my own in 3d and that link provides a great amount of detail! Definitely helped me figure out some aspects of hex tiling =-D

Mungoid commented Nov 20, 2013

@Goutte - Thats a fantastic link! I originally wanted to use tiled for my map but i just decided to roll my own in 3d and that link provides a great amount of detail! Definitely helped me figure out some aspects of hex tiling =-D

@anissen

This comment has been minimized.

Show comment
Hide comment
@anissen

anissen Sep 9, 2014

Any update on this issue?

anissen commented Sep 9, 2014

Any update on this issue?

@bjorn

This comment has been minimized.

Show comment
Hide comment
@bjorn

bjorn Sep 9, 2014

Owner

@anissen Nope, sorry. I've been trying to focus on getting a Tiled 0.10 release out for the past weeks. It has such a huge amount of new features that I don't really want to delay it further... on the other hand this is one of the main features still missing to make Tiled more complete. :-/

Owner

bjorn commented Sep 9, 2014

@anissen Nope, sorry. I've been trying to focus on getting a Tiled 0.10 release out for the past weeks. It has such a huge amount of new features that I don't really want to delay it further... on the other hand this is one of the main features still missing to make Tiled more complete. :-/

@anissen

This comment has been minimized.

Show comment
Hide comment
@anissen

anissen Sep 9, 2014

Thanks for your reply. It's perfectly understandable that you want to focus on finishing 0.10. I'm looking forward to it 👍
That being said, there's clearly a big interest in having hexagonal support in a future version of Tiled. Keep up the good work.

anissen commented Sep 9, 2014

Thanks for your reply. It's perfectly understandable that you want to focus on finishing 0.10. I'm looking forward to it 👍
That being said, there's clearly a big interest in having hexagonal support in a future version of Tiled. Keep up the good work.

@tr37ion

This comment has been minimized.

Show comment
Hide comment
@tr37ion

tr37ion Sep 23, 2014

@bjorn Great to hear you are about to finish 0.10. I hope, you find the time to add hexagonal tiles later on. I guess, implementing hexagonal tiles is quite complicated, because those tiles can be asymmetric of width and hight. Beginning with evenly sized hexagonal tiles would be a great start.

tr37ion commented Sep 23, 2014

@bjorn Great to hear you are about to finish 0.10. I hope, you find the time to add hexagonal tiles later on. I guess, implementing hexagonal tiles is quite complicated, because those tiles can be asymmetric of width and hight. Beginning with evenly sized hexagonal tiles would be a great start.

@bjorn

This comment has been minimized.

Show comment
Hide comment
@bjorn

bjorn Sep 23, 2014

Owner

@tr37ion Actually 0.10 is out since a week now!

As for hexagonal, I don't think the tile sizes will be problematic, it's more that hex needs additional rendering parameters. But maybe I will just support one variation at first.

Owner

bjorn commented Sep 23, 2014

@tr37ion Actually 0.10 is out since a week now!

As for hexagonal, I don't think the tile sizes will be problematic, it's more that hex needs additional rendering parameters. But maybe I will just support one variation at first.

@gregorth

This comment has been minimized.

Show comment
Hide comment
@gregorth

gregorth Sep 30, 2014

+1 about priority of that feature.

+1 about priority of that feature.

@pgolebiowski

This comment has been minimized.

Show comment
Hide comment
@pgolebiowski

pgolebiowski Oct 3, 2014

+2 about priority of that feature. One from me and another from a friend of mine :)

+2 about priority of that feature. One from me and another from a friend of mine :)

@bjorn bjorn self-assigned this Oct 5, 2014

@BenjaminFarris

This comment has been minimized.

Show comment
Hide comment
@BenjaminFarris

BenjaminFarris Oct 7, 2014

+1 priority. Also I might have some time to help out . ping me if you'd like the help

+1 priority. Also I might have some time to help out . ping me if you'd like the help

@bjorn

This comment has been minimized.

Show comment
Hide comment
@bjorn

bjorn Oct 7, 2014

Owner

@BenjaminFarris Thanks for the offer but I'm currently unsure what to ask help with. For me it's currently mainly a problem of getting around to it. In fact somebody has offered to sponsor this feature a few days ago, making it the first thing on my list. I will try to get this done in the next week.

Once in there will be hex-specific improvements that could be made to the tools. Things like line drawing, copying regions or the fill tool do not work correctly on staggered maps currently.

Owner

bjorn commented Oct 7, 2014

@BenjaminFarris Thanks for the offer but I'm currently unsure what to ask help with. For me it's currently mainly a problem of getting around to it. In fact somebody has offered to sponsor this feature a few days ago, making it the first thing on my list. I will try to get this done in the next week.

Once in there will be hex-specific improvements that could be made to the tools. Things like line drawing, copying regions or the fill tool do not work correctly on staggered maps currently.

@bjorn

This comment has been minimized.

Show comment
Hide comment
@bjorn

bjorn Oct 15, 2014

Owner

I've recently pushed my work on hexagonal map support to master so the daily builds include support for this now, at least two variations of "pointy top" hexagonal. Give it a try!

One caveat is that currently a new hexagonal map will start out looking pretty much the same as staggered isometric. It is only after you increase the "Tile Side Length" in the map properties that it will start to appear hexagonal (since by default the length of the side is 0).

I hope to get around to adding support "flat top" hexagonal later this week, and I'm also considering to add support for "hexagonal isometric", which would be a variation of the isometric renderer but with a hexagonal grid.

Owner

bjorn commented Oct 15, 2014

I've recently pushed my work on hexagonal map support to master so the daily builds include support for this now, at least two variations of "pointy top" hexagonal. Give it a try!

One caveat is that currently a new hexagonal map will start out looking pretty much the same as staggered isometric. It is only after you increase the "Tile Side Length" in the map properties that it will start to appear hexagonal (since by default the length of the side is 0).

I hope to get around to adding support "flat top" hexagonal later this week, and I'm also considering to add support for "hexagonal isometric", which would be a variation of the isometric renderer but with a hexagonal grid.

@bjorn

This comment has been minimized.

Show comment
Hide comment
@bjorn

bjorn Nov 6, 2014

Owner

Adding support for "flat top" hexagonal took way longer than I had anticipated. The main issue with it was that it meant staggering the X axis, which required a rather different way of rendering to keep the tiles in the correct order. I also did not find a nice way to share code like grid drawing, layer bounding boxes and converting screen position to tile position. But, it's now finally done and pushed as 915fd32.

So, there is no support for "hexagonal isometric" yet, which I still hope to add later, but I consider this issue closed. The one problem with having to discover the "tile side length" property in the Map properties also remains, but I'll try to solve that later as well. Finally I'll also have to update the documentation about the new properties and how they affect the rendering.

Owner

bjorn commented Nov 6, 2014

Adding support for "flat top" hexagonal took way longer than I had anticipated. The main issue with it was that it meant staggering the X axis, which required a rather different way of rendering to keep the tiles in the correct order. I also did not find a nice way to share code like grid drawing, layer bounding boxes and converting screen position to tile position. But, it's now finally done and pushed as 915fd32.

So, there is no support for "hexagonal isometric" yet, which I still hope to add later, but I consider this issue closed. The one problem with having to discover the "tile side length" property in the Map properties also remains, but I'll try to solve that later as well. Finally I'll also have to update the documentation about the new properties and how they affect the rendering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment