How to make static rigid body solid.

ivopeterka
Posts: 3
Joined: Fri Jun 03, 2011 12:46 pm

How to make static rigid body solid.

Post by ivopeterka »

Can anybody help me with following problem?

I'm completely new to Bullet and I'm trying to accomplish some task in it, which as its part has horizontal movement of one object on top of another. I created little example, where I first let fall small box

Code: Select all

	btTransform Transform2;
	Transform2.setIdentity();
	btVector3 position = btVector3(0,10,0);
	Transform2.setOrigin(position);
	btDefaultMotionState *MS2 = new btDefaultMotionState(Transform2);
	btCollisionShape *CS2 = new btBoxShape(btVector3(0.5,0.5,0.5));
	btVector3 LocalInertia2;
	CS2->calculateLocalInertia(1,LocalInertia2);
	btRigidBody *RB2 = new btRigidBody(1, MS2, CS2, LocalInertia2);
on a platform (static rigid body)

Code: Select all

	btTransform Transform1;
	Transform1.setIdentity();
	Transform1.setOrigin(btVector3(0,0,0));
	btDefaultMotionState *MS1 = new btDefaultMotionState(Transform1);
	btCollisionShape *CS1 = new btBoxShape(btVector3(5,0.5,5));
	btVector3 LocalInertia1;
	CS1->calculateLocalInertia(1.0,LocalInertia1);
	btRigidBody* RB1 = new btRigidBody(0, MS1, CS1, LocalInertia1);
I want to then slide the box on top of the platform. So I added Central Impulse (I ensured, that it is applied some time after the box fells on the platform). It comes as this:

Code: Select all

if(currTime - origTime > 3000 && !bForced)
{
	RB2->applyCentralImpulse(btVector3(0.1f,0,0.1f));
	bForced = true;
}
The problem is, that after applying impulse (and I tried also something like this with applyForce) the box albeit starts to move to the side, however it also starts to sink into the platform.

Is there any way how to make the platform solid (as a stone), so the box doesn't sink into it?

The Bullet world I'm using is initialized as follows

Code: Select all

btDefaultCollisionConfiguration *CollisionConfiguration = new btDefaultCollisionConfiguration();
btBroadphaseInterface *BroadPhase = new btAxisSweep3(btVector3(-1000, -1000, -1000), btVector3(1000, 1000, 1000));
btCollisionDispatcher *Dispatcher = new btCollisionDispatcher(CollisionConfiguration);
btSequentialImpulseConstraintSolver *Solver = new btSequentialImpulseConstraintSolver();
btDiscreteDynamicsWorld *World = new btDiscreteDynamicsWorld(Dispatcher, BroadPhase, Solver, CollisionConfiguration);
Thanks in advance for any advice.
ivopeterka
Posts: 3
Joined: Fri Jun 03, 2011 12:46 pm

Re: How to make static rigid body solid.

Post by ivopeterka »

Well, some time ago I found it. The problem was

Code: Select all

CS1->calculateLocalInertia(1.0,LocalInertia1);
as it should be

Code: Select all

CS1->calculateLocalInertia(0,LocalInertia1);
for the platform. Simply in one of the two places, where mass is defined, I used 1 in place of 0 by mistake ... .
User avatar
Dr.Shepherd
Posts: 168
Joined: Tue Jan 04, 2011 11:47 pm

Re: How to make static rigid body solid.

Post by Dr.Shepherd »

ivopeterka wrote:Well, some time ago I found it. The problem was

Code: Select all

CS1->calculateLocalInertia(1.0,LocalInertia1);
as it should be

Code: Select all

CS1->calculateLocalInertia(0,LocalInertia1);
for the platform. Simply in one of the two places, where mass is defined, I used 1 in place of 0 by mistake ... .
ok, so you set the platform to be a dynamic object as well, is it?