Tips for a train simulator

Community Forums/General Help/Tips for a train simulator

Blitzplotter(Posted 2010) [#1]
I'm toying the idea of trying to make a train simulator game, with say up to 20 or 30 trains.

What I'm wondering is - is the best way to make some 3d tracks in a world and then sit a 'train ' on top of the 3d rails - making the train heavy enough so that it will not 'come off the tracks' so to speak. The main problem I see with this approach is at the 'points' where train tracks merge/diverge.

I'm thinking about making it with a physics engine - JV-ODE, very early days but I'm thinking of adopting an OO kind of approach to the management of trains on the track. The nice thing is, the physics engine will automatically cause a 'train wreck' if mis management leads to any head on collisions or rear ending.


Vorderman(Posted 2010) [#2]
Sounds like a lot of work to achieve something that can be done just as well in a more simple way.

I think you'll probably get neater results either -

a) just making the train follow the rails and then add extra code to check for excess speed, then convert to ODE objects only once the train has come off the tracks and is crashing. This is the same approach as with non-physics driven animated characters that convert to a physics ragdoll when killed).

or

b) use ODE all the time but only effectively in 1 dimension (ie. Z, down the track ) - ignore the X and Y directions (the across-the-rails sideways direction and vertical). Make the train objects follow the track spline in the 3d world with only their forward and backward position and movement linked to ODE, and set their 3d position so they always stay on the curve of the track spline. This prevents your physics simulation having to somehow follow the track spline or rails which is going to be tricky and fairly prone to going wrong, especially as you say at the track junctions. Then switch over to full 3d physics only once the train is derailed and crashing (ie. when it corners too fast or hits another object with too much force). If you keep all your physics trains along the same static axis then they should automatically deal with shunting and impacts, you just need to decide when the impacts are too great and the simulation needs to switch to a full 3d simulation for the crash.

You should easily be able to use the spline curve to calculate if the train has exceeded the maximum cornering speed, very easy to do if your track spline is made from a series of points.


Blitzplotter(Posted 2010) [#3]
Thanks for the suggestions, I have not ventured down the path of using waypoints yet within either native Blitz3D or JV-ODE. I presume I would neet to associate some waypoints with the track to get the train to 'follow' the track.

these look promising:-

http://www.blitzbasic.com/Community/posts.php?topic=62053#693939

http://www.blitzbasic.com/Community/posts.php?topic=48384#538331


ESP(Posted 2010) [#4]
Have a look at the Leadwerks demo. It has a train running around a track using physics :)

Robin


Blitzplotter(Posted 2010) [#5]
Thanks will have a look later


Blitzplotter(Posted 2010) [#6]
Just had a quick peek, it does look quite impressive.