360° tracklaying prototype

Discuss a Transport Tycoon-like game being programmed by forum users.

Moderator: Transport Empire Moderators

User avatar
PJayTycy
Route Supervisor
Route Supervisor
Posts: 429
Joined: 09 Mar 2004 20:30

Post by PJayTycy »

Steve wrote:If incorperated into the game, the changing of radius of the circles would be too much, i'd much prefer a single option. I think i've mentioned that before though.
I know that was mentionned before and I agree, but I didn't work on it the last weeks (due to exams). This is just a snapshot of the code as-is for the moment.
Steve wrote:I also noticed that if the points were placed quite close together and the radius of the circles was made too big, then the track would go round the circle on the other side of the track in order to loop around.
Isn't that a nice feature :lol: ? There are 4 routes calculated (starting at the left/right circle and ending at the left/right circle). Sometimes one of them is impossible (when points are too close). I always show the shortest one of the possible routes, but you can always choose another one.

The solution I thought about for solving this problem, would be to add a third circle to wrap around it (see attached pic).
Attachments
proposed solution for starting/ending sections that are too close to each other.
proposed solution for starting/ending sections that are too close to each other.
too close - solution.png (1.96 KiB) Viewed 11600 times
User avatar
Steve
Tycoon
Tycoon
Posts: 2085
Joined: 10 Jan 2004 20:19
Location: London
Contact:

Post by Steve »

Yes, that's much better than the alternative :)
Shrimp
Engineer
Engineer
Posts: 22
Joined: 02 Oct 2004 01:14
Location: Montreal, Canada

Post by Shrimp »

Hello,

I've been away for a long time so I'm not completely up to date on the discussions so bear with me please :)

I have looked at you little applet and I think this is going the right way. However, like some have mentionned, I think this is a bit complex for the "average joe player".

The problem of linking 2 straight lines or more generally 2 points with a tangent direction has been solved in numerous applications through the use of bezier splines (a 4th order function). The curvature function of any spline segment is the 3rd derivative of the function (IIRC). Therefore limiting the curvature is simply checking against that function.

For the player, this translate into simple actions. Several drawing packages (those who do vector drawing, not bitmap drawing) already do this to do polyline shapes: Click down (specify first point), drag and release mouse (specify tangeant), click other point, drag and release (second point and tangeant specified) and the curve is drawn. A simple line is simply 2 click without any dragging. In our case, when the minimal curvature is not respected, the tangeants can be automatically adjusted.

So here are some scenarios:
Case A: Completely new track (see the pictures, sorry for the quality)
1- Click the first point
2- Click the second point and drag
3- Click a third point and drag etc.

Case B: Connecting 2 pieces of existing track
1- Click the junction point anywhere on track 1 (this defines both the point and the tangeant since at the junction the direction must be the same)
2- Click the junction point anywhere on track 2 (this defines both point and tangeant as well).

Case C: Modifying an existing track. Lets say you want to add more bends to avoid going through a lake.
1- Add a new point by clicking on the track (with the "modify" tool)
2- Move this point where you want the bend to go
3- Adjust the curvature using the tangeant handles

How's that? I will try to get down to do a prototype too, if my job stops taking 50-60 hours... :(
Attachments
bpline3.gif
bpline3.gif (1.96 KiB) Viewed 11539 times
bspline2.gif
bspline2.gif (2.05 KiB) Viewed 11539 times
bspline1.gif
bspline1.gif (2.08 KiB) Viewed 11539 times
User avatar
PJayTycy
Route Supervisor
Route Supervisor
Posts: 429
Joined: 09 Mar 2004 20:30

Post by PJayTycy »

Feel free to add a bezier function to this prototype. That might be less work than creating a complete new one.
User avatar
Hyronymus
Tycoon
Tycoon
Posts: 13233
Joined: 03 Dec 2002 10:36
Location: The Netherlands
Contact:

Post by Hyronymus »

PJayTycy wrote:Feel free to add a bezier function to this prototype. That might be less work than creating a complete new one.
Is that something fancied by someone of us? Or should we just archive it?
User avatar
aarona
Traffic Manager
Traffic Manager
Posts: 221
Joined: 26 May 2006 15:54
Location: Perth, Australia
Contact:

Post by aarona »

Pardon the pun but I think this thread is on the wrong track.
User avatar
XeryusTC
Tycoon
Tycoon
Posts: 15415
Joined: 02 May 2005 11:05
Skype: XeryusTC
Location: localhost

Post by XeryusTC »

I like bezier splines for track laying, beziers are quite nice to make tracks with, look at Theme Park World for example.

http://www.macgamezone.com/images/tests ... rld/01.jpg
http://www.pelipaketti.net/kuvat/tpw/th ... rld_01.jpg
Don't panic - My YouTube channel - Follow me on twitter (@XeryusTC) - Play Tribes: Ascend - Tired of Dropbox? Try SpiderOak (use this link and we both get 1GB extra space)
Image
OpenTTD: manual #openttdcoop: blog | wiki | public server | NewGRF pack | DevZone
Image Image Image Image Image Image Image
User avatar
aarona
Traffic Manager
Traffic Manager
Posts: 221
Joined: 26 May 2006 15:54
Location: Perth, Australia
Contact:

Post by aarona »

Yeah, bézier curves are the way to go.
The question is, to what order?
Cubic is common, and has two control points.
User avatar
Purno
Tycoon
Tycoon
Posts: 16659
Joined: 30 Mar 2004 12:30
Location: Almere, The Netherlands

Post by Purno »

Trainz Railroad Simulator uses splines for tracks too, but than without the tangeant-thingies. Works quite well, but I wonder if we shouldn't use something tile-ish for a transportation game...
TE is not a train sim after all...
Contributor to the The 2cc Set and Dutch Trainset. Inventor of the Metro concept. Retired Graphics Artist.
Image Image
Download TT | Latest TTDPatch | OpenTTD | OpenTTDCoop | BaNaNaS: OpenTTD content system | 2048² OTTD scenario of the Netherlands
GRF Codec | GRF Crawler | GRF Maker | Usefull graphics & tools sites | NML Documentation Wiki | NFO Documentation Wiki
All my graphics are licensed under GPL. "Always remember you're unique, just like everyone else."
User avatar
XeryusTC
Tycoon
Tycoon
Posts: 15415
Joined: 02 May 2005 11:05
Skype: XeryusTC
Location: localhost

Post by XeryusTC »

aarona wrote:Cubic is common, and has two control points.
Bezier is the same as cubic, except from the fact that bezier allows you to edit the tangeant and cubic doesn't allow any influence (maybe weight though) AFAIK. And you don't have to show the tangeant, TPW gave you a tool where you could "turn" a pilon with, which is basicly the same as dragging the tangeant around.
Purno wrote:Works quite well, but I wonder if we shouldn't use something tile-ish for a transportation game...
TE is not a train sim after all...
I agree with you on the fact that TE is still no train simulator, but allow more directions for trains to travel is a big thing I missed in TT. RRT also allowed 360 tracks, but that system was kinda lame because it made a turn at the place you started dragging and made everything as straight as possible. We just need a good way to implement bezier splines so it is EASY to use for the user.
Don't panic - My YouTube channel - Follow me on twitter (@XeryusTC) - Play Tribes: Ascend - Tired of Dropbox? Try SpiderOak (use this link and we both get 1GB extra space)
Image
OpenTTD: manual #openttdcoop: blog | wiki | public server | NewGRF pack | DevZone
Image Image Image Image Image Image Image
User avatar
aarona
Traffic Manager
Traffic Manager
Posts: 221
Joined: 26 May 2006 15:54
Location: Perth, Australia
Contact:

Post by aarona »

XeryusTC wrote:Bezier is the same as cubic, except from the fact that bezier allows you to edit the tangeant and cubic doesn't allow any influence
When I said cubic, I meant a Bezier curve of the third order. Second order is quadratic (one control point), etc. Editing the tangents are a way of making it C1 continuous. (i.e. dx/dt is continuous for all t in the domain)
User avatar
TossIB
Engineer
Engineer
Posts: 67
Joined: 08 Aug 2004 08:21
Location: Germany

Post by TossIB »

I have some problems with splines (Bézier curves). :(

First of all, I think its not handy to move control points which are outside the the curve. This is fine on a blank workspace, but since you are in a gaming environement you want to lay down some tracks and not think about tangents and rubber bands pulling the track to the control points just to get it round that mountain. See what I mean? Perspective and distraction don't work well with geometrik intuition.

Second, there is no way to build a circle with splines (the radius is not constant). It's just impossible. You need at least two but better more to achive a reasonable approximation.

Quadric splines (1 CP) only bend in one drection and are therefor easier to deal with. Unfortunately they are painfully ugly also (parable). The radius is not constant and not null at the ends of the spline (more on that later).

Qubic and higher splines (2-n CP) are nicer, but also have a huge problem. Every time you tweak one single CP the whole thing bends and not only the area where you want to.

Conclusion: Have a rather large number of splines of low order and don't force the player to lay down every CP by himself. In other words we need a complex algorithm to fit the splines to the desired form. In other words, splines are no solution to the main problem but take it to a whole new level.

:roll: <- yeah right... programmers should have problems too...

There may be a solution in B-splines and/or NURBS Just throwing some keywords in since im not too well informed on these. Both have the advantage, that CP are on the curve AFAIK. Don't know if there is some free code available. Most of the development in this area was done by commercial software.

OR

Do it all by ourselfs. Track is composed of three Elements: Straights, circles and transitions.
Transitions are the areas in which the Radius gradually changes. In reality you cant just put a cicle right after a straight, it will result in all the passengers complaining about beeing janked around. You need smooth transitions.
Shouldn't be too hard me thinks. Need to think about it...
\°| Greetz, TossIB |°/
User avatar
XeryusTC
Tycoon
Tycoon
Posts: 15415
Joined: 02 May 2005 11:05
Skype: XeryusTC
Location: localhost

Post by XeryusTC »

TossIB wrote:First of all, I think its not handy to move control points which are outside the the curve. This is fine on a blank workspace, but since you are in a gaming environement you want to lay down some tracks and not think about tangents and rubber bands pulling the track to the control points just to get it round that mountain. See what I mean? Perspective and distraction don't work well with geometrik intuition.
You don't actually need to show the tengeant, or it's control points. You can give the user some method of "rotating" the control point, which actually affects its tengeant. This is how they did it in Theme Park World (good example as always ;) ), they gave you a "Rotate pylon" tool (the pylon being the CP on the spline), this tool presented a very good method of affecting the tengeant.
Don't panic - My YouTube channel - Follow me on twitter (@XeryusTC) - Play Tribes: Ascend - Tired of Dropbox? Try SpiderOak (use this link and we both get 1GB extra space)
Image
OpenTTD: manual #openttdcoop: blog | wiki | public server | NewGRF pack | DevZone
Image Image Image Image Image Image Image
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Post by Zuu »

Background
Okay, first this is not Beizer-curves. Actually my modell use the assumption that curves have the same radus thoght the whole curve. As I've understood some thinks that looks bad.

(but if you use beizer-stuff aren't the minimum radius of the curve going to be smaller than if you use a curve with fixed radius? And the bigger radius, the faster you can drive though it, isn't it?)



Idea
Simplifications/limits:
* Each arc/curve-section have only one radius though the whole curve.
* I have not taken into account minimum radius which makes the connection task more complicated than I've asumed. Though it should be easy to detect illeagal soulutions and use an alternative solver for those cases.

[EDIT: I wrote "Method ... " in the corner of the figures, it should really be "Case .... " or "Figure ... ". Sorry for confusion.]

Soulution
Though three images (1, 2 and 3) I explain a way of trackbuilding based on fixed-radius.

For those who can not read the text in the images it is dublicated in scalable form below.



Figure text in scaleable format
Figure 1: New track
1. Choose P1 and P2
2. Optionally adjust Q to any position on the line L.

Figure 2: Append
1. Choose an ending point of track T. (P1)
2. Choose the target point P2
3. The engine will form a curve from P1 to P2. (and take into account the required angle at P1)

Only ONE soulution exists.

T end at P1 with a certain angle

Figure 3: Connect
1. Choose P1 and P2 which should be enging points on other tracks.
2. Angles for P1 and P2 are given from their tracks (T1 and T2)
3. The engine use twoo curves C1 and C2 to connect P1 and P2 with eachothe
r. (C1 and C2 are connected with eachother at P3)

Infinite soulutions exists!
Attachments
Figure 3: Connect
Figure 3: Connect
path_building_method_connect.png (83.78 KiB) Viewed 11021 times
Figure 2: Append
Figure 2: Append
path_building_method_append.png (75.29 KiB) Viewed 11021 times
Figure 1: New
Figure 1: New
path_building_method_new.png (59.28 KiB) Viewed 11021 times
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
TossIB
Engineer
Engineer
Posts: 67
Joined: 08 Aug 2004 08:21
Location: Germany

Post by TossIB »

That's actually a pretty good solution me thinks.

Nevertheless there are two problems yet to be solved.
(cureve in this context should be read as a piece of a circle)

1. Like said before in reality never ever is ther a curve directly attached at a straight track. There are always transition segments where the radius gradually changes. Maybe there is no need to be this precise since this will be no super-realistic simulation. - Needs some discussion.

2. You lay down staight track and then append a curve to it. Everything is fine, the curve is determined by the ending point. when you want to add staight track now you can't choose the direction any more, only length. But it's hard to see for the player, where the staight track will head to far far away, when placing the curve. The shorter the curve the harder for the player. Maybe this can be solved by showing the tangent of the ending point while building the curve, but surly this effect will result in the player placing straigt track first and using the algorithm to connect curves.
\°| Greetz, TossIB |°/
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Post by Zuu »

TossIB wrote:1. Like said before in reality never ever is ther a curve directly attached at a straight track. There are always transition segments where the radius gradually changes. Maybe there is no need to be this precise since this will be no super-realistic simulation. - Needs some discussion.
I don't think this is something that we should include in our model. At least not if it is handeled in a way wich means that the user have to control this pre-bending.

But if you say that you can change the radius X-steps per Y meter track, and you always change the radius this amount it can be included in my model above, though it might complicate it to a state where connections might get significantly harder (=takes more CPU) to calculate. But that need to bee looked at in more deepth.
TossIB wrote:2. You lay down staight track and then append a curve to it. Everything is fine, the curve is determined by the ending point. when you want to add staight track now you can't choose the direction any more, only length. But it's hard to see for the player, where the staight track will head to far far away, when placing the curve.
I can't either see why would it be impossible to have two curves after each other.

As in figure 3 in my previous post. For point P3 the coordinates and the angle of the black line (going thoght the dot representating P3) is stored. Actually for every point the coordinates and angle is stored.

(Maybe dirrection is a better word than angle, even if the dirrection is given by a angle on the unit circle. )

Actually in principle a straight track could just be a curve which does not bend. However I guess for the implemention it might be a huge optimazition to handle straight tracks differently than curves as curves might need to be aproximated by lines before it is sent to OpenGL. But in pure principles I see no use of separate straight tracks from curved tracks.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
ValHallA|SW
Engineer
Engineer
Posts: 36
Joined: 24 Aug 2003 18:10

Post by ValHallA|SW »

If I check how Trainz-tracklaying works: when appending, it sacrifices the tangent of the original track to form a nicer curve, unless the user chooses not to. ('straighten track tool'). Also, curves are rendered by their begin- and end tangents, not by seperate pieces. I'm not sure wether I'm being helpful or not, but think about downloading the trainz demo and playing around with the editor a bit for some ideas :)

-val out
Post Reply

Return to “General Transport Empire Discussion”

Who is online

Users browsing this forum: No registered users and 16 guests