How to disable rigid body reaction to external forces

toglia

16-06-2010 17:15:50

I have been like crazy trying to freeze the position of some of my dynamic objects but I can't seem to find a way of doing it.

Lets say you had some obstacles in your game, these obstacles should move and rotate deliberately but they may not vary their position or angular velocity with any collision. Could be the a door in a labyrinth, for example.

I have tried lifting some flags, but I can't find flags fitting this behavior anyway. If I set my rigid body to KINEMATIC for example, I can't move o rotate it anymore.

I must be missing a simple option here...

I would appreciate any help.

toglia

16-06-2010 22:19:30

Possibly I'm using wrong search patterns. How would you guys call this?

Fish

16-06-2010 23:32:48

You can make them static by defining them with a mass of 0. That will prevent the object from moving. You can then move the object manually:
// First, move the node that your mesh is attached to.
mNode->setPosition(newPosition);

// Activate the static rigid body.
mBody->getBulletRigidBody()->activate(true);

// Grab the current transform for the rigid body.
btTransform xForm = mBody->getBulletRigidBody()->getWorldTransform();

// Set the new world position in the transform.
xForm.setOrigin(btVector3( mNode->getPosition().x, mNode->getPosition().y, mNode->getPosition().z) );

// Set the transform for the rigid body.
mBody->getBulletRigidBody()->setWorldTransform(xForm);


- Fish

toglia

17-06-2010 05:23:45

Thanks. I was using rigid body forces and torque, no wonder...

Another thing, Normally I used to update my scene nodes with a btMotionState, and it worked great. Apparently, this also doesn't work with kinematic objects?

EDIT: I have found kinematic bodies don't enter the the btMotionState setWorlTransform method, so its inevitable to update the scene-node manually. Again, thanks for your your help. I can move on now.