In the previous tutorial, we added a cutting wall on the right hand side of the approach to the tunnel. In this tutorial, we will concentrate our efforts on the left hand side, creating a ground of flat water separated from the track by a walled walkway.
Additional objects used in this tutorial session may be found here:
http://vps.bvecornwall.co.uk/dennislance/DLTUTORIAL_1_13.zip
Unzip to the DLTUTORIAL_1 in your objects folder.
Time to get to work…
In the previous tutorial, we added a rising gradient on the approach to the tunnel. The area of water on the left hand side must be level (so that it represents a waterfront location), so our first job is to use the height command to ensure that the object we create to represent the water remains at the same level along the length of the route while the track rises up from it.
Looking at the code, we find that in this section of code several pitch commands were inserted to represent the gradually increasing gradient:
1 2 3 4 5 6 7 8 9 10 |
0,.Ground 2,.back 0,.railtype 0;1,.sta yourname1;9.2720;09.2805;;1;1;;;7;10;;0,.railstart 1;3.5;0;1,.brightness 240,.pitch 0,.dike 0;-1;1,.height 10,.railstart 10;45;-25;53,.wall 10;1;1, 25,.stop 0,.limit 121,.pitch 2,.rail 10;35;-20, 50,.freeobj 0;20,.pitch 4,.rail 10;19;-12, 71,.beacon 44003;0;1;0,.freeobj 0;33, 74,.freeobj 0;32, 75,.sigf 3;1;-2.75;4.6,.section 0;2;4,.freeobj 0;40;-0.5;-0.2,.freeobj 0;32,.pitch 8,.rail 10;11;-8, 100,.pitch 12,.rail 10;7;-4, 125,.pitch 16,.rail 10;5;-2, 150,.pitch 20,.rail 10;4;-1, 175,.pitch 24,.rail 10;3.5;0, |
So how do these pitch commands change the height of the track above a level surface?
To answer this question we must work out the height change the gradient induces over each 25metre length, remembering that we are starting at a height of 10m.
At 0metres, the pitch value was 0, therefore no height change occurs in the first 25metres, so at 25m, the height will of the track will still be 10m and we should add this to the code:
1 |
25,.stop 0,.limit 121,.pitch 2,.rail 10;35;-20,.height 10, |
At 25m, the gradient changes to 1/500 (remembering the equation to convert pitch to gradient, pitch = 1000/y). Therefore, in 25m, the height of the track will increase by 25/500 = 0.05m. So, after 25m at pitch 2, the height of the track will be 10.05m. Inserting this into the route file,
1 |
50,.freeobj 0;20,.pitch 4,.rail 10;19;-12,.height 10.05, |
At 50metres, the pitch changes to 4 and hence the gradient becomes 1/250. Therefore, in 25metres, the height of the track will increase by 25/250 = 0.1m. So, at 75metres, the height of the track will be 10.05+0.1 = 10.15m. Inserting this into the route file,
1 |
75,.sigf 3;1;-2.75;4.6,.section 0;2;4,.freeobj 0;40;-0.5;-0.2,.freeobj 0;32,.pitch 8,.rail 10;11;-8,.height 10.15, |
At 75metres, the pitch changes to 8 and hence the gradient becomes 1/125. Therefore, in 25metres, the height of the track will increase by 25/125 = 0.2m. So, at 100metres, the height of the track will be 10.15+0.2 = 10.35m. Inserting this into the route file,
1 |
100,.pitch 12,.rail 10;7;-4,.height 10.35, |
Continuing these calculations in the same manner, the height values we need to add for the remaining track to the tunnel entrance are as follows:
1 2 3 4 5 6 |
125,.pitch 16,.rail 10;5;-2,.height 10.65, 150,.pitch 20,.rail 10;4;-1,.height 11.05, 175,.pitch 24,.rail 10;3.5;0,.height 11.55, 200,.height 12.15, 225,.height 12.75, 250,.freeobj 0;50,.railtype 0;21,.railtype 1;21,.brightness 240,.wallend 10,.height 13.35, |
Once we enter the tunnel, the height of the tracks above the surrounding round level remains relevant as it can still be viewed before the tunnel is entered. So, continuing to enter the height calculations:
1 2 3 4 5 6 7 8 9 |
300,.freeobj 0;51,.height 13.95, 325,.freeobj 0;52,.railtype 0;23,.railtype 1;23,.brightness 100,.height 14.55, 350,.curve 2000;2,.railtype 0;15,.railtype 1;15,.brightness 240,.height 15.15, 375,.curve 1000;7,.railtype 0;12,.railtype 1;12,.height 15.75, 400,.pitch 20,.height 16.65, 425,.height 17.15, 450,.height 17.65, 475,.height 18.15, 500,.pitch 15,.height 18.65, |
After this point, the water surface wil not be clearly visible and we do not need to continue with these calculations.
Now we need to create our ground object. For this, we will start off with a single, horizontal face, the object file being saved as sea_1.CSV and indexed as ground 2 in the route file. This ground should be applied at 0m in place of ground 1.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
CreateMeshBuilder, addVertex,-108, 0.0, 28, AddVertex,0, 0.0, 28, AddVertex,0, -0.2, -2, AddVertex,-108, -0.2, -2, AddFace,0,1,2,3, GenerateNormals, LoadTexture,sea_1.bmp, SetTextureCoordinates,0,0,0, SetTextureCoordinates,1,1,0, SetTextureCoordinates,2,1,0.45, SetTextureCoordinates,3,0,0.45, |
There is a degree of overlap in the z-direction as well as a small height change to ensure no gaps appear as we view from the different heights and angles when travelling up the hill. The texture has also been distorted slightly, ideally our 108x30m area would use the bitmap 1×0.28 times (the width to length ratio of the flat face). However, in this instance, a single continuous wave was visible along the whole length of the water; completely unrealistic but by using slightly more of the texture image, this effect was largely overcome.
At the moment, the water only extends 108m to the left – for a larger expanse of water, a second face can be added which extends further to the left. However, because of the colour differences across the width of the texture, we can produce a mirror image of the texture to avoid an unsightly discontinuity. This can be done by swapping the x parameters in the settexturecoordinates command, so our second face looks like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
CreateMeshBuilder, addVertex,-216, 0.0, 28, AddVertex,-107, 0.0, 28, AddVertex,-107, -0.2, -2, AddVertex,-216, -0.2, -2, AddFace,0,1,2,3, GenerateNormals, LoadTexture,sea_1.bmp, SetTextureCoordinates,0,1,0, SetTextureCoordinates,1,0,0, SetTextureCoordinates,2,0,0.45, SetTextureCoordinates,3,1,0.45, |
Also as part of the ground, we can add a walkway which is separated from the railway tracks by a wall. Because this is going to be attached to the gound, the effect of increasing height will become more apparent. For the main face of the wall, add the following to the ground object file:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
CreateMeshBuilder, addVertex,-6.2, 11, -0.1, AddVertex,-6.2, 11, 25.1, AddVertex,-6, 8.5, 25.1, AddVertex,-6, 8.5, -0.1, AddFace,0,1,2,3, GenerateNormals, LoadTexture,wall_1.bmp, SetTextureCoordinates,0,0,0, SetTextureCoordinates,1,2,0, SetTextureCoordinates,2,2,1, SetTextureCoordinates,3,0,1, |
And for the capping stones, using the same texture but applying a small part of it horizontally (to give a more 3d appearance to the wall), add the following code to the object file:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
CreateMeshBuilder, addVertex,-6.95, 11, -0.1, AddVertex,-6.95, 11, 25.1, AddVertex,-6.2, 11, 25.1, AddVertex,-6.2, 11, -0.1, AddFace,0,1,2,3, GenerateNormals, LoadTexture,wall_1.bmp, SetTextureCoordinates,0,0,0, SetTextureCoordinates,1,2,0, SetTextureCoordinates,2,2,0.095, SetTextureCoordinates,3,0,0.095, |
The next job is to add the walkway on the other side of the wall from the tracks and place some fencing to the top of the wall where it becomes low. The 11metre wide walkway can be added to the current ground file;
1 2 3 4 5 6 7 8 9 10 11 12 13 |
CreateMeshBuilder, addVertex,-17.1, 8.5, -0.2, AddVertex,-17.1, 8.5, 25.1, AddVertex,-6.1, 8.5, 25.1, AddVertex,-6.1, 8.5, -0.2, AddFace,0,1,2,3, GenerateNormals, LoadTexture,walkway.bmp, SetTextureCoordinates,0,0,0, SetTextureCoordinates,1,2,0, SetTextureCoordinates,2,2,1, SetTextureCoordinates,3,0,1, |
Our final task for this tutorial is to make use of the wall command to add some lineside fencing (in the form of simple railings) to the walkway as it approaches the tunnel. To do this, we must create a new single faced object file; this should be saved in the objects directory as fence_1.CSV. It is worth noting that the fence itself has intentionally been made overscale to help reduce the flickering associated with fine details.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
CreateMeshBuilder, addVertex,-6.2, 0.5, -0.1, AddVertex,-6.2, 0.5, 25.1, AddVertex,-6.2, -1.45, 25.1, AddVertex,-6.2, -1.45, -0.1, AddFace,0,1,2,3, GenerateNormals, LoadTexture,fence_1.bmp, SetTextureCoordinates,0,0,0, SetTextureCoordinates,1,8,0, SetTextureCoordinates,2,8,1, SetTextureCoordinates,3,0,1, setdecaltransparentcolor,0,0,0, |
The wall object must be indexed in the route file (as it appears on the left hand side of the rail, it is logical to make it a wallL object):
1 |
.wallL(1) DLTUTORIAL\fence_1.csv, |
It should then be applied starting after 200m:
1 |
200,.height 12.15,.wall 0;-1;1, |
By attaching the fence to the running rail rather than the ground, the apparent height of the fence (relative to the running rail) is not changing. If the railings were added to the ground object, they would have been submerged in ballast as the tunnel was approached.
In this part, we have examined the interaction between the pitch and height commands to ensure a level ground has been created as the height of the running rail was increased. The ground itself was composed of a flat plane of water with a walkway and protective wall which was reduced in height as the climb towards the tunnel entrance progressed. Finally, railings were associated with the running rail to ensure these appeared to remain at a constant height despite the rising gradient.
In the next part, we will finish off the tunnel approach scene by adding a rocky outcrop jutting out into the water and add some detail to the top of the tunnel. The gaps around the tunnel walls will also be tidied up before we take a look at constructing a station.