Skip to content
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
Closed

Add support for hexagonal maps #1

bjorn opened this issue Apr 12, 2011 · 27 comments
Assignees
Labels
missing feature It's not just a feature, it's a feature that really should be there!
Milestone

Comments

@bjorn
Copy link
Member

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
Copy link

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
Copy link

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
Copy link
Member Author

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
Copy link

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
Copy link

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
Copy link
Member Author

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
Copy link

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
Copy link

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
Copy link
Member Author

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
Copy link

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
Copy link
Member Author

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
Copy link
Member Author

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
Copy link

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
Copy link
Member Author

bjorn commented Nov 6, 2013

@go3k Ah, that's creative!

@cristaloleg
Copy link

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

@Mungoid
Copy link

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
Copy link

anissen commented Sep 9, 2014

Any update on this issue?

@bjorn
Copy link
Member Author

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
Copy link

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
Copy link

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
Copy link
Member Author

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
Copy link

+1 about priority of that feature.

@pgolebiowski
Copy link

+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
Copy link

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

@bjorn
Copy link
Member Author

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
Copy link
Member Author

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
Copy link
Member Author

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
Labels
missing feature It's not just a feature, it's a feature that really should be there!
Projects
None yet
Development

No branches or pull requests