Setting position transform correctly.

steveh
Posts: 22
Joined: Mon Dec 19, 2005 3:15 pm

Setting position transform correctly.

Post by steveh »

Hello,
I'd like to set the position of my static and dynamic objects after they have been created and added to physics world (for example, teleporting an object from one position to another).

Should I use : btCollisionObject::setWorldTransform or setCenterOfMassTransform?

Could someone explain the difference please, they sound very similar.

Also if I'd like (for example) a box to have it's centre of mass at one corner, how to I specify this?

Sorry for all the questions, I'm trying to write wrappers for a cross platform (PC/360/PSP) physics engine and these are the basic things that come up. I've looked through the demos and most of them just seem to have an initial xform.

Many thanks.

Steve.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Setting position transform correctly.

Post by Erwin Coumans »

steveh wrote:Hello,
I'd like to set the position of my static and dynamic objects after they have been created and added to physics world (for example, teleporting an object from one position to another).

Should I use : btCollisionObject::setWorldTransform or setCenterOfMassTransform?

Could someone explain the difference please, they sound very similar.
They are similar, and you can use either. Bullet has a collision detection system, which can be used independently too, in that case just use the btCollisionObject version. Note that you are not supposed to move static objects around, you should use 'kinematic' objects for that. See the CcdPhysicsDemo, there is a #define at the top of the file to show how to animate/move the ground.
Also if I'd like (for example) a box to have it's centre of mass at one corner, how to I specify this?
The local rigid body center is always the center of mass. This means that if you want your cube corner to be at the center of mass, you just shift the cube, using a btCompoundShape. The childshape (cube) can be re-positioned with a child transform, so that the corner is at the local rigid body center.
Sorry for all the questions, I'm trying to write wrappers for a cross platform (PC/360/PSP) physics engine and these are the basic things that come up. I've looked through the demos and most of them just seem to have an initial xform.
Many thanks.
It would be nice if the Bullet project moved forward quicker, with more demos and documentation, but there are only limited resources, so patience (or contributions) are needed for this. My current work on Bullet focusses on Playstation 3 SPU optimizations/parallelization. From time to time, I bring back improvements to the public (open source) version.

Thanks for the feedback,
Erwin
steveh
Posts: 22
Joined: Mon Dec 19, 2005 3:15 pm

Post by steveh »

Many thanks for the quick answers. It's all getting a bit clearer now.

I completely understand with regards to time pressures and keeping docs/demos up to date. I for one appreciate the time and effort you and the contibutors are making!

Regards,

Steve.