Hi Everybody,
I want to simulate a process in Bullet. This process entails the creation of two similar rigibodies in mouvement. During this simulation if a contact between these two objects is detected (in the case if i have a several bodies i want to be able to identify which bodies), i want to delete the two bodies and then create a new rigidbody which is the same size of the two rigidbdie. (see Picture)
For the detection of collision, i know that i have to iterate over all btPersistentManifold. But i don't know how can i do to identify the rigidbody associated to the contact.
How can i do this ? can anyone help me ?
Thank you
Youne
Question about collision detection !
-
- Posts: 40
- Joined: Sun Jan 27, 2008 2:55 pm
Question about collision detection !
You do not have the required permissions to view the files attached to this post.
-
- Posts: 40
- Joined: Sun Jan 27, 2008 2:55 pm
Re: Question about collision detection !
Hi everybody,
i am a mechanical engineer and i don't have much knowledge about the C++ language. So can anyone please help me to resolve my problem.
Thank you!
i am a mechanical engineer and i don't have much knowledge about the C++ language. So can anyone please help me to resolve my problem.
Thank you!
-
- Posts: 5
- Joined: Wed Jun 25, 2008 3:51 pm
Re: Question about collision detection !
Well, I'm not a big expert, but to detect a collision you'll have to setup a collision callback, once you do there is a function:
ContactAddedCallback( btManifoldPoint& cp,
const btCollisionObject* colObj0,int partId0,int index0,
const btCollisionObject* colObj1,int partId1,int index1 )
Inside of it you can cast the colObj0 and colObj1 to the type that you're dealing with.
In order for this to work you'll have to specify in your object's initialization:
yourCollisionObj->setCollisionFlags(pBulletChassisRigidBody->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
ContactAddedCallback( btManifoldPoint& cp,
const btCollisionObject* colObj0,int partId0,int index0,
const btCollisionObject* colObj1,int partId1,int index1 )
Inside of it you can cast the colObj0 and colObj1 to the type that you're dealing with.
In order for this to work you'll have to specify in your object's initialization:
yourCollisionObj->setCollisionFlags(pBulletChassisRigidBody->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: Question about collision detection !
Indeed, Yanush suggestion of using a contact callback is a good solution.
If you really want to iterate over contact manifolds, you can get to the rigid body by casting the body pointers (manifold->getBody0() and manifold->getBody1()), to a btRigidBody.
Hope this helps,
Erwin
If you really want to iterate over contact manifolds, you can get to the rigid body by casting the body pointers (manifold->getBody0() and manifold->getBody1()), to a btRigidBody.
Hope this helps,
Erwin