Stick objects together after the collision

User avatar
Dr.Shepherd
Posts: 168
Joined: Tue Jan 04, 2011 11:47 pm

Stick objects together after the collision

Post by Dr.Shepherd »

Hi, all,

anyone has any idea about how to stick two objects together after they collide with each other ?

I am creating a character controller, and in my case, when the feet and ground collide with each other (assuming there is no relative movement), the contact point can be regarded as a hinge constraint, so the leg rotates like a hinge joint. But how to build this constraint automatically when every everytime the contact point is changing ?

My current method is to first determine if the feet collide with the ground, then found the contact point, then build the constraint. It's a bit complex. Is there any method that can automatically detect the contact point and stick these two together ?

Thanks !
User avatar
Dr.Shepherd
Posts: 168
Joined: Tue Jan 04, 2011 11:47 pm

Re: Stick objects together after the collision

Post by Dr.Shepherd »

OK, I will answer by myself.

We can use the customContactCallback, when we detect there is a contact added between the foot and the ground, then make it as a hinge joint. This can be achieved by

Code: Select all

typedef bool (*ContactAddedCallback)(     btManifoldPoint& cp,     const btCollisionObject* colObj0,     int partId0,     int index0,     const btCollisionObject* colObj1,     int partId1,    int index1);
These parameters are sufficient enough to get all the information related with the contact manifold.

Cheers