I'm creating a MultiBody and I'm having a hard time figuring out whether or not I am actually supposed to have control over where to place the colliders?
To take the MultiDofDemo example provided, in the code there is the following:
Code: Select all
for (int i = 0; i < pMultiBody->getNumLinks(); ++i)
{
[b]btVector3 posr = local_origin[i + 1] + btVector3(30.f, 1.f, 0.f);//
// float pos[4]={posr.x(),posr.y(),posr.z(),1};
btScalar quat[4] = {-world_to_local[i + 1].x(), -world_to_local[i + 1].y(), -world_to_local[i + 1].z(), world_to_local[i + 1].w()};
btCollisionShape* box = new btBoxShape(linkHalfExtents);
btMultiBodyLinkCollider* col = new btMultiBodyLinkCollider(pMultiBody, i);
col->setCollisionShape(box);
btTransform tr;
tr.setIdentity();
tr.setOrigin(posr);
tr.setRotation(btQuaternion(quat[0], quat[1], quat[2], quat[3]));
col->setWorldTransform(tr);
col->setFriction(friction);
pWorld->addCollisionObject(col, 2, 1 + 2);
pMultiBody->getLink(i).m_collider = col;[/b]
}
Code: Select all
pMultiBody->getLink(i).m_collider = col;
Code: Select all
for (int i = 0; i < pMultiBody->getNumLinks(); ++i)
{
btCollisionShape* box = new btBoxShape(linkHalfExtents);
btMultiBodyLinkCollider* col = new btMultiBodyLinkCollider(pMultiBody, i);
col->setCollisionShape(box);
col->setFriction(friction);
pWorld->addCollisionObject(col, 2, 1 + 2);
pMultiBody->getLink(i).m_collider = col;
}
Thanks everyone, any help would be greatly appreciated!