Jump to content

Microsoft Train Simulator using Babylon 5


altreality
 Share

Recommended Posts

I am wondering how good is the physics support for designing a train simulator in Babylon 5. It would probably involve applying multiple wheel forces to stabilize a locomotive and make it follow a track.

 

Also if I am trying to render outdoor scenes like a train running through a vast green valley with many trees and hills in the distance, how can such scenes be handled in Babylon 5 ?

 

Are there some tricks possible to give a great visual experience without slowing the game by much ?

Link to comment
Share on other sites

I'm not sure why you'd need to compute fancy physics to do such a thing!

 

Look at the train demo on babylonjs.com to see what I mean.

 

Distance trees wouldn't need to be 3D - they could be sprites: http://www.babylonjs.com/playground/#2IPMDX

 

And to have hill meshes zooming past, you wouldn't need a millions meshes - you can have it so when one zooms by, it teleports in front of you, like a chain.

 

Other that that, I can't help you. :)

Link to comment
Share on other sites

  • 2 weeks later...

Yay, Microsoft Train Sim... I love it!  Welcome to the forum, Altreality!

 

Have you used the MS Train Sim route editor?  In there, you can see that some "far things" are actually flat planes with 2D pictures on them.  Generally, in MSTS, your 'view' is always from the location of the train (except for the old yard cam hack which let you fly a camera anywhere). 

 

Having your view always being from the train... gives you an advantage when it comes to LOD tricks.

 

And yes, if you want to try to honor all the fun physics found in MSTS, you are in for a physics challenge.  But I am with you!!!  I would absolutely LOVE a version of MSTS in WebGL, and would be a big fan of your project.  Track files and rolling stock files are all in ASCII text, and could all be parsed with JS, so all those files from the original MSTS would not need rewriting.  And, the incremental loading and tiled landscape that MSTS does... is also available in BJS.

 

Yes, I am quite sure it can be done, and Babylon.js would be a perfectly fine framework to do it.  That would be SO COOL!!!

 

There are some Microsoft employees nearby here, too, and I bet you/we could get some help from "the Gods"... if you/we got stuck on something.  What a great project it would be.  Microsoft, if they were smart, would just plain write a Babylon.js webGL version of MSTS... FOR us.  I would gladly donate substantial $$$ to the cause... because MSTS rocks!  Sigh.  So cool.

 

I'll give the product development people at Microsoft... a phone call... and have them re-open MS Game Studios and have them get started on this.  I can't wait! 

 

But "Babylon 5" was a TV show, not a webGL framework.  ;)

Link to comment
Share on other sites

  • 3 years later...
On 10/4/2014 at 6:00 PM, altreality said:

I am wondering how good is the physics support for designing a train simulator in Babylon 5. It would probably involve applying multiple wheel forces to stabilize a locomotive and make it follow a track.

 

Also if I am trying to render outdoor scenes like a train running through a vast green valley with many trees and hills in the distance, how can such scenes be handled in Babylon 5 ?

 

Are there some tricks possible to give a great visual experience without slowing the game by much ?

Although an old post still good questions.

Physics

Physics calculations for train simulators can become quite advanced quickly, as many bodies will be connected to each other (the locomotive and each wagon) and the bogeys must be constrained to the rail path. Also the physics working on a train can become destructive very fast. That's why I found a very expensive study book (300 euro) on railroad engineering that almost takes a master's degree to understand how to place real world track that WOULDN'T derail the train in the first place. 🙂 And that's why most train simulators 'cheat' and create their own simplified physics and train operation / track following code. And most train games are simply tile-based or only allow 45 and 90 degree turns etc. But I guess you don't want that much simplification 🙂

If you train simulator doesn't need very strange things like "up side down loops", then you can reduce the complexity by projecting your train and track on 2D plane (X0Z).

    Straight track is easy. Straight lines 🙂
    Use (partial) circles for curves.
    Connect straight tracks to curves using an Euler curve/spiral segment.

Super-elevation can be computed in some kind of post-process (after you placed the track) to counter any physics that would make the high speed train derail in a curve (e.g. go straight instead of take the curve).

The "problem" with the standard bezier curves in train simulators is that they may look nice curves but are difficult to evenly interpolate (e.g. when your train needs to move equidistance).

Outdoor scenes

Whether for a browser based application or for desktop applications, large outdoor scenes may not be your friend in 3D. Unless it's a desert scene perhaps 🙂

  • For large outdoor scenes you can indeed use sprites for trees.
  • And you need instances (instead of clones).
  • For non-sprites, like buildings, use LOD (Level of Detail) for your meshes.
  • Be sure to 'freeze' the matrix for non-moving objects. That saves some computations.
  • And then there's other optimizations like Octrees. These break down your world into segments. Based on the camera position and view, only parts of the world in front of your camera will be evaluated for rendering.

Still, with those optimizations, I'm still struggling to get a good frame rate on low- and mid-end devices. But I believe it can be done on the powerful computers. 🙂

Demo

I've been breaking my head on the train mathematics, but your can see my results so far in my BabylonJS Model Train Simulator game here:

https://quintushegie.com/gardentrains/

My game is not the 'realistic' Microsoft Train Simulator type, but you'll get the point... most computations and challenges remain the same.

Q

[Added] B.T.W. Jerome has made an example of a rollercoaster demo, which is also a nice starting point for objects following path. Check out his Roller Coaster demo on http://jerome.bousquie.fr/BJS/demos/  )

 

Edited by QuintusHegie
Added rollercoaster demo from Jerome for inspiration
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...