I am pretty new to bullet and for the moment I am only using it to do simple collision detection with the purpose being of object selection.
I have various objects that are drawn in an openGL canvas and all of them are static. For bullet I just use primitive shapes.
On my render function I remove all bullet rigid bodies and add them again in order to reflect the new location and orientation of the equivalent opengl objects.
I am able to do simple ray collision to test which object is selected/clicked. Now I would like to be able to do rubber band selection in order to select multiple objects on screen.
I read that btPairCachingGhostObject is the way to go so I have been trying to implement that but I think I am missing something.
Theoretically I should calculate the near and far edges of my frustrum from the rubber band rectangle and add them to a btConvexHullShape which i will then pass to my btPairCachingGhostObject.
But for now lets just make it simple and just use a btBoxShape and actually a rather large one to be sure.
So after my selection finished via the means of a rubberband I do :
Code: Select all
btBoxShape* box = new btBoxShape(btVector3(3000,3000,3000))
btPairCachingGhostObject* frustum = new btPairCachingGhostObject();
frustum->setCollisionShape(box);
frustum->setCollisionFlags(frustum->getCollisionFlags()|btCollisionObject::CF_NO_CONTACT_RESPONSE);
this->dynamicsWorld->addCollisionObject(frustum);
btBroadphasePairArray& collisionPairs = frustum->getOverlappingPairCache()->getOverlappingPairArray();
const int numObjects=collisionPairs.size();
I checked my dynamicsWorld by debugDrawWorld() and I see that my box shape definitely includes all my objects.
Any help would be much appreciated !