INTRODUCTION
In this part, curved platforms will be added to the third station following consideration of the problem of constructing such objects. The value of using a spreadsheet to help with the calculations will be demonstrated, allowing not only curved platforms but also curved walls to easily be constructed once the principles are known.
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.
Objects required for this tutorial may be found here
Objects for tutorial 4_3.zip. These should be unzipped to the appropriate objects directory (DLTUTORIAL).
The route file we shall start this series with is available here
DLTUTORIAL_4_2_final.zip.
Time to get to work!
During the previous tutorial, straight platform objects were positioned on curved tracks at the third station. The results on the left hand side are a bit misleading as the object was turned through 180 degrees and is therefore drawn from -25 - 0metres, exaggerating the effect of the curvature of the track. However, on the right hand side, although the results look reasonable, it is clearly apparent that 25m straight sections of platform have been used. To overcome this, a 'curved' object should be used, the faces of which are parallel with the line of the track.
Before simply building a multifaced object where the x-offsets are all at a fixed distance, the problem must be considered in a little more detail. When BVE draws objects, the x-offset is measured from the centre of the running track at 0m. Not a problem on straight sections, but on curved sections of track, straight objects will appear jagged;
Here, the red line represents the track, the black line a straight object positioned on the curved track. Distance A-B = 25m. This shows that not only will the object appear 'jagged' but that the distance from the track will vary.
What we need, is a curved object, as represented in yellow,
So how is this achieved? The answer is to calculate the displacement using the equation of a circle, x2 + y2 = r2 , as was used in tutorial 1.4 for calculating diverging curves.
The need to use the equation of a circle becomes apparent when we add the line followed by the x offset (x=0);
From this diagram, it can be seen that on the right hand side, the curved object initially converges towards the line x=0 (the black line joining points A and B) until halfway along the length (z=12.5m), where the curved object then diverges from the line x=0. Correction must therefore also be made to allow for the displacement of this line; all should become clear once construction of a curved object is started.
It is worth noting that the radii of the track and curved objects will be different although given that the track radius is likely to be over 100m (except for on the very tightest of curves), the radii of the curved objects approximates closely to the track radius.
Now that we understand the nature of the problem, we can start building our curved objects (that parallel the track).
The first task is to decide on the number of faces we want our object to have; to some extent, this will depend on the curve radius, tighter curves benefiting from a greater number of faces. For our example object, we will split the object into ten faces (probably over the top except for very tight radius curves). Using the equation of a circle, the displacements due to the curve may be calculated;
If the curve radius is 500m, then r2 = 250000. Rearranging the equation of a circle to r2-y2 = x2, we can calculate the following;
|
x |
x2 |
z2 |
z |
offset of curve (x) m |
|
500.0000 |
250000.00 |
0.00 |
0.0 |
0.0000 |
|
499.9937 |
249993.75 |
6.25 |
2.5 |
0.0063 |
|
499.9750 |
249975.00 |
25.00 |
5.0 |
0.0250 |
|
499.9437 |
249943.75 |
56.25 |
7.5 |
0.0563 |
|
499.9000 |
249900.00 |
100.00 |
10.0 |
0.1000 |
|
499.8437 |
249843.75 |
156.25 |
12.5 |
0.1563 |
|
499.7749 |
249775.00 |
225.00 |
15.0 |
0.2251 |
|
499.6937 |
249693.75 |
306.25 |
17.5 |
0.3063 |
|
499.5998 |
249600.00 |
400.00 |
20.0 |
0.4002 |
|
499.4935 |
249493.75 |
506.25 |
22.5 |
0.5065 |
|
499.3746 |
249375.00 |
625.00 |
25.0 |
0.6254 |
Where the offset of the curve (x) = 500-x.
These calculations are not enough to define the x coordinates of the object - the offset values at 0 and 25m both need to be identical (and in this instance, zero). The reason that the x offset is continually increasing is that no allowance has been made for the displacement of the rail over the length of the curve (i.e. the black line running between A & B in the third diagram. Knowing that the offset of the straight line will be 0.6254m (as we calculated it above), we can calculate the offsets of the straight line at 2.5m intervals;
|
offset of curve (x) m |
z |
offset of straight line |
difference (x) |
|
0.0000 |
0 |
0.0000 |
0.0000 |
|
0.0063 |
2.5 |
0.0623 |
0.0560 |
|
0.0250 |
5 |
0.1246 |
0.0996 |
|
0.0563 |
7.5 |
0.1869 |
0.1306 |
|
0.1000 |
10 |
0.2492 |
0.1491 |
|
0.1563 |
12.5 |
0.3114 |
0.1552 |
|
0.2251 |
15 |
0.3737 |
0.1487 |
|
0.3063 |
17.5 |
0.4360 |
0.1297 |
|
0.4002 |
20 |
0.4983 |
0.0982 |
|
0.5065 |
22.5 |
0.5606 |
0.0541 |
|
0.6254 |
25 |
0.6254 |
0.0000 |
It is the difference between the offset of the curve and the offset of the straight line which needs to be used when defining the x coordinates of our curved object.
Remembering that the straight platform vertical face was positioned at x = 1.8m and that overhang of carriages needs to be allowed for on the curves, the x coordinates all need to be 1.955m to the left of the 'difference x' values we have just calculated (this is from 1.8 + 0.155).
Putting this into practice, create a new object file named curved_platform_500L.CSV. Index this in the route file as free object 65 and position a series of these on the 500m radius curve at the third station (replacing the current platform objects).
Creating the mesh block for the first face;
CreateMeshBuilder,
addVertex,-1.955, 0.9, 0,
AddVertex,-1.955, -0.2, 0,
AddVertex,-1.899, 0.9, 2.5,
AddVertex,-1.899, -0.2, 2.5,
Notice how the x displacement has been moved to the right at 2.5m by the distance calculated previously.
The rest of the code for this face is standard stuff; the only point to be aware of is that both faces of curved lineside objects may be visible and use of AddFace2, may be necessary.
AddFace,0,2,3,1,
GenerateNormals,
LoadTexture,platform side 1.bmp,
SetTextureCoordinates,0,0.0,0,
SetTextureCoordinates,2,0.1,0,
SetTextureCoordinates,3,0.1,1,
SetTextureCoordinates,1,0.0,1,
The remaining vertices and faces can be added systematically (using the same technique as was used for building the tunnel wall, looking for patterns in the code). For the second and third faces, add the following to the object;
CreateMeshBuilder,
addVertex,-1.955, 0.9, 0,
AddVertex,-1.955, -0.2, 0,
AddVertex,-1.899, 0.9, 2.5,
AddVertex,-1.899, -0.2, 2.5,
Addvertex,-1.856, 0.9, 5,
Addvertex,-1.856, -0.2, 5,
Addvertex,-1.825, 0.9, 7.5,
Addvertex,-1.825, -0.2, 7.5,
AddFace,0,2,3,1,
AddFace,2,4,5,3,
AddFace,4,6,7,5,
GenerateNormals,
LoadTexture,platform side 1.bmp,
SetTextureCoordinates,0,0,0,
SetTextureCoordinates,2,0.1,0,
SetTextureCoordinates,3,0.1,1,
SetTextureCoordinates,1,0,1,
SetTextureCoordinates,2,0.1,0,
SetTextureCoordinates,4,0.2,0,
SetTextureCoordinates,5,0.2,1,
SetTextureCoordinates,3,0.1,1,
SetTextureCoordinates,4,0.2,0,
SetTextureCoordinates,6,0.3,0,
SetTextureCoordinates,7,0.3,1,
SetTextureCoordinates,5,0.2,1,
Notice the patterns of the vertex coordinates, faces and settexturecoordinates commands; these need to be continued until all the faces have been added. Once all the faces have been built, the object file should look something like this;
CreateMeshBuilder,
AddVertex,-1.955, 0.9, 0,
AddVertex,-1.955, -0.2, 0,
AddVertex,-1.899, 0.9, 2.5,
AddVertex,-1.899, -0.2, 2.5,
Addvertex,-1.856, 0.9, 5,
Addvertex,-1.856, -0.2, 5,
Addvertex,-1.825, 0.9, 7.5,
Addvertex,-1.825, -0.2, 7.5,
Addvertex,-1.806, 0.9, 10,
Addvertex,-1.806, -0.2, 10,
Addvertex,-1.8, 0.9, 12.5,
Addvertex,-1.8, -0.2, 12.5,
Addvertex,-1.807, 0.9, 15,
Addvertex,-1.807, -0.2, 15,
Addvertex,-1.826, 0.9, 17.5,
Addvertex,-1.826, -0.2, 17.5,
Addvertex,-1.857, 0.9, 20,
Addvertex,-1.857, -0.2, 20,
AddVertex,-1.901, 0.9, 22.5,
AddVertex,-1.901, -0.2, 22.5,
AddVertex,-1.955, 0.9, 25,
AddVertex,-1.955, -0.2, 25,
AddFace,0,2,3,1,
AddFace,2,4,5,3,
AddFace,4,6,7,5,
AddFace,6,8,9,7,
AddFace,8,10,11,9,
AddFace,10,12,13,11,
AddFace,12,14,15,13,
AddFace,14,16,17,15,
AddFace,16,18,19,17,
AddFace,18,20,21,19,
GenerateNormals,
LoadTexture,platform side 1.bmp,
SetTextureCoordinates,0,0,0,
SetTextureCoordinates,2,0.1,0,
SetTextureCoordinates,3,0.1,1,
SetTextureCoordinates,1,0,1,
SetTextureCoordinates,2,0.1,0,
SetTextureCoordinates,4,0.2,0,
SetTextureCoordinates,5,0.2,1,
SetTextureCoordinates,3,0.1,1,
SetTextureCoordinates,4,0.2,0,
SetTextureCoordinates,6,0.3,0,
SetTextureCoordinates,7,0.3,1,
SetTextureCoordinates,5,0.2,1,
SetTextureCoordinates,6,0.3,0,
SetTextureCoordinates,8,0.4,0,
SetTextureCoordinates,9,0.4,1,
SetTextureCoordinates,7,0.3,1,
SetTextureCoordinates,8,0.4,0,
SetTextureCoordinates,10,0.5,0,
SetTextureCoordinates,11,0.5,1,
SetTextureCoordinates,9,0.4,1,
SetTextureCoordinates,10,0.5,0,
SetTextureCoordinates,12,0.6,0,
SetTextureCoordinates,13,0.6,1,
SetTextureCoordinates,11,0.5,1,
SetTextureCoordinates,12,0.6,0,
SetTextureCoordinates,14,0.7,0,
SetTextureCoordinates,15,0.7,1,
SetTextureCoordinates,13,0.6,1,
SetTextureCoordinates,14,0.7,0,
SetTextureCoordinates,16,0.8,0,
SetTextureCoordinates,17,0.8,1,
SetTextureCoordinates,15,0.7,1,
SetTextureCoordinates,16,0.8,0,
SetTextureCoordinates,18,0.9,0,
SetTextureCoordinates,19,0.9,1,
SetTextureCoordinates,17,0.8,1,
SetTextureCoordinates,18,0.9,0,
SetTextureCoordinates,20,1.0,0,
SetTextureCoordinates,21,1.0,1,
SetTextureCoordinates,19,0.9,1,
Now all that needs to be done is the construction of the remaining platform components (coping stones, tactile surface and main surface); this is not as difficult as it might seem. For example, the coping edge will simply be a vertical face between 1.03 and 1.1m high and positioned 0.35m to the right of the face we have just constructed.
Use of a spreadsheet to perform calculations like this can really speed-up complex object creation; here are some of the ones I have developed for constructing curved trackside objects;
Note - to prevent having to edit the 'Loadtexture' statement after copying into a text editor, add - &".bmp," - to - =C8 - in cell C65 it will them together, saves you having to do it manually after copying to notepad.
=C8&".bmp," (thanks to M. Vasey)
For objects on the left hand side of the track.....
curved wall creator_LHS.zip
and on the right hand side of the track.....
curved wall creator_RHS.zip
I have included the finished curved platforms in the objects download; the route file makes use of .X format files to both minimise the possible effects on frame rate which the large number of faces may have and also to fine-tune the appearance of the objects without using additional textures.
After this tutorial, the route file should look something like this.....
DLTUTORIAL_4_3_final.zip - I have not re-sited the station stop point or the signal (which cannot be seen sround the curve).
In the next (and final) tutorial, I will describe how to construct a model of an actual (rather than ficticious) building, starting from just a couple of photos.