Object on Object

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
luxtram
Route Supervisor
Route Supervisor
Posts: 420
Joined: 10 May 2016 19:09

Object on Object

Post by luxtram »

I am continuing the discussion started under graphic development viewtopic.php?p=1176269#p1176269.

How feasible would it be to include a possibility for objects to accept other objects, including standard game objects like roads, on top of them with defined height (must be a multiple of actual height differences between levels) while allowing other objects, but especially roads, below them?

Main use case I have in mind is possibility to create an elevated transit system on top of existing roads, but this idea could work for other concepts like viaducts, metro etc.
ElevatedTransit.png
ElevatedTransit.png (68.06 KiB) Viewed 11871 times
Other similar concept I have in mind is stacking objects to combine them. For example I start with the back of the fence sprite, then add tree and then front of the fence.
California City Sets viewtopic.php?t=76786
1000 building set viewtopic.php?t=75250
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4766
Joined: 09 Sep 2007 05:03
Location: home

Re: Object on Object

Post by Alberth »

Depending on how much effort you're willing to spend, from not very to trivial feasible.

In the general case, you'll end up with layers of traffic above each other, eg a road layer and on top of that a track layer, etc.
In the current map array, there is room for 1 layer only. Sure you may have hills, but only one layer of traffic. Tunnels and bridges don't count, as they are fake.

If you introduce elevated tracks by means of a height offset 'hack', it won't be long until a non-suspecting player wants to cross under those tracks. I don't think you can explain why you can't do that, since the graphics fully suggest it's possible.


The only useful way out, in my view, is to introduce multi-level traffic in general. Change the map array such that you can have as many layers as you like. At that point, your idea is obsolete, as the current newgrf would be able to handle it. In addition, you can do a whole lot of other things as well, such as subway systems, or signals on tunnels and bridges, although I believe that should not be added, the game is more challenging if tunnels and bridges don't have signal capacity. It may be impossible to prevent that though :p
Being a retired OpenTTD developer does not mean I know what I am doing.
User avatar
Kalen
Traffic Manager
Traffic Manager
Posts: 160
Joined: 07 Jun 2008 22:07
Location: Portugal

Re: Object on Object

Post by Kalen »

Alberth wrote:Tunnels and bridges don't count, as they are fake.
What about freeform bridges which can be placed the same way as one places, say, tram tracks on top of either clear ground or existing road/track? Is that even remotely a realistic possibility? That would at least give us curves, though it still wouldn't do anything about slopes.
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4766
Joined: 09 Sep 2007 05:03
Location: home

Re: Object on Object

Post by Alberth »

Kalen wrote:What about freeform bridges which can be placed the same way as one places, say, tram tracks on top of either clear ground or existing road/track? Is that even remotely a realistic possibility? That would at least give us curves, though it still wouldn't do anything about slopes.
Bridges don't exist, only the entry and exit tile exist. You find the exit from the entry by continuing to move in the same direction as the entry indicates, until you hit the exit tile. Add some magic to add graphics along that stretch of tiles, and everybody believes there is a bridge, while in reality there is only empty sky above ground tiles, and a flying train without wings. The transparent bridges setting shows pretty well what really exists :)


Making a turn or going up or down cannot be done, as you break the "continue moving in same direction until you hit the exit tile" code. Unless you know a simple recipe to find the other end from one side of course, but so far nobody came up with anything else, afaik.
Being a retired OpenTTD developer does not mean I know what I am doing.
luxtram
Route Supervisor
Route Supervisor
Posts: 420
Joined: 10 May 2016 19:09

Re: Object on Object

Post by luxtram »

Alberth wrote:Making a turn or going up or down cannot be done, as you break the "continue moving in same direction until you hit the exit tile" code. Unless you know a simple recipe to find the other end from one side of course, but so far nobody came up with anything else, afaik.
Which files are related to the bridge travel and travel on regular roads?
California City Sets viewtopic.php?t=76786
1000 building set viewtopic.php?t=75250
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4766
Joined: 09 Sep 2007 05:03
Location: home

Re: Object on Object

Post by Alberth »

luxtram wrote:Which files are related to the bridge travel and travel on regular roads?
I have no idea, I cannot remember what's where in 300K lines of code especially if I never looked it up before. My usual strategy is to checkout a copy, and search for the point I am interested in.

I think the main entry point for you is from road vehicle, as that's the thing that is moving. That would suggest some roadveh_* file.
Being a retired OpenTTD developer does not mean I know what I am doing.
luxtram
Route Supervisor
Route Supervisor
Posts: 420
Joined: 10 May 2016 19:09

Re: Object on Object

Post by luxtram »

Alberth wrote:
luxtram wrote:Which files are related to the bridge travel and travel on regular roads?
I have no idea, I cannot remember what's where in 300K lines of code especially if I never looked it up before. My usual strategy is to checkout a copy, and search for the point I am interested in.

I think the main entry point for you is from road vehicle, as that's the thing that is moving. That would suggest some roadveh_* file.
Thanks! Found it. Most of the related code is in the roadveh_cmd.cpp and tunnelbridge_cmd.cpp. I'll have a look.
California City Sets viewtopic.php?t=76786
1000 building set viewtopic.php?t=75250
maquinista
Tycoon
Tycoon
Posts: 1829
Joined: 10 Jul 2006 00:43
Location: Spain

Re: Object on Object

Post by maquinista »

luxtram wrote:I am continuing the discussion started under graphic development viewtopic.php?p=1176269#p1176269.

How feasible would it be to include a possibility for objects to accept other objects, including standard game objects like roads, on top of them with defined height (must be a multiple of actual height differences between levels) while allowing other objects, but especially roads, below them?

Main use case I have in mind is possibility to create an elevated transit system on top of existing roads, but this idea could work for other concepts like viaducts, metro etc.

ElevatedTransit.png

Other similar concept I have in mind is stacking objects to combine them. For example I start with the back of the fence sprite, then add tree and then front of the fence.
Maybe you are suggesting a Locomotion style game:
viewtopic.php?f=30&t=75019
Sorry if my english is too poor, I want learn it, but it isn't too easy.[/list][/size]
luxtram
Route Supervisor
Route Supervisor
Posts: 420
Joined: 10 May 2016 19:09

Re: Object on Object

Post by luxtram »

maquinista wrote:Maybe you are suggesting a Locomotion style game:
viewtopic.php?f=30&t=75019
Well, it would not say that. But it is matter of branding.

What I would in fact like to have are

a) more elevation options,
b.1) bridges that turn as viaducts
b.2) bridges that turn as overhead traffic,
c) bridges over houses,
d) subways.
California City Sets viewtopic.php?t=76786
1000 building set viewtopic.php?t=75250
luxtram
Route Supervisor
Route Supervisor
Posts: 420
Joined: 10 May 2016 19:09

Re: Object on Object

Post by luxtram »

Alberth wrote: 09 Sep 2016 19:21 Making a turn or going up or down cannot be done, as you break the "continue moving in same direction until you hit the exit tile" code. Unless you know a simple recipe to find the other end from one side of course, but so far nobody came up with anything else, afaik.
It's an older thread but I have new ideas.

But first things first, to put every reader to the same page, so to speak.

In the screenshot there are 3 marked road sections: AB, CD and EF.

It may look like the road CD is the longest because it goes over the hill. But it is not true. The length of the road in tiles(!) is exactly the same as AB (if you don't believe it, just count the tiles).

The big hill in the middle of the screen is just a big optical illusion. It doesn't exist.

What Alberth is saying in the previous posts is that from the point of view of the OpenTTD engine, the whole map is flat 2D array. There are really no elevations. There is no 3rd dimension.

Having this illusion out of our minds, let's consider the road EF that has a tunnel in the middle.

In the game there could be another road section between the two tunnel ends. But these sections are not directly connected because there are two tunnel end points between them and when a vehicle enter the tunnel entry tile then instead of continuing uphill, it will instead continue going on the illusory level until it encounter another tunnel entry.

Turning Bridge 1.png
Turning Bridge 1.png (658.32 KiB) Viewed 9739 times
California City Sets viewtopic.php?t=76786
1000 building set viewtopic.php?t=75250
luxtram
Route Supervisor
Route Supervisor
Posts: 420
Joined: 10 May 2016 19:09

Re: Object on Object

Post by luxtram »

The very same principle applies to the bridges.

If a vehicle enter any bridge end point A, B, C, D, it will just continue straight to the same direction until it encounter the next bridge end point.

When it comes from the direction of A, it first encounters A, continues straight until it encounters B and gets back to the road again where it encounters C after the turn and continues straight until it encounters D.

Turning Bridge 2.png
Turning Bridge 2.png (666.97 KiB) Viewed 9738 times
California City Sets viewtopic.php?t=76786
1000 building set viewtopic.php?t=75250
luxtram
Route Supervisor
Route Supervisor
Posts: 420
Joined: 10 May 2016 19:09

Re: Object on Object

Post by luxtram »

If we wanted to have a bridge with a turn then the question becomes - how can a vehicle know when to turn when there are no bridge ends in the middle of the bridge???

It obviously can not.

Turning Bridge 3.png
Turning Bridge 3.png (630.26 KiB) Viewed 9735 times
California City Sets viewtopic.php?t=76786
1000 building set viewtopic.php?t=75250
luxtram
Route Supervisor
Route Supervisor
Posts: 420
Joined: 10 May 2016 19:09

Re: Object on Object

Post by luxtram »

Unless we introduce a new special object!

A bridge middle point.

This could have two layers A and B where layer A would act like a tunnel and layer B will act like a bridge end point.

Turning Bridge 4.png
Turning Bridge 4.png (635.85 KiB) Viewed 9732 times
California City Sets viewtopic.php?t=76786
1000 building set viewtopic.php?t=75250
desertbus95
Engineer
Engineer
Posts: 40
Joined: 30 Jul 2024 07:21

Re: Object on Object

Post by desertbus95 »

luxtram wrote: 03 Oct 2024 20:36 Unless we introduce a new special object!

A bridge middle point.

This could have two layers A and B where layer A would act like a tunnel and layer B will act like a bridge end point.


Turning Bridge 4.png
:bow:
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4766
Joined: 09 Sep 2007 05:03
Location: home

Re: Object on Object

Post by Alberth »

luxtram wrote: 03 Oct 2024 20:36 Unless we introduce a new special object!

A bridge middle point.

This could have two layers A and B where layer A would act like a tunnel and layer B will act like a bridge end point.
Very late to the party, but you mean like this? With trains you get the additional option to add a signal at the corner.
Image
Attachments
Screenshot from 2024-12-31 15-52-43.png
Screenshot from 2024-12-31 15-52-43.png (91.07 KiB) Viewed 8684 times
Being a retired OpenTTD developer does not mean I know what I am doing.
luxtram
Route Supervisor
Route Supervisor
Posts: 420
Joined: 10 May 2016 19:09

Re: Object on Object

Post by luxtram »

Alberth wrote: 31 Dec 2024 14:55
luxtram wrote: 03 Oct 2024 20:36 Unless we introduce a new special object!

A bridge middle point.

This could have two layers A and B where layer A would act like a tunnel and layer B will act like a bridge end point.
Very late to the party, but you mean like this? With trains you get the additional option to add a signal at the corner.
Image
Yes, this is the idea in general, but no inclination - it's replaced by a special tile type.
California City Sets viewtopic.php?t=76786
1000 building set viewtopic.php?t=75250
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 23 guests