Collisions?

ripper9100
Posts: 10
Joined: Mon Sep 08, 2008 2:27 am

Collisions?

Post by ripper9100 »

Hi,

I need to trigger an action when a certain object in my scene gets hit. How would I go about doing this? Is getCollisionflag() useful for this? Does it notify me when this object has been hit?
mickey
Posts: 107
Joined: Fri Sep 19, 2008 6:08 pm

Re: Collisions?

Post by mickey »

Hi

See if this wiki entry here can help you out:

http://www.bulletphysics.com/mediawiki- ... d_Triggers
ripper9100
Posts: 10
Joined: Mon Sep 08, 2008 2:27 am

Re: Collisions?

Post by ripper9100 »

Thanks, have got it sort of working but I have a small problem. In my project I am throwing a ball in a rectangular room and I want to trigger a certain event if I hit the object in the middle of the room. At the moment I am using the gContactAddedCallback and it works. If a ball hits that object it will trigger the event. But for my application I only want to trigger an event if the ball hits the object without bouncing off anything else. How can I achieve this?

I'm using this function from one of the bullet demos to handle the collision detection:

Code: Select all

bool CustomMaterialCombinerCallback(btManifoldPoint& cp, const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1)
{
	if (colObj0->getCollisionFlags() & btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK)
	{
		
	}

	if (colObj1->getCollisionFlags() & btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK)
	{
		//trigger event
		}
	return true;
}
Is what I want to do achievable by modifying this function or do I need another approach?
mickey
Posts: 107
Joined: Fri Sep 19, 2008 6:08 pm

Re: Collisions?

Post by mickey »

I'm not too sure but I'll try:

A. I think there's a way so that when your object collides with another object, it does not resolve anything (eg bounce/push the other objects away) - you probably do this by setting some flags or group them. Sorry if I'm a little vague as I'm not very sure entirely.

B. gContactAddedCallback - do you think you can use this instead? So before the collision gets processed, remove the object from the dynamics world?
ripper9100
Posts: 10
Joined: Mon Sep 08, 2008 2:27 am

Re: Collisions?

Post by ripper9100 »

mickey, thanks for your help but unfortunately I'm still stuck. Does anybody know how I can do this?
Ralith
Posts: 4
Joined: Sun Mar 15, 2009 7:20 pm

Re: Collisions?

Post by Ralith »

Store a flag that gets set if the object bounces off something else, then only act if the flag is unset.