{"id":232,"date":"2014-03-14T13:25:59","date_gmt":"2014-03-14T13:25:59","guid":{"rendered":"http:\/\/www.bvecornwall.co.uk\/wordpress\/?page_id=232"},"modified":"2021-06-20T18:40:50","modified_gmt":"2021-06-20T18:40:50","slug":"route-building-tutorial-4-track-layout-and-textures-run-sounds","status":"publish","type":"page","link":"http:\/\/www.bvecornwall.co.uk\/wordpress\/route-building-tutorial-4-track-layout-and-textures-run-sounds\/","title":{"rendered":"Route Building Tutorial 4: Track Layout and Textures &#038; Run Sounds"},"content":{"rendered":"<p>In this fourth tutorial, we will take a look changing the position of the adjacent track, alter the appearance of the track and introduce run sounds.<br \/>\n<b><\/b><\/p>\n<p><b><span style=\"font-size: large;\">Time to open the route file and get coding\u2026<\/span><\/b><\/p>\n<p>The route file we created previously should look something like this:<\/p>\n<pre class=\"theme:bve lang:bve decode:true\">Route.Comment Route learning with Dennis,\r\nRoute.Gauge 1435,\r\nRoute.DeveloperID yourname123,\r\nRoute.change 1,\r\nwith train,\r\nTrain.Folder cl170,\r\nWith Structure\r\n\r\n.Rail(1) DLTUTORIAL_1\\straight.b3d,\r\n.Rail(2) DLTUTORIAL_1\\250_l.b3d,\r\n.Rail(3) DLTUTORIAL_1\\500_l.b3d,\r\n.Rail(4) DLTUTORIAL_1\\750_l.b3d,\r\n.Rail(5) DLTUTORIAL_1\\1000_l.b3d,\r\n.Rail(6) DLTUTORIAL_1\\1250_l.b3d,\r\n.Rail(7) DLTUTORIAL_1\\1500_l.b3d,\r\n.Rail(8) DLTUTORIAL_1\\2000_l.b3d,\r\n.Rail(9) DLTUTORIAL_1\\250_r.b3d,\r\n.Rail(10) DLTUTORIAL_1\\500_r.b3d,\r\n.Rail(11) DLTUTORIAL_1\\750_r.b3d,\r\n.Rail(12) DLTUTORIAL_1\\1000_r.b3d,\r\n.Rail(13) DLTUTORIAL_1\\1250_r.b3d,\r\n.Rail(14) DLTUTORIAL_1\\1500_r.b3d,\r\n.Rail(15) DLTUTORIAL_1\\2000_r.b3d,\r\n\r\n.Ground(1) DLTUTORIAL_1\\ground1.csv,\r\n\r\n.Freeobj(1) DLTUTORIAL_1\\stop_500m.csv,\r\n.Freeobj(2) DLTUTORIAL_1\\stop_here.csv,\r\n\r\nTexture.Background(0) DLTUTORIAL_1\\background_1.bmp,\r\n\r\nWith Track,\r\n0,.Ground 1,.back 0,.railtype 0;1,.sta yourname1; 09.2720;09.2805;1;1;0;;;7;10;;0,\r\n.railstart 1;3.5;0;1,\r\n\r\n25,.stop 0,\r\n350,.curve 2000;2,.railtype 0;15,.railtype 1;15,\r\n375,.curve 1000;7,.railtype 0;12,.railtype 1;12,\r\n775,.curve 2000;2,.railtype 0;15,.railtype 1;15,\r\n800,.curve 0;0,.railtype 0;1,.railtype 1;1,\r\n2100,.freeobj 0;1,\r\n\r\n2500,.sta yourname2; 09.3100;09.3200;;-1;;;;30;30;;0,\r\n\r\n2600,.Stop 0;5;5,.freeobj 0;2,\r\n\r\n4500,.freeobj 0;1,\r\n\r\n4900,.sta yourname3; 09.3600;09.3700;;-1;;;;30;30;;0,\r\n\r\n5000,.Stop 1;10;10,.freeobj 0;2,<\/pre>\n<p>The adjacent track (which we have indexed as rail 1) runs the entire length of the route 3.5 metres to the right of the running rail. If we wish to alter the relative position, we need to use the rail command;<\/p>\n<p><b>.rail <\/b>n;x;y;t,<br \/>\nWhere n is the index of the rail, x is the distance to the left (negative values) or right (positive values) of the running rail, y is the distance below (negative values) or above (positive values) of the running rail, t is the rail type as defined in the \u2018with structure\u2019 section of the route file.<\/p>\n<p>Notice the similarity of the of this command to the railstart command we have used at the start of the route. This command may also be simplified by omitting any unchanged parameters at the end of the command (as we will in the example below).<\/p>\n<p>Using the rail command, we can make our tracks diverge at the second station to allow inclusion of an island platform. If we assume this platform is to be <span style=\"text-decoration: underline;\">about<\/span> 13 metres wide, rail 1 must be moved so that it is 15 metres to the right of the running rail. This greater distance is to allow for the half width of the tracks (as all distances are measured from the centre of the tracks) and necessary clearance between the train and platform edges.<\/p>\n<p>Looking at the route file, we currently have:<\/p>\n<pre class=\"lang:bve decode:true\">800,.curve 0;0,.railtype 0;1,.railtype 1;1,\r\n2100,.freeobj 0;1,\r\n2500,.sta yourname2; 09.3100;09.3200;;-1;;;;30;30;;0,\r\n2600,.Stop 0;5;5,.freeobj 0;2,<\/pre>\n<p>First, try adding a rail command to move the secondary rail 15m to the right of our running rail at the station:<\/p>\n<pre class=\"lang:bve decode:true\">2500,.sta yourname2; 09.3100;09.3200;;-1;;;;30;30;;0,.rail 1;15,<\/pre>\n<p>Save the route, load it up and see what happens by viewing the route (no need to drive it, we can use viewer mode to do this).<\/p>\n<p>Clearly, this is not correct. Rail 1 moves from 3.5 to 15m to the right of the running rail in just 25m and the track is all in straight sections. We could smooth things out a bit by adding incremental changes to the distance between the running rails by adding more rail commands:<\/p>\n<pre class=\"lang:bve decode:true\">2425,.rail 1;6.375,\r\n2450,.rail 1;9.25,\r\n2475,.rail 1;12.125,\r\n2500,.sta yourname2; 09.3100;09.3200;;-1;;;;30;30;;0,.rail 1;15,<\/pre>\n<p>This looks much better but by no means perfect. Lets think about what we can do using smooth curves.<\/p>\n<p>Ideally, we want a construction something like this where, both the running rail and the adjacent rail curve on approaching the island platform:<\/p>\n<div id=\"attachment_233\" style=\"width: 251px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.bvecornwall.co.uk\/wordpress\/wp-content\/uploads\/2014\/03\/island_plan.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-233\" class=\"size-full wp-image-233\" alt=\"A basic plan for the tracks of our island platform\" src=\"http:\/\/www.bvecornwall.co.uk\/wordpress\/wp-content\/uploads\/2014\/03\/island_plan.jpg\" width=\"241\" height=\"109\" data-id=\"233\" \/><\/a><p id=\"caption-attachment-233\" class=\"wp-caption-text\">A basic plan for the tracks of our island platform<\/p><\/div>\n<p>To achieve this, we must curve our running rail (the top rail on this diagram) first to the left and then to the right before straightening out. The adjacent rail (rail 1 in our\u00a0route) must curve first to the right and then to the left before straightening out. Now all we need to do is decide the radii of the curves to be used and calculate the distances between the two rails at the locations marked\u00a01 and\u00a02 (knowing that at location 1 our adjacent rail is 3.5 metres to the right of the running rail.<\/p>\n<p>If we think about practical operation of the railway, the curves must not be of such sharp radius as to excessively slow passing trains, so a curve radius of ~750-1000m would be fine.<\/p>\n<p>In our route, we now need to think about the combinations of curve length and radius available to us which will displace the track by about 3 metres.<\/p>\n<p>Why 3m? Consider the end of this curve as being at location 2 on the track diagram. We want the total distance between the rails to be ~15m, the distance currently being 3.5m, so the total displacement required by one track is 6m and half of this will be achieved using the first of our two (reversing) curves.<\/p>\n<p>Time for some maths\u2026..<b>take your time over this &#8211; it is a tricky subject which requires some thought.<\/b><\/p>\n<p>Using the equation of a circle, given by the formula x<sup>2<\/sup> + y<sup>2<\/sup> = r<sup>2<\/sup> , we can calculate that a 1000m radius curve wil be displaced by 2.8m over a distance of 75m &#8211; a little under our target value but we have curved rail objects of this radius which we can use. (The calculations can be performed by hand, or, on the index page, there is a link to a simple spreadsheet which can perform these calculations. Other solutions to problems of this nature have also been published).<\/p>\n<p>Working out the displacment at 25m intervals (which is required for BVE coding), we have:<br \/>\n\n<table id=\"tablepress-1\" class=\"tablepress tablepress-id-1\">\n<thead>\n<tr class=\"row-1\">\n\t<th class=\"column-1\">offset X (m)<\/th><th class=\"column-2\">y<\/th>\n<\/tr>\n<\/thead>\n<tbody class=\"row-striping row-hover\">\n<tr class=\"row-2\">\n\t<td class=\"column-1\">0.00<\/td><td class=\"column-2\">0<\/td>\n<\/tr>\n<tr class=\"row-3\">\n\t<td class=\"column-1\">0.31<\/td><td class=\"column-2\">25<\/td>\n<\/tr>\n<tr class=\"row-4\">\n\t<td class=\"column-1\">1.25<\/td><td class=\"column-2\">50<\/td>\n<\/tr>\n<tr class=\"row-5\">\n\t<td class=\"column-1\">2.82<\/td><td class=\"column-2\">75<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/p>\n<p>Remember, this is the displacement given by one curve only. We have two diverging curves which were initially 3.5 metres apart. The total distance between the running rail and rail 1 will therefore be (2 x calculated offset) + 3.5 and as our curve commences at 2425m we also need to add this to the y values, giving us the following distances between the rails:<br \/>\n\n<table id=\"tablepress-2\" class=\"tablepress tablepress-id-2\">\n<thead>\n<tr class=\"row-1\">\n\t<th class=\"column-1\">Distance between rails (m)<\/th><th class=\"column-2\">Distance along route (m)<\/th>\n<\/tr>\n<\/thead>\n<tbody class=\"row-striping row-hover\">\n<tr class=\"row-2\">\n\t<td class=\"column-1\">3.5<\/td><td class=\"column-2\">2425<\/td>\n<\/tr>\n<tr class=\"row-3\">\n\t<td class=\"column-1\">4.13<\/td><td class=\"column-2\">2450<\/td>\n<\/tr>\n<tr class=\"row-4\">\n\t<td class=\"column-1\">6.00<\/td><td class=\"column-2\">2475<\/td>\n<\/tr>\n<tr class=\"row-5\">\n\t<td class=\"column-1\">9.13<\/td><td class=\"column-2\">2500<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<!-- #tablepress-2 from cache --><\/p>\n<p>Now it\u2019s time to add our calculated displacements into the route code. We will also need to change the rail type of the running rail to use a left handed 1000m radius curve (indexed as rail (5) in the \u2018with structure\u2019 part of the route file). Similarly, the rail type of the adjacent rail needs to be a right handed 1000m radius curve, indexed as rail (12). Finally, using the curve command, we must also let BVE know we will be going around a 1000m radius curve to the left.<\/p>\n<p>Before adding our smoothly curved diverging rails, we first need to remove any changes previously made. Instead, the code we need to add is:<\/p>\n<pre class=\"lang:bve decode:true\">2425,.railtype 0;5,.rail 1;3.5,.curve -1000;0,\r\n2450,.rail 1;4.13;0;12,\r\n2475,.rail 1;6.00,\r\n2500,.sta yourname2; 09.3100;09.3200;;-1;;;;30;30;;0,.rail 1;9.13,<\/pre>\n<p>Note how the rail command has been shortened when no changes are being made to the y offset or rail type. No cant is present on this curve.<\/p>\n<p>We are now half way through building our reversing curve which approaches the island platform (having constructed the track between locations 1 and 2 on our diagram). At the moment, this looks no better than our first effort. Don\u2019t worry, we\u2019ll finish it off in the next tutorial.<\/p>\n<p>For a little light relief, lets now have a look at changing the appearance of the track.<\/p>\n<p>In amongst the objects, you will find bitmaps named \u201cdl_track.bmp\u201d and \u201cdl_ballast.bmp\u201c. These were cut from a photo I took recently on a trip to Dawlish &#8211; the orginal being \u201cDSCF0056.JPG\u201c. We can use these bitmaps to replace the Switch 1.5 default textures.<\/p>\n<p>For the straight track, this has been performed by opening up the object file \u201cstraight.b3d\u201d and replacing all occurrences of schotter1.bmp with dl_ballast and also replacing all occurrences of schwellen1.bmp with dl_track.bmp. The file was then resaved as DL_STRAIGHT.B3D (if using notepad, include the .b3d extension and choose \u2018all files\u2019 from the \u2018save as type\u2019 list).<\/p>\n<p>Before we can use this track object, we need to index it in the \u2019with structure\u2019 section of the route file by adding this code:<\/p>\n<pre class=\"lang:bve decode:true\">.Rail(51) DLTUTORIAL_1\\dl_straight.b3d,<\/pre>\n<p>Now, in the same way as we have been using curved rail objects, we can use this straight track object by using the rail type command. So, to change the track texture after the first curve, alter the code which specifies which rail type is being used from;<\/p>\n<pre class=\"lang:bve decode:true \" >800,.curve 0;0,.railtype 0;1,.railtype 1;1,<\/pre>\n<p>To:<\/p>\n<pre class=\"lang:bve decode:true \" >800,.curve 0;0,.railtype 0;51,.railtype 1;51,<\/pre>\n<p>Whether this is an improvement or not is open to debate &#8211; the bitmaps I have used need a little fine tuning as the rail in the original bitmap can still be seen under the rail generated in the object file and this should be changed to a darker rust colour. Nevertheless, the principle of modifying objects by using different textures (re-skinning) has been demonstrated.<\/p>\n<p>The bitmaps to be used should be 8 bit indexed colour images dimensioned in ^2 (i.e. 16, 32, 64, 128 etc). For example 128&#215;64 images are ok, 106&#215;65 will not display correctly.<\/p>\n<p>Use of true RGB colour bitmaps is possible but not encouraged as file sizes are significantly increased and display problems will occur when transparent regions are required.<\/p>\n<p>Before publishing modified objects, copyright issues must be resolved.<\/p>\n<p>So far, the default track sound has been used throughout our route. However, the sounds heard from a cab will be quite different on jointed or continuous track and will also vary when passing through tunnels or bridges. To enable these different sounds to be used, we must index rail types with the sounds. This is done in accordance with the BVE track sound standard, BVETSS. More information can be found at http:\/\/www.railsimroutes.co.uk\/<\/p>\n<p>The standard sounds are as follows:<br \/>\n\n<table id=\"tablepress-3\" class=\"tablepress tablepress-id-3\">\n<thead>\n<tr class=\"row-1\">\n\t<th class=\"column-1\">Run Sound #<\/th><th class=\"column-2\">Train Sound File<\/th><th class=\"column-3\">Description<\/th>\n<\/tr>\n<\/thead>\n<tbody class=\"row-striping row-hover\">\n<tr class=\"row-2\">\n\t<td class=\"column-1\">0<\/td><td class=\"column-2\">Run0.wav<\/td><td class=\"column-3\">Jointed rails, wooden sleepers<\/td>\n<\/tr>\n<tr class=\"row-3\">\n\t<td class=\"column-1\">1<\/td><td class=\"column-2\">Run1.wav<\/td><td class=\"column-3\">Jointed rails, concrete sleepers and jointed track higher linespeed with wind noise <\/td>\n<\/tr>\n<tr class=\"row-4\">\n\t<td class=\"column-1\">2<\/td><td class=\"column-2\">Run2.wav<\/td><td class=\"column-3\">Continuous welded rail<\/td>\n<\/tr>\n<tr class=\"row-5\">\n\t<td class=\"column-1\">3<\/td><td class=\"column-2\">Run3.wav<\/td><td class=\"column-3\">Continuous welded rail - Tunnel and bridge<\/td>\n<\/tr>\n<tr class=\"row-6\">\n\t<td class=\"column-1\">4<\/td><td class=\"column-2\">Run4.wav<\/td><td class=\"column-3\">Jointed rails, wooden sleepers - Tunnel and bridge<\/td>\n<\/tr>\n<tr class=\"row-7\">\n\t<td class=\"column-1\">5<\/td><td class=\"column-2\">Run5.wav<\/td><td class=\"column-3\">Passing train sound, continuous welded rail <\/td>\n<\/tr>\n<tr class=\"row-8\">\n\t<td class=\"column-1\">6<\/td><td class=\"column-2\">Run6.wav<\/td><td class=\"column-3\">Continuous welded rail on steel bridge <\/td>\n<\/tr>\n<tr class=\"row-9\">\n\t<td class=\"column-1\">7<\/td><td class=\"column-2\">Run7.wav<\/td><td class=\"column-3\">Passing train sound, jointed rails<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<!-- #tablepress-3 from cache --><\/p>\n<p>Now, to use these, we need to use the train.run command:<br \/>\n<strong>Train.Run<\/strong>(i) n,<br \/>\nWhere i is the indexed track and n is the run sound number.<\/p>\n<p>If for example, we wanted our standard straight track to sound like continuous rail rather than the default jointed track, we would need to change the start of the route file to look like this:<\/p>\n<pre class=\"lang:bve decode:true \" >with train,\r\nTrain.Folder cl170,\r\nTrain.Run(0) 2,<\/pre>\n<p>This will only change the sound of the standard straight track and not the curves. If these are to sound as continuous rail as well, we would need to add additional Train.Run commands to make the assignments for ALL of the curved rail types like this:<\/p>\n<pre class=\"lang:bve decode:true \" >Train.Folder cl170,\r\nTrain.Run(0) 2,\r\nTrain.Run(1) 2,\r\nTrain.Run(2) 2,\r\nTrain.Run(3) 2,\r\nTrain.Run(4) 2,\r\nTrain.Run(5) 2,\r\nTrain.Run(6) 2,\r\nTrain.Run(7) 2,\r\nTrain.Run(8) 2,\r\nTrain.Run(9) 2,\r\nTrain.Run(10) 2,\r\nTrain.Run(11) 2,\r\nTrain.Run(12) 2,\r\nTrain.Run(13) 2,\r\nTrain.Run(14) 2,\r\nTrain.Run(15) 2,<\/pre>\n<p>If we were to drive the route now, all of the original track will make the sound of continous welded rail.<\/p>\n<p>In practice, at some point on the route, we will be passing under a bridge. As each indexed rail type can only have one run sound associated with it, we must index the same rail type again in the \u2018with structure\u2019 section of the route and asign our sound to this in the \u2018with train\u2019 section. We can do this by adding the following code into our railtypes section:<\/p>\n<pre class=\"lang:bve decode:true \" >.Rail(20) DLTUTORIAL_1\\straight.b3d,;standard straight track under bridge,<\/pre>\n<p><em>;standard straight track under bridge,<\/em> is a comment which I have added as a reminder of the sound associated with the rail type. Such non-functional comments must start with a semicolon and end with a comma.<\/p>\n<p>We also need to assign a run sound to this new railtype, which we do by adding this to the end of the Train.Run section:<\/p>\n<pre class=\"lang:bve decode:true \" >Train.Run(20) 3,<\/pre>\n<p>Now, it&#8217;s possible to simulate the sound of our train passing under a bridge by adding this code to the main routefile:<\/p>\n<pre class=\"lang:bve decode:true \" >1025,.railtype 0;20,\r\n1050,.railtype 0;1,<\/pre>\n<p>You will notice that the appearance of our track now changes when we change the railtype in order to pass under the bridge. On the other hand, if we had indexed Railtype 20 with the track object dl_straight.b3d, then this wouldn&#8217;t happen. If we wish to change the appearance of the adjacent track in a similar way at the same location, we must change our routefile to look like this:<\/p>\n<pre class=\"lang:bve decode:true \" >1025,.railtype 0;20,.railtype 1;1,<\/pre>\n<p>OR THIS:<\/p>\n<pre class=\"lang:bve decode:true \" >1025,.railtype 0;20,.railtype 1;20,<\/pre>\n<p>You will notice that both Railtypes 1 and 20 are identical in appearance, as they use the same object file (STRAIGHT.B3D), and that differing run sounds only affect the primary running rail.<\/p>\n<p>So, at the moment our route now uses track of varying appearance and sound. We also have a half built pair of diverging curves at the second station.<br \/>\nIn the next tutorial, we will finish the track construction necessary to fit the island platform at the second station and also create a simple diverging junction. For a little light relief, it will also start raining.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this fourth tutorial, we will take a look changing the position of the adjacent track, alter the appearance of the track and introduce run sounds. <\/p>\n<p>Time to open the route file and get coding\u2026<\/p>\n<p>The route file we created previously should look something like this:<\/p>\n<p> Route.Comment Route learning with Dennis, Route.Gauge 1435, Route.DeveloperID yourname123, Route.change 1, with train, Train.Folder cl170, 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)  [&#8230;]<br \/><a href=\"http:\/\/www.bvecornwall.co.uk\/wordpress\/route-building-tutorial-4-track-layout-and-textures-run-sounds\/\">&raquo; Continue Reading.<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"open","template":"page-templates\/full-width.php","meta":{"footnotes":""},"class_list":["post-232","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/www.bvecornwall.co.uk\/wordpress\/wp-json\/wp\/v2\/pages\/232","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.bvecornwall.co.uk\/wordpress\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.bvecornwall.co.uk\/wordpress\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.bvecornwall.co.uk\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.bvecornwall.co.uk\/wordpress\/wp-json\/wp\/v2\/comments?post=232"}],"version-history":[{"count":2,"href":"http:\/\/www.bvecornwall.co.uk\/wordpress\/wp-json\/wp\/v2\/pages\/232\/revisions"}],"predecessor-version":[{"id":1010,"href":"http:\/\/www.bvecornwall.co.uk\/wordpress\/wp-json\/wp\/v2\/pages\/232\/revisions\/1010"}],"wp:attachment":[{"href":"http:\/\/www.bvecornwall.co.uk\/wordpress\/wp-json\/wp\/v2\/media?parent=232"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}