openBVE logo
Project Status (21st April 2019)
Welcome to the Blog, where I'll be posting progress updates, work-in-progress screenshots, information about the progress I'm making with active projects, as well as anything else I feel is worth mentioning. Hopefully more frequent updates here will make the wait for upcoming releases more bearable! News from 2008, all the way back to 2001, can be found in the News Archive. YouTube ChannelMy openBVE videos and other comments from users and myself can also be found via my YouTube channel.

Blog and Progress Updates

Animated Exterior Car Objects

Posted by Anthony Bowden on 26th February 2009 at 10:00 pm

openBVE / X-City South screenshot - see video belowAs most of you will likely know already, » openBVE « now enables developers to use animated exterior car objects. I was pleasantly surprised by all the positive feedback and comments regarding my last video which I uploaded to YouTube (thank you!), but one criticism which was pointed out several times was the disparity between the quality of the scenic visuals, and the rather simplistic objects used to represent the class 323 EMU–the objects were fine for BVE’s passing trains, but less so when you can move the camera up close and look at the details, or lack thereof. I didn’t think it was worth spending much time on this latter aspect until animation could be applied to the exterior car objects, but now this is possible, I’ve been working on some far better 3D models for the class 323. I had hoped to get this task finished sooner, but it’s taken longer than I originally expected unfortunately–the main difficulty was getting the rounded cab looking right, and texturing it correctly. However, I’m now happy with the appearance, and so I present the work-in-progress fully 3D exterior car objects for openBVE and Cross-City South v1.4. Incidentally, as with all my openBVE/BVE objects, these models are entirely hand coded, with no “help” from 3D modelling software.

Currently the objects are rather more complex than I originally intended (so far, the entire three coach EMU contains around 8200 vertices/4900 faces), and there is a performance penalty that comes with using them; on a fairly typical BVE route, framerates should be okay, but when paired with a very highly detailed and intensively animated route such as Cross-City South v1.4, a fast PC will likely be required to enjoy both extensively detailed animated scenery and detailed external car objects with reasonable framerates. What I intend to do, for those of you with slower hardware, is release alternative versions of the exterior car objects with lower polygon counts, and because of the way I’ve created the textures, the end result should still look good despite less complex geometry. Even these lower detail versions will be rather better than the previous objects though. Emoticon Smile So ultimately, if framerates are a problem, you can simply choose either richly detailed scenery, or richly detailed train objects, depending on which is more important to you.

Currently, the models include the following standard animated features:

  • Rotating wheelsets including wheelslip effects (with provision for animated suspension, and bogie rotation should such functionality be possible in future)
  • Bi-parting, sliding plug doors (some issues with door open/close sound synchronisation–see below)
  • Moving window reflections (twin-layered with transparency, to create a parallax effect)

The models also include the following animated features linked to plugin (UKMUt.dll) variables:

  • Windscreen wipers (left/right sweep, plus arc motion; the wipers aren’t perfect–see below)
  • Head and tail lights (both ends of train)
  • Interior lights (on or off via pantograph up/down button)
  • LED destination display with flicker (on or off via pantograph up/down button)
  • Working pantograph (all illuminated features also extinguish when pantograph is lowered)

I’ve also prepared another video to show these features. Please note, the 3D objects aren’t finished yet; some textures need updating, and I’ve yet to add interior fittings. Developers might want to continue reading on, as I’ll explain how some of these animations have been implemented, and share some sample code from the .ANIMATED objects.

Horizontal Rule
Video: Demonstration of class 323 animated exterior car objects (work-in-progress)

» Link to YouTube page (HD – best quality) «
» Link to YouTube page (High Quality) «

Horizontal Rule

I also thought you might like to see a high resolution image of Cross-City South v1.4 and the new high detail class 323; in this screenshot, I’m running openBVE fullscreen at a resolution of 1280×1024, with 8x anti-aliasing and 16x anisotropic filtering enabled (on a Radeon HD 2600 Pro graphics card). Bilinear interpolation was enabled in openBVE’s settings, with the Transparency mode set to Sharp. I was getting around 16-19 fps at the time; the framerates in the next version of openBVE will hopefully be a little higher due to performance optimisations where animated object normals are concerned, although this gain may be offset by the addition of more animated scenery objects to the route:

openBVE/Cross-City South v1.4 screenshot--click to enlarge

openBVE / Cross-City South v1.4 plus 323 screenshot–click to enlarge

Horizontal Rule

Horizontal Rule
Rotating Wheelsets
Horizontal Rule
openBVE / Class 323 screenshot - please see video above

The first things I tried to animate were the wheelsets. Initially I had difficulty getting this to work as anticipated, and observed unexpected results while using the Speedometer variable, i.e. the resulting wheelset rotation appeared as though it were based upon acceleration rate rather than an actual velocity value (and » Ron « found the same when he first tried to animate wheelsets, it would seem). I usually like to try and figure out solutions to such problems myself, but sadly I’m not the reincarnation of Pierre de Fermat, and as such, my mathematical knowledge was insufficient. Fortunately, a way forward could be found over at the » openBVE Japanese « site, which includes some helpful material covering animated objects and functions. The following function can be used to rotate each wheelset:

RotateXFunction = value + mod [(speedometer * delta), 2.765] / 2.765 * 3.14 * 2

Incidentally, 2.765 is the circumference of the wheel. The above formula works perfectly, but initially I wondered if it was more complicated than it needed to be, so I attempted to find a more simple alternative, and somehow arrived at the following formula, where the value 0.05949986086344 results from (pi / 0.88) / 60, where 0.88 is the diameter of the wheel:

Not goodRotateXFunction = value + speedometer * 0.05949986086344

Initially this seemed to work well, but on closer examination, the end result wasn’t as good as the more complex formula because the rate of rotation varies with the framerate, and I observed no difference in performance between the two anyway.


Thanks to a certain mathematically adept someone, I now have a new formula which is better in terms of performance and ease of use:

CorrectRotateXFunction = value + delta * speedometer / WHEEL_RADIUS_IN_METRES
Horizontal Rule
Animated Doors
Horizontal Rule
openBVE / Class 323 screenshot - please see video above

The bi-parting sliding plug doors are comprised of a pair of 3D door objects, which slide forwards and backwards via a translation along the Z axis, with values supplied via the left/rightdoors[i] variables, e.g:

Right door animation (Updated):

Position = 0.002, 0, -5.552
States = Class323_Door_2_R_Dark.csv, Class323_Door_2_R.csv
TranslateZFunction = rightdoors[0] + 0.864
TranslateXFunction = min[power[10 * (rightdoors[0] – 0.1), 3] + 1, 1] * 0.05
StateFunction = pluginstate[31]

Position = 0.002, 0, -6.417
States = Class323_Door_2a_R_Dark.csv, Class323_Door_2a_R.csv
TranslateZFunction = -rightdoors[0] + 0.864
TranslateXFunction = min[power[10 * (rightdoors[0] – 0.1), 3] + 1, 1] * 0.05
StateFunction = pluginstate[31]

Left door animation:

Position = -0.002, 0, -5.552
States = Class323_Door_2_L_Dark.csv, Class323_Door_2_L.csv
TranslateZFunction = leftdoors[0] + 0.864
TranslateXFunction = -min[power[10 * (leftdoors[0] – 0.1), 3] + 1, 1] * 0.05
StateFunction = pluginstate[31]

Position = -0.002, 0, -6.417
States = Class323_Door_2a_L_Dark.csv, Class323_Door_2a_L.csv
TranslateZFunction = -leftdoors[0] + 0.864
TranslateXFunction = -min[power[10 * (leftdoors[0] – 0.1), 3] + 1, 1] * 0.05
StateFunction = pluginstate[31]

The StateFunction command is there to switch between illuminated and non-illuminated versions of the door objects, and pluginstate[31] is equivalent to the ats31 subject in the class 323’s panel2.cfg file (when used with Simon Gathercole’s UKMUt.dll), i.e. the Line Light indicator (so the lights appear to go out when the pantograph is lowered). The objects are also translated along the X axis so they “plug” into the bodyside when fully closed. Unfortunately the door open and close sounds aren’t fully synchronised with the door motion; with UK trains, warning beeps are heard before the doors actually start to close, but the beeps are contained within the door closing audio file, and of course the visible doors start to close as soon as the beeping starts. The duration of the door opening motion is also shorter than the duration of the door opening audio files. I haven’t tried having door animation controlled via plugin variables yet; when I have time I’ll look into this further.

Horizontal Rule
Animated Window Reflections
Horizontal Rule
openBVE / Class 323 screenshot - please see video above

The window reflections are made from two semi-transparent surfaces, which have texture shifting functions applied, based upon the current speed of the train, e.g:

Window reflection animation:

Position = 0, 0, 0
States = ..\Class323_DMSO_1_WindowReflections.csv
TextureShiftXFunction = value + speed * 0.001

Position = 0, 0, 0
States = ..\Class323_DMSO_1_WindowReflections_bg.csv
TextureShiftXFunction = value + speed * 0.0001

There’s a foreground reflection texture with transparency, showing near-track bushes, and there’s also a background reflection texture, showing a low resolution version of the backdrop (ground and sky) texture, and this surface’s texture is shifted more slowly than the foreground texture, creating a rather nice parallax effect when the train is in motion. The overall effect looks rather good in my opinion, but of course, if the reflection textures depict a Summer scene, but the train is used on a Winter route with snow, it looks a little silly…

Horizontal Rule
Interior Illumination
Horizontal Rule
openBVE / Class 323 screenshot - please see video above

Interior lighting strips, along with interior fittings and additional semi-transparent yellow surfaces to lighten the windows when viewed from outside at night (allowing adequate night-lighting effects while still being able to have daytime window reflections), are displayed when the pantograph is raised, and swapped for non-emissive versions when the pan is lowered, so it’s possible to turn the carriage lights on and off. When the pantograph is lowered, all exterior lights are also state-changed or translated so they appear to extinguish, and won’t illuminate until the pantograph is raised again. This is achieved using if[pluginstate[31] ... ] commands, as demonstrated in the next section.

Horizontal Rule
Animated Pantograph
Horizontal Rule
openBVE / Class 323 screenshot - please see video above

The pantograph itself can be visibly raised and lowered, with the head having a Y axis translation applied, and the upper and lower arms having X axis rotation, along with Y and Z axis translation applied. The pantograph animation is conditional upon the state of the value of plugin variable 31, or the ats31 subject in the class 323’s panel2.cfg. The code I’ve written which enables this is as follows (since updated on the 5th July 2009, thanks to a post by michelle herself):

Pantograph animation (updated 5th July 2009):

Position = 0, 4.24, 9.071
States = ..\Pantograph_BWHS_Head.csv
TranslateYFunction = if[pluginstate[31] == 0, if[value > -0.97, value – delta * 0.49, -0.97], if[value < 0, value + delta * 0.49, 0]]

Position = 0, 4.24, 9.071
States = ..\Pantograph_BWHS_UpperArm.csv
TranslateYFunction = if[pluginstate[31] == 0, if[value > -0.45, value – delta * 0.225, -0.45], if[value < 0, value + delta * 0.225, 0]]
RotateXFunction =     if[pluginstate[31] == 0, if[value > -0.29, value – delta * 0.145, -0.29], if[value < 0, value + delta * 0.145, 0]]
TranslateZFunction = if[pluginstate[31] == 0, if[value < 0.06, value + delta * 0.03, 0.06], if[value > 0, value – delta * 0.03, 0]]

Position = 0, 4.24, 9.071
States = ..\Pantograph_BWHS_LowerArm.csv
TranslateYFunction = if[pluginstate[31] == 0, if[value > -0.45, value – delta * 0.225, -0.45], if[value < 0, value + delta * 0.225, 0]]
RotateXFunction = if[pluginstate[31] == 0, if[value < 0.27, value + delta * 0.135, 0.27], if[value > 0, value – delta * 0.135, 0]]
TranslateZFunction = if[pluginstate[31] == 0, if[value < 0.06, value + delta * 0.03, 0.06], if[value > 0, value – delta * 0.03, 0]]

Horizontal Rule
Animated Wipers and Working Headlights
Horizontal Rule
openBVE / Class 323 screenshot - please see video above

The windscreen wipers aren’t as good as I’d like them to be yet; when the if[pluginstate[i] ... ] conditions are satisfied and the truevalue formulae are executed, the wipers can jump to a position mid-sweep rather than starting to move from their currently held position. The same problem can happen when switching the wipers off as well, although the way I’ve implemented it, the wipers will stop in whatever position they are in when the wipers are turned off. More work needed here… Each wiper is comprised of two arms, and a wiper blade. The code so far, is as follows:

Wiper animation (code for left wiper only; reverse the signs of each occurrence of ‘power[]’ for the right wiper, excluding the one in the last TranslateYFunction command):

States = ..\Class323_DMSO_Wiper_L_1.csv
Position = -0.56, 2.27, 0
RotateZFunction = if[pluginstate[198] > 0, power[1 – abs[cos[time]], 0.5] * 1.3, value]

States = ..\Class323_DMSO_Wiper_L_1a.csv
Position = -0.5, 2.27, 0
RotateZFunction = if[pluginstate[198] > 0, power[1 – abs[cos[time]], 0.5] * 1.3, value]

States = ..\Class323_DMSO_Wiper_L_1b.csv
Position = -0.55, 2.28, 0
TranslateXFunction = if[pluginstate[198] > 0, -power[1 – abs[cos[time]], 0.5] * 0.73, value]
TranslateYFunction = if[pluginstate[198] > 0, power[sin[time * 2], 2] * 0.13, value]

The last TranslateYFunction command moves the wiper blade up and down at the correct speed, which when combined with the X axis translation, creates the overall effect of an arc movement rather than a simple left-right motion.

Horizontal Rule

The head (and tail) lights are linked to the proving lights in the cab (the ats20 and ats21 subjects in the class 323’s panel2.cfg). Each headlight configuration has it’s own csv object. The headlights will only be illuminated when the pantograph is also raised (dependent on the state of plugin variable 31, or the ats31 subject in panel2.cfg). When the tail lights at one end of the train are on, they automatically turn off at the other end of the train. For the rear of the train, the headlights can only illuminate if the tail lights are also off. The code which enables all of this is as follows (please note, I’m presenting two alternative ways of implementing the lights on the leading vehicle, the reason why can be found below):

Head and tail lights:

Class323_DMSO_1.animated (lead vehicle) OPTION 1

States = ..\null.csv, ..\Class323_Headlights_0.csv, ..\Class323_Headlights_1.csv, ..\Class323_Headlights_2.csv
Position = 0, 0, 0
RotateYFunction = 3.1416
StateFunction = if[pluginstate[31] == 1, pluginstate[20], 0]

States = ..\null.csv, ..\Class323_Taillights_1.csv
Position = 0, 0, 0
RotateYFunction = 3.1416
StateFunction = if[pluginstate[31] == 1, pluginstate[21], 0]

Class323_DMSO_1.animated (lead vehicle) OPTION 2

States = ..\Class323_Headlights_0.csv
Position = 0, 0, 0
RotateYFunction = 3.1416
TranslateYFunction = if[pluginstate[31] == 1, if[pluginstate[20] == 1, 0, -600], -600]

States = ..\Class323_Headlights_1.csv
Position = 0, 0, 0
RotateYFunction = 3.1416
TranslateYFunction = if[pluginstate[31] == 1, if[pluginstate[20] == 2, 0, -600], -600]

States = ..\Class323_Headlights_2.csv
Position = 0, 0, 0
RotateYFunction = 3.1416
TranslateYFunction = if[pluginstate[31] == 1, if[pluginstate[20] == 3, 0, -600], -600]

[Object] States = ..\Class323_Taillights_1.csv
Position = 0, 0, 0
RotateYFunction = 3.1416
TranslateYFunction = if[pluginstate[31] == 1, if[pluginstate[21] == 1, 0, -600], -600]

Class323_DMSO_3.animated (rear vehicle)

States = ..\null.csv, ..\Class323_Headlights_0.csv, ..\Class323_Headlights_1.csv, ..\Class323_Headlights_2.csv
Position = 0, 0, 0
StateFunction = if[pluginstate[31] == 1, if[pluginstate[21] == 1, pluginstate[20], 0], 0]

States = ..\Class323_Taillights_1.csv, ..\null.csv
Position = 0, 0, 0
StateFunction = if[pluginstate[31] == 1, if[pluginstate[31] == 1, pluginstate[21], 0], 1]

In Option 1 above, the lead vehicle’s headlights are changed using StateFunction commands alone. This method works fine, but the first time each state is changed to, you’ll see the object’s texture isn’t loaded until a fraction of a second after the object is displayed, leading to a flash of colour which is a little distracting. Using Option 2 gets around this issue however, because the headlight objects and textures are always loaded upon swtiching to an external view, and are displayed by translating the relevant object along the Y axis instead, conditional upon the value read via the pluginstate[i] variable. As these textures are always loaded in an external view, StateFunction commands alone can be used in the rear vehicle.

Incidentally, the RotateYFunction = 3.1416 lines simply rotate the relevant objects 180° around the Y axis (the value is in radians, rather than degrees).

What I need to do next, is add interior fittings such as seats, luggage racks, LCD TV screens, and so-on. I might make some more progress with the route itself instead though, as to be honest I could do with a break from modelling the minutiae of train objects for a while. Emoticon Smile

Tags: , , , , , ,

70 Responses to “Animated Exterior Car Objects”

  1. michaeltvs says:

    Small thing to add that you are probably aware of. One thing I learnt whilst animating wheels for Trainz railway simulator, after a certain speed (think its an arbitrary 20mph) the wheel animation no longer run forward, they run backward. This is most noticeable on spoked wheels, but also on others.

  2. tom says:

    When will it be released because it looks awesome!!!!:)

    • Anthony_B says:

      I want to release both Cross-City South v1.4 and the 323 this year, but I can’t be any more specific as I have quite a lot of work to be doing. I promise they will get released though. 🙂 Thanks for the comment!

    • Michaeltvs, it’s better if you ask that what still needs to be done before releasing (I mean what kind animations, which part of the route is currently under construction, etc.) that isn’t made yet, because it is more likely able to be replied!

      • Anthony_B says:

        I apologise for the lack of progress lately. I’m spending most of my free time working on openBVE 2 at the moment, so there’s not a lot for me to report on where my routes are concerned, as I only have time to do bits here and there. I do want to have a new route ready shortly after openBVE 2 is released though, so as soon as I have enough time to dedicate to it, my plan is to complete the remaining work on Cross-City South v1.4 as this is the route I’ll be able to finish more quickly. I may of course demonstrate some of the things I’ve yet to add via another video showing either route, though.

        I’ll certainly be relieved when I’ve managed to get at least one of the routes released at long last!

  3. bkzdeadliest says:

    hey anthony man its great and hopefully it will released but listen can you help me with the doors please like i have tried eveything but it wont let me make my train the way i want it you see im modding my nycta r160 seimens train and i want to put animated doors on it but i dont know where to do it like im having trouble with the formula what i did is i copied your formula, copied and paste on a new cfg file and it still comes out all gray like also i put all the pics in and everything but no use can you help me please i have been trying to do this for a long time now for 2-3 months now so please help me and/or give me advice?? thanks!

  4. Haven says:

    go to our downloads section and look!

    • Anthony_B says:

      Firstly, thanks for telling me about this, several months after the last comment. 😉 Frankly, I’m not inclined to voluntarily spend my time launching a mini-investigation into every single person who asks me a question, go through an entire forum checking up on everyone to find out who they are and what they’re doing, or go through a download archive to see if their name is somewhere in a credit list – these kinds of things are for the BVEStation community to work through, not me, or anyone else. I have enough to be doing as it is.

      Secondly, people who go around throwing insults and calling other people morons, would be wise to consider trying twice as hard as everyone else, to make sure that they’re not merely projecting their own personal problems and/or psychological immaturity onto, or into, other people. Otherwise, when they throw their accusations around, they run the risk of talking about their own flaws without even realising it, while this is plainly visible to those who know better. I’m not saying that you are such a person, incidentally, merely that this is the thought which popped into my head upon reading the manner in which you commented.

      Thirdly, if I viewed the world through the same lens which you do, from the same vantage point as your own, then I might agree that I am indeed a moron. But if you viewed the world through the same lens which I do, and from my vantage point, then you might have realised that I would see something which you didn’t see, and you might have rephrased your comment in such a way, that it doesn’t carry the potential for doing more harm than good to the reputation of BVEStation (unless your aim is to do harm to the BVEStation community, of course – I wouldn’t know either way). Now, I’m just as capable of stupidity as anyone else is – I might be showing it by writing this reply – but I’m not quite stupid enough to be blind to some of the things I’ve just talked about. The more intelligent people know how stupid they can be, but a truly stupid person never recognises their own stupidity.

      Anyway, thank you for giving me some interesting things to think about, and if you celebrate Christmas, then I wish you a merry one (genuinely).

  5. Chi Yung Wong says:

    i can download this train??

  6. Tanner says:


    could you please send e a copy of this train via email please please please!!

    iam begging you it looks great

  7. Anthony, would you please update this article with switching from UkMUt to UkTrainSys’s StateFunction command values? It would be needed for me…

    • Anthony_B says:

      Hi there. 🙂

      I might have some time next week to update the article, and release a new version of UkTrainSys as well – I have some time off work, so we’ll see…

  8. tegn pa laktose allergi – Blog

  9. era biler hillerod abningstider – Blog

  10. goda nyttiga soppor – Blog

  11. Modelos says:

    certainly like your web-site but you have to take a look at
    the spelling on quite a few of your posts.

    Several of them are rife with spelling issues and I in finding it very
    troublesome to inform the truth nevertheless I’ll certainly come back again.

  12. pirater un telephone portable juste avec le numero – Blog

  13. kostnad gjuta platta – Blog

  14. my website says:

    my website – Blog

  15. blödning i början av graviditet – Blog

  16. traitement pour champignon ongle pied – Blog

  17. bacon i ovn says:

    bacon i ovn – Blog

  18. kakkelborde til haven – Blog

  19. consulta21 says:

    consulta21 – Blog

  20. best sound reproduction – Blog

  21. tourisme says:

    tourisme – Blog

  22. billiga skor malmö – Blog

  23. kleding blouse – Blog

  24. june dress ida sjöstedt – Blog

  25. bleka tänderna sundsvall – Blog

  26. utslag i nacken – Blog

  27. savon toilette intime femme – Blog

  28. piacente spa landskrona – Blog

  29. hva betyr livsstil – Blog

  30. varma bad budapest – Blog

  31. Critical Essay – Blog

  32. Secret Tradition – Blog

  33. Astral Body says:

    Astral Body – Blog

  34. filippa k stovlar – Blog

  35. historisk euro kurs – Blog

  36. Как заработать – Blog

  37. speaking trance – Blog

  38. porn video says:

    I am now not sure where you’re getting your info, but good topic.
    I must spend a while finding out more or understanding more.
    Thank you for fantastic information I was searching for this
    info for my mission.

  39. купить диплом института

    blog topic

  40. Adas driving says:

    What’s up to all, it’s truly a pleasant for me to pay a visit this web page, it contains priceless Information.

  41. This paragraph is in fact a nice one it helps new web visitors, who are wishing in favor of blogging.

  42. сериалы онлайн – Blog

  43. сериалы 2021 онлайн – Blog

  44. – Blog

  45. Сериалы 2022 онлайн – Blog

  46. Фильмы 2021 онлайн – Blog

  47. . says:

    . – Blog

  48. читать мангу – Blog

  49. Лучшие сериалы – Blog

  50. комиксы онлайн – Blog

  51. Лучшие фильмы lostfilm – Blog

  52. Смотреть тут бесплатно – Blog

  53. Скачати манхву безкоштовно – Blog

  54. Комікси марвел – Blog

  55. Сериалы онлайн lostfilm – Blog

  56. Мультфильмдер 2022 онлайн – Blog

  57. * says:

    * – Blog

  58. Онлайн комикстер базасы – Blog

  59. тіркеусіз фильмдер және SMS lostfilm – Blog

  60. де подивитися фільм – Blog

  61. кращі фільми lostfilm – Blog

  62. webpage says:

    Me recomendaram este site e me informaram
    que o assunto era sempre discutido em alto nível. Acessei e pude
    perceber exatamente isto. Muito bom pelo conteúdo!

  63. my blog says:

    I have normally set myself objectives and it motivates me to function really hard.

Leave a Reply