Page 1 of 1
Project: Subway
Posted: 09 Nov 2008 01:29
by technosnorunt58
Hi I am new here and I would like to start a project to create subways in OpenTTD.
If you would like to be a coder or drawer poast here.
If you do theise are REAL subway models.
EDIT: I can/will draw.
Updates:
Re: Project: Subway
Posted: 09 Nov 2008 02:48
by DJ Nekkid
there is a whole lot of metro/subway trains included in the 2cc-set, and we would love to have more if you want to draw:). However; your initial thread seem to be placed in the dev section, and not the grapics section...
Getting "underground" building into OTTD however is somewhat more difficult. There is a couple of ideas out there, but none of them has been acted on, and the devs have not made any "official" statements (that i know of), that such a project have been started.
The closest things is probably Belugas' (iirc) attempt to get signals on bridge tiles. (And i __think__ that can be adopted to tunnels at some point?

Re: Project: Subway
Posted: 09 Nov 2008 12:25
by Kanibal
The easiest way to simulate a kind of subway that I've found is to use trams on a lower level to the city and only leaving tunnels for corners and the station stops.
All that would really require is some kind of 'subway train' graphic that runs on tram tracks.
Re: Project: Subway
Posted: 09 Nov 2008 12:56
by Yexo
technosnorunt58 wrote:Hi I am new here and I would like to start a project to create subways in OpenTTD.
If you would like to be a coder or drawer poast here.
If you do theise are REAL subway models.
Updates:
So what are you going to do yourself? If you want other to help, your best chance it to make a good start (ie code a patch) and show it off. If others like the way you implemented it, they might help with coding and or graphics.
Re: Project: Subway
Posted: 09 Nov 2008 13:58
by technosnorunt58
I do not know how to code that much.
Don't some subways go above ground also?

Re: Project: Subway
Posted: 09 Nov 2008 14:39
by CommanderZ
They in fact go only above ground in OTTD

Re: Project: Subway
Posted: 10 Nov 2008 04:03
by audigex
Its a nice idea and I hope it gets implemented, but it will be a lot of work...
Drawing the sprites is easy enough - creating an actual underground, that's not so easy

Re: Project: Subway
Posted: 10 Nov 2008 12:58
by technosnorunt58
Sure it is!!! All we need to do is make everything semi-transparent like buildings, roads, grass, trees, and water. And code the underground so things on top can go on it.
Re: Project: Subway
Posted: 10 Nov 2008 13:11
by Roujin
Uhm, methinks that you should leave the judging if something is easy or not to the people who can code.
You can draw all sorts of things for OpenTTD, that's never difficult (note - I do not mean to belittle the work of artists!). You could also draw space shuttles, tornados and whatnot - no problem. The difficult thing is always how to code it.
Re: Project: Subway
Posted: 10 Nov 2008 15:33
by audigex
That's my point.
One possible way could be to have a second "map" of tiles for the underground, not viewable on the standard view, and "linking" stations that go between the underground and above ground.
Eg a 1 tile entrance above ground that creates a below ground 4x4 2-"level" station for subway trains; kinda like an ICE system.
The two levels (one for NS and one for EW traffic could just share tiles but with no collision detection unless trains are heading on the same plane.
That would be doable, but it will most likely involve editing large swathes of pathfinder etc and the drawing of the map... a lot of work. That's not to say it can't be done - but you would have to find someone prepared to do a lot of work for it on the coding front.
Re: Project: Subway
Posted: 10 Nov 2008 17:08
by Expresso
Best way is not to go for a workaround, as that might create issues in the future.
To get underground levels you need a completely different map array (to curb memory consumption). This translates to changeing about half of openttd (quite a lot of work, especially since most/all devs are either students or have day jobs).
Lets see what changes need to be done:
- Make a wrapper class for the TileIndex (the tileindex is a unique value representing the offset in the map array), to support both new and old tileindexes (this is step 1 of your project, also the easiest step).
- Make a wrapper class for the map array and populate it with the functions which calculate all kinds of things which are needed by the various parts of openttd (quite easy, but lots of work). Make sure the class functions are used instead of the global ones.
- Write the replacement map array (basically a Memory pool storing 16x16 or 8x8 blocks of tiles). Make sure it's accessed properly (otherwise havoc will ensue once you're using it).
- Get rid of the runtime TileIndex conversion, by providing converted versions of the map class functions (relatively easy, but quite a lot). NOTE: you cannot get rid of the old ones, since you might need them to load scenarios/savegames from previous versions.
At this point you still haven't got a 3D map array (the thing you need for underground, but the basics are there... this is quite some subversion revisions further, but everything should be doable up to this point.
There are no visible results at this point, except an openttd which might be a bit slower.
This allows for non-uniform maps (well... within certain limits). For this lots of additional work is required, but at the moment that isn't of interest... technosnorunt58 wanted subways, and for that we need quite a bit of additional work:
- At this point layers need to be stacked in the map array, implementing this shouldn't be much of a problem. There are a few approaches to handling this, each having its own advantages and disadvantages.
- Get the new TileIndex an additional nybble (for the height).
This was the easy part, now for the hard part. This part is the most work, and probably not as easy either.
- Split out tunnel and bridge code, for easy conversion later. Is this really needed?
- Adapt various checks throughout the code to see what's above/below the current tile (lots of work).
- Adapt the viewport to take the 3D map array into account.
- Put all tiles on different heights (according to their tile height). However, still treat the map as 2D (makes life easier).
- Adapt the map generator for the 3D map.
- Correct the tunnel and bridge functions to actually put rails/roads on the map in the appropriate 3D tile (converters for savegames).
- Adapt the map functions to make use of the 3D functionality (underground/overground rails).
Still nothing visible, though the worst part is done at this point (a year further, with some luck). Still no underground. That comes now. With this part the artists are of a little use.
- First the UI needs some love. Have you dreamt up an easy to use way to edit with multiple layers, without behaving like locomotion? That needs to be implemented at this point.
- Make openttd aware of what's underground and above ground and stop rendering when the border is reached (underground renders from below to the surface, and above ground renders from the surface to the top of the map array.
Why all this? Well, if you go for multiple layers, you should do it right from the start instead of discovering some day that it doesn't quite work as well as expected.
NOTE: I'm not a dev, but have take a few looks at the code.
Re: Project: Subway
Posted: 10 Nov 2008 17:51
by Antdovu
Mostly I agree with what Expresso said but some of what he said isn't necessarily true for every reasonable approach.
The main problems in my opinion:
- It isn't too hard to get something working. It is hard to make it work well, be reasonable fast and not use a huge amount of memory.
- You need a good way to be able to edit in 3 dimensions.
- You need a good way to render the world in 3 dimensions fast.
- Huge amount of existing code might need to be modified. This will likely introduce a swarm of huge bugs.
My thoughts about the possible implementation:
- Could use a rolling amount of layers (keeps memory requirement down, allows flexible terrain, makes rendering difficult)
- The views could be split into 2: above ground (forests, towns, bridges, etc) and below the ground (tunnels, subway, under the sea, underground stations).
- You don't necessarily need to be compatible with the old map other than allow converting the old into the new when loading.
I am sure that it could be done but it would likely need more than a couple of people working on it together and a
lot of time. If the project will ever be undertaken then I would highly suggest making a formal design for it before any coding.
Re: Project: Subway
Posted: 10 Nov 2008 21:35
by technosnorunt58
It would need to intersect with tunnles already there.
Witch in my mind would be a possable glitch.
Re: Project: Subway
Posted: 11 Nov 2008 01:29
by audigex
That's why I suggested foax levels
You can't actually choose what levels the track is on (this reduces some of the workload dramatically)
Instead trains travelling NS are on "level 1" which is always above "level 2" (EW trains); these two tracks can then cross each other with no issues
Diagonal tracks are visualised as "slopes" or similar, to allow trains to change direction - these cannot intersect with either NS, SW or other diagonal tracks and are strictly 1-track-per-tile.
It's workable in either format; and would IMO be a great addition to the game in the realism it can offer (buses always struggle to cope with large cities full of passengers)... I just don't think anyone has that much spare time on their hands.
Re: Project: Subway
Posted: 11 Nov 2008 04:03
by technosnorunt58
So should we start?
Re: Project: Subway
Posted: 11 Nov 2008 10:32
by DaleStan
Only if you're using the royal we there.
Re: Project: Subway
Posted: 11 Nov 2008 12:28
by technosnorunt58
DaleStan wrote:Only if you're using the royal we there.
What does that mean???
Re: Project: Subway
Posted: 11 Nov 2008 12:29
by Gremnon
The royal we, where we is used instead of I.
To put it bluntly, DaleStan's not interested, and tbh, I don't think any else is either.
Re: Project: Subway
Posted: 11 Nov 2008 12:36
by planetmaker
technosnorunt58 wrote:So should we start?
It's up to you on how to spend your time. If properly done, it may be an awesome patch.
For inspiration have a look at
http://devs.openttd.org/~smatz/3d/
Re: Project: Subway
Posted: 11 Nov 2008 15:17
by CommanderZ
planetmaker wrote:technosnorunt58 wrote:So should we start?
It's up to you on how to spend your time. If properly done, it may be an awesome patch.
For inspiration have a look at
http://devs.openttd.org/~smatz/3d/
This is amazing, I never know someone actually tried to code this. Thanks for a link.