Translating a kinetic plane with boxes on top.

Netich

20-08-2010 14:46:27

Hi, ive been trying to learn bullet and ogrebullet for some days. I can set up some rigid bodies on the top of a plane, but now i would like to move the plane (rotation or translation) to create some kind of puzzle involiving physics.

I set the plane as a kinematic object like this.

defaultPlaneBody->enableActiveState();
defaultPlaneBody->setKinematicObject(true);
defaultPlaneBody->disableDeactivation();


and then use translate to move the plane:
defaultPlaneBody->getBulletRigidBody()->translate(btVector3(0.02, 0.02, 0.02));
(some example values, the idea is the user can control the plane)

The problem i get is the boxes on the top jump becouse the plane collide with them, or dont move if i translate the plane only in X-Z direction. The behaviour is ok if i lower the plane though.

What is the best way to achieve this? I would like to tell the physics engine, that the position im giving is the last position, but he has to move the plane step by step...

Thanks in advance

jonathanblacknight

20-08-2010 15:04:54

I think i don't understood your question so right,

why you using kinematic objects for a sample box? Did you try with A rigid body with a simple collision shape?

Netich

20-08-2010 15:49:06

Sorry, but english is not my main language. Ill try to keep it simple:

What i want is to raise the plane like an elevator, and the boxes above the plane should go up with it. Now every frame i move the plane, but the boxes jump becouse the plane moves instantaneously.

jonathanblacknight

20-08-2010 20:36:14

in your update method (frameStarted or something) you will need to move the plane slowly, in frame started you have a float the timeSinceLastFrame, multiply this for a small number until it reach the destination