Switching from ODE to Bullet, CenterOfMass problem

peacemoon
Posts: 15
Joined: Wed Sep 03, 2008 12:52 pm

Offset when object has mass???

Post by peacemoon »

Hello,
I created an object with these codes

Code: Select all

 	startTransform.setOrigin(btVector3(-0.2f,0.0f,0.1f));
  	csAvatar = new btSphereShape(btScalar(AVATAR_RADIUS));
  	collisionShapes.push_back(csAvatar);
  	//mass = AVATAR_MASS;
        mass = 0;
  	btDefaultMotionState* msAvatar = new btDefaultMotionState(startTransform);
  	btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,msAvatar,csAvatar,localInertia);
  	bbAvatar = new btRigidBody(rbInfo);
  	dynamicsWorld->addRigidBody(bbAvatar);
and i read the position of this object again in loop with these codes

Code: Select all

  btTransform trans = bbAvatar->getCenterOfMassTransform();
  float a_pos[3] = {trans.getOrigin().getX(), trans.getOrigin().getY(), trans.getOrigin().getZ()};
  printf("%4.2f %4.2f %4.2f \n",a_pos[0],a_pos[1],a_pos[2]);
But i found that, when i setted mass = 0, i have the right position of the object which i had setted when i created the object (-0.2,0.0,0.1)

But when i seted mass = 4, i received another position of the object (-0.2,-0.34,0.1)

Can anyone help me out?
Thanks
peacemoon
Posts: 15
Joined: Wed Sep 03, 2008 12:52 pm

Switching from ODE to Bullet, CenterOfMass problem

Post by peacemoon »

Hello,
i have just switched from ODE to Bullet, i have problem to set position of an object. As in ODE, when i try to set position of an object, i just set the position of the center of the object. I try to do the same things with bullet, but my object is just shifted away from the position which i want to set. Can anyone explain me more about this ?
Thanks
An
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Offset when object has mass???

Post by Erwin Coumans »

Please don't double post, your similar posts have been merged.

In Bullet, the world transform of a btRigidBody is also the center of mass.

Do the demos work fine with you?

Can you provide the full modified BasicDemo that shows your problem?
For character/avatars, you should check out the CharacterDemo.

Hope this helps,
Erwin