Several problems using Bullet

IFMaster_2005
Posts: 1
Joined: Thu May 29, 2008 10:27 pm

Several problems using Bullet

Post by IFMaster_2005 »

Hello everybody, this is my first time here, and working with a physics engine.

I'm working in a small game using Ogre as a Render Engine, and i integrate OgreBullet.
I have several doubts about how to use it:

At this moment all what i need is, a lot of static objets (but maybe i want to move them oportunally) and all of them don't need to collide between them.
And several kinematic objects (objetcs like the player or enemies controlled by the logic of my game).

I define static objetcs with a shape, and a rigidBody->setStaticShape method.

And i define my kinematic objects like this:

Code: Select all

defaultBody->setShape(playerEntity->getOgreEntity()->getParentSceneNode(), sceneCubeShape, gDynamicBodyRestitution, gDynamicBodyFriction, gDynamicBodyMass, pos);
	defaultBody->getBulletRigidBody()->setUserPointer(this);

	defaultBody->getBulletRigidBody()->setCollisionFlags( defaultBody->getBulletRigidBody()->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
	defaultBody->getBulletRigidBody()->setActivationState(DISABLE_DEACTIVATION);
A guy tells me if i want to move my kinematic entities i must use linearVelocity, because teleport them with setPosition is not a good idea, but my problem is:
Using this configuration, when i try to apply a linearVelocity to my player it doesn't move, but if i teleport it (with setPosition), it moves right and collide with the static objects.

Some one can explin me what i'm doing bad, or if there are a better way to do what i need?

Thanks a lot in advance, i'm really a noob with physics and i'm with this a lot of time :S

PD: Sorry about my poor english
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Several problems using Bullet

Post by Erwin Coumans »

Check out all sections within USE_KINEMATIC_GROUND definition in Bullet/Demos/CcdPhysicsDemo, it has implementation details on how to use kinematic objects. Make sure to disable deactivation:

Code: Select all

body->setCollisionFlags( body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
body->setActivationState(DISABLE_DEACTIVATION);
Technically, using velocities would allow a better future implementation, but right now the results are the same. When setting a new position for kinematic objects, Bullet will internally calculate the velocity for kinematic objects based on this motion state.
Thanks,
Erwin