I'm new to bullet.
What I like to do:
I have a terrain which is a btBvhTriangleMeshShape in bullet I think.
Now I like to test multiple positions for a collision with that terrain.
This should be done with a box I can move around and give me the information if it's
colliding with that terrain.
My current code looks so:
Code: Select all
btVector3 worldAabbMin(-10000,-10000,-10000);
btVector3 worldAabbMax(10000,10000,10000);
btAxisSweep3* broadphase = new btAxisSweep3(worldAabbMin, worldAabbMax);
btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration);
btCollisionWorld* world = new btCollisionWorld(dispatcher, broadphase, collisionConfiguration);
// Terrain:
btTriangleMesh* groundMesh = new btTriangleMesh(true, false);
groundMesh->addTriangle(btVector3(0,0,0), btVector3(100,0,0), btVector3(0,0,100));
btBvhTriangleMeshShape* groundMeshShape = new btBvhTriangleMeshShape(groundMesh, true, true);
btCollisionObject* terrain = new btCollisionObject();
terrain->setCollisionShape(groundMeshShape);
world->addCollisionObject(terrain);
// Test box:
btBoxShape* boxShape = new btBoxShape(btVector3(1.f, 1.f, 1.f));
btCollisionObject* box = new btCollisionObject();
box->setCollisionShape(boxShape);
world->addCollisionObject(box);
// Setting positions:
terrain->setWorldTransform(btTransform(btQuaternion(0,0,0,1), btVector3(0,0,0)));
box->setWorldTransform(btTransform(btQuaternion(0,0,0,1), btVector3(100,0,100)));
// Check for collisions
world->performDiscreteCollisionDetection();
// With this configuration this methods returns 1. But why?
std::cout << world->getDispatcher()->getNumManifolds() << std::endl;
I think the scene should look something like that:
Code: Select all
* []
***
*****
******
I really need a solution for this and I am near to become crazy...
Thanks