Open Beast96GT opened 12 years ago
I think this should be done in the software that uses the map, i.e. if you're making an OpenGL game, have your OpenGL loader adjust the coordinates accordingly. I don't see a need for the GUI and all other loaders to support a feature like that.
I guess it may still be confusing to see different coordinates in Tiled than in the game. So, when such a feature would be implemented in Tiled, it would have to be purely a presentation thing and not something that affects any internal data structures or the map format.
In that case, also consider offsets. Maps in my game are chunks of a large world, so (0, 0) in a map might translate to (256, 512) in the game.
You're right. I currently modify the coordinates for my game.. however, I would argue the benefit of such a feature would make things more clear during placement, and at almost no cost. I vote implement. :)
=Chris
On Tue, Aug 14, 2012 at 11:38 AM, Petr Viktorin notifications@github.comwrote:
In that case, also consider offsets. Maps in my game are chunks of a large world, so (0, 0) in a map might translate to (256, 512) in the game.
— Reply to this email directly or view it on GitHubhttps://github.com/bjorn/tiled/issues/249#issuecomment-7731675.
I think this is a good idea, rather than having to adjust the code in game it would make more sense just to have an option here. Then you wouldn't need to make boilerplate code just to invert the access in game for every object.
Just wondering if this is a dead feature request or if it's been moved somewhere else. And just to be clear, is this feature about changing the status bar display?
So for instance in the above picture you'd have an option to display 0, 0 instead of 0, 15.
Just wondering if this is a dead feature request or if it's been moved somewhere else. And just to be clear, is this feature about changing the status bar display?
This issue represents the most up-to-date state. After a short discussion there was a general agreement that it would be nice for Tiled to support this (indeed affecting the status bar display only), but so far no work has been done on it. It's not dead because it's still open for implementation.
I'm thinking about forking and adding this feature but I'm not sure if it should just be a checkbox to invert or something more complicated as suggested above.
I think that the best solution would be a pop-up on the status bar that lets you set an offset (x, y). So for instance if you have a 16x16 and you want the bottom left to be (0, 0) you'd set an offset of (0, -16).
If that sounds unreasonable let me know, or if you had a different idea. :smile:
Offsets are a more advanced feature, the main thing here is Y flipping (in Tiled the Y coordinate grows down, in OpenGL it traditionally grows up). You can do that with a checkbox, plus some attribute saved in the map file. If you do that, adding e.g. X flipping and X/Y offsets should be straightforward.
It seems to me that if you just add an offset you wouldn't need to flip it. X flipped would simply be setting an offset of your maps width. Unless displaying negative numbers is unacceptable, I think it would be a viable solution.
Though I guess that it might not be immediately obvious to set the offset to your maps width or height in order to get the inverted values.
I originally requested this feature because I use openGL coordinates to correlate to map tiles (as Petr said). However, it makes the entire process more tedious for visualizing placement and debugging in general when you have to flip the Y coordinates. Which checkbox are you talking about? I'd still really like to see this feature implemented if it's not.
Chris Long
On Thu, Oct 30, 2014 at 9:03 AM, Petr Viktorin notifications@github.com wrote:
Offsets are a more advanced feature, the main thing here is Y flipping (in Tiled the Y coordinate grows down, in OpenGL it traditionally grows up). You can do that with a checkbox, plus some attribute saved in the map file. If you do that, adding e.g. X flipping and X/Y offsets should be straightforward.
— Reply to this email directly or view it on GitHub https://github.com/bjorn/tiled/issues/249#issuecomment-61095951.
Which checkbox are you talking about?
@Beast96GT I'm talking about adding a check box (perhaps on the statusbar) that inverts y when ticked. Which was the original suggestion as far as I can tell, but other suggestions have been made since which I wanted to consider before I did any work.
If you can do that, it would be awesome. I would think it would be trivial to implement, but I haven't looked at the source...
On Thu, Oct 30, 2014 at 10:00 AM, Graham Hughes notifications@github.com wrote:
Which checkbox are you talking about?
@Beast96GT https://github.com/Beast96GT I'm talking about adding a check box (perhaps on the statusbar) that inverts y when ticked. Which was the original suggestion as far as I can tell, but other suggestions have been made since which I wanted to consider before I did any work.
— Reply to this email directly or view it on GitHub https://github.com/bjorn/tiled/issues/249#issuecomment-61106189.
Unfortunately adding a checkbox on the actual status bar is not something I can accept in general, because it would add visual noise for the majority of people who have no need for this feature. I think it would be fine as a checkbox in the Preferences dialog, though.
Sure. It should be in the general preferences as once it's set, you're probably not going to change it again. Let me know if you go through with it!
On Thu, Oct 30, 2014 at 4:44 PM, Thorbjørn Lindeijer < notifications@github.com> wrote:
Unfortunately adding a checkbox on the actual status bar is not something I can accept in general, because it would add visual noise for the majority of people who have no need for this feature. I think it would be fine as a checkbox in the Preferences dialog, though.
— Reply to this email directly or view it on GitHub https://github.com/bjorn/tiled/issues/249#issuecomment-61174876.
I'm much in favor of this feature request! :)
Also requested on the forum.
This feature would be very helpful.
I think this is a good idea, rather than having to adjust the code in game it would make more sense just to have an option here. Then you wouldn't need to make boilerplate code just to invert the access in game for every object.
@davos555 I realize I'm a bit late with this reply, but I just thought I'd point out that I see this option as only a display option in Tiled. It would not affect the actual coordinates stored in a TMX file. So if you want to use the inverted coordinates in your game, you'll still have to invert them while or after loading the map. That is because if the TMX format would support storing inverted coordinates, then every loader out there would suddenly need to add such conversion code.
@bjorn Why can't this conversion be applied transparently during the save process so that loaders do not have to do anything at all?.. Aren't coords actually saved?
That's a sound idea, but the most important part for me is changing the y coordinate in the status bar. It's much easier to implement.
On Nov 28, 2016 3:19 PM, "Igor Savin" notifications@github.com wrote:
@bjorn https://github.com/bjorn Why can't this conversion be applied transparently during the save process so that loaders do not have to do anything at all?.. Aren't coords actually saved?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/bjorn/tiled/issues/249#issuecomment-263412878, or mute the thread https://github.com/notifications/unsubscribe-auth/AMVB7u0ZZDuKkb7EGY-0oCzmDi7l3ZFqks5rC1OJgaJpZM4AFnjd .
@bjorn Why can't this conversion be applied transparently during the save process so that loaders do not have to do anything at all?.. Aren't coords actually saved?
@kibertoad There are many loaders either integrated into various game development frameworks or provided by 3rd parties, that both read the map file and render the map. When an option to invert the Y axis in the TMX file is introduced, then in order to render the map correctly, they would all need to be aware of this option and invert the Y axis when appropriate while rendering.
I think it is better to keep a particular coordinate system on the file format level so that we are all on the same page. At the same time, I understand that some people are working with their coordinates inverted, and that it could help if Tiled could display them as such.
@ShipshapeDetour In addition to the status bar I think it'll need to affect the Properties view as well, but still you're right that this is less work than changing the interpretation of the data.
@bjorn Yes, if this is implemented as "invertCoords = true" parameter. What I mean by "transparently" is that if "invertCoords = true" is set, then on saving map Tiled will replace "X=1, Y=1" with "X=1, Y=100", and on loading (through Tiled) swap it all back.
Any news on this feature? Would the option also affect x and y coordinates in Python export plugins?
@viking This is currently not one of my priorities, though I think it would be a good issue for somebody new to Tiled development to look into, so I've now tagged it as such.
To avoid making the map format more complex, it is planned to only affect the display of coordinates in Tiled. So it would not affect Python export plugins.
I'm interested in trying to implement this feature. Just to be clear all that needs to be done is add a check box in the settings to flip the y coordinates of tiles that is being displayed in the status bar right? Nothing else involving actually saving the maps or modifying the properties view as mentioned above? I'm confident i can do that, but this is my first time contributing so any pointers would be greatly apreciated. :)
Just to be clear all that needs to be done is add a check box in the settings to flip the y coordinates of tiles that is being displayed in the status bar right? Nothing else involving actually saving the maps or modifying the properties view as mentioned above?
Almost. Note that the status bar is not the only place where coordinates are displayed. And it does also affect the Properties view, since the flipping should probably be applied to both tile coordinates and the object coordinates:
Object coordinates are also displayed (optionally) in the Objects view. It's a column you can enable by right-clicking on the header. So the flipping needs to be supported also by the MapObjectModel
.
Object coordinates are editable in the Properties view. In this case, the flipping needs to happen before setting the value of the property and when applying changes the user made using this control (in reverse). This is the PropertyBrowser
.
Thanks for working on this, @divitto, and feel free to ask any additional questions!
I've been looking over the source code in my spare time the last few days. I think it would help me a lot if you could more clearly define what exactly needs to be done, maybe a high level list of things you would do. I'm having a hard time figuring out where to start so to speak, and i think it stems from not clearly understanding the goal and everything it affects. Thanks for your time i understand you are busy with the real problems. :)
@divitto So, there are several places that show a tile location to the user. One such location is the hovered coordinate in the status bar. Here's one place where this text is created:
By finding usages of setStatusInfo
you can find additional locations. You will also see that for objects tools, it includes the pixel coordinates as well. These are the locations that would need to be adjusted, such that in terms of the displayed coordinate, the origin is in the bottom-left (Y axis inverted).
In addition, I mentioned the coordinates displayed in the Properties view for a selected object. This happens here:
Since we should not confuse the user by presenting two coordinate systems, these coordinates will need to be inverted as well. But internally the coordinates will stay like they are, so when the user changes these values, they need to be inverted again before applying them to the object (in applyMapObjectValue
).
Finally (if I don't forget anything), the Objects view can optionally display object coordinates. This is done over here:
Since there are so many places spread over the code where coordinates will need to be inverted, it will make sense to write a small helper class for this, which should check the user preferences (see preferences.h
, which is where you'll add this option) and perform the conversion when needed.
Awesome i understand. I will get right on this as soon as possible. :)
@bjorn I Believe i have completed the task. The only problem i am having is that if you place an object in standard mode and then switch to inverted coordinates (or vice-versa) the object you placed will not automaticly update it's coordinates in the PropertyBrowser, you have to move the object to make it update the coordinates in the PropertyBrowser. How do i get the PropertyBrowser to update it's display when the user clicks my checkBox in the preferences? I hope that is clear enough, I am still pretty new to the signals and slots system. It seems like i would want to create a signal whenever the checkBox is clicked that is connected to a slot that updates the PropertyBrowser but i can't seem to get it figured out. Otherwise everything looks great, any ideas?
@divitto Sounds great! Please open a pull request so I could have a look at the implementation.
Indeed I expect you have added a boolean property to the Preferences
class that determines whether the Y axis should be inverted. This property should have a signal emitted when it is changed, like most other preferences, and the PropertyBrowser
should connect to this and make sure to update the properties in case it is displaying a MapObject
. It is not the first signal from the preferences that the PropertyBrowser
connects to: it will look pretty similar to its connection to the Preferences::objectTypesChanged
signal (except that the slot should call updateProperties
instead of updateCustomProperties
).
@bjorn I created the pull request a few days ago but i just noticed the little red X next to my request. Did everything work okay?
@divitto Let's discuss that on the pull request (#1897). :-)
Given the issue I raised in https://github.com/mapeditor/tiled/pull/2040#issuecomment-450242395, I've removed the "good first issue" and "help wanted" labels. Issues with open design questions aren't very good first issues, and I'm not actively looking for help with this issue either.
At this point, I'm starting to think the correct thing to do is more than just shallow changes; an entire separate fork of Tiled needs to be created and maintained that flips Y at all levels - from UI down to data and data format. The industry has pretty much converged on positive Y being up in 2D and anything otherwise is just pure legacy. I think we need to at some point make an option for a clean break and for those who do, never look back.
Could we come up with an effort estimate for that in terms of an initial change list?
Currently the tiling y-axis starts with the height at 0 at the top and incrementing as it goes down the map. I think it would a be a nice feature, but relatively simple task, to add some kind of checkbox option to invert the Y axis so that (0,0) starts at the bottom and then (0, 1) is the tile above.
Thanks!