Elevation feature
Moderator: OpenTTD Developers
Elevation feature
Hi,
While creating a map with quite a lot of mountains, I've been wondering if it would be possible to have a new slope height (typically twice the standard elevation) ?
Unlike the default slope, this new one wouldn't be buildable, forcing players to find another route.
I'm thinking about this because I'm often trying to recreate some parts of the Alps, and the very steep slopes cannot really be done in the game, so deep valleys IRL are not really that deep, and it's not too much of a challenge.
Not knowing the insides of the game engine I have no idea if it's possible without breaking it, moreover I have no idea if it's something that would fit in the game design.
While creating a map with quite a lot of mountains, I've been wondering if it would be possible to have a new slope height (typically twice the standard elevation) ?
Unlike the default slope, this new one wouldn't be buildable, forcing players to find another route.
I'm thinking about this because I'm often trying to recreate some parts of the Alps, and the very steep slopes cannot really be done in the game, so deep valleys IRL are not really that deep, and it's not too much of a challenge.
Not knowing the insides of the game engine I have no idea if it's possible without breaking it, moreover I have no idea if it's something that would fit in the game design.
Re: Elevation feature
Hello zifox,
I don't think this could be done without a complete rework of almost any line of the game source code
I believe this is a feature request that exists from the origin of TTDPatch about 25 years in the past now
I don't think this could be done without a complete rework of almost any line of the game source code
I believe this is a feature request that exists from the origin of TTDPatch about 25 years in the past now
Re: Elevation feature
It's actually not THAT bad.
you only need 3 things:
- rework the map storage to store all corners of each tile, instead of just one
- rework the drawing code because now more tiles could potentially be on screen in need of drawing (possible performance impact)
- introduce a way to see tiles that could now be blocked by mountains and cliffs [note: this is usually the big showstopper]
Re: Elevation feature
What about going the other way? Introduce a half-height slope and treat it as a normal slope, whereas the old type of slope would be considered a "cliff". I understand this doesn't affect the effort required to modify the map format and the rendering code, but at least the tile visibility won't be an issue.
Re: Elevation feature
Hmmm that's quite interesting. I think I'll try to dig deeper into this. I need to clone the source repo first...Eddi wrote: ↑21 Sep 2022 11:40It's actually not THAT bad.
you only need 3 things:
- rework the map storage to store all corners of each tile, instead of just one
- rework the drawing code because now more tiles could potentially be on screen in need of drawing (possible performance impact)
- introduce a way to see tiles that could now be blocked by mountains and cliffs [note: this is usually the big showstopper]
You seem to have a good understanding of the way the graphic engine work, could I bother you with some questions later ?
Last edited by zifox on 21 Sep 2022 19:44, edited 1 time in total.
Re: Elevation feature
Yes that would solve the visibility issue, but the would not answer my question in the first place: have deep valleys and high cliffs !odisseus wrote: ↑21 Sep 2022 16:31 What about going the other way? Introduce a half-height slope and treat it as a normal slope, whereas the old type of slope would be considered a "cliff". I understand this doesn't affect the effort required to modify the map format and the rendering code, but at least the tile visibility won't be an issue.
Re: Elevation feature
note that the word "only" is quite the understatement, each of these 3 tasks is quite complicated. and there are a lot of minor things to consider as well, like making sure a rail on top of a cliff isn't connected with a rail on the bottom of a cliff.
questions like that are better phrased openly to the public. nobody knows the whole code. different people know things better about certain parts of the code.You seem to have a good understanding of the way the graphic engine work, could I bother you with some questions later ?
Re: Elevation feature
Hello
Tschö, Auge
No it wouldn't. With greater height differences the problem of visibility will come back again.zifox wrote: ↑21 Sep 2022 19:41Yes that would solve the visibility issue …odisseus wrote: ↑21 Sep 2022 16:31 What about going the other way? Introduce a half-height slope and treat it as a normal slope, whereas the old type of slope would be considered a "cliff". I understand this doesn't affect the effort required to modify the map format and the rendering code, but at least the tile visibility won't be an issue.
Your question was answered. No, it isn't possible in the current state of the game. Yes, it would be possible, if and when the issues, named by Eddi (and maybe further issues), would be solved.
Tschö, Auge
Re: Elevation feature
I beg to differ. The perspective in OpenTTD works in such a way that you can see the whole tile if you can see its front corner. In particular, a mountain's back slope is entirely visible, as are any flat tiles lying next to the slope. If some of the slope tiles were half the usual steepness, they would basically be an average between a normal slope and a flat tile. Such a tile could not possibly obscure the tiles that lie behind any more than a flat tile does.
- Attachments
-
- back-slope.png (28.86 KiB) Viewed 3275 times
Re: Elevation feature
Hello
When the "normal" height difference is halved, the game would need graphics for all infrastructure tiles as tracks, roads, etc. that are affected by this change (beside the landscape sprites in itself). The movement of up- and downhill moving vehicles would need adaption, the position of trees on these tiles must be adapted, etc. pp. And last but not least the developer of this feature has to decide if roads and tracks should be buildable on tiles that are then cliffs or not (with the then presumably upcoming discussions).
And in the end someone would ask for steeper and higher cliffs like in Locomotion (where this is possible) and then your solution would break. In that moment the backside would be invisible, at least in case of the backside of a vertical cliff. In Locomotion you can turn around the map in 90-degree-steps. In TTD/OpenTTD you cannot and if this should get implemented, the game would need a lot more graphics because of the now unnecessary but then needed, visible backsites of anything.
As said, for me this is a not convincing idea.
Tschö, Auge
I agree to your argumentation in the limits of your idea. But if the OP writes about cliffs and you offer to define only the current steepness as cliff whereas the "normal" steepness would be halved, this is a IMHO not convincing solution (neither optically nor functionally).
When the "normal" height difference is halved, the game would need graphics for all infrastructure tiles as tracks, roads, etc. that are affected by this change (beside the landscape sprites in itself). The movement of up- and downhill moving vehicles would need adaption, the position of trees on these tiles must be adapted, etc. pp. And last but not least the developer of this feature has to decide if roads and tracks should be buildable on tiles that are then cliffs or not (with the then presumably upcoming discussions).
And in the end someone would ask for steeper and higher cliffs like in Locomotion (where this is possible) and then your solution would break. In that moment the backside would be invisible, at least in case of the backside of a vertical cliff. In Locomotion you can turn around the map in 90-degree-steps. In TTD/OpenTTD you cannot and if this should get implemented, the game would need a lot more graphics because of the now unnecessary but then needed, visible backsites of anything.
As said, for me this is a not convincing idea.
Tschö, Auge
Re: Elevation feature
I took a quick look at the code, and as I understand it, everything is hardcoded. Indeed, it won't be easy to change anything. Not easy, but possible. I'm optimistic.
A piece of good news visually speaking. The TILE_HEIGHT is exactly half the TILE_SIZE, meaning that doubling the TILE_HEIGHT would not actually hide anything, in theory. We wouldn't see the slope opposite the view anymore, but nothing would be hidden by the slope. (that would be an issue if we could build road/tracks in the diagonale line on slopes, which we can't.)
I need to configure the project properly, I'd like to try and see how the game reacts if I set TILE_HEIGHT to 16, visually. If the result is acceptable, i'll dig deeper into this matter. I'll drop the idea if it is not, from what I've seen, as mentionned before, that would be a show stopper, the whole drawing engine would need to be rewritten.
A piece of good news visually speaking. The TILE_HEIGHT is exactly half the TILE_SIZE, meaning that doubling the TILE_HEIGHT would not actually hide anything, in theory. We wouldn't see the slope opposite the view anymore, but nothing would be hidden by the slope. (that would be an issue if we could build road/tracks in the diagonale line on slopes, which we can't.)
I need to configure the project properly, I'd like to try and see how the game reacts if I set TILE_HEIGHT to 16, visually. If the result is acceptable, i'll dig deeper into this matter. I'll drop the idea if it is not, from what I've seen, as mentionned before, that would be a show stopper, the whole drawing engine would need to be rewritten.
Re: Elevation feature
TILE_HEIGHT is probably not a thing that you should change.
Re: Elevation feature
Indeed that was not, the title screen would not even load, I had a crash because a train couldn't find a track, apparently.
Weird that the path finding could be impacted by this variable.
Is there a way to load the game without any background scene ?
Weird that the path finding could be impacted by this variable.
Is there a way to load the game without any background scene ?
Re: Elevation feature
yes, if you delete opntitle.dat, an empty map is created on game start.
Re: Elevation feature
Thanks, that did the trick.
I did a few tests, and I'm surprised. As the following screenshot shows, with a tile height of 16px, once I created a slope, the cursor snaps higher than the tile displayed, which is expected. What's not expected is the low height difference: naïvely I thought the space between the ball and the top of the tile under it would be exactly the height of the tile. But that's not the case.
Nevermind, I raised the terrain again, to see where the next tile woud be drawn. As expected, it's not touching the tile below, but like in the screenshot above, it's not as high as I'd thought it would. (both screenshots of coherent)
Ok, so I called the bluff and raised again: Again, not what I expected, but coherent with the other two.
I did a few tests, and I'm surprised. As the following screenshot shows, with a tile height of 16px, once I created a slope, the cursor snaps higher than the tile displayed, which is expected. What's not expected is the low height difference: naïvely I thought the space between the ball and the top of the tile under it would be exactly the height of the tile. But that's not the case.
Nevermind, I raised the terrain again, to see where the next tile woud be drawn. As expected, it's not touching the tile below, but like in the screenshot above, it's not as high as I'd thought it would. (both screenshots of coherent)
Ok, so I called the bluff and raised again: Again, not what I expected, but coherent with the other two.
Re: Elevation feature
I'm quite puzzled. The gap between the tiles is a third of the height of the tile.
But the code clearly states:
I'm missing something, but I don't know what.///< Height of a height level in world coordinate AND in pixels in #ZOOM_LVL_BASE.
Re: Elevation feature
A positive thing: the code already handles "steep slopes" (height difference equal to 2 between two corners), that why we can't build in the steepest direction of a slope. So handling even higher differences shouldn't need extra code.
I'm intrigued...
I'm intrigued...
Re: Elevation feature
Your measurement is wrong ...
I attached a picture to more easily explain.
- The yellow lines represent the edges of a flat tile if one would be there (not very accurate I admit)
- you are measuring from the center of a lower tile to the corner of a higher located tile ... this is not correct and leads to your confusion.
- The orange scriblings is where you should be measuring from.
Anyhoo ... good luck with your project.
- Attachments
-
- tileheight.png (314.41 KiB) Viewed 3035 times
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.
Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.
Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
Re: Elevation feature
Thanks for pointing that out !
It does make sense, but then I'm having difficulties linking the size of the tile to its height. At the beginning, seeing in the code that TILE_HEIGHT = (TILE_SIZE)/2 and the seeing the result on the screen, I thought both values were in "screen space". There must be a ratio applied somewhere when drawing.
More research needed on my side !
It does make sense, but then I'm having difficulties linking the size of the tile to its height. At the beginning, seeing in the code that TILE_HEIGHT = (TILE_SIZE)/2 and the seeing the result on the screen, I thought both values were in "screen space". There must be a ratio applied somewhere when drawing.
More research needed on my side !
Re: Elevation feature
Does anybody know where I could find the source for zBase ? I'd like to try and make a few sprites for double elevation slopes, but the openttd coop website doesn't answer anymore (bad gateway)
Who is online
Users browsing this forum: No registered users and 8 guests