In this sixth tutorial, we will add code to extend the ‘disappearing‘ rails, use a modified track object to remove the gap in the rails and also add pointwork at our diverging junction. For more realistic running, speed limits will also be introduced.
Additional objects used in this tutorial session may be found here:
http://vps.bvecornwall.co.uk/dennislance/DLTUTORIAL_1_6.zip
Unzip to the objects folder.
Time to open the route file and get coding…
The route file we created previously should look something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
Route.Comment Route learning with Dennis, Route.Gauge 1435, Route.DeveloperID yourname123, Route.change 1, with train, Train.Folder cl170, Train.Run(0) 2, Train.Run(1) 2, Train.Run(2) 2, Train.Run(3) 2, Train.Run(4) 2, Train.Run(5) 2, Train.Run(6) 2, Train.Run(7) 2, Train.Run(8) 2, Train.Run(9) 2, Train.Run(10) 2, Train.Run(11) 2, Train.Run(12) 2, Train.Run(13) 2, Train.Run(14) 2, Train.Run(15) 2, Train.Run(20) 3, With Structure .Rail(1) DLTUTORIAL_1\straight.b3d, .Rail(2) DLTUTORIAL_1\250_l.b3d, .Rail(3) DLTUTORIAL_1\500_l.b3d, .Rail(4) DLTUTORIAL_1\750_l.b3d, .Rail(5) DLTUTORIAL_1\1000_l.b3d, .Rail(6) DLTUTORIAL_1\1250_l.b3d, .Rail(7) DLTUTORIAL_1\1500_l.b3d, .Rail(8) DLTUTORIAL_1\2000_l.b3d, .Rail(9) DLTUTORIAL_1\250_r.b3d, .Rail(10) DLTUTORIAL_1\500_r.b3d, .Rail(11) DLTUTORIAL_1\750_r.b3d, .Rail(12) DLTUTORIAL_1\1000_r.b3d, .Rail(13) DLTUTORIAL_1\1250_r.b3d, .Rail(14) DLTUTORIAL_1\1500_r.b3d, .Rail(15) DLTUTORIAL_1\2000_r.b3d, .Rail(20) DLTUTORIAL_1\straight.b3d,;standard straight track under bridge, .Rail(51) DLTUTORIAL_1\dl_straight.b3d, .Ground(1) DLTUTORIAL_1\ground1.csv, .Freeobj(1) DLTUTORIAL_1\stop_500m.csv, .Freeobj(2) DLTUTORIAL_1\stop_here.csv, Texture.Background(0) DLTUTORIAL_1\background_1.bmp, With Track, 0,.Ground 1,.back 0,.railtype 0;1,.sta yourname1; 09.2720;09.2805;1;1;0;;;7;10;;0, .railstart 1;3.5;0;1, 25,.stop 0, 350,.curve 2000;2,.railtype 0;15,.railtype 1;15, 375,.curve 1000;7,.railtype 0;12,.railtype 1;12, 775,.curve 2000;2,.railtype 0;15,.railtype 1;15, 800,.curve 0;0,.railtype 0;51,.railtype 1;51, 1025,.railtype 0;20,.railtype 1;1, 1050,.railtype 0;1,.beacon 21;0;0;10, 2100,.freeobj 0;1,.beacon 21;0;0;70, 2425,.railtype 0;5,.rail 1;3.5,.curve -1000;0,.railtype 1;12, 2450,.rail 1;4.13;0;12, 2475,.rail 1;6.00, 2500,.sta yourname2; 09.3100;09.3200;;-1;;;;30;30;;0,.rail 1;9.13,.curve 1000;0, .railtype 0;12,.railtype 1;5, 2525,.rail 1;12.26, 2550,.rail 1;14.13, 2575,.curve 0;0,.railtype 0;1,.rail 1;14.73,.railtype 1;1, 2800,.Stop 0;25;5,.freeobj 0;2, 2850,.curve 1000;0,.railtype 0;12,.railtype 1;5,.rail 1;14.73, 2875,.rail 1;14.13, 2900,.rail 1;12.26, 2925,.rail 1;9.13,.curve -1000;0,.railtype 0;5,.railtype 1;12, 2950,.rail 1;6.00, 2975,.rail 1;4.13, 3000,.rail 1;3.5,.curve 0;0,.railtype 0;1,.railtype 1;1, 3050,.curve -250;0,.railtype 0;2,.railtype 1;2,.railstart 2;0;0;1,.railstart 3;3.5;0;1, 3075,.rail 2;1.25,.rail 3;4.75, 3100,.curve 0;0,.railtype 0;1,.railtype 1;1,.rail 2;5.05,.rail 3;8.55,3125,.rail 2;10.13,.rail 3;13.63 3150,.rail 2;15.21,.rail 3;18.71 3175,.rail 2;20.29,.rail 3;23.79 3200,.rail 2;25.37,.rail 3;28.87 3225,.rail 2;30.45,.rail 3;33.95 3250,.rail 2;35.53,.rail 3;39.03 3275,.rail 2;40.61,.rail 3;44.11 3300,.rail 2;45.69,.rail 3;49.19 3325,.railend 2;50.77,.railend 3;54.27 4500,.freeobj 0;1, 4900,.sta yourname3; 09.3600;09.3700;;-1;;;;30;30;;0, 5000,.Stop 1;10;10,.freeobj 0;2, |
Our first job is to extend the straight mainline after the diverging junction so that it does not appear to suddenly end. We can do this by continuing to displace these by 5.08m further to the right of the running rail for every 25m along the route. In the previous tutorial, we ended the straight mainline tracks (rails 2 and 3) at 3325m using the railend command. To continue the mainline tracks, the following change must be made from:
1 |
3325,.railend 2;50.77,.railend 3;54.27, |
To:
1 |
3325,.rail 2;50.77,.rail 3;54.27, |
We then need to add the following code to continue our mainline tracks for a further 500m:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
3350,.rail 2;55.85,.rail 3;59.35, 3375,.rail 2;60.93,.rail 3;64.43, 3400,.rail 2;66.01,.rail 3;69.51, 3425,.rail 2;71.09,.rail 3;74.59, 3450,.rail 2;76.17,.rail 3;79.67, 3475,.rail 2;81.25,.rail 3;84.75, 3500,.rail 2;86.33,.rail 3;89.83, 3525,.rail 2;91.41,.rail 3;94.91, 3550,.rail 2;96.49,.rail 3;99.99, 3575,.rail 2;101.57,.rail 3;105.07, 3600,.rail 2;106.65,.rail 3;110.15, 3625,.rail 2;111.73,.rail 3;115.23, 3650,.rail 2;116.81,.rail 3;120.31, 3675,.rail 2;121.89,.rail 3;125.39, 3700,.rail 2;126.97,.rail 3;130.47, 3725,.rail 2;132.05,.rail 3;135.55, 3750,.rail 2;137.13,.rail 3;140.63, 3775,.rail 2;142.21,.rail 3;145.71, 3800,.rail 2;147.29,.rail 3;150.79, 3825,.railend 2;152.37,.railend 3;155.87, |
Save the route and check the changes were successful.
Now that the tracks do not suddenly end in the distance, we next need to modify the rail object to ensure no gaps are visible in the straight mainline section. To do this, we need to extend the length of the straight rail object slightly.
This has been done in the object file STRAIGHT_EXTENDED.B3D which is included in the objects download for this tutorial. Comparison of this object with STRAIGHT.B3D, the track object currently in place, shows the length of the object has been increased by 40cm backwards and forwards. (Don’t worry about object coding, apart from changing textures, this subject is outside the remit of these tutorials. An excellent guide to object coding is available from Luigi Cartello’s site at: http://bve.altervista.org/guide.html ).
Before trying to use this extended section, we need to index it in our railtype section, by adding this:
1 |
.Rail(52) DLTUTORIAL_1\straight_extended.b3d, |
At 3050, we then need to change the rail types of rails 1 and 2 (Our mainline tracks), changing from:
1 |
3050,.curve -250;0,.railtype 0;2,.railtype 1;2,.railstart 2;0;0;1,.railstart 3;3.5;0;1, |
To:
1 |
3050,.curve -250;0,.railtype 0;2,.railtype 1;2,.railstart 2;0;0;52,.railstart 3;3.5;0;52, |
When the route is viewed, you should now be able to see that the gaps in the rails have been eliminated.
The final change we are going to make to the track work (for now!) is to add some points to the junction. To do this, we are going to replace the sections of plain track with a suitable free object. This, like the track objects, has been created using Switch 15 and is included in the objects download for this tutorial.
Before positioning the points, they must first be indexed as a free object by adding the following statement into the freeobjects list in the ’with structure’ section of the code:
1 |
.Freeobj(10) DLTUTORIAL_1\switch_L_250.b3d, |
We can now position our set of points as a freeobject at position 3075, by changing our code there to look like this:
1 |
3075,.rail 2;1.25,.rail 3;4.75,.freeobj 0;10;1.25;0;8.56, |
When positioning a free object, the code required is as follows:
.freeobj I;T;X;Y;R,
Where I is the index of the object as defined in the ‘with structure’ section, T is the rail to which the object is being associated, X is the distance, in metres, to the left (negative) or right (positive) of the running rail, Y is the distance, in metres, below (negative) or above (positive) the running rail, R is the angle, in degrees, by which the object is to be rotated
It is a requirement of ‘Switch’ that the distance between the two rails exceeds 3.5metres and that the length of the objects are in increments of 25m. For our 250m radius curve, if the points were 25m long, the distance between the rails would be 1.25m (as we calculated when positioning the diverging curve). Because of this, the points constructed for 250m radius diverging curves must be 50m long.
Because the mid-distance of the points is set at 0m (the length of the object extending from -25m to +25m), they must be located 25m forwards of where the rails actually diverge, hence the positioning at 3075m.
The points have been placed 1.25m to the right of the running rail (rail 0), again as a consequence of the way ‘Switch’ builds the objects. The straight track of the points is displaced by this distance away from the curved track (which forms our running rail) at 25m along the length of the object (again, this is known from the curve calculations we used to construct the divergence).
Finally, we need to rotate the points object by an amount consistent with having travelled 25m along a 250m radius curve. The degree of rotation applied was found by trial and error although it could be calculated by working out the distance travelled around the circumference of the curve and the angle subtended by this arc.
If we now view our junction, we find that where we have placed the points, the track now appears very ‘flickery’. This is a phenomenon called Z-Fighting, and is caused by two textures being overlaid in the same position, namely the original track and the points objects. To overcome this, we need to remove the original track objects which are present where the points are located. The easiest way of doing this is to use a null (blank) rail object in place of the normal track object. A null rail object has been included in the objects download (NULL_RAIL.B3D), which, if we open up the object file is seen to contain just a single vertex, the minimum code possible in an object file.
Before using the null rail, we must first index this as a rail object by adding this statement to the ‘with structure’ section of the route file, like this:
1 |
.Rail(53) DLTUTORIAL_1\null_rail.b3d, |
We should then replace the track textures between 3050m and 3100m, by changing our routefile to look like this:
1 2 3 4 5 |
3000,.rail 1;3.5,.curve 0;0,.railtype 0;1,.railtype 1;1, 3050,.curve -250;0,.railtype 0;53,.railtype 1;2,.railstart 2;0;0;53,.railstart 3;3.5;0;52, 3075,.rail 2;1.25,.rail 3;4.75,.freeobj 0;10;1.25;0;8.59, 3100,.curve 0;0,.railtype 0;1,.railtype 1;1,.rail 2;5.05;0;52,.rail 3;8.55, 3125,.rail 2;10.13,.rail 3;13.63, |
You will notice that the railtype of rails 0 & 2 were changed to our null rail object at position 3050, and then returned to the standard rail objects at position 3100.
Also notice that the track object of rail 2 is defined by extending the rail command to include our railtype.
Perform the same operation for our next set of points (rails 1 & 3), and your routefile should now look like this:
1 2 3 4 5 |
3000,.rail 1;3.5,.curve 0;0,.railtype 0;1,.railtype 1;1, 3050,.curve -250;0,.railtype 0;53,.railtype 1;53,.railstart 2;0;0;53,.railstart 3;3.5;0;53, 3075,.rail 2;1.25,.rail 3;4.75,.freeobj 0;10;1.25;0;8.59,.freeobj 0;10;4.75;0;8.59, 3100,.curve 0;0,.railtype 0;1,.railtype 1;1,.rail 2;5.05;0;52,.rail 3;8.55;0;52, 3125,.rail 2;10.13,.rail 3;13.63, |
If the route is now viewed, a region of ‘flickering’ still occurs over the region where we have two superimposed points objects. This could be overcome by producing a modified points object which omits the overlaid region (or the whole junction could be modelled using a single ‘custom built’ object). However, as object building (or modification) is largely beyond the scope of this tutorial, we will leave the objects ‘as built‘.
On viewing the route, it is apparent that a small gaps remain in the right hand track between the straight track and the points. This can be overcome by using our extended straight track object for the right hand rail. To do this, change our code at position 3000 from:
1 |
3000,.rail 1;3.5,.curve 0;0,.railtype 0;1,.railtype 1;1, |
To look like this:
1 |
3000,.rail 1;3.5,.curve 0;0,.railtype 0;1,.railtype 1;52, |
For the moment then, that’s the track laying completed for our route. Laying the plain line was straightforward, just using the curve command to make our track follow the desired route (graduating the curves where necessary). We then introduced smooth curves as replacement track objects and also saw how to use these to diverge and converge tracks around the island platform and diverging junction. Finally, we replaced the curved track objects at the junction with points. We will deal with gradients once we start ‘landscaping’ the route.
The junction itself could really do with more work – we have uncovered several deficiencies in the ‘Switch’ generated objects and we could do with a proper crossover. However, this utility is very much easier for the beginner to use than ‘hand building’ the junction, something which even seasoned route builders can find difficult!
It is now time to start enhancing the operational aspects of our route, looking initially at introducing speed limits. To add or change the speed limit, the limit command is used:
.limit X;Y
Where X is the speed limit in KMH (to convert MPH to KMH, multiply by 1.61), Y is the distance in metres after the command at which the restriction will be enforced.
To make the linespeed of the first part of our route 75MPH, we need to add this code:
1 |
25,.stop 0,.limit 121, |
Notice that that the second parameter has not been included as we want the speed limit to be effective immediately (and BVE will default this value to zero if it is not specified).
We also need to include a lineside sign to let the driver know what the speed limit is. Before doing this, we must index a suitable object (one of which has been included in the objects download) as a free object. We can do this by adding this to our freeobjects section:
1 |
.freeobj(20) DLTUTORIAL_1\limit_75.x, |
Next, add the object, so our code now looks like this:
1 2 |
25,.stop 0,.limit 121, 50,.freeobj 0;20, |
With the short distances between stops on our route, it is unlikely 75MPH will be exceeded, but if so, the standard BVE warning will be applied on screen.
Approaching the second station, a reduced speed limit is required, 20MPH being necessary due to the reverse curves being present. To add this, we again need to index our sign object by again adding this code to our freeobjects section:
1 |
.freeobj(21) DLTUTORIAL_1\limit_20.x, |
We then need to position this sign where our reduced speed limit becomes effective by adding this code:
1 |
2375,.limit 32,.freeobj 0;21, |
Also needed will be an advanced warning board for this speed restriction, and again we need to index a free object:
1 |
.freeobj(22) DLTUTORIAL_1\warning_20.x, |
The location of the advanced warning board must allow a sufficient distance for all train types to decelerate from the permitted line speed, taking gradients into consideration.
The deceleration distances are published online by Railway Group Safety and should be adhered to if prototypical operation is to be followed. For our speed restriction, advanced warning must be given 1267m before the restriction, therefore the warning board must be placed at 1100m (after rounding to the nearest 25m);
1 |
1100,.freeobj 0;22, |
We will leave the remaining speed restrictions until the next tutorial where we will also look at adding AWS warnings to the restrictions and protecting the end of our route with TPWS.