Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Wed May 23, 2012 7:21 pm 
Offline

Joined: Wed May 23, 2012 7:08 pm
Posts: 17
Hi
I was trying to use the collision detection using bullet physics. I had some problems regarding that. I am a new to bullet physics.
I used the code from the demos for collision detection (App_CollisionInterfaceDemo). Please see the code below. Is this right way to check for two boxes collision? Also how do I know if the boxes collided? Is this the right method to check for collision detection using oriented bounding box or is there another method? Can anyone help me to get started on this? Also if some someone has a demo code for checking whether two objects collide or not, it would be greatly appreciated.

btCollisionObject objects[maxNumObjects];
btCollisionWorld* collisionWorld = 0;
btMatrix3x3 basisA;
basisA.setIdentity();

btMatrix3x3 basisB;
basisB.setIdentity();

objects[0].getWorldTransform().setBasis(basisA);
objects[1].getWorldTransform().setBasis(basisB);

btBoxShape* boxA = new btBoxShape(btVector3(1,1,1));
boxA->setMargin(0.f);

btBoxShape* boxB = new btBoxShape(btVector3(0.5,0.5,0.5));
boxB->setMargin(0.f);
objects[0].setCollisionShape(boxA);//&hullA;
objects[1].setCollisionShape(boxB);//&hullB;

btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration);
btVector3 worldAabbMin(-1000,-1000,-1000);
btVector3 worldAabbMax(1000,1000,1000);

btAxisSweep3* broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax);

//SimpleBroadphase is a brute force alternative, performing N^2 aabb overlap tests
//SimpleBroadphase* broadphase = new btSimpleBroadphase;

collisionWorld = new btCollisionWorld(dispatcher,broadphase,collisionConfiguration);



objects[0].getWorldTransform().setOrigin(btVector3(0.0f,3.f,0.f));

btQuaternion rotA(0.739f,-0.204f,0.587f,0.257f);
rotA.normalize();

objects[0].getWorldTransform().setRotation(rotA);

objects[1].getWorldTransform().setOrigin(btVector3(0.0f,4.248f,0.f));

collisionWorld->addCollisionObject(&objects[0]);
collisionWorld->addCollisionObject(&objects[1]);
collisionWorld->performDiscreteCollisionDetection();

btDrawingResult renderCallback;

collisionWorld->contactPairTest(&objects[0],&objects[1],renderCallback);


Thanks
Amrish Kumar


Attachments:
File comment: Attached ifile
CollisionInterface.cpp [2.09 KiB]
Downloaded 47 times
Top
 Profile  
 
PostPosted: Thu May 24, 2012 11:58 am 
Offline

Joined: Wed May 23, 2012 7:08 pm
Posts: 17
Can anyone help??????????????


Top
 Profile  
 
PostPosted: Thu May 24, 2012 1:59 pm 
Offline

Joined: Wed May 23, 2012 7:08 pm
Posts: 17
Hi
I got some of the bounding box collision detection code working but it is not able to detect collision.

I am attaching the file in this regard. I made two boxes and using broad phase collision method.

Can anyone look and tell why btManifoldpt (contact points) are empty while in reality the boxes are hitting

Thanks
amrish Kumar


Attachments:
CollisionInterface.cpp [2.43 KiB]
Downloaded 48 times
Top
 Profile  
 
PostPosted: Thu May 24, 2012 5:06 pm 
Offline

Joined: Thu Apr 12, 2012 11:54 pm
Posts: 3
It seems like you want to use bullet to check for collisions, then resolve the effects of the collision yourself? Instead of just adding some boxes and have them bounce around on their own. Have a look at the example here, it's two boxes colliding (text mode).

Of course, maybe you want to do something else and need to check for collisions. In which case I can't help. :D


Attachments:
test.cpp [3.15 KiB]
Downloaded 65 times
Top
 Profile  
 
PostPosted: Sat Jan 05, 2013 4:54 pm 
Offline

Joined: Mon May 21, 2012 7:44 am
Posts: 8
I got your pm.

I ended up using Newton as opposed to Bullet physics as it seemed to be able to handle simple shapes more easily. I was also interested in just detecting the collision. My solution (with the problems I faced) is fairly well documented on Newtons forum in this thread:

http://newtondynamics.com/forum/viewtop ... f=9&t=7230

This is a video showing (except a rendering error) my final solution.

http://www.youtube.com/watch?v=eiaZBUgsQAQ

Hope this helps.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group