Hello,
I have a compound object that consists of a 4 sides and a floor. Within it I have a box and I'm trying to determine which child object of the compound object has been involved in the collision.
I have a got the collision with the compound object working by looping around the manifolds eg:
int numManifolds = pDynamicsWorld->getDispatcher()->getNumManifolds();
for (int i=0;i<numManifolds;i++)
{
btPersistentManifold* contactManifold = pDynamicsWorld->getDispatcher()->getManifoldByIndexInternal(i);
btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->getBody0());
btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->getBody1());
etc
}
But I can't see any easy way of determining which child object of the compound object has been hit.
Edit: The reason I want this is so that I can play different sound effects based on whether the box inside the room hits the floor or wall.
Any pointers/clues would be really helpful.
Thanks in advance,
James
Compound object and collision question.
-
Flix
- Posts: 456
- Joined: Tue Dec 25, 2007 1:06 pm
Re: Compound object and collision question.
The way I did it (source code here: http://bulletphysics.org/Bullet/phpBB3/ ... =17&t=4498), was using a contact added callback instead of the "default" collision system.jmbrook2 wrote: I have a got the collision with the compound object working by looping around the manifolds eg:
int numManifolds = pDynamicsWorld->getDispatcher()->getNumManifolds();
for (int i=0;i<numManifolds;i++)
{
btPersistentManifold* contactManifold = pDynamicsWorld->getDispatcher()->getManifoldByIndexInternal(i);
btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->getBody0());
btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->getBody1());
etc
}
But I can't see any easy way of determining which child object of the compound object has been hit.
Basically I've set an appropriate flag to the compound rigid body, "marked" the child shape in my custom contact added callback and done other complicated stuff (i.e. removing the child shape and recalculate the center of mass of the compound shape in my case) outside of it.
Anyway maybe you can access the child shape index itself somewhere in the "default" collision system as well (I've not tried it so far and I don't know if it's possible).
Hope it helps.
-
jmbrook2
- Posts: 5
- Joined: Mon May 18, 2009 9:20 pm
Re: Compound object and collision question.
Hello Flix,
That is really useful, I'll take a look at that source.
Your demo of breakable compound objects has rather distracted me
I like that a lot. Need to workout how I can make use of that!
Cheers,
James
That is really useful, I'll take a look at that source.
Your demo of breakable compound objects has rather distracted me
Cheers,
James