RayCastVehicle -> instantiate on ground

Post Reply
SeriousToys
Posts: 4
Joined: Fri Feb 10, 2012 2:07 pm

RayCastVehicle -> instantiate on ground

Post by SeriousToys » Fri Feb 10, 2012 2:11 pm

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

User avatar
xissburg
Posts: 46
Joined: Sat May 19, 2007 9:28 pm

Re: RayCastVehicle -> instantiate on ground

Post by xissburg » Mon Feb 13, 2012 12:26 am

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.

kloplop321
Posts: 55
Joined: Sun Jan 01, 2012 7:37 pm

Re: RayCastVehicle -> instantiate on ground

Post by kloplop321 » Mon Feb 13, 2012 12:31 am

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.

SeriousToys
Posts: 4
Joined: Fri Feb 10, 2012 2:07 pm

Re: RayCastVehicle -> instantiate on ground

Post by SeriousToys » Mon Feb 13, 2012 11:39 am

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

kloplop321
Posts: 55
Joined: Sun Jan 01, 2012 7:37 pm

Re: RayCastVehicle -> instantiate on ground

Post by kloplop321 » Mon Feb 13, 2012 3:36 pm

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..

SeriousToys
Posts: 4
Joined: Fri Feb 10, 2012 2:07 pm

Re: RayCastVehicle -> instantiate on ground

Post by SeriousToys » Wed Feb 15, 2012 3:51 pm

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...

kloplop321
Posts: 55
Joined: Sun Jan 01, 2012 7:37 pm

Re: RayCastVehicle -> instantiate on ground

Post by kloplop321 » Wed Feb 15, 2012 7:46 pm

Then I suggest setting it to sleep before the first frame after you instantiate it.

Post Reply