Skip to content

Instantly share code, notes, and snippets.

@erwincoumans
Created October 2, 2017 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save erwincoumans/b8a110b5c228b378161068cd25fa7d2c to your computer and use it in GitHub Desktop.
Save erwincoumans/b8a110b5c228b378161068cd25fa7d2c to your computer and use it in GitHub Desktop.
{
btCompoundShape* compoundShape = new btCompoundShape();
btBoxShape* cube = new btBoxShape(btVector3(0.5, 0.5, 0.5));
m_collisionShapes.push_back(cube);
btTransform transform;
transform.setIdentity();
transform.setOrigin(btVector3(0, 0, 0));
compoundShape->addChildShape(transform, cube);
transform.setIdentity();
transform.setOrigin(btVector3(0, 1, 0));
compoundShape->addChildShape(transform, cube);
transform.setIdentity();
transform.setOrigin(btVector3(0, 2, 0));
compoundShape->addChildShape(transform, cube);
transform.setIdentity();
transform.setOrigin(btVector3(0, 1, 1));
compoundShape->addChildShape(transform, cube);
transform.setIdentity();
transform.setOrigin(btVector3(0, 10, 0));
btScalar masses[4]={1,1,1,1};
btTransform principal;
btVector3 inertia;
compoundShape->calculatePrincipalAxisTransform(masses,principal,inertia);
btCompoundShape* compound2 = new btCompoundShape();
m_collisionShapes.push_back(compound2);
#if 0
compound2->addChildShape(principal.inverse(), compoundShape);
#else
for (int i=0;i<compoundShape->getNumChildShapes();i++)
{
compound2->addChildShape(compoundShape->getChildTransform(i)*principal.inverse(),compoundShape->getChildShape(i));
}
#endif
delete compoundShape;
createRigidBody(1.0 , transform, compound2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment