In this tutorial, we will add code to extend the ‘disappearing‘ rails, ue 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.
Throughout this series of tutorials, pre-existing code will be coloured blue and changes being made to the code will be shown in red. New code to be added will be coloured green.
Additional objects are required for this tutorial may be found here…..
DLTUTORIAL_1_6 OBJECTS.zip. Any pre-existing object files may be overwritten.
Time to open the route file and get coding…
The route file we created previously should look something like this
DLTUTORIAL_AFTER 1_5.zip.
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;
3325,.railend 2;50.77,.railend 3;54.27,
to
3325,.
rail 2;50.77,.rail 3;54.27,before adding this code to continue these tracks for a further 500m;
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.
Note - the route file contained in DLTUTORIAL_AFTER 1_5.zip is missing commas at the end of 3150 - 3325. Please ensure these are present.
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 outside the remit of these tutorials. An excellent guide to object coding is available at http://bve.altervista.org/guide.html).
Before using the extended straight section, we need to index the track object by adding
.Rail(51) DLTUTORIAL_1\dl_straight.b3d,
.Rail(52) DLTUTORIAL_1\straight_extended.b3d,
.Ground(1) DLTUTORIAL_1\ground1.csv,
and then changing the rail types of rails 1 and 2; changing from;
3050,.curve -250;0,.railtype 0;2,.railtype 1;2,.railstart 2;0;0;1,.railstart 3;3.5;0;1,
to
3050,.curve -250;0,.railtype 0;2,.railtype 1;2,.railstart 2;0;0;
52,.railstart 3;3.5;0;52,Now, when the route is viewed, 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 ’with structure’ section of the code,
.Freeobj(2) DLTUTORIAL_1\stop_here.csv,
.Freeobj(10) DLTUTORIAL_1\switch_L_250.b3d,
Texture.Background(0) DLTUTORIAL_1\background_1.bmp,
Now we can position the points as a free object,
3050,.curve -250;0,.railtype 0;2,.railtype 1;2,.railstart 2;0;0;52,.railstart 3;3.5;0;52,
3075,.rail 2;1.25,.rail 3;4.75,
.freeobj 0;10;1.25;0;8.56,3100,.curve 0;0,.railtype 0;1,.railtype 1;1,.rail 2;5.05,.rail 3;8.59,
When positioning a free object, the code required is
.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
The positioning of our points requires a little thought because of the way ‘Switch’ constructs these objects.
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.
*** Note - a solution to the problem of calculating the angle of rotation has kindly been provided by Fabiano Bracaloni and can be found here...
tutorial 1_6 additional.htm ***
If we now view our junction, we find that where we have placed the points, the track now appears very ‘flickery’. This 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;
.Rail(52) DLTUTORIAL_1\straight_extended.b3d,
.Rail(53) DLTUTORIAL_1\null_rail.b3d,
.Ground(1) DLTUTORIAL_1\ground1.csv,
And then replacing the track textures (rail types) between 3050 and 3100m; changing the code from;
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;52,.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,.rail 3;8.55,
3125,.rail 2;10.13,.rail 3;13.63,
to
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,
Notice how we have defined the track object of rail 2 by extending the rail command to include the rail type.
Performing the same operations for the second set of points, change the code from;
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,
to
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 the code from;
3000,.rail 1;3.5,.curve 0;0,.railtype 0;1,.railtype 1;1,
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,
to
3000,.rail 1;3.5,.curve 0;0,.railtype 0;1,.railtype 1;
52,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,
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 the code
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 the code;
.freeobj(10) DLTUTORIAL_1\switch_L_250.b3d,
.freeobj(20) DLTUTORIAL_1\limit_75.x,
Texture.Background(0) DLTUTORIAL_1\background_1.bmp,
Then to add the free object,
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 adding the code
.freeobj(20) DLTUTORIAL_1\limit_75.x,
.freeobj(21) DLTUTORIAL_1\limit_20.x,
Texture.Background(0) DLTUTORIAL_1\background_1.bmp,
Then position the sign at the distance the restriction becomes effective;
2100,.freeobj 0;1,.beacon 21;0;0;70,
2375,.limit 32,.freeobj 0;21,
2425,.railtype 0;5,.rail 1;3.5,.curve -1000;0,.railtype 1;12,
Also needed will be an advanced warning board for this speed restriction, again we need to index a free object;
.freeobj(21) DLTUTORIAL_1\limit_20.x,
.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);
1050,.railtype 0;1,.beacon 21;0;0;10,
1100,.freeobj 0;22,
2100,.freeobj 0;1,.beacon 21;0;0;70,
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.