Contemplating usage for a project...

Sep 14, 2009 at 2:19 PM


First up I will come clean and say i've not got as far as even downloading the examples yet, i'm just mulling over the ideas at the moment as to how to generally implement a 3D Physics engine in to my project.

The project is a train simulator, so you have trains rolling along rails.  I've implemented a basic path following system for this to occur and all seems well; now I'm coming to want to have units interacting with each other, gravity taking effect, momentum and so forth it seems like a reasonable time to start thinking about this.

What are your initial thoughts on this? I did wonder if in fact a 2D engine might even be sufficient but then I would like to be able to measure the lateral forces as a train goes around a curve - I presume I could do this with a physics engine like Oops?

Essentially at the moment all the units have a collision box, and a speed - so the first goal is to make it so that one unit can influence anothers speed either by pulling it, pushing it or banging in to it.  Second goal is for momentum and gravity so that when going down a hill it rolls.  Then when going around a curve i'd like to know how much force, to know whether it is going to tip over.  Lastly, the stresses and forces excerpted on the couplings between units.


Any thoughts would be most appreciated!




Sep 15, 2009 at 12:29 AM

Hi Matt, Cool idea! And pretty interesting too!

Initially, using a 3d physics engine seems like the way to go.  You can represent each of your units with a collision box (or more), like you said, attach them together via some sort of constraint/joint and apply forces to the units and they should just react accordingly.

The interesting parts of your idea are the rails and the wheels.  Most vehicle simulations use rays "casted" from the bottom of the vehicle to represent wheels.  The rays are the diameter of a wheel and when they collide with the ground, forces are applied to the vehicle to keep it moving realistically.  But to start, you could just represent wheels with just collision spheres attached to the unit's collision box rigidly and constrained to a path of some sort (representing a rail).

With Oops!, you get CollisionBoxes and CollisionSpheres and you can attach them together to make unique shapes.  There's also a point-to-point constraint that would help with linking units together and a good start to writing a constaint (or constaints) that would help with keeping the train (and units) on the tracks.

I can see a few issues with my "proposal" such as how do you not constrain the wheels on a tight turn or going over a quick hill.  I'm sure there are ways to writing the constraint to allow for this.  Maybe, turning on/off constraints based on speed or momentum.

Anyways, Good luck.  Let me know if need any more info.


Sep 15, 2009 at 9:28 AM

Thanks for the reply, sounds interesting; I think i'll put what i've done thus far to one side and get a copy of Oops installed and start playing and see what I can do.  I'm still not entirely sure about using the physics engine to actually keep the train on the rails; plus when you start looking at junctions and switches / points it seems to me that things get much more complicated, if anything it seems like overkill but I guess i'll start with the main bodies, try joining them together, get a general feel for the framework and then start using that knowledge to understand how best to apply it to the question of rails; where really the only question I can think of thus far is managing the units' lateral forces around curves.

Still, much to think about and much to play with - thanks again!