Page 1 of 1

RayCastVehicle -> instantiate on ground

Posted: Fri Feb 10, 2012 2:11 pm
by SeriousToys
Hi all,

I have modelled a train as a series of btRayCastVehicles, tied together through btPoint2PointConstraints. So far so good :-).
The train is riding over bumpy terrain.

Right now, I instantiate the train a couple of decimeters above the ground, and when the simulation starts, it falls down a little bit and bounces for a while, until the suspensions settle.

I want to instantiate the train such that every wagon is resting on the ground, and so no initial bumpy effect is generated by the physics engine. How can I instantiate the raycast vehicles such that all p2p constraints are met, but also all the wheels are perfectly neutral resting on the ground?

Regards,
Robert

Re: RayCastVehicle -> instantiate on ground

Posted: Mon Feb 13, 2012 12:26 am
by xissburg
You could start your simulation but not render it. Wait for it to stabilize and then present it to the user. It's like, the stabilization task is part of the scene loading task.

Re: RayCastVehicle -> instantiate on ground

Posted: Mon Feb 13, 2012 12:31 am
by kloplop321
Ah, here's an idea, if you're loading physics and graphics stuff, you could load all of the physics data first, then in another thread, let the world simulate (and let things fall asleep) while you load graphics resources(but don't instantiate new entities while you simulate, that's stupid). That way you are making good use of CPU time while you're waiting for resources to load from the slower media such as the hard drive.

Anyway just an idea, but it generally is a good idea to let things settle before presenting them to the user, otherwise the world will seem hectic while the player sees things.

Re: RayCastVehicle -> instantiate on ground

Posted: Mon Feb 13, 2012 11:39 am
by SeriousToys
Hi all,

Thanks for this idea, I will give it a try!

Though it hurts my programmer heart, I must say :-), I'd rather do some projections down to the ground and translate and rotate the vehicles such that they are instantiated in perfect balance right from the start...

Regards,
Robert

Re: RayCastVehicle -> instantiate on ground

Posted: Mon Feb 13, 2012 3:36 pm
by kloplop321
The problem is if you want to be dynamic and not have the car bounce a bit when the player first steps on it.

Such constraints have to simulate to find their equilibrium, if you hardcode such, then every single car you have better be 100% the same in every way.

Its not too hard to do this pre-simulation..

Re: RayCastVehicle -> instantiate on ground

Posted: Wed Feb 15, 2012 3:51 pm
by SeriousToys
Just to be clear: I don't mind the vehicle bouncing when the player steps on it.

I just don't once it to bounce in the first frame of the simulation.
The vehicle is then just parked on the side of the road... I want it to stand there quietly....

So therefore I though I'd be able to do some ray casts from the vehicle down to the world when instantiating the (parked) vehicles. Later on, during the game, they will move, but that's fine...

Re: RayCastVehicle -> instantiate on ground

Posted: Wed Feb 15, 2012 7:46 pm
by kloplop321
Then I suggest setting it to sleep before the first frame after you instantiate it.