Created
October 2, 2017 15:09
-
-
Save erwincoumans/b8a110b5c228b378161068cd25fa7d2c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
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