Below is an image of the btPairCachingGhostObject which uses the btCompoundShape with it's origin set as follows (where y is up -z forward):
Code: Select all
this->ghostObject->getWorldTransform().setOrigin(btVector3(2, 0, 0));
Below is how the btCompoundShape and btPairCachingGhostObject are being generated:
Code: Select all
btCylinderShape* cyl = new btCylinderShape(btVector3(this->radius, (1.25f / 2.0f), this->radius));
btTransform cylTran;
cylTran.setIdentity();
cylTran.setOrigin(btVector3(0,0,0));
btSphereShape* sphereSmall = new btSphereShape(0.36f);
btTransform sphereSmallTran;
sphereSmallTran.setIdentity();
sphereSmallTran.setOrigin(btVector3(0, -0.77456, 0));
btSphereShape* blendSphere = new btSphereShape(0.4f);
btTransform blendSphereTran;
blendSphereTran.setIdentity();
blendSphereTran.setOrigin(btVector3(0, -0.62507, 0));
btCompoundShape* compoundShape = new btCompoundShape();
compoundShape->addChildShape(cylTran, cyl);
compoundShape->addChildShape(sphereSmallTran, sphereSmall);
compoundShape->addChildShape(blendSphereTran, blendSphere);
this->shape = compoundShape;
this->ghostObject = new btPairCachingGhostObject();
this->ghostObject->setCollisionShape(this->shape);
this->ghostObject->setCollisionFlags(btCollisionObject::CF_NO_CONTACT_RESPONSE);
this->collisionWorld->getDynamicsWorld()->addCollisionObject(this->ghostObject, btBroadphaseProxy::KinematicFilter, btBroadphaseProxy::StaticFilter | btBroadphaseProxy::DefaultFilter);
this->collisionWorld->getDynamicsWorld()->getPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());
this->ghostObject->getWorldTransform().setOrigin(btVector3(2, 0, 0));