simple ghost object

Please don't post Bullet support questions here, use the above forums instead.
z3a
Posts: 1
Joined: Sat Mar 05, 2011 8:33 am

simple ghost object

Post by z3a »

Hi,

I'm trying to implement a simple ghost object, this is how I create the ghost objects:

Code: Select all

    btGhostPairCallback* ghostCall = new btGhostPairCallback();
    world->getBroadphase()->getOverlappingPairCache()->setInternalGhostPairCallback(ghostCall);

    btGhostObject* ghostObj = new btGhostObject();
    btCollisionShape* shape = new btBoxShape(btVector3(ofGetWidth()+1000, ofGetHeight()+1000, 50));
    ghostObj->setCollisionShape(shape);
    btTransform trans;
    trans.setIdentity();
    trans.setOrigin(btVector3(0,0,-500));
    ghostObj->setWorldTransform(trans);
    ghostObj->setCollisionFlags( btCollisionObject::CF_NO_CONTACT_RESPONSE);
    world->addCollisionObject(ghostObj,btBroadphaseProxy::SensorTrigger,btBroadphaseProxy::AllFilter & ~btBroadphaseProxy::SensorTrigger);
and this is how to try to find the collision:

Code: Select all

	btCollisionObject* obj = world->getCollisionObjectArray()[j];
	btRigidBody* body = btRigidBody::upcast(obj);

        btAlignedObjectArray < btCollisionObject* > objsInsidePairCachingGhostObject;
        btAlignedObjectArray < btCollisionObject* >* pObjsInsideGhostObject = NULL;
        btGhostObject* ghost = btGhostObject::upcast(obj);

        if(ghost){
            objsInsidePairCachingGhostObject.resize(0);
            pObjsInsideGhostObject = &ghost->getOverlappingPairs();
            cout << ghost->getNumOverlappingObjects() << endl;
but I always get a response that all my world objects are in collision with the ghost object.

Anyone can help me to get a functional simple ghost object?

thanks