Hi there, I have (beginners) question about the world transform of compound shapes.
It sais in the manual that "The world transform of a rigid body is in Bullet always equal to its center of mass"
What exactly does mean in practice? In my situation I would create a compoundshape, and add some child shapes. Chances are big, my center of the compound shape, is not the same as the center of mass of the object.
When I create the object I have to pass a motionstate, with a worldtransform. Is the center of my compoundshape positioned at that point, or is the objects center of mass positioned at that point?
And if this isn't the case, what happens after that? Does bullet immediatly change the the world transform to match the center of gravity? And does it then also update the child's motion state to match this new worldtransform of their parent, or .. ?
What I do now:
I create a motion state for the compoundshape
I create a compound shape
#For each child shape:
I create a motionstate for the child object (I feel like I wouldn't have to do this, cause the local position/rotation of the child shape should never change right?)
I remember how much mass the child shapes add (totalmass+=childmass)
I create a collisionshape for the child
I add it to the compound shape
#endfor
I call calculateLocalInertia on the compound shape, using totalmass
I make a ConstructionInfo
I make the body
I add the body
So what exactly happens to the worldtransforms in the motionstates of the compound, and of the children? Or does nothing happen and do I have a problem cause my worldtransform of the compound is not at the center of mass of the object?
Thanks a lot for any help!
Center of mass World Transform for compound shapes
-
- Posts: 109
- Joined: Tue May 01, 2012 10:42 am
-
- Posts: 456
- Joined: Tue Dec 25, 2007 1:06 pm
Re: Center of mass World Transform for compound shapes
AFAIK, Bullet does not know and does not try to calculate the center of mass of the compound shape you pass to it: it just takes the point (0,0,0) in that shape and makes it the center of mass of your shape.STTrife wrote:my center of the compound shape, is not the same as the center of mass of the object.
If you need to move it from there, you can shift all the child shapes inside the compound shape, or you can just create a new compound shape and add as a child shape the old compound shape shifted by an offset.
The object center of mass [(0,0,0) inside the compound shape] is positioned at that point.STTrife wrote:When I create the object I have to pass a motionstate, with a worldtransform. Is the center of my compoundshape positioned at that point, or is the objects center of mass positioned at that point?
STTrife wrote:I create a motionstate for the child object (I feel like I wouldn't have to do this, cause the local position/rotation of the child shape should never change right?)

The latter as far as I know. But you can shift the center of mass inside the btCompoundShape manually and then update the local inertia.STTrife wrote:Or does nothing happen and do I have a problem cause my worldtransform of the compound is not at the center of mass of the object?
There's a demo posted by Erwin you can download from here that can be useful: http://bulletphysics.org/Bullet/phpBB3/ ... shift+demo