zak wrote:pBody->SetMassMatrix( Ixx, Iyy, Izz, mass );
pBody->SetCollisionShape( new ndShapeSphere( radius ) );
then SetMassMatrix() doesn't work.
It works only if a nsShapeInstance is already setted with pBody->SetCollisionShape() before it is called.
I think I see what you mean there.
if you loo at the source code of
- Code: Select all
void ndBodyKinematic::SetMassMatrix(dFloat32 mass, const dMatrix& inertia)
{
mass = dAbs(mass);
ndShape* const shape = m_shapeInstance.GetShape();
if ((mass < D_MINIMUM_MASS) || shape->GetAsShapeNull() || !shape->GetAsShapeConvex())
{
mass = D_INFINITE_MASS * 2.0f;
}
if you call to set the mass of a body and the body was just created, teh body will have a defaul shape with is the a null shape. so setting the mass of a body wi the a null shape will has no effect sine bodies with null shape or a static are static bodes
my suggestion is to do it the the reverse order, set teh shape them the mass matrix.
- Code: Select all
pBody->SetCollisionShape( new ndShapeSphere( radius ) );
pBody->SetMassMatrix( Ixx, Iyy, Izz, mass );
or better yet
- Code: Select all
pBody->SetCollisionShape( new ndShapeSphere( radius ) );
pBody->SetMassMatrix(mass, pBody->GetCollisionShape());
also notice that
pBody->SetCollisionShape( new ndShapeSphere( radius ) )
is not possible since teh funtion is proto is,
void ndBodyKinematic::SetCollisionShape(const ndShapeInstance& shapeInstance);
you can not assign a shapes to a body, you can only assign an instance of a shape.
new ndShapeSphere( radius )