I have a rigidbody which is constructed using a compound collision shape, then later in the program I need to access the children of the compoundshape but I only have to pointer to the rigidbody. I can get the the collisionshape from the rigidbody using ->getCollisionShape(), but I don't know how to access the child shapes from this, using ->getChildShape(index) doesn't work, but I don't know how to go about this. Is there a solution or will I need to keep hold of the pointer to the original compoundshape. Here is my code at the moment, many thanks.
Code: Select all
mycompoundshape= new btCompoundShape;
mycompoundshape->addChildShape( transform , collisionshape );
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass, motionState,mycompoundshape,localInertia);
rigidbody = new btRigidBody(rbInfo);
// lots of code here
//
if (rigidbody->getCollisionShape()->isCompound()==true) {
for(int i=0 ; i<rigidbody->getCollisionShape()->getNumChildShapes();i++){ // this does not work
rigidbody->getCollisionShape->getChildShape(i); // or this
}
}
Rob